WebCraft Tools

  • News
  • WordPress
    • WordPress Basics
    • WordPress Advanced
    • WordPress Performance
    • WordPress Security
    • WordPress Commerce
    • WordPress Troubleshooting
    • WordPress Themes
  • SEO and Analytics
WebCraft Tools › WordPress Advanced › Adding dashboard-like help tabs to your plugin administration pages

Adding dashboard-like help tabs to your plugin administration pages

Last updated on April 19, 2017 by Editorial Staff

If you’ve used WordPress for long, you’ve probably noticed a contextual help tab in the upper-right hand corner of the dashboard. It looks something like this:

 

While working on the newest version of one of our plugins, I was looking for a place to display help information. After trying a few different solutions, I decided that I’d really like to use the same contextual help menu seen above. I was able to find instructions on Google, but they were spread over a few different websites, so I thought I’d put together this post.  In this quick tutorial I’ll show you how you can add the contextual help menu to your plugin. It’s really a simple project.

First, I’m assuming that you’ve already created your plugin. This code can go anywhere in your plugin code, for my usage, I created a separate help.php and put all of this in it.

[php]

$screen = get_current_screen();

$screen->add_help_tab( array(
‘id’ => ‘my_help_tab’, // This should be unique for the screen.
‘title’ => ‘My Tab Title’,
‘content’ => ‘My Help Content’,
// ‘callback’ => ‘my_callback_function’,
// Use ‘callback’ instead of ‘content’ for a function callback that renders the tab content.
) );

[/php]

If you wanted to add multiple help tabs, you wouldn’t have to repeat $screen = get_current_screen();.

[php]
<pre>$screen = get_current_screen();

$screen->add_help_tab( array(
‘id’ => ‘my_help_tab’, // This should be unique for the screen.
‘title’ => ‘My Tab Title’,
‘content’ => ‘My Help Content’,
// ‘callback’ => ‘my_callback_function’,
// Use ‘callback’ instead of ‘content’ for a function callback that renders the tab content.
) );
$screen->add_help_tab( array(
‘id’ => ‘my_second_help_tab’, // This should be unique for the screen.
‘title’ => ‘My Second Tab Title’,
‘content’ => ‘More Help Tab Content’,
// ‘callback’ => ‘my_callback_function’,
// Use ‘callback’ instead of ‘content’ for a function callback that renders the tab content.
) );</pre>
[/php]

So, that’s all there is to it. In the examples above, I’ve set the content with the ‘content’ variable, but you can also use ‘callback’ to define a function which will output the help text. This is helpful if you want to create more dynamic help text.

On Wednesday we’ll talk about how to replicate the dashboard’s  “Screen Options” tab in your plugins.

Tweet
Pin
Share
0 Shares

Filed Under: WordPress Advanced

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Site Links

  • Contact Us
  • Disclosure Statement
  • Privacy Policy

About WebCraft.tools

WebCraft.tools is your free resource for building, maintaining, and improving your WordPress website. Whether you are building your first site or have been building them for years, WebCraft.tools aims to provide you with tips, tricks, tutorials, and reviews to take your WordPress site to the next level.

© 2017 - 2026 · WebCraft Tools · Built by the WP Ninjas, LLC