-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template Parts: Fix loading issue (#28088)
* Inject theme attribute in theme provided template content * Remove theme attribute from exported templates
- Loading branch information
Showing
4 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Test `gutenberg_edit_site_export` and its helper functions. | ||
* | ||
* @package Gutenberg | ||
*/ | ||
|
||
class Edit_Site_Export_Test extends WP_UnitTestCase { | ||
function test_remove_theme_attribute_from_content() { | ||
$content_without_theme_attribute = '<!-- wp:template-part {"slug":"header","theme":"tt1-blocks","align":"full","tagName":"header","className":"site-header"} /-->'; | ||
$template_content = _remove_theme_attribute_from_content( $content_without_theme_attribute ); | ||
$expected = '<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header"} /-->'; | ||
$this->assertEquals( $expected, $template_content ); | ||
|
||
// Does not modify content when there is no existing theme attribute. | ||
$content_with_existing_theme_attribute = '<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header"} /-->'; | ||
$template_content = _remove_theme_attribute_from_content( $content_with_existing_theme_attribute ); | ||
$this->assertEquals( $content_with_existing_theme_attribute, $template_content ); | ||
|
||
// Does not remove theme when there is no template part. | ||
$content_with_no_template_part = '<!-- wp:post-content /-->'; | ||
$template_content = _remove_theme_attribute_from_content( $content_with_no_template_part ); | ||
$this->assertEquals( $content_with_no_template_part, $template_content ); | ||
} | ||
} | ||
|