-
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
Template Part Block: Use get_block_file_template
for rendering
#52892
Template Part Block: Use get_block_file_template
for rendering
#52892
Conversation
get_block_file_template
for rendering
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 @ockham!
The new function doesn't seem to |
I just did, and it seemed to work fine in my testing. (I made a quick child theme of TT3 locally and verified that it picked up the parent's template parts; I then added a modified I don't quite see why |
Since this PR has approval and parent themes seem to be working fine for me, I'll go ahead and merge (in order to unblock #51449). Happy to tweak or revert in case we find that it's breaking something after all! |
This introduced a regression: #56013 |
What?
Change the Template Part block's render method (
render_block_core_template_part
) to useget_block_file_template
rather than a number of lower-level functions.Why?
Higher-level functions such as
get_block_file_template
apply filters (such as the eponymousget_block_file_template
) that otherwise aren't invoked. (This is relevant e.g. for #51449.)Furthermore, it can be argued that if a high-level function is available to what otherwise requires calling a number of lower-level functions, it's preferable to use the high-level function (unless there are side effects and/or performance issues, of course) 😄
How?
By using
get_block_file_template
(which returns aWP_Block_Template
object) in the code branch that loads a block template from a theme file, thus supplanting calls to the lower-level_get_block_template_file
and_inject_theme_attribute_in_block_template_content
functions.Note that
get_block_file_template
invokes both of them in its function body. (_inject_theme_attribute_in_block_template_content
is called via_build_block_template_result_from_file
).Testing Instructions
Verify that Template Parts still work as before: