Skip to content

Instantly share code, notes, and snippets.

@ideag
Last active October 1, 2019 21:13
Show Gist options
  • Save ideag/4fb6dc104d1dfad68469 to your computer and use it in GitHub Desktop.
Save ideag/4fb6dc104d1dfad68469 to your computer and use it in GitHub Desktop.
A simple proof-of-concept plugin to hide specific plugins from Plugins' list in WP Admin if it is a Multisite install and the user is not the Super Administrator.
<?php
/*
Plugin Name: Arunas Hides Plugins
Plugin URI: http://arunas.co/hidesplugins
Description: A simple proof-of-concept plugin to hide specific plugins from Plugins' list in WP Admin if it is a Multisite install and the user is not the Super Administrator.
Author: Arūnas Liuiza
Version: 0.2
Author URI: http://arunas.co/
*/
add_filter('all_plugins', array( 'ArunasHidesPlugins', 'hide') );
class ArunasHidesPlugins {
public static $hidden = array(
'hello.php',
'akismet/akismet.php',
'arunas-hides-plugins/arunas-hides-plugins.php',
'someplugin/someplugin.php',
);
public static function hide( $plugins ) {
if ( is_multisite() && !is_super_admin() ) {
foreach ( $plugins as $key => $val ) {
if ( in_array( $key, self::$hidden ) ) {
unset( $plugins[ $key ] );
}
}
}
return $plugins;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment