the_block_editor_meta_boxes()
- Since
- 5.0.0
- Source
wp-admin/includes/post.php:2366
Compatibility
- WordPress
- since 5.0.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.
Performance profile
How much work a call to the_block_editor_meta_boxes() 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
- 64–83
- Plugin surface
- 1 hook
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 139.
Third-party callbacks on 'filter_block_editor_meta_boxes' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach query, option, cache, serialize 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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost the_block_editor_meta_boxes() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!wp_script_is() | 64–66 | apply_filters(), the_block_editor_meta_box_post_form_hidden_fields(), admin_url(), esc_url(), wp_nonce_field(), wp_json_encode(), wp_add_inline_script(), wp_script_is(), get_current_user_id(), get_user_meta(), wp_add_inline_script() |
wp_script_is() | 69–71 | apply_filters(), the_block_editor_meta_box_post_form_hidden_fields(), admin_url(), esc_url(), wp_nonce_field(), wp_json_encode(), wp_add_inline_script(), wp_script_is(), printf(), get_current_user_id(), get_user_meta(), wp_add_inline_script() |
!wp_script_is() | 76–78 | apply_filters(), the_block_editor_meta_box_post_form_hidden_fields(), admin_url(), esc_url(), wp_nonce_field(), wp_json_encode(), wp_add_inline_script(), wp_script_is(), get_current_user_id(), get_user_meta(), wp_enqueue_script(), wp_add_inline_script(), wp_add_inline_script() |
wp_script_is() | 81–83 | apply_filters(), the_block_editor_meta_box_post_form_hidden_fields(), admin_url(), esc_url(), wp_nonce_field(), wp_json_encode(), wp_add_inline_script(), wp_script_is(), printf(), get_current_user_id(), get_user_meta(), wp_enqueue_script(), wp_add_inline_script(), wp_add_inline_script() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 139 | 64–83 | 16 | |
| 8.5 | 139 | 64–83 | 16 | |
| 8.4 | 139 | 64–83 | 16 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 141 | 64–85 | 16 | |
| 8.2 | 141 | 64–85 | 16 | |
| 8.1 | 141 | 64–85 | 16 | |
| 7.4 | 141 | 64–85 | 16 |
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 · 1
One hook fires while the_block_editor_meta_boxes() runs, in this order:
- apply_filters( filter_block_editor_meta_boxes )filterline 2382 (+16 into the body)
Fires right before the meta boxes are rendered.
Uses · 13
- apply_filters()Calls the callback functions that have been added to a filter hook.
- the_block_editor_meta_box_post_form_hidden_fields()Renders the hidden form required for the meta boxes form.
- esc_url()Checks and cleans a URL.
- admin_url()Retrieves the URL to the admin area for the current site.
- wp_nonce_field()Retrieves or display nonce hidden field for forms.
- esc_attr()Escaping for HTML attributes.
- do_meta_boxes()Meta-Box template function.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
- wp_add_inline_script()Adds extra code to a registered script.
- wp_script_is()Determines whether a script has been added to the queue.
- get_user_meta()Retrieves user meta field for a user.
- get_current_user_id()Gets the current user's ID.
Show all 13
- wp_enqueue_script()Enqueues a script.
Source code
function the_block_editor_meta_boxes() { global $post, $current_screen, $wp_meta_boxes; // Handle meta box state. $_original_meta_boxes = $wp_meta_boxes; /** * Fires right before the meta boxes are rendered. * * This allows for the filtering of meta box data, that should already be * present by this point. Do not use as a means of adding meta box data. * * @since 5.0.0 * * @param array $wp_meta_boxes Global meta box state. */ $wp_meta_boxes = apply_filters( 'filter_block_editor_meta_boxes', $wp_meta_boxes ); $locations = array( 'side', 'normal', 'advanced' ); $priorities = array( 'high', 'sorted', 'core', 'default', 'low' ); // Render meta boxes. ?> <form class="metabox-base-form"> <?php the_block_editor_meta_box_post_form_hidden_fields( $post ); ?> </form> <form id="toggle-custom-fields-form" method="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>"> <?php wp_nonce_field( 'toggle-custom-fields', 'toggle-custom-fields-nonce' ); ?> <input type="hidden" name="action" value="toggle-custom-fields" /> </form> <?php foreach ( $locations as $location ) : ?> <form class="metabox-location-<?php echo esc_attr( $location ); ?>" onsubmit="return false;"> <div id="poststuff" class="sidebar-open"> <div id="postbox-container-2" class="postbox-container"> <?php do_meta_boxes( $current_screen, $location, $post ); ?> </div> </div> </form> <?php endforeach; ?> <?php $meta_boxes_per_location = array(); foreach ( $locations as $location ) { $meta_boxes_per_location[ $location ] = array(); if ( ! isset( $wp_meta_boxes[ $current_screen->id ][ $location ] ) ) { continue; } foreach ( $priorities as $priority ) { if ( ! isset( $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ] ) ) { continue; } $meta_boxes = (array) $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ]; foreach ( $meta_boxes as $meta_box ) { if ( false === $meta_box || ! $meta_box['title'] ) { continue; } // If a meta box is just here for back compat, don't show it in the block editor. if ( isset( $meta_box['args']['__back_compat_meta_box'] ) && $meta_box['args']['__back_compat_meta_box'] ) { continue; } $meta_boxes_per_location[ $location ][] = array( 'id' => $meta_box['id'], 'title' => $meta_box['title'], ); } } } /* * Sadly we probably cannot add this data directly into editor settings.Changelog
Introduced in 5.0.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.9.7 tag, from
src/wp-admin/includes/post.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.