plugin_action_links

最后更新于:2021-11-27 14:40:10

apply_filters( ‘plugin_action_links’, string[] $actions, string $plugin_file, array $plugin_data, string $context )

Filters the action links displayed for each plugin in the Plugins list table.

参数

$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’.

源文件

文件: gc-admin/includes/class-gc-plugins-list-table.php

View on Trac

/**
 * Add settings link to plugin actions
 *
 * @param  array  $plugin_actions
 * @param  string $plugin_file
 * @since  1.0
 * @return array
 */
function add_plugin_link( $plugin_actions, $plugin_file ) {

    $new_actions = array();

    if ( basename( plugin_dir_path( __FILE__ ) ) . 'comment-limiter.php' === $plugin_file ) {
        $new_actions['cl_settings'] = sprintf( __( '<a href="https://docs.gechiui.com/hooks/plugin_action_links/%s">Settings</a>', 'comment-limiter' ), esc_url( admin_url( 'options-general.php?page=comment-limiter' ) ) );
    }

    return array_merge( $new_actions, $plugin_actions );
}
add_filter( 'plugin_action_links', 'add_plugin_link', 10, 2 );