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
This commit is contained in:
parent
02979900ea
commit
7c8c385a3c
|
@ -997,18 +997,20 @@ final class WP_Theme implements ArrayAccess {
|
||||||
return $page_templates;
|
return $page_templates;
|
||||||
$page_templates = array();
|
$page_templates = array();
|
||||||
|
|
||||||
$files = (array) self::scandir( $this->get_template_directory(), 'php' );
|
$files = (array) self::scandir( $this->get_stylesheet_directory(), 'php' );
|
||||||
if ( $this->is_child_theme() )
|
|
||||||
$files = array_merge_recursive( $files, (array) self::scandir( $this->get_stylesheet_directory(), 'php' ) );
|
|
||||||
|
|
||||||
foreach ( $files['php'] as $file ) {
|
foreach ( $files['php'] as $file => $full_path ) {
|
||||||
$headers = get_file_data( $file, array( 'Template Name' => 'Template Name' ) );
|
$headers = get_file_data( $full_path, array( 'Template Name' => 'Template Name' ) );
|
||||||
if ( empty( $headers['Template Name'] ) )
|
if ( empty( $headers['Template Name'] ) )
|
||||||
continue;
|
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 );
|
$this->cache_add( 'page_templates', $page_templates );
|
||||||
|
|
||||||
|
if ( $this->parent() )
|
||||||
|
$page_templates += $this->parent()->get_page_templates();
|
||||||
|
|
||||||
return $page_templates;
|
return $page_templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue