hooked_block_(hooked_block_type) filter-hookWP 6.5.0

Filters the parsed block array for a given hooked block.

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

Usage

add_filter( 'hooked_block_(hooked_block_type)', 'wp_kama_hooked_block_type_filter', 10, 5 );

/**
 * Function for `hooked_block_(hooked_block_type)` filter-hook.
 * 
 * @param array|null                      $parsed_hooked_block The parsed block array for the given hooked block type, or null to suppress the block.
 * @param string                          $hooked_block_type   The hooked block type name.
 * @param string                          $relative_position   The relative position of the hooked block.
 * @param array                           $parsed_anchor_block The anchor block, in parsed block array format.
 * @param WP_Block_Template|WP_Post|array $context             The block template, template part, post object, or pattern that the anchor block belongs to.
 *
 * @return array|null
 */
function wp_kama_hooked_block_type_filter( $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context ){

	// filter...
	return $parsed_hooked_block;
}
$parsed_hooked_block(array|null)
The parsed block array for the given hooked block type, or null to suppress the block.
$hooked_block_type(string)
The hooked block type name.
$relative_position(string)
The relative position of the hooked block.
$parsed_anchor_block(array)
The anchor block, in parsed block array format.
$context(WP_Block_Template|WP_Post|array)
The block template, template part, post object, or pattern that the anchor block belongs to.

Changelog

Since 6.5.0 Introduced.

Where the hook is called

insert_hooked_blocks()
hooked_block_(hooked_block_type)
set_ignored_hooked_blocks_metadata()
hooked_block_(hooked_block_type)
wp-includes/blocks.php 985
$parsed_hooked_block = apply_filters( "hooked_block_{$hooked_block_type}", $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context );
wp-includes/blocks.php 1043
$parsed_hooked_block = apply_filters( "hooked_block_{$hooked_block_type}", $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context );

Where the hook is used in WordPress

wp-includes/blocks.php 1160
add_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX );
wp-includes/blocks.php 1166
remove_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX );