Changeset 54860
- Timestamp:
- 11/21/2022 04:48:33 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template-utils.php
r54831 r54860 504 504 $template = new WP_Block_Template(); 505 505 $template->id = $theme . '//' . $template_file['slug']; 506 $template->theme = $theme;506 $template->theme = ! empty( $template_file['theme'] ) ? $template_file['theme'] : $theme; 507 507 $template->content = _inject_theme_attribute_in_block_template_content( $template_content ); 508 508 $template->slug = $template_file['slug']; -
trunk/tests/phpunit/tests/block-template-utils.php
r54402 r54860 124 124 } 125 125 126 /** 127 * Tests that _build_block_template_result_from_post() returns the correct theme 128 * for the template when a child theme is active. 129 * 130 * @ticket 55437 131 * 132 * @covers ::_build_block_template_result_from_post 133 */ 134 function test_build_block_template_result_from_post_with_child_theme() { 135 switch_theme( 'block-theme-child' ); 136 137 $template = _build_block_template_result_from_post( 138 self::$template_post, 139 'wp_template' 140 ); 141 142 $this->assertSame( self::TEST_THEME, $template->theme ); 143 } 144 126 145 function test_build_block_template_result_from_file() { 127 146 $template = _build_block_template_result_from_file( … … 160 179 $this->assertSame( 'wp_template_part', $template_part->type ); 161 180 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 181 } 182 183 /** 184 * Tests that _build_block_template_result_from_file() returns the correct theme 185 * for the template when a child theme is active. 186 * 187 * @ticket 55437 188 * 189 * @covers ::_build_block_template_result_from_file 190 */ 191 function test_build_block_template_result_from_file_with_child_theme() { 192 switch_theme( 'block-theme-child' ); 193 194 $template = _build_block_template_result_from_file( 195 array( 196 'slug' => 'single', 197 'path' => __DIR__ . '/../data/templates/template.html', 198 'theme' => self::TEST_THEME, 199 ), 200 'wp_template' 201 ); 202 203 $this->assertSame( self::TEST_THEME, $template->theme ); 162 204 } 163 205
Note: See TracChangeset
for help on using the changeset viewer.