From 78d11eedea3f43dd559815998e752adcc7fa85ba Mon Sep 17 00:00:00 2001 From: Andrew 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: https://develop.svn.wordpress.org/trunk@20317 602fd350-edb4-49c9-b593-d223f7449a82 --- 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 d35e92f753..998913c32f 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; }