Using WordPress ‘after_plugin_row_{$plugin_file}’ PHP action

The after_plugin_row_{$plugin_file} WordPress PHP action fires after each specific row in the Plugins list table. The dynamic portion of the hook name, $plugin_file, refers to the path to the plugin file relative to the plugins directory.

Usage

add_action('after_plugin_row_' . $plugin_file, '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. See get_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_{$plugin_file}

Examples

Add a custom message after a specific plugin row

add_action('after_plugin_row_sample-plugin/sample-plugin.php', 'add_custom_message', 10, 3);

function add_custom_message($plugin_file, $plugin_data, $status) {
    echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update">Custom message after plugin row</td></tr>';
}

Display a warning if a plugin is inactive

add_action('after_plugin_row_sample-plugin/sample-plugin.php', 'display_inactive_warning', 10, 3);

function display_inactive_warning($plugin_file, $plugin_data, $status) {
    if ($status == 'inactive') {
        echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update">Warning: This plugin is inactive!</td></tr>';
    }
}

Show plugin update information

add_action('after_plugin_row_sample-plugin/sample-plugin.php', 'show_plugin_update_info', 10, 3);

function show_plugin_update_info($plugin_file, $plugin_data, $status) {
    if ($status == 'upgrade') {
        echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update">Update available: Version ' . $plugin_data['new_version'] . '</td></tr>';
    }
}

Display a custom message for auto-update-enabled plugins

add_action('after_plugin_row_sample-plugin/sample-plugin.php', 'display_auto_update_message', 10, 3);

function display_auto_update_message($plugin_file, $plugin_data, $status) {
    if ($status == 'auto-update-enabled') {
        echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update">This plugin has auto-updates enabled.</td></tr>';
    }
}

Add custom CSS class to a specific plugin row

add_action('after_plugin_row_sample-plugin/sample-plugin.php', 'add_custom_css_class', 10, 3);

function add_custom_css_class($plugin_file, $plugin_data, $status) {
    echo '<style>tr[data-plugin="' . $plugin_file . '"] { background-color: #f0f0f0; }</style>';
}