get_dropins

Check the wp-content directory and retrieve all drop-ins with any plugin data.

Description

(array) get_dropins(); 

Returns (array)

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


Usage

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

Defined (2)

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

/wp-admin/includes/plugin.php  
  1. function get_dropins() { 
  2. $dropins = array(); 
  3. $plugin_files = array(); 
  4.  
  5. $_dropins = _get_dropins(); 
  6.  
  7. // These exist in the wp-content directory 
  8. if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) { 
  9. while ( ( $file = readdir( $plugins_dir ) ) !== false ) { 
  10. if ( isset( $_dropins[ $file ] ) ) 
  11. $plugin_files[] = $file; 
  12. } else { 
  13. return $dropins; 
  14.  
  15. @closedir( $plugins_dir ); 
  16.  
  17. if ( empty($plugin_files) ) 
  18. return $dropins; 
  19.  
  20. foreach ( $plugin_files as $plugin_file ) { 
  21. if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) 
  22. continue; 
  23. $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. 
  24. if ( empty( $plugin_data['Name'] ) ) 
  25. $plugin_data['Name'] = $plugin_file; 
  26. $dropins[ $plugin_file ] = $plugin_data; 
  27.  
  28. uksort( $dropins, 'strnatcasecmp' ); 
  29.  
  30. return $dropins; 
  1. function _get_dropins() { 
  2. $dropins = array( 
  3. 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE 
  4. 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load 
  5. 'db-error.php' => array( __( 'Custom databaseerrormessage.' ), true ), // auto on error 
  6. 'install.php' => array( __( 'Custom install script.' ), true ), // auto on install 
  7. 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance 
  8. 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load 
  9. ); 
  10.  
  11. if ( is_multisite() ) { 
  12. $dropins['sunrise.php' ] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE 
  13. $dropins['blog-deleted.php' ] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog 
  14. $dropins['blog-inactive.php' ] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog 
  15. $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog 
  16.  
  17. return $dropins;