[wp-trac] [WordPress Trac] #59572: Block Hooks: Allow passing block definitions
WordPress Trac
noreply at wordpress.org
Mon Oct 9 17:09:04 UTC 2023
#59572: Block Hooks: Allow passing block definitions
-----------------------------+------------------------------
Reporter: Bernhard Reiter | Owner: Bernhard Reiter
Type: enhancement | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Comment (by Bernhard Reiter):
Tentative idea:
{{{
diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index 00d9fdae3e..90cf58ab33 100644
--- a/src/wp-includes/blocks.php
+++ b/src/wp-includes/blocks.php
@@ -804,6 +804,10 @@ function make_before_block_visitor( $hooked_blocks,
$context ) {
*/
$hooked_block_types = apply_filters(
'hooked_block_types', $hooked_block_types, $relative_position,
$anchor_block_type, $context );
foreach ( $hooked_block_types as
$hooked_block_type ) {
+ if ( is_array( $hooked_block_type ) &&
isset( $hooked_block_type['blockName'] ) && isset(
$hooked_block_type['attrs'] ) ) {
+ $markup .=
get_comment_delimited_block_content( $hooked_block_type['blockName'],
$hooked_block_type['attrs'], '' );
+ continue;
+ }
$markup .=
get_comment_delimited_block_content( $hooked_block_type, array(), '' );
}
}
}}}
(Needs repeating the same for the other three relative positions.)
Not super pretty, but at least somewhat consistent. One downside is that
we called the filter `hooked_block_types`; but here, they'd become actual
hooked block instances.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59572#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list