From 0dc52c80436a51448369676417212459b674fce6 Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 29 Feb 2012 20:18:53 +0000 Subject: [PATCH] Translate page template names! Have WP_Theme::get_page_templates() return templates keyed by filename, not by template name, as it makes more sense. Flip this in get_page_templates() to be compatible. fixes #6007. git-svn-id: http://svn.automattic.com/wordpress/trunk@20041 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/theme.php | 2 +- wp-includes/class-wp-theme.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 420bb32c0..4ac66c1f5 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -81,7 +81,7 @@ function delete_theme($template, $redirect = '') { * @return array Key is the template name, value is the filename of the template */ function get_page_templates() { - return wp_get_theme()->get_page_templates(); + return array_flip( wp_get_theme()->get_page_templates() ); } /** diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index a58a8acc5..3f9a3803b 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -921,10 +921,10 @@ final class WP_Theme implements ArrayAccess { $files = array_merge_recursive( $files, (array) self::scandir( $this->get_stylesheet_directory(), $this->get_stylesheet_directory(), 'php' ) ); foreach ( $files['php'] as $file ) { - $headers = get_file_data( $file, array( 'Name' => 'Template Name' ) ); - if ( empty( $headers['Name'] ) ) + $headers = get_file_data( $file, array( 'Template Name' => 'Template Name' ) ); + if ( empty( $headers['Template Name'] ) ) continue; - $page_templates[ $headers['Name'] ] = basename( $file ); + $page_templates[ basename( $file ) ] = $this->translate_header( 'Template Name', $headers['Template Name'] ); } $this->cache_add( 'page_templates', $page_templates );