apply_filters( "plugin_action_links_{$plugin_file}", string[] $actions, string $plugin_file, array $plugin_data, string $context )

Filters the list of action links displayed for a specific plugin in the Plugins list table.


Description Description

The dynamic portion of the hook name, $plugin_file, refers to the path to the plugin file, relative to the plugins directory.


Top ↑

Parameters Parameters

$actions

(string[]) An array of plugin action links. By default this can include 'activate', 'deactivate', and 'delete'. With Multisite active this can also include 'network_active' and 'network_only' items.

$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().

$context

(string) The plugin context. By default this can include 'all', 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', and 'search'.


Top ↑

Source Source

File: wp-admin/includes/class-wp-plugins-list-table.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
4.9.0 The 'Edit' link was removed from the list of action links.
2.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by shossain571
    // Link to settings page from plugins screen
    add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'add_action_links' );
    function add_action_links ( $links ) {
    	$mylinks = array(
    		'<a href="' . admin_url( 'options-general.php?page=mysettings' ) . '">Settings</a>',
    	);
    	return array_merge( $links, $mylinks );
    }
    
  2. Skip to note 2 content
    Contributed by techtimo
    $plugin_file = plugin_basename(__FILE__)

    That works great if you add the filter in the main plugin file.

    If not that’s not the case, you need to specify it.

    Let’s say you have the following directory structure:
    wp-content/plugins/wpdocs-plugin/wpdocs-plugin.php

    The $plugin_file then needs to be wpdocs-plugin/wpdocs-plugin.php

  3. Skip to note 3 content
    Contributed by Sagar Bagul

    If you want to add this in class file then take below reference,

    add_filter( 'plugin_action_links_' . $plugin_file_path, array( $this, 'wpdocs_custom_action_link' ) );
    public function wpdocs_custom_action_link( $links ) { 
        // Build URL.
        $url = add_query_arg( 'page', 'custom-settings', get_admin_url() . 'tools.php' );
    
        // Create the link and escape .
        $setting_link = '<a href="' . esc_url( $url ) . '">' . __( 'Custom Settings', 'domain' ) . '</a>';
    
        // Adds the link to the end of the array.
        array_push( $links, $setting_link );
    
        return $links;
    }

You must log in before being able to contribute a note or feedback.