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
if ( !function_exists( 'get_plugin_files' ) ) { require_once ABSPATH . '/wp-admin/includes/plugin.php'; } // The plugin. $plugin = ''; // NOTICE! Understand what this does before running. $result = get_plugin_files($plugin);
Defined (1)
The function is defined in the following location(s).
- /wp-admin/includes/plugin.php
- function get_plugin_files($plugin) {
- $plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
- $dir = dirname($plugin_file);
- $plugin_files = array($plugin);
- if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) {
- $plugins_dir = @ opendir( $dir );
- if ( $plugins_dir ) {
- while (($file = readdir( $plugins_dir ) ) !== false ) {
- if ( substr($file, 0, 1) == '.' )
- continue;
- if ( is_dir( $dir . '/' . $file ) ) {
- $plugins_subdir = @ opendir( $dir . '/' . $file );
- if ( $plugins_subdir ) {
- while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
- if ( substr($subfile, 0, 1) == '.' )
- continue;
- $plugin_files[] = plugin_basename("$dir/$file/$subfile");
- }
- @closedir( $plugins_subdir );
- }
- } else {
- if ( plugin_basename("$dir/$file") != $plugin )
- $plugin_files[] = plugin_basename("$dir/$file");
- }
- }
- @closedir( $plugins_dir );
- }
- }
- return $plugin_files;
- }