Add custom plugin_action_links and plugin_row_meta to a plugin
In this tutorial, you will learn how to add custom action links to your plugin, like on this screenshot:

plugin_action_links hook and “Docs” and “Support” links using plugin_row_meta, to my Inventory Sync for WooCommerce plugin.In order to do it, we will need to use the following WordPress hooks:
plugin_action_links(ornetwork_admin_plugin_action_linksfor WordPress Multisite) in order to add or remove the action links under the plugin name,plugin_row_metawill help you if you’d like to add something under the plugin description.
And now, let’s jump straight to the examples.
plugin_action_links
Let’s begin by adding a plugin settings link now.
For example, let’s say our custom plugin is exactly like my Inventory Sync plugin – it adds its settings somewhere deep in the WooCommerce settings pages, so it won’t be easy to find.

plugin_action_links filter hook.That’s why we going to use the plugin_action_links filter hook in order to provide an easy navigation to the plugin settings right from the plugin activation page.
add_filter( 'plugin_action_links', 'rudr_settings_link', 25, 2 );
function rudr_settings_link( $links_array, $plugin_file_name ){
// $plugin_file_name is plugin-folder/plugin-name.php
// inside main plugin file, basename( __FILE__ ) == plugin-name.php
if( strpos( $plugin_file_name, basename( __FILE__ ) ) ) {
// we can add one more array element at the beginning with array_unshift()
array_unshift( $links_array, '<a href="#">Settings</a>' );
}
return $links_array;
}The main thing you should know about plugin_action_links and plugin_row_meta hooks is that these hooks are fired for every installed plugin. That’s why the strpos() condition is crucial; otherwise, your custom link to the plugin settings will appear for every activated plugin on your website.
But it is also possible to completely skip the part with the condition if you add the plugin file name straight to the plugin_action_links_{$plugin_file} hook.
add_filter(
'plugin_action_links_plugin-name/plugin-name.php',
function( $links ){
array_unshift( $links, '<a href="#">Settings</a>' );
return $links;
}
);Of course, using plain HTML here is a very simplified idea; for example, this line in my plugin looks like this:
array_unshift(
$links,
sprintf(
'<a href="%s">%s</a>',
add_query_arg(
array(
'page' => 'wc-settings',
'tab' => 'products',
'section' => 'inventory',
),
'admin.php'
),
esc_html__( 'Settings' )
)
);network_admin_plugin_action_links in WordPress Multisite
There is not 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:
network_admin_plugin_action_links,network_admin_plugin_action_links_{$plugin_file}/plugin-name.php;
For example, if I wanted to add a link to the settings page for my Simple Multisite Crossposting plugin in order for it to be displayed on the Network dashboard plugins page, then I’d need to use the network_admin_plugin_action_links hook.
More plugin_action_links parameters
No matter which of the above hooks you use, all of them have the same parameters, for example:
add_filter(
'plugin_action_links',
function( $links, $plugin_file_name, $plugin_data, $context ) {
},
10, 4 );Everything should be pretty much clear with the $links_array and $plugin_file_name arguments, but what about the other two?
Well, the $plugin_data obviously contains all the plugin information like “Name,” “Description,” “Author,” etc. Another argument, $context, can be one of the following values: all, active, recently_activated, inactive, upgrade, dropins, mustuse, and search.
plugin_row_meta
Well, it is kind of sad, that the plugin_row_meta hook doesn’t have the same variation with a plugin file name as a part of it (like plugin_action_links_{$plugin_file}), so using a condition is a must here.
As an example, let’s add links to the plugin documentation and support pages.
add_filter( 'plugin_row_meta', 'rudr_row_meta_links', 10, 4 );
function rudr_row_meta_links( $links, $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[] = '<a href="#">Docs</a>';
$links[] = '<a href="#">Support</a>';
}
return $links;
}Result:

Misha Rudrastyh
Hey guys and welcome to my website. For more than 15 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
Hello my friend
You have not closed the
if(), just passing this information :) :)See below
if( strpos( $plugin_file_name, basename(__FILE__) ) ) {Hello and thank you! Fixed 🙃
Hello, How can remove all row meta?
Hey Selim,
Not working :(
Ok, got the problem. Thanks for sharing it.