Filter hook 'hooked_block_types'

in WP Core File wp-includes/blocks.php at line 1027

View Source

hooked_block_types

Filter Hook
Description
Adds a list of hooked block types to an anchor block's ignored hooked block types. This function is meant for internal use only.

Hook Information

File Location wp-includes/blocks.php View on GitHub
Hook Type Filter
Line Number 1027

Hook Parameters

Type Name Description
array $parsed_anchor_block The anchor block, in parsed block array format.
string $relative_position The relative position of the hooked blocks. Can be one of 'before', 'after', 'first_child', or 'last_child'.
array $hooked_blocks An array of hooked block types, grouped by anchor block and relative position.
WP_Block_Template|WP_Post|array $context The block template, template part, or pattern that the anchor block belongs to.

Usage Examples

Basic Usage
<?php
// Hook into hooked_block_types
add_filter('hooked_block_types', 'my_custom_filter', 10, 4);

function my_custom_filter($parsed_anchor_block, $relative_position, $hooked_blocks, $context) {
    // Your custom filtering logic here
    return $parsed_anchor_block;
}

Source Code Context

wp-includes/blocks.php:1027 - How this hook is used in WordPress core
<?php
1022  	$hooked_block_types = isset( $hooked_blocks[ $anchor_block_type ][ $relative_position ] )
1023  		? $hooked_blocks[ $anchor_block_type ][ $relative_position ]
1024  		: array();
1025  
1026  	/** This filter is documented in wp-includes/blocks.php */
1027  	$hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context );
1028  	if ( empty( $hooked_block_types ) ) {
1029  		return '';
1030  	}
1031  
1032  	foreach ( $hooked_block_types as $index => $hooked_block_type ) {

PHP Documentation

<?php
/**
 * Adds a list of hooked block types to an anchor block's ignored hooked block types.
 *
 * This function is meant for internal use only.
 *
 * @since 6.5.0
 * @access private
 *
 * @param array                           $parsed_anchor_block The anchor block, in parsed block array format.
 * @param string                          $relative_position   The relative position of the hooked blocks.
 *                                                             Can be one of 'before', 'after', 'first_child', or 'last_child'.
 * @param array                           $hooked_blocks       An array of hooked block types, grouped by anchor block and relative position.
 * @param WP_Block_Template|WP_Post|array $context             The block template, template part, or pattern that the anchor block belongs to.
 * @return string Empty string.
 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/blocks.php
Related Hooks

Related hooks will be displayed here in future updates.