[wp-trac] [WordPress Trac] #59572: Block Hooks: Allow passing block definitions
WordPress Trac
noreply at wordpress.org
Thu Jan 25 13:47:03 UTC 2024
#59572: Block Hooks: Allow passing block definitions
--------------------------------------+------------------------------
Reporter: Bernhard Reiter | Owner: Bernhard Reiter
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.5
Component: Editor | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Changes (by Bernhard Reiter):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"57354" 57354]:
{{{
#!CommitTicketReference repository="" revision="57354"
Block Hooks: Introduce a new `hooked_block_{$block_type}` filter.
Add a new `hooked_block_{$block_type}` filter that allows modifying a
hooked block (in parsed block format) prior to insertion, while providing
read access to its anchor block (in the same format).
This allows block authors to e.g. set a hooked block's attributes, or its
inner blocks; the filter can peruse information about the anchor block
when doing so. As such, this filter provides a solution to both #59572 and
#60126.
The new filter is designed to strike a good balance and separation of
concerns with regard to the existing
[https://developer.wordpress.org/reference/hooks/hooked_block_types/
`hooked_block_types` filter], which allows addition or removal of a block
to the list of hooked blocks for a given anchor block -- all of which are
identified only by their block ''types''. This new filter, on the other
hand, only applies to ''one'' hooked block at a time, and allows modifying
the entire (parsed) hooked block; it also gives (read) access to the
parsed anchor block.
Props gziolo, tomjcafferkey, andrewserong, isabel_brison, timbroddin,
yansern.
Fixes #59572, #60126.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59572#comment:33>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list