Using WordPress ‘network_admin_plugin_action_links’ PHP filter

The network_admin_plugin_action_links filter allows you to modify the action links displayed for each plugin in the Network Admin Plugins list table on a WordPress multisite installation.

Usage

add_filter('network_admin_plugin_action_links', 'your_custom_function', 10, 4);

function your_custom_function($actions, $plugin_file, $plugin_data, $context) {
    // your custom code here
    return $actions;
}

Parameters

  • $actions (string[]): An array of plugin action links. By default, this can include ‘activate’, ‘deactivate’, and ‘delete’.
  • $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.
  • $context (string): The plugin context. By default, this can include ‘all’, ‘active’, ‘inactive’, ‘recently_activated’, ‘upgrade’, ‘mustuse’, ‘dropins’, and ‘search’.

Examples

add_filter('network_admin_plugin_action_links', 'add_custom_link', 10, 4);

function add_custom_link($actions, $plugin_file, $plugin_data, $context) {
    $actions['custom_link'] = '<a href="https://example.com">Custom Link</a>';
    return $actions;
}

This code adds a custom link to the plugin action links. The link will have the text “Custom Link” and point to “https://example.com“.

add_filter('network_admin_plugin_action_links', 'remove_delete_link', 10, 4);

function remove_delete_link($actions, $plugin_file, $plugin_data, $context) {
    if ($plugin_file == 'your-plugin/your-plugin.php') {
        unset($actions['delete']);
    }
    return $actions;
}

This code removes the delete link for a specific plugin with the file path ‘your-plugin/your-plugin.php’.

add_filter('network_admin_plugin_action_links', 'change_activate_text', 10, 4);

function change_activate_text($actions, $plugin_file, $plugin_data, $context) {
    if (isset($actions['activate'])) {
        $actions['activate'] = str_replace('Activate', 'Enable', $actions['activate']);
    }
    return $actions;
}

This code changes the text of the activate link from “Activate” to “Enable”.

add_filter('network_admin_plugin_action_links', 'add_settings_link', 10, 4);

function add_settings_link($actions, $plugin_file, $plugin_data, $context) {
    if ($plugin_file == 'your-plugin/your-plugin.php') {
        $actions['settings'] = '<a href="' . network_admin_url('settings.php?page=your-plugin-settings') . '">Settings</a>';
    }
    return $actions;
}

This code adds a settings link for a specific plugin with the file path ‘your-plugin/your-plugin.php’. The link will point to the settings page of the plugin.

add_filter('network_admin_plugin_action_links', 'hide_action_links_for_inactive', 10, 4);
function hide_action_links_for_inactive($actions, $plugin_file, $plugin_data, $context) {
if ($context == 'inactive') {
    $actions = array();
}
return $actions;

This code hides all action links for inactive plugins in the Network Admin Plugins list table.