How To Hide A WordPress Plugin From Plugins

  • Thanks for participating in our community, Discuss and Learn. All Forum members are allowed to create threads and posts. Resources posted here should be CLEAN and SAFE. Do not post “offensive” posts, links, or images. Remain respectful of other members at all times.

Destin

Moderator
Staff member
Moderator
Programmer
Developer
May 28, 2021
27
4
3
Bulawayo
ecowebzim.com
I recently had to develop a unique plugin for a client's website while working on their website. Because the user was a newbie and the plugin held some sensitive functions to run his website, I wanted to hide it from him.

You might wish to conceal a plugin from the plugin list if your client employs you to do work that just requires you to install a plugin. You don't want your client to discover that you simply charged them for the plugin installation.

In this tutorial, I’ll show how you can easily hide a WordPress plugin from plugin list. The plugin will still work, but will not appear in the plugin list.

PHP:
function hide_plugin_ecowebzim() {
  global $wp_list_table;
  $hidearr = array('plugin-directory/plugin-file.php');
  $myplugins = $wp_list_table->items;
  foreach ($myplugins as $key => $val) {
    if (in_array($key,$hidearr)) {
      unset($wp_list_table->items[$key]);
    }
  }
}

add_action('pre_current_active_plugins', 'hide_plugin_ecowebzim');

Replace plugin-directory/plugin-file.php in above code with your plugin’s directory and file name. You can find this info by clicking on edit plugin link from the plugin list.

If you want to hide the plugin from your WordPress Multisite, then you above snippet will not remove the plugin from the Network admin list. Here’s a snippet that will work on the WordPress Multisite

PHP:
function mu_hide_plugins_network( $plugins ) {
    // let's hide akismet
    if( in_array( 'akismet/akismet.php', array_keys( $plugins ) ) ) {
        unset( $plugins['akismet/akismet.php'] );
    }
    return $plugins;
}

add_filter( 'all_plugins', 'mu_hide_plugins_network' );

I used Akismet as an example. You’d have to replace akismet/akismet.php with the directory and file name of the plugin you’re trying to hide.

If you found this post useful, please comment below!!​

 

Forum statistics

Threads
106
Messages
166
Members
101
Latest member
Chrisgivap