[wp-trac] [WordPress Trac] #59549: Blocks: Remove block visitor indirection in hooked blocks insertion
WordPress Trac
noreply at wordpress.org
Thu Oct 5 13:45:15 UTC 2023
#59549: Blocks: Remove block visitor indirection in hooked blocks insertion
-----------------------------+-----------------------------
Reporter: Bernhard Reiter | Owner: Bernhard Reiter
Type: enhancement | Status: assigned
Priority: normal | Milestone: 6.4
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
It might make sense to remove the extra indirection (i.e. the
`make_before_block_visitor` and `make_after_block_visitor` factories) that
we currently have around the visitor callbacks that we pass to
`traverse_and_serialize_blocks`.
The original idea behind that indirection was a clean-room level
separation of concerns: While I wanted the `hooked_block_types` filter to
be aware of the template, template part, or pattern that it belongs to, I
wanted to keep `traverse_and_serialize_block(s)` perfectly unaware of this
extra information. The best way I could think of at the time was the
indirection through the `make_` factories.
However, I'm coming round to considering the alternative of passing the
extra context to `traverse_and_serialize_block(s)` after all, and then
have that function pass it as an argument to the callbacks. Importantly,
to preserve separation of context, for the purpose of
`traverse_and_serialize_block(s)`, I'd like the extra data to be
completely generic (i.e. a `mixed` datatype with no assumptions with
regard to what it contains); it's solely up to the caller what that extra
data looks like, and how it is used by the callbacks.
This might help improve performance of Block Hooks related logic a bit.
Furthermore, it unlocks the ability to pass additional data to the
callbacks.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59549>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list