Make WordPress Core

Changeset 55493

Timestamp:
03/08/2023 10:43:32 PM (17 months ago)
Author:
hellofromTonya
Message:

Site Editor: Revert r54860.

[54860] caused a regression. Changes to a parent theme's template part (i.e.e when a child theme does not override that template part) no longer saved in the Site Editor. Reverting the changeset resolves the regression.

Props mreishus, hellofromTonya, azaozz, ironprogrammer, antonvlasenko.

Fixes #57630.
See #55437.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-template-utils.php

    r55194 r55493  
    504504    $template                 = new WP_Block_Template();
    505505    $template->id             = $theme . '//' . $template_file['slug'];
    506     $template->theme          = ! empty( $template_file['theme'] ) ? $template_file['theme'] : $theme;
     506    $template->theme          = $theme;
    507507    $template->content        = _inject_theme_attribute_in_block_template_content( $template_content );
    508508    $template->slug           = $template_file['slug'];
  • trunk/tests/phpunit/tests/block-template-utils.php

    r55457 r55493  
    120120    }
    121121
    122     /**
    123      * Tests that _build_block_template_result_from_post() returns the correct theme
    124      * for the template when a child theme is active.
    125      *
    126      * @ticket 55437
    127      *
    128      * @covers ::_build_block_template_result_from_post
    129      */
    130     public function test_build_block_template_result_from_post_with_child_theme() {
    131         switch_theme( 'block-theme-child' );
    132 
    133         $template = _build_block_template_result_from_post(
    134             self::$template_post,
    135             'wp_template'
    136         );
    137 
    138         $this->assertSame( self::TEST_THEME, $template->theme );
    139     }
    140 
    141122    public function test_build_block_template_result_from_file() {
    142123        $template = _build_block_template_result_from_file(
     
    175156        $this->assertSame( 'wp_template_part', $template_part->type );
    176157        $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area );
    177     }
    178 
    179     /**
    180      * Tests that _build_block_template_result_from_file() returns the correct theme
    181      * for the template when a child theme is active.
    182      *
    183      * @ticket 55437
    184      *
    185      * @covers ::_build_block_template_result_from_file
    186      */
    187     public function test_build_block_template_result_from_file_with_child_theme() {
    188         switch_theme( 'block-theme-child' );
    189 
    190         $template = _build_block_template_result_from_file(
    191             array(
    192                 'slug'  => 'single',
    193                 'path'  => __DIR__ . '/../data/templates/template.html',
    194                 'theme' => self::TEST_THEME,
    195             ),
    196             'wp_template'
    197         );
    198 
    199         $this->assertSame( self::TEST_THEME, $template->theme );
    200158    }
    201159
Note: See TracChangeset for help on using the changeset viewer.