Everything about plugin_action_links and plugin_row_meta

Look at this screenshot:

plugin_action_links and plugin_row_meta filters example
By the way, if the plugin on the screenshot seems interesting for you, find out more on this page.

The key idea is very simple — if you want to add some links under the plugin name, use plugin_action_links filter hook (or network_admin_plugin_action_links for WordPress Multisite), if you would like to add something under a plugin description, plugin_row_meta will help you.

Let’s try to add the settings link now. The only thing you should know about plugin_action_links and plugin_row_meta is that these hooks are fired for every installed plugin! 😁

So you have to perform some conditional checks, and there are two ways to do it.

1. Check if it is the plugin you need inside the function


add_filter( 'plugin_action_links', 'misha_settings_link', 10, 2 );

function misha_settings_link( $links_array, $plugin_file_name ){
	// $plugin_file_name is plugin-folder/plugin-name.php

	// if you use this action hook inside main plugin file, use basename(__FILE__) to check
	if( strpos( $plugin_file_name, basename(__FILE__) ) ) {
		// we can add one more array element at the beginning with array_unshift()
		array_unshift( $links_array, 'Settings' );
	}
	
	return $links_array;
}

2. plugin_action_links_plugin-name/plugin-name.php

But you can skip the part of the code with condition, just add the plugin file name to the hook.


add_filter( 'plugin_action_links_plugin-name/plugin-name.php', 'misha_settings_link' );
 
function misha_settings_link( $links_array ){
	array_unshift( $links_array, 'Settings' );
	return $links_array;
}

The result:

Example of using plugin_action_links filter
Settings link is added with the help of plugin_action_links filter hook.

There is not so much to say. Just if you’re running a WordPress Multisite network and if you want to add plugin action links to the Network Dashboard plugin page, use:

More hook parameters

No matter which of the above hooks you use, all of them have the same parameters, example:


add_filter( 'plugin_action_links', 'misha_settings_link', 10, 4 );

function misha_settings_link( $links_array, $plugin_file_name, $plugin_data, $context ){

	...

Everything should be clear with $links_array and $plugin_file_name but what about the rest?

$plugin_data
(Array) Contains all the plugin meta information, like Name, Description, Author, AuthorURI etc.
$context
(String) The plugin status. It can include by default: ‘all’, ‘active’, ‘recently_activated’, ‘inactive’, ‘upgrade’, ‘dropins’, ‘mustuse’, and ‘search’.

plugin_row_meta

Well, it is sad, but plugin_row_meta doesn’t have a hook with plugin file name in it. So, you must use a condition. Let’s add FAQ, Support and Check for updates links with its help.


add_filter( 'plugin_row_meta', 'misha_support_and_faq_links', 10, 4 );
 
function misha_support_and_faq_links( $links_array, $plugin_file_name, $plugin_data, $status ){
	
	if( strpos( $plugin_file_name, basename(__FILE__) ) {
		// you can still use array_unshift() to add links at the beginning
		$links_array[] = 'FAQ';
		$links_array[] = 'Support';
		$links_array[] = 'Check for updates';
	}
 
	return $links_array;
}

Result:

Add three more links with WordPress plugin_row_meta filter.
FAQ, Support and Check for updates links are added with the help of plugin_row_meta.
Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X