Make WordPress Core


Ignore:
Timestamp:
03/29/2012 05:37:37 AM (13 years ago)
Author:
nacin
Message:

Use new scandir() return value (key is path relative to theme, value is absolute path) in WP_Theme->get_page_templates(). Use parent()->get_page_templates() and merge in a parent's page templates, rather than extra logic. see [20312], see #20103.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-theme.php

    r20316 r20317  
    998998        $page_templates = array();
    999999
    1000         $files = (array) self::scandir( $this->get_template_directory(), 'php' );
    1001         if ( $this->is_child_theme() )
    1002             $files = array_merge_recursive( $files, (array) self::scandir( $this->get_stylesheet_directory(), 'php' ) );
    1003 
    1004         foreach ( $files['php'] as $file ) {
    1005             $headers = get_file_data( $file, array( 'Template Name' => 'Template Name' ) );
     1000        $files = (array) self::scandir( $this->get_stylesheet_directory(), 'php' );
     1001
     1002        foreach ( $files['php'] as $file => $full_path ) {
     1003            $headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) );
    10061004            if ( empty( $headers['Template Name'] ) )
    10071005                continue;
    1008             $page_templates[ basename( $file ) ] = $this->translate_header( 'Template Name', $headers['Template Name'] );
     1006            $page_templates[ $file ] = $this->translate_header( 'Template Name', $headers['Template Name'] );
    10091007        }
    10101008
    10111009        $this->cache_add( 'page_templates', $page_templates );
     1010
     1011        if ( $this->parent() )
     1012            $page_templates += $this->parent()->get_page_templates();
     1013
    10121014        return $page_templates;
    10131015    }
Note: See TracChangeset for help on using the changeset viewer.