wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
make_before_block_visitor is private and should not be used in themes or plugins directly.
make_before_block_visitor › WordPress Function
Seit6.4.0
Veraltetn/v
› make_before_block_visitor ( $hooked_blocks, $context, $callback = 'insert_hooked_blocks' )
| Zugriff: |
|
| Parameter: (3) |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: | |
| Changelog: |
|
Returns a function that injects the theme attribute into, and hooked blocks before, a given block.
The returned function can be used as$pre_callback argument to traverse_and_serialize_block(s),
where it will inject the theme attribute into all Template Part blocks, and prepend the markup for
any blocks hooked before the given block and as its parent's first_child, respectively.
This function is meant for internal use only.Ähnliche Funktionen: make_after_block_visitor, wp_render_block_visibility_support, before_last_bar, parse_blocks, wp_use_widgets_block_editor
Quellcode
function make_before_block_visitor( $hooked_blocks, $context, $callback = 'insert_hooked_blocks' ) {
/**
* Injects hooked blocks before the given block, injects the `theme` attribute into Template Part blocks, and returns the serialized markup.
*
* If the current block is a Template Part block, inject the `theme` attribute.
* Furthermore, prepend the markup for any blocks hooked `before` the given block and as its parent's
* `first_child`, respectively, to the serialized markup for the given block.
*
* @param array $block The block to inject the theme attribute into, and hooked blocks before. Passed by reference.
* @param array $parent_block The parent block of the given block. Passed by reference. Default null.
* @param array $prev The previous sibling block of the given block. Default null.
* @return string The serialized markup for the given block, with the markup for any hooked blocks prepended to it.
*/
return function ( &$block, &$parent_block = null, $prev = null ) use ( $hooked_blocks, $context, $callback ) {
_inject_theme_attribute_in_template_part_block( $block );
$markup = '';
if ( $parent_block && ! $prev ) {
// Candidate for first-child insertion.
$markup .= call_user_func_array(
$callback,
array( &$parent_block, 'first_child', $hooked_blocks, $context )
);
}
$markup .= call_user_func_array(
$callback,
array( &$block, 'before', $hooked_blocks, $context )
);
return $markup;
};
}