-
Notifications
You must be signed in to change notification settings - Fork 42
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 #1144
Comments
Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels. |
Updating this ticket to be a combined dev note for 'Block Hooks' as this has changed in the Gutenberg tracker. Experiment: Auto-inserting blocks on the frontend and in the editor (via REST API) #51449- Dev Note tracking: Experiment: Auto-inserting blocks on the frontend and in the editor (via REST API) #51449 |
@abhansnuk when do you need the Dev Note posted by? |
Hi @ndiego Ideally, we need it by Monday... but do check in if there are blockers... |
Excellent dev note @ndiego and really like your explanation and dividing this into two clear points, plus explaining why this causes some limitations. I have done the second review for time, and
I wondered as this is going to be a very useful feature for eCommerce, whether there was a tag that has been used before on dev notes for flagging up notes particularly useful for eCommerce. @bph you might already know. Thanks Nick for writing this dev note. Perhaps it is one that will give rise to some case study posts on the Dev Blog. |
Thanks @abhansnuk! I'll add a few additional props when you are out. The code blocks still need a final review tomorrow by @gziolo. |
I reviewed the post:
waiting for @gziolo's review to be published |
The example included could get some tiny changes: function example_block_hooks( $hooked_blocks, $position, $anchor_block, $context ) {
// Template/Template Part hooks.
if ( $context instanceof WP_Block_Template ) {
// Hooks the "Like" button block before the Post Title in the Single template.
if (
'core/post-title' === $anchor_block &&
'before' === $position &&
'single' === $context->slug
) {
$hooked_blocks[] = 'ockham/like-button';
}
// Hooks the Login/Logout link block after the Navigation block if the context of the template part is a header.
if (
'core/group' === $anchor_block &&
'last_child' === $position &&
'header' === $context->area
) {
$hooked_blocks[] = 'core/loginout';
}
}
// Pattern hooks.
if ( is_array( $context ) && isset( $context['slug'] ) ) {
// Hooks into the Post Meta pattern in the Twenty Twenty-Four theme.
if (
'core/post-terms' === $anchor_block &&
'after' === $position &&
'twentytwentyfour/post-meta' === $context['slug']
) {
$hooked_blocks[] = 'ockham/like-button';
}
}
return $hooked_blocks;
} The list of proposed changes:
|
I added updated the code examples. Thank you, @gziolo |
Published: Introducing Block Hooks for dynamic blocks |
Thanks everyone. I see this has been published. Team effort 💪 |
Published link https://make.wordpress.org/core/2023/10/15/introducing-block-hooks-for-dynamic-blocks/ |
Marked as needing a standalone dev note on the Gutenberg repo. Two tickets were combined in Oct 2023 to be one dev note on Block Hooks area.
For info, the full list and discussion on these tickets WordPress/gutenberg#54998
The text was updated successfully, but these errors were encountered: