The after_plugin_row WordPress PHP action fires after each row in the Plugins list table, allowing you to perform actions or modify the output for each plugin row.
Usage
add_action('after_plugin_row', 'your_custom_function', 10, 3); function your_custom_function($plugin_file, $plugin_data, $status) { // your custom code here }
Parameters
$plugin_file
(string) – Path to the plugin file relative to the plugins directory.$plugin_data
(array) – An array of plugin data. Seeget_plugin_data()
and the ‘plugin_row_meta’ filter for the list of possible values.$status
(string) – Status filter currently applied to the plugin list. Possible values are: ‘all’, ‘active’, ‘inactive’, ‘recently_activated’, ‘upgrade’, ‘mustuse’, ‘dropins’, ‘search’, ‘paused’, ‘auto-update-enabled’, ‘auto-update-disabled’.
More information
See WordPress Developer Resources: after_plugin_row
Examples
Display a custom message for a specific plugin
Display a custom message under the row of a specific plugin in the Plugins list table.
add_action('after_plugin_row', 'display_custom_message', 10, 3); function display_custom_message($plugin_file, $plugin_data, $status) { if ('your-plugin/your-plugin.php' == $plugin_file) { echo '<tr><td colspan="3" style="color: #ff0000;">This is a custom message for the Your Plugin.</td></tr>'; } }
Show a warning for outdated plugins
Show a warning message for plugins that haven’t been updated in over a year.
add_action('after_plugin_row', 'warn_outdated_plugins', 10, 3); function warn_outdated_plugins($plugin_file, $plugin_data, $status) { $last_updated = strtotime($plugin_data['LastUpdated']); if ((time() - $last_updated) > 31536000) { // 1 year in seconds echo '<tr><td colspan="3" style="color: #ff0000;">Warning: This plugin has not been updated in over a year. Consider finding an alternative.</td></tr>'; } }
Add a custom link to plugin row actions
Add a custom link to the row actions of each plugin.
add_action('after_plugin_row', 'add_custom_link', 10, 3); function add_custom_link($plugin_file, $plugin_data, $status) { $custom_link = '<a href="https://example.com" target="_blank">Visit Custom Link</a>'; echo '<script>jQuery(document).ready(function() { jQuery("#' . esc_attr($plugin_file) . ' .row-actions").append(" | ' . addslashes($custom_link) . '"); });</script>'; }
Display the total number of active plugins
Display the total number of active plugins at the bottom of the Plugins list table.
add_action('after_plugin_row', 'display_total_active_plugins', 10, 3); function display_total_active_plugins($plugin_file, $plugin_data, $status) { static $active_plugins_count = 0; if ('active' == $status) { $active_plugins_count++; } if ($GLOBALS['wp_list_table']->is_last_page()) { echo '<tr><td colspan="3">Total Active Plugins: ' . $active_plugins_count . '</td></tr>'; } }
Highlight premium plugins
Highlight premium plugins in the Plugins list table by changing their background color.
add_action('after_plugin_row', 'highlight_premium_plugins', 10, 3); function highlight_premium_plugins($plugin_file, $plugin_data, $status) { $premium_plugins = array( 'premium-plugin-1/premium-plugin-1.php', 'premium-plugin-2/premium-plugin-2.php', ); if (in_array($plugin_file, $premium_plugins)) { echo '<script>jQuery(document).ready(function() { jQuery("#' . esc_attr($plugin_file) . '").css("background-color", "#f0f8ff"); });</script>'; } }
Show plugin ratings
Display the rating of each plugin in the Plugins list table, based on your predefined list of ratings.
add_action('after_plugin_row', 'show_plugin_ratings', 10, 3); function show_plugin_ratings($plugin_file, $plugin_data, $status) { $plugin_ratings = array( 'plugin-1/plugin-1.php' => 4.5, 'plugin-2/plugin-2.php' => 3.0, 'plugin-3/plugin-3.php' => 5.0, ); if (array_key_exists($plugin_file, $plugin_ratings)) { echo '<tr><td colspan="3">Rating: ' . $plugin_ratings[$plugin_file] . ' stars</td></tr>'; } }
These examples should help you understand how to use the after_plugin_row action in various scenarios. Feel free to modify the code according to your needs.