update_ignored_hooked_blocks_postmeta( stdClass $post ): stdClass
- Since
- 6.6.0
- Source
wp-includes/blocks.php:1177
Description
Currently only supports wp_navigation post types.
Compatibility
- WordPress
- since 6.6.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
$poststdClass- Post object.
Return value
stdClass- The updated post object.
Performance profile
How much work a call to update_ignored_hooked_blocks_postmeta() 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
- Heavy
- Scaling
- Constant
- Instructions
- 4–114
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 118.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_post()called directly - serializeserialisation
json_decode()called directly - hookthird-party callbacks
apply_filters()one call below update_ignored_hooked_blocks_postmeta()
Further down the call graph this can also reach cache, option and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 7 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost update_ignored_hooked_blocks_postmeta() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4–11 | none |
!empty($post) && isset($post) && empty($ignored_hooked_blocks) | 70–73 | get_post_meta(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), remove_serialized_parent_block() |
!empty($post) && isset($post) | 78–81 | get_post_meta(), json_decode(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), remove_serialized_parent_block() |
!empty($post) && isset($post) && empty($existing_ignored_hooked_blocks) | 88–93 | get_post_meta(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_encode(), remove_serialized_parent_block() |
!empty($post) && isset($post) && !empty($ignored_hooked_blocks) && empty($existing_ignored_hooked_blocks) | 96–101 | get_post_meta(), json_decode(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_encode(), remove_serialized_parent_block() |
!empty($post) && isset($post) && !empty($existing_ignored_hooked_blocks) | 101–106 | get_post_meta(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_decode(), array_merge(), array_unique(), json_encode(), remove_serialized_parent_block() |
!empty($post) && isset($post) && !empty($ignored_hooked_blocks) && !empty($existing_ignored_hooked_blocks) | 109–114 | get_post_meta(), json_decode(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_decode(), array_merge(), array_unique(), json_encode(), remove_serialized_parent_block() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 118 | 4–114 | 9 | |
| 8.5 | 118 | 4–114 | 9 | |
| 8.4 | 118 | 4–114 | 9 | |
| 8.3 | 118 | 4–114 | 9 | |
| 8.2 | 118 | 4–114 | 9 | |
| 8.1 | 118 | 4–114 | 9 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 119 | 4–115 | 9 |
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.
Uses · 7
- get_post_meta()Retrieves a post meta field for the given post ID.
- get_comment_delimited_block_content()Returns the content of a block, including comment delimiters.
- get_post()Retrieves post data given a post ID or post object.
- apply_block_hooks_to_content()Runs the hooked blocks algorithm on the given content.
- parse_blocks()Parses blocks out of a content string.
- remove_serialized_parent_block()Accepts the serialized markup of a block and its inner blocks, and returns serialized markup of the inner blocks.
- WP_Post::__construct()Constructor.
Source code
function update_ignored_hooked_blocks_postmeta( $post ) { /* * In this scenario the user has likely tried to create a navigation via the REST API. * In which case we won't have a post ID to work with and store meta against. */ if ( empty( $post->ID ) ) { return $post; } /* * Skip meta generation when consumers intentionally update specific Navigation fields * and omit the content update. */ if ( ! isset( $post->post_content ) ) { return $post; } /* * Skip meta generation when the post content is not a navigation block. */ if ( ! isset( $post->post_type ) || 'wp_navigation' !== $post->post_type ) { return $post; } $attributes = array(); $ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true ); if ( ! empty( $ignored_hooked_blocks ) ) { $ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true ); $attributes['metadata'] = array( 'ignoredHookedBlocks' => $ignored_hooked_blocks, ); } $markup = get_comment_delimited_block_content( 'core/navigation', $attributes, $post->post_content ); $existing_post = get_post( $post->ID ); // Merge the existing post object with the updated post object to pass to the block hooks algorithm for context. $context = (object) array_merge( (array) $existing_post, (array) $post ); $context = new WP_Post( $context ); // Convert to WP_Post object. $serialized_block = apply_block_hooks_to_content( $markup, $context, 'set_ignored_hooked_blocks_metadata' ); $root_block = parse_blocks( $serialized_block )[0]; $ignored_hooked_blocks = isset( $root_block['attrs']['metadata']['ignoredHookedBlocks'] ) ? $root_block['attrs']['metadata']['ignoredHookedBlocks'] : array(); if ( ! empty( $ignored_hooked_blocks ) ) { $existing_ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true ); if ( ! empty( $existing_ignored_hooked_blocks ) ) { $existing_ignored_hooked_blocks = json_decode( $existing_ignored_hooked_blocks, true ); $ignored_hooked_blocks = array_unique( array_merge( $ignored_hooked_blocks, $existing_ignored_hooked_blocks ) ); } if ( ! isset( $post->meta_input ) ) { $post->meta_input = array(); } $post->meta_input['_wp_ignored_hooked_blocks'] = json_encode( $ignored_hooked_blocks ); } $post->post_content = remove_serialized_parent_block( $serialized_block ); return $post;}Changelog
Introduced in 6.6.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 6.7.7 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.