Changeset 20327 for trunk/wp-includes/class-wp-theme.php
- Timestamp:
- 03/30/2012 02:06:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-theme.php
r20324 r20327 397 397 return $this->get_stylesheet(); 398 398 case 'Template Files' : 399 $files = $this->get_files( 'php' , 1);399 $files = $this->get_files( 'php' ); 400 400 if ( $this->parent() ) 401 $files = array_merge( $files, $this->parent()->get_files( 'php' , 1) );401 $files = array_merge( $files, $this->parent()->get_files( 'php' ) ); 402 402 return $files; 403 403 case 'Stylesheet Files' : … … 962 962 * returns an array, with the keys being the file types, and the values being an array of files for those type. 963 963 */ 964 public function get_files( $type = null, $depth = 0) {964 public function get_files( $type ) { 965 965 $files = $this->cache_get( 'files' ); 966 966 if ( ! is_array( $files ) ) { 967 $files = (array) self::scandir( $this->get_stylesheet_directory(), array( 'php', 'css' ), $depth);967 $files = (array) self::scandir( $this->get_stylesheet_directory(), array( 'php', 'css' ), 1 ); 968 968 foreach ( $files as &$group ) 969 969 ksort( $group ); 970 unset( $group );971 970 $this->cache_add( 'files', $files ); 972 971 } … … 994 993 995 994 $page_templates = $this->cache_get( 'page_templates' ); 996 if ( is_array( $page_templates ) ) 997 return $page_templates; 998 $page_templates = array(); 999 1000 $files = (array) self::scandir( $this->get_stylesheet_directory(), 'php', 1 ); 1001 1002 foreach ( $files['php'] as $file => $full_path ) { 1003 $headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) ); 1004 if ( empty( $headers['Template Name'] ) ) 1005 continue; 1006 $page_templates[ $file ] = $this->translate_header( 'Template Name', $headers['Template Name'] ); 1007 } 1008 1009 $this->cache_add( 'page_templates', $page_templates ); 995 996 if ( ! is_array( $page_templates ) ) { 997 $page_templates = array(); 998 999 $files = (array) self::scandir( $this->get_stylesheet_directory(), 'php', 1 ); 1000 1001 foreach ( $files['php'] as $file => $full_path ) { 1002 $headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) ); 1003 if ( empty( $headers['Template Name'] ) ) 1004 continue; 1005 $page_templates[ $file ] = $headers['Template Name']; 1006 } 1007 1008 $this->cache_add( 'page_templates', $page_templates ); 1009 } 1010 1011 if ( $this->load_textdomain() ) { 1012 foreach ( $page_templates as &$page_template ) { 1013 $page_template = $this->translate_header( 'Template Name', $page_template ); 1014 } 1015 } 1010 1016 1011 1017 if ( $this->parent() ) … … 1027 1033 * for the found files, particularly when this function recurses to lower depths. 1028 1034 */ 1029 private static function scandir( $path, $extensions, $depth = 1, $relative_path = '' ) {1035 private static function scandir( $path, $extensions, $depth = 0, $relative_path = '' ) { 1030 1036 if ( ! is_dir( $path ) ) 1031 1037 return false;
Note: See TracChangeset
for help on using the changeset viewer.