[wp-trac] [WordPress Trac] #60769: Block Hooks: Consolidate approach to get the list of hooked blocks.
WordPress Trac
noreply at wordpress.org
Wed Mar 13 14:28:40 UTC 2024
#60769: Block Hooks: Consolidate approach to get the list of hooked blocks.
---------------------------+-----------------------------
Reporter: tomjcafferkey | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
Our current approach to getting hooked blocks has two parts to it:
1. We use `get_hooked_blocks()` to get all of the hooked blocks which are
hooked from the `block.json` file.
2. In function `insert_hooked_blocks` we apply the filter callbacks
(passing a derived value from step 1 as the default value) to get hooked
blocks that are applied by the `hooked_block_types` filter.
Currently it's a bit confusing and without knowledge you'd assume
`get_hooked_blocks()` would retrieve ''all'' of the hooked blocks.
Additionally it feels like you have to run a few different pieces of code
separately and combine their resulting values to get a complete picture
which could result in some bugs or unnecessary complexities.
I feel there's room for improvement to provide a better API for getting
all of the hooked blocks by consolidating these two approaches into a
single function somehow.
How this to work we would also need to know the current context so we can
pass that data to the filter callbacks.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60769>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list