Adding JavaScript to WP Dashboard

Hi,

I want to add a JavaScript "Feedback" or "Support" widget (Zendesk or something similar) to the public area AND admin area of a WordPress multisite installation. Adding it to the public side is easy. But what's the best way to do it in the Dashboard? I know there are certain recommended ways to modify the admin area, especially to make it update-safe.

Any ideas would be appreciated.

Thanks,

Mark

  • DavidM
    • DEV MAN’s Mascot

    Hi wpcdn,

    Taking a look at Zendesk, it is a very nice way to present support and feedback and what you brought up in the other thread about having the Contextual Help tab pull up that screen or popover really does seem like the optimal way to do that in the WordPress admin area. I'm not aware of a way to customize those tabs like that but I'll run that by some folks over here to see if they would know.

    Apart from that, I'd have to say the best way I could think of to present support within the admin area has already been done with Supporter and the Support System plugin.
    https://premium.wpmudev.org/project/support-system

    A simpler way would be to provide a dashboard widget for support, which is very easily achieved and detailed at the following:
    http://wp-snippets.com/add-a-dashboard-widget/

    Cheers,
    David

  • wpcdn
    • Syntax Hero

    A simpler way would be to provide a dashboard widget for support, which is very easily achieved and detailed at the following:
    http://wp-snippets.com/add-a-dashboard-widget/

    Looks good for support and in general. However, I think that code is entered to functions.php in a theme, right? So is that a problem in multisite when users can choose from multiple themes? I'd hate having to add this code to functions.php in 100+ themes. Is there a way to achieve the same results for each user with one set of code?

    the best way I could think of to present support within the admin area has already been done with Supporter and the Support System plugin.

    Those are both excellent options. In fact, we almost went with those but we ended up choosing Zendesk for reasons related to centralization (one helpdesk for multiple multisite installations). Your Support System plugin is very nice, especially with the ticket system integrated right there in the Dashboard.

    Taking a look at Zendesk, it is a very nice way to present support and feedback and what you brought up in the other thread about having the Contextual Help tab pull up that screen or popover really does seem like the optimal way to do that in the WordPress admin area.

    Yes, our ideal solution would be for users to simply click the normal "Help" tab and launch the Zendesk Dropbox. Otherwise, we'll probably use the WPMU DEV Admin Help Content plugin to create a mini-helpdesk in the normal contextual help area. It will have a link to the Zendesk Dropbox, as well as direct links to the main help topics in the Zendesk. It's one extra click to launch the Dropbox, but still an elegant solution (we think).

  • Shawn
    • The Crimson Coder

    @wpcdn, yes, you can use it anywhere. The functions.php reference was just an example to demonstrate the following action:
    add_action('wp_dashboard_setup', 'add_your_dashboard_widget' );

    Drop it into a php file in mu-plugins and it'll take effect sitewide for all users. Or put it in 'plugins' and you can enable/disable it at will.

  • wpcdn
    • Syntax Hero

    Thanks for letting me know that Shawn! That is great...lots of those snippets look interesting, but I wondered if the implementation was limited to themes. And I didn't want to modify each theme we offer.

    Points given. :slight_smile:

  • wpcdn
    • Syntax Hero

    Followup question: With this snippet, is there any way to specify where the custom widget appears in the Dashboard? For example, I'd hate to have a "Welcome!" widget show up at the bottom.

    Otherwise, would the WPMU DEV New Blog Template plugin allow me to set the widget position so that new sub-sites would inherit it? The question is whether that's one of the settings that is transferred to a new site.

    (I don't have access to a test install at the moment or I'd just try myself.)

  • Shawn
    • The Crimson Coder

    Having not tried this myself, I imagine that would be where the priority would weigh in. If you want it to be first use:
    add_action('wp_dashboard_setup', 'add_your_dashboard_widget', 1 );
    And if you want it last, use:
    add_action('wp_dashboard_setup', 'add_your_dashboard_widget', 99 );

    The default priority for all custom actions and filters is 10, so by default without a priority parameter it would be below most others (many internal actions and filters often have priority from 5 to 10).

  • DavidM
    • DEV MAN’s Mascot

    Hey guys, sorry for the late response in the discussion but I just realized I still have the code I used for a dashboard widget plugin maker, so I'll post it here in case you might find it useful.

    I used it alongside White-Shadow's Raw HTML plugin: http://wordpress.org/extend/plugins/raw-html/

    Thus the [raw] shortcodes. The site I had it running in is down at the moment so I don't have an online demo for it currently. But it did work perfectly for myself and copying that code into a post or page with Raw HTML activated should take care of everything so that you can generate the plugin code from your own site.

    If you have any trouble with it, let me know and I'll see what I can do.

    Cheers,
    David

  • DavidM
    • DEV MAN’s Mascot

    Oh please do share ideas on that! I actually had an idea for a plugin generator generator where you could easily provide your own base code and have it create a plugin generator using it. I thought it would work better than constantly creating the generator code from scratch for new base code like dashboard widget code, basic plugin code or widget code. If you're interested I'd love to get a thread started on this. :slight_smile:

  • Shawn
    • The Crimson Coder

    I wrote an anti-spam plugin a few weeks ago that allows strings, regex patterns and custom code processing to be performed via filters. I only have it enabled on a few of my smaller (50-500 user) WPMU blogs right now, but alone it's 99.99% effective in catching spam signups and in conjunction with Anti-Splog it pushes success to 100% with very very low (almost zero) collateral damage.

    I have been brewing over how to enable a user to create custom processing filters without having to know very much about PHP or the WP plugins functionality. This is going to make it not only possible -- but easy. Now to find the time to actually do it. :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.