[wp-trac] [WordPress Trac] #59424: Blocks: Introduce filter to allow easy addition of hooked blocks
WordPress Trac
noreply at wordpress.org
Mon Sep 25 08:42:59 UTC 2023
#59424: Blocks: Introduce filter to allow easy addition of hooked blocks
---------------------------------------------+-----------------------------
Reporter: Bernhard Reiter | Owner: Bernhard
| Reiter
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.4
Component: General | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests commit | Focuses:
---------------------------------------------+-----------------------------
Changes (by Bernhard Reiter):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"56673" 56673]:
{{{
#!CommitTicketReference repository="" revision="56673"
Blocks: Introduce filter to allow easy addition of hooked blocks.
Introduce a `hooked_block_types` filter that allows easier conditional
addition (or removal) of hooked blocks for a given anchor block and
relative position.
{{{#!php
function insert_shopping_cart_hooked_block( $hooked_blocks, $position,
$anchor_block, $context ) {
if ( 'after' === $position && 'core/navigation' === $anchor_block
&& /** $context is header template part **/ ) {
$hooked_blocks[] = 'mycommerce/shopping-cart';
}
return $hooked_blocks;
}
add_filter( 'hooked_block_types', 'insert_shopping_cart_hooked_block', 10,
4 );
}}}
Props gziolo, nerrad, dmsnell, ndiego.
Fixes #59424.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59424#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list