-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Block Hooks API: Update block-template-utils for first-last child template parts #6867
base: trunk
Are you sure you want to change the base?
Block Hooks API: Update block-template-utils for first-last child template parts #6867
Conversation
…d blocks for template parts
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
This is looking good! Love to see the re-use of Is it possible to get away with even fewer changes (to |
As it stands using that filter in the templates controller only gives us the following information; I think we have two options to fix that:
|
Having looked at it again. If the template already has a database record we get the |
Is that really a problem though? Can't we implicitly assume |
Another thing I realized is that on a higher level, For the editor (i.e. the REST API), we might be able to use |
Unless I'm misunderstanding what you're saying here. Those pieces are covered by the updates I made to |
No, that's fine! I guess I was hoping to unify first/last child insertion into |
tests/phpunit/tests/blocks/updateIgnoredHookedBlocksPostMeta.php
Outdated
Show resolved
Hide resolved
bc236c9
to
aaea68d
Compare
…-into-template-part
… wp_template_part
…rt_block is run as a visitor callback
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Currently you are unable to insert hooked blocks in
first_child
andlast_child
positions of template parts. This is because, similarly to the Navigation block the anchor block (core/navigation
/core/template-part
) and its children are detached in the markup from one and other.To solve this issue we have approached it in a similar way by mocking the anchor block in such cases for the purpose of running the block hooks algorithm against it and extracting any related metadata (e.g.
ignoredHookedBlocks
) which are then stored in postmeta.Trac ticket: https://core.trac.wordpress.org/ticket/60854
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
Testing instructions
core/loginout
block as afirst_child
into template parts._wp_ignored_hooked_blocks
data fromwp_postmeta
from your site and perform steps 1-3 again for modified templates.functions.php
block.json