mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-15 14:20:24 +00:00
Patterns: Don't inject theme attribute on frontend.
Having the patterns registry inject the `theme` attribute into all Template Part blocks inside every pattern was found to negatively impact performance. It turns out that it's only required for the editor (i.e. in the REST API) but not on the frontend; there, it's instead possible to fall back to the currently active theme. The latter change was made to the Pattern and Template Part blocks in https://github.com/WordPress/gutenberg/pull/55217, which was sync'ed to Core in [56849]. Consequently, this changeset removes `theme` attribute insertion from the frontend. Props flixos90, gziolo, dmsnell, hellofromtonya. Fixes #59583. git-svn-id: https://develop.svn.wordpress.org/trunk@56896 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -161,64 +161,6 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
|
||||
$this->assertEmpty( $template_part->modified );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 59325
|
||||
*
|
||||
* @covers ::_build_block_template_result_from_file
|
||||
*
|
||||
* @dataProvider data_build_block_template_result_from_file_injects_theme_attribute
|
||||
*
|
||||
* @param string $filename The template's filename.
|
||||
* @param string $expected The expected block markup.
|
||||
*/
|
||||
public function test_build_block_template_result_from_file_injects_theme_attribute( $filename, $expected ) {
|
||||
$template = _build_block_template_result_from_file(
|
||||
array(
|
||||
'slug' => 'single',
|
||||
'path' => DIR_TESTDATA . "/templates/$filename",
|
||||
),
|
||||
'wp_template'
|
||||
);
|
||||
$this->assertSame( $expected, $template->content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function data_build_block_template_result_from_file_injects_theme_attribute() {
|
||||
$theme = 'block-theme';
|
||||
return array(
|
||||
'a template with a template part block' => array(
|
||||
'filename' => 'template-with-template-part.html',
|
||||
'expected' => sprintf(
|
||||
'<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /-->',
|
||||
$theme
|
||||
),
|
||||
),
|
||||
'a template with a template part block nested inside another block' => array(
|
||||
'filename' => 'template-with-nested-template-part.html',
|
||||
'expected' => sprintf(
|
||||
'<!-- wp:group -->
|
||||
<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /-->
|
||||
<!-- /wp:group -->',
|
||||
$theme
|
||||
),
|
||||
),
|
||||
'a template with a template part block with an existing theme attribute' => array(
|
||||
'filename' => 'template-with-template-part-with-existing-theme-attribute.html',
|
||||
'expected' => '<!-- wp:template-part {"slug":"header","theme":"fake-theme","align":"full","tagName":"header","className":"site-header"} /-->',
|
||||
),
|
||||
'a template with no template part block' => array(
|
||||
'filename' => 'template.html',
|
||||
'expected' => '<!-- wp:paragraph -->
|
||||
<p>Just a paragraph</p>
|
||||
<!-- /wp:paragraph -->',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 59338
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user