the_block_editor_meta_box_post_form_hidden_fields( WP_Post $post )
- Since
- 5.0.0
- Source
wp-admin/includes/post.php:2537
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.
Parameters
$postWP_Post- Current post object.
Performance profile
How much work a call to the_block_editor_meta_box_post_form_hidden_fields() 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
- Scales with input
- Instructions
- 103–113
- Plugin surface
- 3 hooks
- Called by
- 1
Reaches the database via get_post().
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 120.
Third-party callbacks on 'edit_form_after_title', 'edit_form_advanced', 'block_editor_meta_box_hidden_fields' 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
do_action()called directly - querycontent query
get_post()one call below the_block_editor_meta_box_post_form_hidden_fields()
Further down the call graph this can also reach 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_box_post_form_hidden_fields() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 103–105 | esc_attr(), wp_get_referer(), wp_get_current_user(), wp_nonce_field(), ob_start(), do_action(), do_action(), ob_get_clean(), wp_html_split(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), get_post_status(), wp_nonce_field(), wp_nonce_field(), wp_nonce_field(), do_action() |
| always | 107–109 | esc_attr(), wp_get_referer(), wp_get_current_user(), wp_nonce_field(), ob_start(), do_action(), do_action(), ob_get_clean(), wp_html_split(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), get_post_status(), wp_original_referer_field(), wp_nonce_field(), wp_nonce_field(), wp_nonce_field(), do_action() |
| always | 107–109 | esc_attr(), wp_get_referer(), wp_get_current_user(), wp_nonce_field(), ob_start(), do_action(), do_action(), ob_get_clean(), wp_html_split(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), esc_url(), get_post_status(), wp_nonce_field(), wp_nonce_field(), wp_nonce_field(), do_action() |
| always | 111–113 | esc_attr(), wp_get_referer(), wp_get_current_user(), wp_nonce_field(), ob_start(), do_action(), do_action(), ob_get_clean(), wp_html_split(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), esc_url(), get_post_status(), wp_original_referer_field(), wp_nonce_field(), wp_nonce_field(), wp_nonce_field(), do_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 119 | 103–112 | 7 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 120 | 103–113 | 7 | |
| 8.4 | 120 | 103–113 | 7 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 126 | 103–113 | 7 | |
| 8.2 | 126 | 103–113 | 7 | |
| 8.1 | 126 | 103–113 | 7 | |
| 7.4 | 126 | 103–113 | 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 the_block_editor_meta_box_post_form_hidden_fields() runs, in this order:
- do_action( edit_form_advanced )actionline 2559 (+22 into the body)
Fires after 'normal' context meta boxes have been output for all post types other than 'page'.
- do_action( block_editor_meta_box_hidden_fields )actionline 2601 (+64 into the body)
Adds hidden input fields to the meta box save form.
Uses · 10
- esc_attr()Escaping for HTML attributes.
- wp_get_referer()Retrieves referer from '_wp_http_referer' or HTTP referer.
- wp_get_current_user()Retrieves the current user object.
- wp_nonce_field()Retrieves or display nonce hidden field for forms.
- do_action()Calls the callback functions that have been added to an action hook.
- wp_html_split()Separates HTML elements and comments from the text.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- esc_url()Checks and cleans a URL.
- get_post_status()Retrieves the post status based on the post ID.
- wp_original_referer_field()Retrieves or displays original referer hidden field for forms.
Used by · 1
- the_block_editor_meta_boxes()Renders the meta boxes forms.
Source code
function the_block_editor_meta_box_post_form_hidden_fields( $post ) { $form_extra = ''; if ( 'auto-draft' === $post->post_status ) { $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />"; } $form_action = 'editpost'; $nonce_action = 'update-post_' . $post->ID; $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />"; $referer = wp_get_referer(); $current_user = wp_get_current_user(); $user_id = $current_user->ID; wp_nonce_field( $nonce_action ); /* * Some meta boxes hook into these actions to add hidden input fields in the classic post form. * For backward compatibility, we can capture the output from these actions, * and extract the hidden input fields. */ ob_start(); /** This filter is documented in wp-admin/edit-form-advanced.php */ do_action( 'edit_form_after_title', $post ); /** This filter is documented in wp-admin/edit-form-advanced.php */ do_action( 'edit_form_advanced', $post ); $classic_output = ob_get_clean(); $classic_elements = wp_html_split( $classic_output ); foreach ( $classic_elements as $element ) { if ( ! str_starts_with( $element, '<input ' ) ) { continue; } if ( preg_match( '/\stype=[\'"]hidden[\'"]\s/', $element ) ) { echo $element; } } ?> <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_id; ?>" /> <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" /> <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" /> <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post->post_type ); ?>" /> <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" /> <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" /> <?php if ( 'draft' !== get_post_status( $post ) ) { wp_original_referer_field( true, 'previous' ); } echo $form_extra; wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); // Permalink title nonce. wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); /** * Adds hidden input fields to the meta box save form. * * Hook into this action to print `<input type="hidden" ... />` fields, which will be POSTed back to * the server when meta boxes are saved. * * @since 5.0.0 * * @param WP_Post $post The post that is being edited. */ do_action( 'block_editor_meta_box_hidden_fields', $post );}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 7.1.0 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.