Make WordPress Core

Ticket #38696: 38696.diff

File 38696.diff, 3.2 KB (added by swissspidy, 9 years ago)
  • src/wp-admin/edit-form-advanced.php

    diff --git src/wp-admin/edit-form-advanced.php src/wp-admin/edit-form-advanced.php
    index 392b514..1627439 100644
    foreach ( get_object_taxonomies( $post ) as $tax_name ) { 
    259259        add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
    260260}
    261261
    262 if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( null, $post_type ) ) > 0 ) {
     262if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) {
    263263        add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' );
    264264}
    265265
  • src/wp-includes/class-wp-theme.php

    diff --git src/wp-includes/class-wp-theme.php src/wp-includes/class-wp-theme.php
    index 66f623e..8b3661a 100644
    final class WP_Theme implements ArrayAccess { 
    10821082                $post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array();
    10831083
    10841084                if ( $this->parent() ) {
    1085                         $post_templates += $this->parent()->get_page_templates( $post );
     1085                        $post_templates += $this->parent()->get_page_templates( $post, $post_type );
    10861086                }
    10871087
    10881088                /**
  • new file tests/phpunit/data/themedir1/page-templates-child/style.css

    diff --git tests/phpunit/data/themedir1/page-templates-child/style.css tests/phpunit/data/themedir1/page-templates-child/style.css
    new file mode 100644
    index 0000000..2b54037
    - +  
     1/*
     2Theme Name: Page Template Child Theme
     3Theme URI: http://example.org/
     4Description: An example child theme with page templates
     5Version: 0.1
     6Author: Mr. WordPress
     7Author URI: http://wordpress.org/
     8Template: page-templates
     9
     10This is just a stub to test the loading of the above metadata.
     11
     12*/
  • tests/phpunit/tests/admin/includesTheme.php

    diff --git tests/phpunit/tests/admin/includesTheme.php tests/phpunit/tests/admin/includesTheme.php
    index ba76bf1..5319006 100644
    class Tests_Admin_includesTheme extends WP_UnitTestCase { 
    8585                ), get_page_templates( null, 'post' ) );
    8686                $this->assertEquals( array(), get_page_templates( null, 'bar' ) );
    8787        }
     88
     89        /**
     90         * @ticket 38696
     91         */
     92        function test_page_templates_child_theme() {
     93                $theme = wp_get_theme( 'page-templates-child' );
     94                $this->assertNotEmpty( $theme );
     95
     96                switch_theme( $theme['Template'], $theme['Stylesheet'] );
     97
     98                $this->assertEqualSetsWithIndex( array(
     99                        'Top Level' => 'template-top-level-post-types.php',
     100                        'Sub Dir'   => 'subdir/template-sub-dir-post-types.php',
     101                ), get_page_templates( null, 'foo' ) );
     102                $this->assertEqualSetsWithIndex( array(
     103                        'Top Level' => 'template-top-level-post-types.php',
     104                        'Sub Dir'   => 'subdir/template-sub-dir-post-types.php',
     105                ), get_page_templates( null, 'post' ) );
     106                $this->assertEqualSetsWithIndex( array(
     107                        'Top Level'                           => 'template-top-level.php',
     108                        'Sub Dir'                             => 'subdir/template-sub-dir.php',
     109                        'This Template Header Is On One Line' => 'template-header.php',
     110                ), get_page_templates() );
     111                $this->assertEquals( array(), get_page_templates( null, 'bar' ) );
     112        }
    88113}