How to hide a plugin from the plugin list

Sometimes you need to hide a plugin from the list and prevent users from seeing it. Sometimes it is a plugin your users don’t have to know it is installed. Sometimes it is a plugin which can have a big impact on your site and you don’t want to even consider users having control over it. Sometimes the plugin is not easy to understand and it’s easier to make it disappear… well, if all you want is to make a plugin invisible, whatever the reason, we will show you how to do that.

Because there is no easy option in WordPress which you can turn on and off, you can easily do it yourself. A small PHP function is something which will help you:

  1. Open functions.php file
  2. Copy and paste the following:
  3. function hide_my_plugin() {
    global $wp_list_table;
    $hideplugin = array('google-maps-widget/google-maps-widget.php');
    $mypluginslist = $wp_list_table->items;
    foreach ($mypluginslist as $key => $val) {
    if (in_array($key,$hideplugin)) {
    unset($wp_list_table->items[$key]);
    }
    }
    }
    add_action('pre_current_active_plugins', 'hide_my_plugin');
  4. Replace path to your plugin which you want to hide
  5. Save changes

Third row in the given example reads ‘google-maps-widget/google-maps-widget.php’.

This is the piece of information you will need to change and provide a path to plugin you want to hide. Not a big deal; just go to your plugin list (this time it is a good thing you still see your plugin listed, right?) and click “Edit” under your plugin. There you have a Relative path to your plugin which you just have to place in the third row.

After you had saved changes, check plugins list to see if your plugin is left behind. Even so it is still working like a ninja hidden in shadows of your WordPress. Awesome, isn’t it?

But what if you have a Multisite? Then previous code won’t work and admins will still be able to see your secret plugin. Don’t worry; there is a similar solution to the problem. Repeat above steps using the following code where path to a plugin is listed in the second row:

function hide_plugin_from_multisite( $plugins ) {
if( in_array('google-maps-widget/google-maps-widget.php', array_keys( $plugins ) ) ) {
unset( $plugins['google-maps-widget/google-maps-widget.php'] );
}
return $plugins;
}
add_filter( 'all_plugins', 'hide_plugin_from_multisite');

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

2 thoughts on “How to hide a plugin from the plugin list

  1. The above code did not work. I pasted it in functions.php file in my theme and it did not work
    function hide_plugin_from_multisite( $plugins ) {
    if( in_array(‘Akistmet/akistmet.php’, array_keys( $plugins ) ) ) {
    unset( $plugins[‘Akistmet/akistmet.php’] );
    }
    return $plugins;
    }
    add_filter( ‘all_plugins’, ‘hide_plugin_from_multisite’);

Leave a Reply

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