Categories
jQuery WordPress

Toggle WordPress Help Menu

It’s not possible (as far as I know) to currently link directly to a help tab in WordPress. Here’s the jQuery solution I cooked up:


/**
* Toggle the WP help menu tab by linking to the tab id
*
* The anchor must have a `rel` of `wp-help`
*/
$(‘a[rel=”wp-help”]’).click(function() {

// Open the help wrapper if it’s not open yet
if($(‘#screen-meta’).is(‘:hidden’)) {
$(‘#contextual-help-link’).click();
}

// Click on the tab link inside the help wrapper
$(‘#screen-meta a[href*=”‘ + $(this).attr(‘href’).replace(‘#’, ”) +'”]’).click();

// We’re just anchor linking; don’t go anywhere
return false;
});

If the tab’s ID that you pass to `$screen->add_help_tab()` is `example-plugin`, then you could create a link like this: `View the help docs`.

By Zack Katz

Zack Katz is the founder of GravityKit and TrustedLogin. He lives in Leverett, Massachusetts with his wife Juniper.