Read More
Read More
Menu Close

    WordPress Add Custom Links Plugin Page

    WordPress Add Custom Links Plugin Page – In this post we see how we can create additional links to plugin on plugin page. These links can be very useful sometime e.g we want add some user guide link to plugin. Let’s start with creating test plugin –

    <?php
    
    /*
     * Plugin Name: Plugin Additional Links on Plugin Page
     * Description: Add additional links to plugin on plugin page along with meta information.
     * Author: Webkul
     * Author URI: https://webkul.com
     * Version: 1.0
     * Text Domain: domain
    */

    The plugin will list on plugin page as shown below –

    WordPress Add Custom Links Plugin Page

    We will use ‘plugin row meta’ hook and add filter on this hook to add additional links. WordPress provides such types of hooks for various actions so that we can easily customize the templates according to our need. And this is the thing which defines the beauty of WordPress.

    So, here we go –

    Start your headless eCommerce
    now.
    Read More
    <?php
    
    /*
     * Plugin Name: Plugin Additional Links on Plugin Page
     * Description: Add additional links to plugin on plugin page along with meta information.
     * Author: Webkul
     * Author URI: https://webkul.com
     * Version: 1.0
     * Text Domain: domain
    */
    
    add_filter( 'plugin_row_meta', 'wk_plugin_row_meta', 10, 2 );
    
    function wk_plugin_row_meta( $links, $file ) {    
        if ( plugin_basename( __FILE__ ) == $file ) {
            $row_meta = array(
              'docs'    => '<a href="' . esc_url( 'https://webkul.com/blog/' ) . '" target="_blank" aria-label="' . esc_attr__( 'Plugin Additional Links', 'domain' ) . '" style="color:green;">' . esc_html__( 'Docs', 'domain' ) . '</a>'
            );
    
            return array_merge( $links, $row_meta );
        }
        return (array) $links;
    }
    

    In above code snippet, we can see that we apply one check ‘plugin_basename( __FILE__ ) == $file’. Actually this filter runs in loop for every plugin , so to add link to particular plugin in which we are working we applied check that file should be same as of current plugin then only the link will add otherwise the link will add to every plugin listed on plugin page.

    Using above code, we added link named Docs, so let’s see how it will look on plugin page –

    WordPress Add Custom Links Plugin Page

    support

    Still have any issue feel free to add a ticket and let us know your views to make the code better https://webkul.uvdesk.com/en/customer/create-ticket/

    Thanks for Your Time! Have a Good Day!

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Table of Content