-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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_template()
for template part lookup
#55956
Comments
cc/ @johnbillion @gziolo @Mamaduka who have worked on this block :) |
Good idea and improvement makes sense to me. The queries used by Differences (I can spot):
I think these still can be applied in render functions, as they are block render specific. |
👍
Are you sure about that? 🤔 In the absence of a published template part, it falls back to theme file template parts, no? gutenberg/packages/block-library/src/template-part/index.php Lines 62 to 67 in e4c8ef8
Yeah, good point; @gziolo also brought this up to me. I have to look more into the history of this change; maybe it's something that should be applied to the methods in
Yeah, maybe. They do need a bit of context that we're otherwise encapsulating in |
This is what I meant by published status:
Exactly. The |
What problem does this address?
The Template Part block has been duplicating functionality (by a low-level implementation of template part lookup from the database with a fallback to block theme provided files) that’s also present in various functions in Core’s
block-template-utils.php
file.This has become a problem at least twice, when we needed Template Part blocks to apply template related filters that are only present in those higher-level methods from
block-template-utils.php
, leading to #52892 and #55811, where we’ve replaced some low-level logic with slightly higher-level methods.This solved the problems at hand. However, there's still a risk that the template part lookup code will continue to diverge — e.g. when an enhancement or bugfix is introduced into the methods in
block-template-utils.php
, the Template Part block might not receive them.What is your proposed solution?
AFAICT, there’s no conceptual need for the implementation of the Template Part block to deviate from what could essentially be done by a single
get_block_template
call.The major obstacle seems to be the presence of the three actions fired by the Template Part block during rendering, introduced by #36884. However, we might be able to accommodate for that by moving those actions over to the respective helper functions in
block-template-utils.php
.The text was updated successfully, but these errors were encountered: