钩子文档

hooked_block_{$hooked_block_type}

💡 云策文档标注

概述

hooked_block_{$hooked_block_type} 是一个动态过滤器,用于修改特定 hooked block 的解析块数组。它允许开发者根据 hooked block 类型、相对位置和上下文调整块内容或抑制其显示。

关键要点

  • 过滤器名称是动态的,基于 $hooked_block_type(hooked block 的类型名称)。
  • 参数包括 $parsed_hooked_block(可修改或设为 null 以抑制块)、$hooked_block_type、$relative_position、$parsed_anchor_block 和 $context。
  • 在 WordPress 6.5.0 版本中引入。
  • 相关函数包括 set_ignored_hooked_blocks_metadata() 和 insert_hooked_blocks()。

📄 原文内容

Filters the parsed block array for a given hooked block.

Description

The dynamic portion of the hook name, $hooked_block_type, refers to the block type name of the specific hooked block.

Parameters

$parsed_hooked_blockarray|null
The parsed block array for the given hooked block type, or null to suppress the block.
$hooked_block_typestring
The hooked block type name.
$relative_positionstring
The relative position of the hooked block.
$parsed_anchor_blockarray
The anchor block, in parsed block array format.
$contextWP_Block_Template|WP_Post|array
The block template, template part, post object, or pattern that the anchor block belongs to.

Source

$parsed_hooked_block = apply_filters( "hooked_block_{$hooked_block_type}", $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context );

Changelog

Version Description
6.5.0 Introduced.