How to hide mu-plugins from Wordpress plugin list screen by overriding Bedrock Autoloader showInAdmin function


#1

Hi, I’m trying to hide must-used plugins list from the WP admin UI. I tried with:

add_filter('show_advanced_plugins', function ($show, $type) {return false;}, 0, 2); and with different priorities but nothing works.

First, I putted the code in a custom plugin but I understood after that the Bedrock Autoloader is called at the end of plugins loading so I tried to add it in app/filter.php and app/admin.php but without success.

I’m not sure if I can try to call the Bedrock Autoloader showInAdmin function to change the $show variable or if there is an other better way to proceed.

Can someone help me please to understand how it could be done?

Thank you


#2

I found that the Bedrock Autoloader already return false to prevent modification on his customization of Must-Used plugins list, and add the updated list to the array $GLOBALS[‘plugins’][‘mustuse’]. The best way I found to achieve it, is to use the same filter in app/admin.php and set the array as empty with a priority of 1 like this:

add_filter('show_advanced_plugins', function($show, $type) {
  $GLOBALS['plugins']['mustuse'] = [];
  return false;
}, 1, 2); 

Maybe someone will have a better idea or an action hook that could execute it at the right moment to follow the current usage of hook, because filter hook wasn’t supposed to execute code (I think).