How to remove/hide action links cluttering under specific plugins’ names

Some plugins place various links under their name on the primary column on the plugin page. So we end up with something like:

Home Page | Support Forums | Documentation | Upgrade to Pro Edition | Donate | Settings | Activate | Delete

In an effort to keep just the standard links Settings | Activate | Delete we use in our custom 01_plugin.php the following code:

 global $pagenow; 
    if( $pagenow == 'plugins.php' ) {
    echo '<style type="text/css">
        .visible .proupgrade, 
        .visible .docs, 
        .visible .forum, 
        .visible .jetpack-home, 
        .visible .support 
            {display: none ; 
            } 
          </style>'; 
    }

When debugging, for some reason, it gives a PHP Warning:

PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /wp-content/plugins/01-plugin/01_plugin.php:282) in /wp-content/plugins/wp-miniaudioplayer/miniAudioPlayer.php on line 231

Can someone point us to the right direction? Which hook should we use?
Is there another way to achieve our goal?

EDIT

To better understand where these links are located, please have a look at the screenshot:

primary-bloated

As you can see they bloat the primary column out of proportion, using/wasting precious space, that could be otherwise awarded to the secondary column.
Note: The primary column does not wrap. The secondary does.

3 Answers
3

You have the right approach. You will want to use the admin_enqueue_scripts hook:

add_action( 'admin_enqueue_scripts', 'wpse_239302_hide_action_links' );
function wpse_239302_hide_action_links() {
    global $pagenow; 
    if ( $pagenow == 'plugins.php' ) {
        ?>
        <style type="text/css">
            .visible .proupgrade,
            .visible .docs,
            .visible .forum,
            .visible .jetpack-home,
            .visible .support { display: none; } 
        </style>
        <?php
    }
}

Leave a Comment