Reputation: 495
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
Reputation: 4611
You don't need anything fancy.
add_filter('all_plugins', '__return_empty_array');
That does the trick for me.
Upvotes: 2