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
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
- Scaling
- Scales with input
- Instructions
- 20–45
- Plugin surface
- 3 hooks
- Called by
- 1
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 76.
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.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls it makes |
|---|---|---|
empty($hooked_block_types) | 20–25 | apply_filters() |
!empty($hooked_block_types) | 38–45 | apply_filters(), array_merge(), array_unique() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 76 | 20–45 | 7 | |
| 8.5 | 76 | 20–45 | 7 | |
| 8.4 | 76 | 20–45 | 7 | |
| 8.3 | 76 | 20–45 | 7 | |
| 8.2 | 76 | 20–45 | 7 | |
| 8.1 | 76 | 20–45 | 7 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 77 | 20–46 | 7 |
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:
- 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.
- apply_filters( hooked_block )filterline 1121 (+21 into the body)
Filters the parsed block array for a given hooked block.
- 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
- insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata()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.
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.
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.