What's new

Welcome to WebForum | Zimbabwe Web Hosting Forum.

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask questions and get answers from our community

Answer

Answer questions and become an expert on all topics.

Contact us

Get in touch with the site administrator directly.

Forum Group

Join the Forum Whatsapp group for daily updates.
  • 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.

How To Hide A WordPress Plugin From Plugins

Destin

Moderator
Staff member
Moderator
Programmer
Developer
Joined
May 28, 2021
Messages
27
Reaction score
4
Points
3
Location
Bulawayo
Website
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
115
Messages
176
Members
89
Latest member
denzel
shape1
shape2
shape3
shape4
shape5
shape6
Back
Top