Tag: admin

Add additional links on the plugins overview page – part 2

A few days ago I already published an article on how to add additional links on the plugins overview page. Yesterday I run again into the plugin “Cleaner Plugin Installer” and saw, David adds for his plugin also links under the plugin description:

Cleaner Plugin Installer with additional links under the description
Under the description of David Deckers plugin are a lot of links.

Usually you just find the version number, a link to the authors webpage and a link to the plugins info. As you can see, the author also placed a link to the FAQ, the support and some other pages.

How did he do this? This line is filtered by plugin_row_meta. The single elements of this line are passed to filter as an array. In contrast to the filter plugin_action_links, which needs to be adjusted to the own plugin this filter is more general. This means: Since we just want to alter the line for our plugin, we have to check, if the current execution of the filter is for our plugin or for another plugin. As a second parameter the name of the plugin file is passed to the filter. So we can use plugin_basename( __FILE__ ) to check, whether our plugin line is filtered right now or another.

To add another element to this line, the code could be something like the following:

Add additional links on the plugins overview page

You know the usual plugin overview page. You have a small description of the plugins, the version, the author, a link to the plugins page and so on. On the left side, you will find the activation and deactivation links as well as the edit links. But from time to time, you will find plugins, which added a settings link or something similar to this line.

This is sometimes useful. Especially for plugins which do not need a lot of attention an additional list point in the admin menu is rather disturbing. In such a case a settings link on the plugin overview page is rather useful. But, how do you add such a link?

I searched a bit, how such plugins add these links and I found the filter hook “plugin_action_links“. This filter contains an array of all action links, which are shown on the overview page. Since these links differ from plugin to plugin, you have to adjust the filter for your own plugin by extending the filter name with the basename of your plugin:

add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'function_to_execute' );

This filter function accepts now the array of links and you can alter the links as you wish. In my example code, I add a link to my web page:

But how to create a admin page which doesn’t appear in the menue? You can use add_submenu_page() and define the parent slug as ‘null’:

add_submenu_page( null, 'Title', 'Title', 'manage_options', 'invisible', 'render_function' );

This page can be reached via the URL wp-admin/?page=invisible, so by simply adding the GET-Parameter page with the page slug.

How to create a help menu in WordPress

Create your own help tab

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:

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.

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:

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:

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:

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