[wp-trac] [WordPress Trac] #59131: Introduce filters to modify/inspect the blocks returned by `do_blocks()`
WordPress Trac
noreply at wordpress.org
Thu Aug 17 15:40:01 UTC 2023
#59131: Introduce filters to modify/inspect the blocks returned by `do_blocks()`
-------------------------+-----------------------------
Reporter: luisherranz | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
The `do_blocks()` function provides a way to process blocks including
block parsing and their subsequent rendering. Currently, it is impossible
for plugins (including Gutenberg) to inspect those values or customize
that logic.
A couple of filters should be introduced that allow to modify or inspect
the blocks before they are included in the final response:
- The first one receives the array of parsed blocks returned by the
`parse_blocks` function. This filter provides an easy way to inspect or
even modify the blocks as a whole, and also gives the opportunity to know
when a call to `do_blocks` has started.
- The second one receives the final HTML rendered returned by the
recursive call to `render_block`. This filter provides an easy way to
inspect or even modify the final rendered output as whole, and also gives
the opportunity to know when a call to `do_blocks` is about to finish.
With the combination of these two filters, it's also possible to ignore
nested calls of `do_blocks` and avoid processing the HTML of blocks more
than once, something that is not possible today using `render_block`
alone.
Target is merging into 6.4.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59131>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list