insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata()
云策文档标注
概述
insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata() 函数用于内部处理,返回指定锚块在特定相对位置处钩入块的标记,并更新锚块的忽略钩入块类型列表。
关键要点
- 函数接受四个参数:$parsed_anchor_block(解析后的锚块数组)、$relative_position(相对位置,可选 'before'、'after'、'first_child' 或 'last_child')、$hooked_blocks(钩入块类型数组)和 $context(上下文,如 WP_Block_Template、WP_Post 或数组)。
- 函数内部调用 insert_hooked_blocks() 和 set_ignored_hooked_blocks_metadata(),分别处理标记生成和元数据设置。
- 返回类型为字符串,表示生成的标记。
- 此函数自 WordPress 6.6.0 版本引入,仅供内部使用。
代码示例
function insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $hooked_blocks, $context ) {
$markup = insert_hooked_blocks( $parsed_anchor_block, $relative_position, $hooked_blocks, $context );
$markup .= set_ignored_hooked_blocks_metadata( $parsed_anchor_block, $relative_position, $hooked_blocks, $context );
return $markup;
}
原文内容
Returns the markup for blocks hooked to the given anchor block in a specific relative position and then adds a list of hooked block types to an anchor block’s ignored hooked block types.
Description
This function is meant for internal use only.
Parameters
$parsed_anchor_blockarrayrequired-
The anchor block, in parsed block array format.
$relative_positionstringrequired-
The relative position of the hooked blocks.
Can be one of'before','after','first_child', or'last_child'. $hooked_blocksarrayrequired-
An array of hooked block types, grouped by anchor block and relative position.
$contextWP_Block_Template|WP_Post|arrayrequired-
The block template, template part, or pattern that the anchor block belongs to.
Source
function insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $hooked_blocks, $context ) {
$markup = insert_hooked_blocks( $parsed_anchor_block, $relative_position, $hooked_blocks, $context );
$markup .= set_ignored_hooked_blocks_metadata( $parsed_anchor_block, $relative_position, $hooked_blocks, $context );
return $markup;
}
Changelog
| Version | Description |
|---|---|
| 6.6.0 | Introduced. |