Ticket #6531: 6531.5a.diff
File 6531.5a.diff, 3.4 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/file.php
70 70 * @since 1.5.0 71 71 * 72 72 * @global array $wp_file_descriptions Theme file descriptions. 73 * @global array $allowed_files List of allowed files. 73 * @global array $allowed_files List of allowed files. 74 74 * @param string $file Filesystem path or filename 75 75 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist. 76 76 * Appends 'Page Template' to basename of $file if the file is a page template … … 123 123 * 124 124 * @param string $folder Optional. Full path to folder. Default empty. 125 125 * @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). 126 * @param bool $skip Optional. Skip hidden files/folders, node_modules type folders. Default true. 126 127 * @return bool|array False on failure, Else array of files 127 128 */ 128 129 function list_files( $folder = '', $levels = 100 ) { … … 132 133 if ( ! $levels ) 133 134 return false; 134 135 136 /** 137 * Filters the array of excluded directories and files while scanning the folder. 138 * 139 * @since 4.9 140 * 141 * @param array $exclusions Array of excluded directories and files. 142 */ 143 $exclusions = (array) apply_filters( 'list_files_exclusions', array( 'CVS', 'node_modules' ) ); 144 135 145 $files = array(); 136 146 if ( $dir = @opendir( $folder ) ) { 137 147 while (($file = readdir( $dir ) ) !== false ) { 138 148 if ( in_array($file, array('.', '..') ) ) 139 149 continue; 150 151 if ( '.' == $file[0] || in_array( $file, $exclusions, true ) ) 152 continue; 153 140 154 if ( is_dir( $folder . '/' . $file ) ) { 141 155 $files2 = list_files( $folder . '/' . $file, $levels - 1); 142 156 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