Ticket #6531: 6531.6.diff
File 6531.6.diff, 4.9 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 $data = get_plugin_data($plugin_file); 198 $label = isset($data['Version']) ? 'list_files_cache_' . $dir . '-' . $data['Version'] : 'list_files_cache_' . $dir; 199 200 $plugin_files = get_transient( $label ); 201 if ( ! empty( $plugin_files ) ) 202 return $plugin_files; 203 196 204 $plugin_files = array($plugin); 197 205 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 } 206 207 $list_files = list_files( $dir ); 208 $list_files = array_map( 'plugin_basename', $list_files ); 209 210 $plugin_files += $list_files; 211 $plugin_files = array_unique( $plugin_files ); 212 220 213 } 221 214 215 set_transient( $label, $plugin_files, HOUR_IN_SECONDS ); 216 222 217 return $plugin_files; 223 218 } 224 219 -
src/wp-admin/theme-editor.php
120 120 foreach ( $file_types as $type ) { 121 121 switch ( $type ) { 122 122 case 'php': 123 $allowed_files += $theme->get_files( 'php', 1 );123 $allowed_files += $theme->get_files( 'php', -1 ); 124 124 $has_templates = ! empty( $allowed_files ); 125 125 break; 126 126 case 'css': 127 $style_files = $theme->get_files( 'css' );127 $style_files = $theme->get_files( 'css', -1 ); 128 128 $allowed_files['style.css'] = $style_files['style.css']; 129 129 $allowed_files += $style_files; 130 130 break; 131 131 default: 132 $allowed_files += $theme->get_files( $type );132 $allowed_files += $theme->get_files( $type, -1 ); 133 133 break; 134 134 } 135 135 } -
src/wp-includes/class-wp-theme.php
976 976 * being absolute paths. 977 977 */ 978 978 public function get_files( $type = null, $depth = 0, $search_parent = false ) { 979 $files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth ); 979 // get and cache all theme files to start with. 980 $label = 'list_files_cache_' . $this->get('Name') . '-' . $this->get('Version'); 981 $all_files = get_transient( $label ); 982 if ( empty( $all_files ) ) { 983 $all_files = (array) self::scandir( $this->get_stylesheet_directory(), null, -1 ); 980 984 981 if ( $search_parent && $this->parent() )982 $files += (array) self::scandir( $this->get_template_directory(), $type, $depth);985 if ( $search_parent && $this->parent() ) 986 $all_files += (array) self::scandir( $this->get_template_directory(), null, -1 ); 983 987 988 set_transient( $label, $all_files, HOUR_IN_SECONDS ); 989 } 990 991 // Filter $all_files by $type & $depth 992 $files = array(); 993 if ( $type ) { 994 $type = (array) $type; 995 $_extensions = implode( '|', $type ); 996 } 997 foreach ($all_files as $key => $file) { 998 if ( -1 != $depth && substr_count($key,'/') > $depth ) continue; // Filter by depth. 999 if ( ! $type || preg_match( '~\.(' . $_extensions . ')$~', $file ) ) { // Filter by type. 1000 $files[ $key ] = $file; 1001 } 1002 } 1003 984 1004 return $files; 985 1005 } 986 1006