post_format_meta_box( WP_Post $post, array $box )
- Since
- 3.1.0
- Source
wp-admin/includes/meta-boxes.php:518
Compatibility
- WordPress
- since 3.1.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.
$boxarray- Post formats meta box arguments.
$idstringMeta box 'id' attribute.$titlestringMeta box title.$callbackcallableMeta box display callback.$argsarrayExtra meta box arguments.
Performance profile
How much work a call to post_format_meta_box() 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
- 7–55
- Plugin surface
- None
- Called by
- 0
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 92.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below post_format_meta_box() - querycontent query
get_post()one call below post_format_meta_box()
Further down the call graph this can also reach cache, option, 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 post_format_meta_box() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!current_theme_supports() | 7 | current_theme_supports() |
current_theme_supports() && !post_type_supports() | 14 | current_theme_supports(), post_type_supports() |
current_theme_supports() && post_type_supports() | 21 | current_theme_supports(), post_type_supports(), get_theme_support() |
current_theme_supports() && post_type_supports() | 49–55 | current_theme_supports(), post_type_supports(), get_theme_support(), get_post_format(), _e(), checked(), get_post_format_string() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 92 | 7–55 | 7 | |
| 8.5 | 92 | 7–55 | 7 | |
| 8.4 | 92 | 7–55 | 7 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 95 | 7–58 | 7 | |
| 8.2 | 95 | 7–58 | 7 | |
| 8.1 | 95 | 7–58 | 7 | |
| 7.4 | 95 | 7–58 | 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.
Uses · 9
- current_theme_supports()Checks a theme's support for a given feature.
- post_type_supports()Checks a post type's support for a given feature.
- get_theme_support()Gets the theme support arguments passed when registering that support.
- get_post_format()Retrieve the format slug for a post
- _e()Displays translated text.
- checked()Outputs the HTML checked attribute.
- get_post_format_string()Returns a pretty, translated version of a post format slug
- esc_attr()Escaping for HTML attributes.
- esc_html()Escaping for HTML blocks.
Source code
function post_format_meta_box( $post, $box ) { if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) : $post_formats = get_theme_support( 'post-formats' ); if ( is_array( $post_formats[0] ) ) : $post_format = get_post_format( $post->ID ); if ( ! $post_format ) { $post_format = '0'; } // Add in the current one if it isn't there yet, in case the active theme doesn't support it. if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) { $post_formats[0][] = $post_format; } ?> <div id="post-formats-select"> <fieldset> <legend class="screen-reader-text"> <?php /* translators: Hidden accessibility text. */ _e( 'Post Formats' ); ?> </legend> <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label> <?php foreach ( $post_formats[0] as $format ) : ?> <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> <?php endforeach; ?> </fieldset> </div> <?php endif;endif;}Changelog
Introduced in 3.1.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/meta-boxes.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.