fix: render synced patterns inside Group blocks in newsletters#2069
Open
jason10lee wants to merge 8 commits intotrunkfrom
Open
fix: render synced patterns inside Group blocks in newsletters#2069jason10lee wants to merge 8 commits intotrunkfrom
jason10lee wants to merge 8 commits intotrunkfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes newsletter MJML rendering so synced patterns (core/block / reusable blocks) render correctly when nested inside core/group blocks, adding safer reusable-block resolution behavior.
Changes:
- Add shared reusable-block resolution with wp_block validation and circular-reference protection.
- Teach
render_mjml_component()to handlecore/block(not just top-level conversion). - Add PHPUnit coverage for nested reusable blocks, stale refs, and circular refs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
includes/class-newspack-newsletters-renderer.php |
Adds core/block rendering support via resolve_reusable_block(), circular guard stack, and resets stack per render. |
tests/test-renderer.php |
Adds regression tests covering nested synced patterns, stale refs, and circular references. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Changes proposed
Synced patterns (reusable blocks /
core/block) placed inside Group blocks were silently stripped from newsletter email output. This happened because:is_empty_block()treatedcore/blockas empty (it has noinnerHTML— content lives in a referencedwp_blockpost). This is similar to a pattern that prevented Remote Data Blocks from rendering on send.render_mjml_component()had no handler forcore/block— resolution only happened at the top level inpost_to_mjml_components()This PR extracts the reusable block resolution into a shared
resolve_reusable_block()method used by both code paths, with additional hardening:post_type === 'wp_block'andpost_status === 'publish'(previously unchecked)get_valid_post_blocks()so thenewspack_newsletters_newsletter_contentfilter is applied to nested patterns, matching top-level behaviorResolves NPPM-2610: Bug: Some Patterns don't display in sent Newsletters when placed inside of a "Group" block
How to test