get_plugin_files

Get a list of a plugin's files.

Description

(array) get_plugin_files( (string) $plugin ); 

Returns (array)

List of files relative to the plugin root.

Parameters (1)

0. $plugin (string)
The plugin.

Usage

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

Defined (1)

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

/wp-admin/includes/plugin.php  
  1. function get_plugin_files($plugin) { 
  2. $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; 
  3. $dir = dirname($plugin_file); 
  4. $plugin_files = array($plugin); 
  5. if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) { 
  6. $plugins_dir = @ opendir( $dir ); 
  7. if ( $plugins_dir ) { 
  8. while (($file = readdir( $plugins_dir ) ) !== false ) { 
  9. if ( substr($file, 0, 1) == '.' ) 
  10. continue; 
  11. if ( is_dir( $dir . '/' . $file ) ) { 
  12. $plugins_subdir = @ opendir( $dir . '/' . $file ); 
  13. if ( $plugins_subdir ) { 
  14. while (($subfile = readdir( $plugins_subdir ) ) !== false ) { 
  15. if ( substr($subfile, 0, 1) == '.' ) 
  16. continue; 
  17. $plugin_files[] = plugin_basename("$dir/$file/$subfile"); 
  18. @closedir( $plugins_subdir ); 
  19. } else { 
  20. if ( plugin_basename("$dir/$file") != $plugin ) 
  21. $plugin_files[] = plugin_basename("$dir/$file"); 
  22. @closedir( $plugins_dir ); 
  23.  
  24. return $plugin_files;