-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject theme stylesheet value as template part theme attribute #53423
Inject theme stylesheet value as template part theme attribute #53423
Conversation
Size Change: +99 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
This fix only seems to work if the template part is in the root of the pattern, i.e. not inside another block such as a group or cover block.
I tested this using Overlaid and Lativ, which I've seen this issue with previously in their home.html templates. Both of their header template parts are inside other blocks within the pattern, and I'm still seeing the 'Template part has been deleted' message:
I think we also need to check the innerBlocks
of each block for template parts too. I've left a potential fix in the inline comments.
Otherwise, this is ace. It'll be so great to fix this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cb99cfe
to
726b1e2
Compare
We are exploring an alternative approach for this solution because the changes on the server seem to have a negative impact on the performance. We are thinking about the following approach: #55217. How we can validate it works as intended? One open question is whether the Pattern returned from REST API needs to have the current theme injected as the |
What?
Fixes #53194
When a Template Part is included in a Pattern the Template Part must have a
theme
attribute else the template part does not render. This is different from including a template part in a template (or another template part) since, in those situations, thetheme
attribute is assumed to be "the current theme".This change replicates that behavior in patterns so that Template Parts referenced from them is assumed to be "the current theme".
Why?
In some design scenarios it's necessary to include content in a pattern (so that the content can be localized, or media references can be included) in such a way that things such as headers and footers contained in template parts need to be included. This change allows that.
How?
When templates are being rendered (both as a view and in the editor) if a template block is being rendered and it is missing the
theme
attribute the current theme's 'stylesheet' property is set as the value.Testing Instructions
Activate a theme with a TEMPLATE that references a PATTERN.
<!-- wp:pattern {"slug":"blank/pattern-with-part"} /-->
The PATTERN should reference a TEMPLATE PART.
And the template part should have content:
Before this patch is applied 'The template part cannot be found' is shown to the user in the editor and view.
After this patch is applied the template part is rendered as expected.