Ticket #6531: 6531.5b.diff
File 6531.5b.diff, 1.5 KB (added by , 7 years ago) |
---|
-
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