From 7c8c385a3ce41f5cd4a3439ebb19ec304eca10d5 Mon Sep 17 00:00:00 2001 From: nacin Date: Thu, 29 Mar 2012 05:37:37 +0000 Subject: [PATCH] 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. git-svn-id: http://svn.automattic.com/wordpress/trunk@20317 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index d35e92f75..998913c32 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -997,18 +997,20 @@ final class WP_Theme implements ArrayAccess { return $page_templates; $page_templates = array(); - $files = (array) self::scandir( $this->get_template_directory(), 'php' ); - if ( $this->is_child_theme() ) - $files = array_merge_recursive( $files, (array) self::scandir( $this->get_stylesheet_directory(), 'php' ) ); + $files = (array) self::scandir( $this->get_stylesheet_directory(), 'php' ); - foreach ( $files['php'] as $file ) { - $headers = get_file_data( $file, array( 'Template Name' => 'Template Name' ) ); + foreach ( $files['php'] as $file => $full_path ) { + $headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) ); if ( empty( $headers['Template Name'] ) ) continue; - $page_templates[ basename( $file ) ] = $this->translate_header( 'Template Name', $headers['Template Name'] ); + $page_templates[ $file ] = $this->translate_header( 'Template Name', $headers['Template Name'] ); } $this->cache_add( 'page_templates', $page_templates ); + + if ( $this->parent() ) + $page_templates += $this->parent()->get_page_templates(); + return $page_templates; }