Posts, Post Types: Fix post type templates with child themes.
After [38951] added support for post type templates beyond pages, this fixes an issue where an empty meta box would be shown when using child themes. Fixes #38696. git-svn-id: https://develop.svn.wordpress.org/trunk@39168 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4b3e128140
commit
5f610350e1
@ -259,7 +259,7 @@ foreach ( get_object_taxonomies( $post ) as $tax_name ) {
|
||||
add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
|
||||
}
|
||||
|
||||
if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( null, $post_type ) ) > 0 ) {
|
||||
if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) {
|
||||
add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' );
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1082,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
$post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array();
|
||||
|
||||
if ( $this->parent() ) {
|
||||
$post_templates += $this->parent()->get_page_templates( $post );
|
||||
$post_templates += $this->parent()->get_page_templates( $post, $post_type );
|
||||
}
|
||||
|
||||
/**
|
||||
|
12
tests/phpunit/data/themedir1/page-templates-child/style.css
Normal file
12
tests/phpunit/data/themedir1/page-templates-child/style.css
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
Theme Name: Page Template Child Theme
|
||||
Theme URI: http://example.org/
|
||||
Description: An example child theme with page templates
|
||||
Version: 0.1
|
||||
Author: Mr. WordPress
|
||||
Author URI: http://wordpress.org/
|
||||
Template: page-templates
|
||||
|
||||
This is just a stub to test the loading of the above metadata.
|
||||
|
||||
*/
|
@ -85,4 +85,29 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
), get_page_templates( null, 'post' ) );
|
||||
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 38696
|
||||
*/
|
||||
function test_page_templates_child_theme() {
|
||||
$theme = wp_get_theme( 'page-templates-child' );
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
switch_theme( $theme['Template'], $theme['Stylesheet'] );
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'foo' ) );
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'post' ) );
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates() );
|
||||
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user