Ayanize
Ayanize

Reputation: 495

How to hide all plugins installed in a WP site?

I want to hide all the plugins installed in my site. How I can achieve this. I tried with the following but it does not seem to work.

function hide_plugins($plugins)
{   
    if ( ! function_exists( 'get_plugins' ) ) {
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
   $plugins = get_plugins();
   foreach($plugins as $plugin){
        if (in_array($plugin, array_keys($plugins))) {
            unset($plugins[$plugin]);
        }
   }
    return $plugins;
}

add_filter('all_plugins', 'hide_plugins');

Source : http://www.wpstuffs.com/hide-installed-plugins-from-dashboard-users-can-not-deactivate-the-plugin/

Upvotes: 0

Views: 1142

Answers (1)

ɴᴀᴛᴇ ᴅᴇᴠ
ɴᴀᴛᴇ ᴅᴇᴠ

Reputation: 4611

You don't need anything fancy.

add_filter('all_plugins', '__return_empty_array');

That does the trick for me.

Upvotes: 2

Related Questions