Repository navigation
Conversation
ishitaj34
marked this pull request as ready for review
November 12, 2026 07:04
Author
|
The CI E2E Tests failure is an upstream runner issue ( All tests pass locally:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #894
Saves unedited theme patterns in templates as
<!-- wp:pattern {"slug":"..."} /-->references instead of copying their full inlined block markup into template files.Why?
When a theme pattern is inserted into a template in the Site Editor, Gutenberg inlines its full block structure and marks the root block with
metadata.patternName.Saving the template with Create Block Theme previously wrote those inlined copies directly into the theme's template files. The template's copy and the standalone pattern file start differing and bug fixes or styling updates made to the pattern never reach the inlined copies in templates.
Core themes build templates using pattern references (
<!-- wp:pattern {"slug":"theme/pattern"} /-->). Saving unedited patterns as references preserves this design, keeps template files clean, and ensures future pattern updates automatically propagate to templates.How?
In
includes/create-theme/theme-templates.php:replace_unedited_theme_patterns()to swap matching unedited blocks for<!-- wp:pattern -->references before localization and export.is_block_matching_pattern()andare_blocks_equivalent()to compare blocks against registered active/parent theme patterns, expanding nested pattern references and normalizing editor metadata and common attribute migrations.cbt_replace_with_pattern_referencefilter to allow opting blocks out of replacement.preservePatternSlugssupport toreplace_template_namespace()so child themes keep references to parent patterns.In
includes/create-theme/theme-create.php:preservePatternSlugs => trueincreate_child_theme().In
tests/test-theme-templates.php:Testing Instructions
Unit tests:
npm run test:unit:php:setupto start wp-env.npm run test:unit:php:base -- --filter Test_Create_Block_Theme_Templates.Manual test:
twentytwentyfive/cta-centered-heading).templates/page.htmland verify the pattern is written as<!-- wp:pattern {"slug":"twentytwentyfive/cta-centered-heading"} /-->.Use of AI Tools