Ticket #6531: 6531.5a.2.diff
File 6531.5a.2.diff, 2.5 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/file.php
132 132 if ( ! $levels ) 133 133 return false; 134 134 135 /** 136 * Filters the array of excluded directories and files while scanning the folder. 137 * 138 * @since 4.9 139 * 140 * @param array $exclusions Array of excluded directories and files. 141 */ 142 $exclusions = (array) apply_filters( 'list_files_exclusions', array( 'CVS', 'node_modules' ) ); 143 135 144 $files = array(); 136 145 if ( $dir = @opendir( $folder ) ) { 137 146 while (($file = readdir( $dir ) ) !== false ) { 138 147 if ( in_array($file, array('.', '..') ) ) 139 148 continue; 149 150 if ( '.' == $file[0] || in_array( $file, $exclusions, true ) ) 151 continue; 152 140 153 if ( is_dir( $folder . '/' . $file ) ) { 141 154 $files2 = list_files( $folder . '/' . $file, $levels - 1); 142 155 if ( $files2 ) -
src/wp-admin/includes/plugin.php
193 193 function get_plugin_files($plugin) { 194 194 $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; 195 195 $dir = dirname($plugin_file); 196 197 $plugin_files = get_transient( 'list_files_cache_' . $dir ); 198 if ( ! empty( $plugin_files ) ) 199 return $plugin_files; 200 196 201 $plugin_files = array($plugin); 197 202 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 } 203 204 $list_files = list_files( $dir ); 205 $list_files = array_map( 'plugin_basename', $list_files ); 206 207 $plugin_files += $list_files; 208 $plugin_files = array_unique( $plugin_files ); 209 220 210 } 221 211 212 set_transient( 'list_files_cache_'. $dir, $plugin_files, MINUTE_IN_SECONDS ); 213 222 214 return $plugin_files; 223 215 } 224 216