[wp-trac] [WordPress Trac] #57278: Add filter to allow filtering of the must-use plugins list in the admin

WordPress Trac noreply at wordpress.org
Mon Dec 5 22:10:04 UTC 2022


#57278: Add filter to allow filtering of the must-use plugins list in the admin
----------------------------+-----------------------------
 Reporter:  nateallen       |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Plugins         |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Currently, the Must-Use plugin list in the WordPress admin only shows
 files that end in `.php`, and there is no way to filter this list. This is
 a problem because we use a single autoloader that allows us to add plugins
 to `mu-plugins` without needing to create a separate PHP file for each
 one.

 As a result, the Must-Use plugin list appears like this:

 [[Image(https://cldup.com/DYT8nmF91L.png)]]

 Admins have no way of knowing which must-use plugins are actually
 installed.

 If there was a filter, we could remove `mu-loader.php` from the list and
 add each plugin individually, like this:

 {{{#!php
 <?php
 function custom_mu_plugin_filter( $mu_plugins ) {
         unset( $mu_plugins['mu-loader.php'] );

         $directories = glob( WPMU_PLUGIN_DIR . '/*', GLOB_ONLYDIR );

         foreach ( $directories as $directory ) {
                 $plugin_file = $directory . '/' . basename( $directory ) .
 '.php';

                 $mu_plugins[ $plugin_file ] = get_plugin_data(
 $plugin_file );
         }

         return $mu_plugins;
 }
 add_filter( 'mu_plugins', 'custom_mu_plugin_filter' );
 }}}

 Which would result in:

 [[Image(https://cldup.com/Fvk7r2jvc1.png)]]

 There are probably other uses for this filter, like hiding a must-use
 plugin from the list that you don't want clients/users seeing.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57278>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list