DEV Community

Shashikant Y
Shashikant Y

Posted on

WordPress plugin action links - thorough notes

Recently I have released a simple light-weight plugin on to add color to the taxonomies. While working on the plugin, I was thinking of the past me who don't know much about the WordPress plugin development's best practices.

If you are an aspiring WP plugin developer, then this post may help you to understand one of the most important things, that is action links.

What are action links?

WordPress plugin action links (i.e., activate, deactivate, delete) are those links that are visible under each plugin on the plugin page.

Purpose of the action links?

Plugin action links are a useful way to provide helpful links to your plugin users like contact, support, or settings page.

One good point about the action link is, it will only be visible when your plugin is active. So, no worry about the visibility of links when your plugin isn't active.

How can I add my own action links?

The plugin_action_links_{$plugin_file} filter is responsible for adding action links where $plugin_file referes to the path of plugin file.

if ( ! function_exists( 'kantbtrue_action_links' ) ) {
     * Filters the list of action links displayed for a specific plugin in the Plugins list table
     * @param array $actions An array of plugin action links.
    function add_action_links ( $actions ) {
        $links = array(
            '<a href="' . admin_url( 'admin.php?page=kbt_settings' ) . '">Settings</a>',
        return array_merge( $actions, $links );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'kantbtrue_action_links' );

More info about the hook - WordPress developer hook page
More examples - Wordpress codex page

Top comments (0)