wppaste
WordPress

set_ignored_hooked_blocks_metadata( array $parsed_anchor_block, string $relative_position, array $hooked_blocks, WP_Block_Template|WP_Post|array $context ): string

Since
6.5.0
Source
wp-includes/blocks.php:1100
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.

Compatibility

WordPress
since 6.5.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$parsed_anchor_blockarray
The anchor block, in parsed block array format.
$relative_positionstring
The relative position of the hooked blocks.
Can be one of 'before', 'after', 'first_child', or 'last_child'.
$hooked_blocksarray
An array of hooked block types, grouped by anchor block and relative position.
$contextWP_Block_Template|WP_Post|array
The block template, template part, or pattern that the anchor block belongs to.

Return value

string
Empty string.

Performance profile

How much work a call to set_ignored_hooked_blocks_metadata() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
20–45

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 76.

Plugin surface
3 hooks

Third-party callbacks on 'hooked_block_types', 'hooked_block', 'hooked_block_{$hooked_block_type}' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly

What one call costs · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost set_ignored_hooked_blocks_metadata() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
empty($hooked_block_types)20–25apply_filters()
!empty($hooked_block_types)38–45apply_filters(), array_merge(), array_unique()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev7620–457
8.57620–457
8.47620–457
8.37620–457
8.27620–457
8.17620–4571 fewer instruction than PHP 7.4
7.47720–467

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 3

3 hooks fire while set_ignored_hooked_blocks_metadata() runs, in this order:

  1. apply_filters( hooked_block_types )filterline 1107 (+7 into the body)

    Filters the list of hooked block types for a given anchor block type and relative position.

  2. apply_filters( hooked_block )filterline 1121 (+21 into the body)

    Filters the parsed block array for a given hooked block.

  3. apply_filters( hooked_block_{$hooked_block_type} )filterline 1124 (+24 into the body)

    Filters the parsed block array for a given hooked block.

Uses · 1

  • apply_filters()Calls the callback functions that have been added to a filter hook.

Used by · 1

Source code

function set_ignored_hooked_blocks_metadata( &$parsed_anchor_block, $relative_position, $hooked_blocks, $context ) {	$anchor_block_type  = $parsed_anchor_block['blockName'];	$hooked_block_types = isset( $anchor_block_type, $hooked_blocks[ $anchor_block_type ][ $relative_position ] )		? $hooked_blocks[ $anchor_block_type ][ $relative_position ]		: array(); 	/** This filter is documented in wp-includes/blocks.php */	$hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context );	if ( empty( $hooked_block_types ) ) {		return '';	} 	foreach ( $hooked_block_types as $index => $hooked_block_type ) {		$parsed_hooked_block = array(			'blockName'    => $hooked_block_type,			'attrs'        => array(),			'innerBlocks'  => array(),			'innerContent' => array(),		); 		/** This filter is documented in wp-includes/blocks.php */		$parsed_hooked_block = apply_filters( 'hooked_block', $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context ); 		/** This filter is documented in wp-includes/blocks.php */		$parsed_hooked_block = apply_filters( "hooked_block_{$hooked_block_type}", $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context ); 		if ( null === $parsed_hooked_block ) {			unset( $hooked_block_types[ $index ] );		}	} 	$previously_ignored_hooked_blocks = $parsed_anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ?? array(); 	$parsed_anchor_block['attrs']['metadata']['ignoredHookedBlocks'] = array_unique(		array_merge(			$previously_ignored_hooked_blocks,			$hooked_block_types		)	); 	// Markup for the hooked blocks has already been created (in `insert_hooked_blocks`).	return '';}

Changelog

Introduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/blocks.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.