Last active
October 1, 2019 21:13
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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