Changeset 41806 for trunk/src/wp-admin/includes/plugin.php
- Timestamp:
- 10/10/2017 05:33:57 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/plugin.php
r41713 r41806 191 191 * @return array List of files relative to the plugin root. 192 192 */ 193 function get_plugin_files( $plugin) {193 function get_plugin_files( $plugin ) { 194 194 $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; 195 $dir = dirname($plugin_file); 196 $plugin_files = array($plugin); 197 if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) { 198 $plugins_dir = @ opendir( $dir ); 199 if ( $plugins_dir ) { 200 while (($file = readdir( $plugins_dir ) ) !== false ) { 201 if ( substr($file, 0, 1) == '.' ) 202 continue; 203 if ( is_dir( $dir . '/' . $file ) ) { 204 $plugins_subdir = @ opendir( $dir . '/' . $file ); 205 if ( $plugins_subdir ) { 206 while (($subfile = readdir( $plugins_subdir ) ) !== false ) { 207 if ( substr($subfile, 0, 1) == '.' ) 208 continue; 209 $plugin_files[] = plugin_basename("$dir/$file/$subfile"); 210 } 211 @closedir( $plugins_subdir ); 212 } 213 } else { 214 if ( plugin_basename("$dir/$file") != $plugin ) 215 $plugin_files[] = plugin_basename("$dir/$file"); 216 } 217 } 218 @closedir( $plugins_dir ); 219 } 220 } 195 $dir = dirname( $plugin_file ); 196 197 $data = get_plugin_data( $plugin_file ); 198 $label = isset( $data['Version'] ) 199 ? sanitize_key( 'files_' . $plugin . '-' . $data['Version'] ) 200 : sanitize_key( 'files_' . $plugin ); 201 $transient_key = substr( $label, 0, 29 ) . md5( $label ); 202 203 $plugin_files = get_transient( $transient_key ); 204 if ( false !== $plugin_files ) { 205 return $plugin_files; 206 } 207 208 $plugin_files = array( plugin_basename( $plugin_file ) ); 209 210 if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) { 211 212 /** 213 * Filters the array of excluded directories and files while scanning the folder. 214 * 215 * @since 4.9.0 216 * 217 * @param array $exclusions Array of excluded directories and files. 218 */ 219 $exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) ); 220 221 $list_files = list_files( $dir, 100, $exclusions ); 222 $list_files = array_map( 'plugin_basename', $list_files ); 223 224 $plugin_files = array_merge( $plugin_files, $list_files ); 225 $plugin_files = array_values( array_unique( $plugin_files ) ); 226 } 227 228 set_transient( $transient_key, $plugin_files, HOUR_IN_SECONDS ); 221 229 222 230 return $plugin_files;
Note: See TracChangeset
for help on using the changeset viewer.