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
This commit is contained in:
nacin 2012-02-29 20:18:53 +00:00
parent a8d45a288f
commit 0dc52c8043
2 changed files with 4 additions and 4 deletions

View File

@ -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() );
}
/**

View File

@ -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 );