Everything about plugin_action_links and plugin_row_meta
Look at this screenshot:
- "Activate", "Deactivate", "Delete" are defaults for any plugin,
- "Settings" link is added with
plugin_action_links
, - Author links and "Visit plugin website" are taken from the main plugin file meta information, just to remind you:
/* * Plugin name: Test * Author: Misha Rudrastyh * Author URI: https://rudrastyh.com * Plugin URI: https://rudrastyh.com/plugins */
- "FAQ", "Support" and "Check for updates" are added with
plugin_row_meta
filter.
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.
plugin_action_links
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
- First of all add the second function parameter, which matches this string
plugin-folder/plugin-name.php
(line 3), - If you use the code just inside the main plugin file, you search for
basename(__FILE__)
which isplugin-name.php
inside the$plugin_file_name
variable withstrpos()
function (line 7). - Add your custom link before the “Deactivate” link with
array_unshift()
function or after the “Deactivate” link with$links_array[]
.
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, '<a href="#">Settings</a>' ); } 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, '<a href="#">Settings</a>' ); return $links_array; }
The result:

network_admin_plugin_action_links for WordPress Multisite
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:
network_admin_plugin_action_links
network_admin_plugin_action_links_plugin-name/plugin-name.php
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[] = '<a href="#">FAQ</a>'; $links_array[] = '<a href="#">Support</a>'; $links_array[] = '<a href="#">Check for updates</a>'; } return $links_array; }
Result:

Comments — 7
Hello my friend
You have not closed the if (), just passing this information :) :)
See below
Correcting the poop I made above .. rsrsrsrs
Hello and thank you! Fixed 🙃
Hello, How can remove all row meta? http://prntscr.com/lqxew1
Hey Selim,
Not working :(
Ok, got the problem. Thanks for share it.
Comments are closed.