Websupporter

Just another Websupporter site

How to create a help menu in WordPress

In this post, I want to address the question, how you can use and extend the help menu, you find in the admin dashboard of WordPress. Usually, this help menu can be found in the top right corner and it gives the user some hints and tips, how to use the current page.

Create help tab
Create help tab

So, lets start with the basics: We have to register a new menu page:

Embed from pastebin.com

Click the button below to load the content from pastebin.com.


Always allow pastebin.com

As you know, add_menu_page() returns the ID of the newly created page, which we will need, since we want to hook into the specific load event for this page. We do so by using

add_action( 'load-' . $page_with_help, 'pwh_add_help_tab' );

In this action, we will be able to register our help tab and give it some contents.

Adding the help tab

In the first step, we need to acquire the current screen. This is be done by get_current_screen(). This function returns the current WP_Screen object, which contains – beside others – the help tabs.

In a second step, we will now add our own help tabs, by using WP_Screen::add_help_tab(). A help tab contains an ID, a title and the actual content.

Embed from pastebin.com

Click the button below to load the content from pastebin.com.


Always allow pastebin.com

With these two simple steps, we can create our own help tabs, which blend perfectly into WordPress. We can also name a callback function, which does the rendering:

Embed from pastebin.com

Click the button below to load the content from pastebin.com.


Always allow pastebin.com

With such a callback function, we have more possibilities to render the output. The callback function can receive two parameters: The current WP_Screen object and the current help tab array:

Embed from pastebin.com

Click the button below to load the content from pastebin.com.


Always allow pastebin.com

Creating Sidebars

Once you have registered a help tab, you can also register a sidebar for the help. This is done quite simple by set_help_sidebar(). Once, you open the help section, you can see the sidebar on the right side of it:

Embed from pastebin.com

Click the button below to load the content from pastebin.com.


Always allow pastebin.com

It is very simple to add a little bit more help for the users of your plugins. So, just do it 🙂

About the author

Seine erste Webseite hat David Remer 1998 in HTML verfasst. Wenig später war er fasziniert von DHTML und JavaScript. Nach jahrelanger Freelancerei arbeitete er zunächst für Inpsyde und ist heute Entwickler bei Automattic. Außerdem hat er das Buch "WordPress für Entwickler" verfasst.

Leave a Reply

Your email address will not be published.