get_mu_plugins

Check the mu-plugins directory and retrieve all mu-plugin files with any plugin data.

Description

(array) get_mu_plugins(); 

WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins).

Returns (array)

Key is the mu-plugin file path and the value is an array of the mu-plugin data.


Usage

  1. if ( !function_exists( 'get_mu_plugins' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/plugin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_mu_plugins(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/plugin.php  
  1. function get_mu_plugins() { 
  2. $wp_plugins = array(); 
  3. // Files in wp-content/mu-plugins directory 
  4. $plugin_files = array(); 
  5.  
  6. if ( ! is_dir( WPMU_PLUGIN_DIR ) ) 
  7. return $wp_plugins; 
  8. if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) { 
  9. while ( ( $file = readdir( $plugins_dir ) ) !== false ) { 
  10. if ( substr( $file, -4 ) == '.php' ) 
  11. $plugin_files[] = $file; 
  12. } else { 
  13. return $wp_plugins; 
  14.  
  15. @closedir( $plugins_dir ); 
  16.  
  17. if ( empty($plugin_files) ) 
  18. return $wp_plugins; 
  19.  
  20. foreach ( $plugin_files as $plugin_file ) { 
  21. if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) 
  22. continue; 
  23.  
  24. $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. 
  25.  
  26. if ( empty ( $plugin_data['Name'] ) ) 
  27. $plugin_data['Name'] = $plugin_file; 
  28.  
  29. $wp_plugins[ $plugin_file ] = $plugin_data; 
  30.  
  31. if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden 
  32. unset( $wp_plugins['index.php'] ); 
  33.  
  34. uasort( $wp_plugins, '_sort_uname_callback' ); 
  35.  
  36. return $wp_plugins;