page_attributes_meta_box( WP_Post $post )
- Since
- 2.7.0
- Source
wp-admin/includes/meta-boxes.php:1003
Compatibility
- WordPress
- since 2.7.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 page_attributes_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
- Constant
- Instructions
- 22–130
- Plugin surface
- 4 hooks
- Called by
- 0
Reaches the database via get_pages().
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 131.
Third-party callbacks on 'page_attributes_dropdown_pages_args', 'page_attributes_meta_box_template', 'default_page_template_title' 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 - optionoption read or write
get_option()called directly - querycontent query
get_pages()one call below page_attributes_meta_box() - cacheobject cache
wp_cache_get()one call below page_attributes_meta_box() - serializeserialisation
maybe_unserialize()one call below page_attributes_meta_box()
Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 36 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost page_attributes_meta_box() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_post_type_hierarchical() && !post_type_supports() | 22 | is_post_type_hierarchical(), get_page_templates(), post_type_supports() |
!is_post_type_hierarchical() && !post_type_supports() | 29 | is_post_type_hierarchical(), get_page_templates(), get_option(), post_type_supports() |
!is_post_type_hierarchical() && post_type_supports() | 42 | is_post_type_hierarchical(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action() |
!is_post_type_hierarchical() && post_type_supports() && !->get_help_tabs() | 47 | is_post_type_hierarchical(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && empty($pages) && !post_type_supports() | 48 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), post_type_supports() |
!is_post_type_hierarchical() && post_type_supports() | 49 | is_post_type_hierarchical(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action() |
!is_post_type_hierarchical() && post_type_supports() && ->get_help_tabs() | 52 | is_post_type_hierarchical(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
!is_post_type_hierarchical() && post_type_supports() && !->get_help_tabs() | 54 | is_post_type_hierarchical(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && empty($pages) && !post_type_supports() | 55 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), post_type_supports() |
is_post_type_hierarchical() && !empty($pages) && !post_type_supports() | 55 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), post_type_supports() |
!is_post_type_hierarchical() && post_type_supports() && ->get_help_tabs() | 59 | is_post_type_hierarchical(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
is_post_type_hierarchical() && !empty($pages) && !post_type_supports() | 62 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), post_type_supports() |
24 further outcomes, up to 130 instructions
!is_post_type_hierarchical() && !post_type_supports() | 66–67 | is_post_type_hierarchical(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() | 68 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() && !->get_help_tabs() | 73 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() | 75 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() | 75 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() && ->get_help_tabs() | 78 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() && !->get_help_tabs() | 80 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() && !->get_help_tabs() | 80 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() | 82 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() && ->get_help_tabs() | 85 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() && ->get_help_tabs() | 85 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
!is_post_type_hierarchical() && post_type_supports() | 86–87 | is_post_type_hierarchical(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() && !->get_help_tabs() | 87 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
!is_post_type_hierarchical() && post_type_supports() && !->get_help_tabs() | 91–92 | is_post_type_hierarchical(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && empty($pages) && !post_type_supports() | 92–93 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() && ->get_help_tabs() | 92 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
!is_post_type_hierarchical() && post_type_supports() && ->get_help_tabs() | 96–97 | is_post_type_hierarchical(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
is_post_type_hierarchical() && !empty($pages) && !post_type_supports() | 99–100 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() | 112–113 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() && !->get_help_tabs() | 117–118 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() | 119–120 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action() |
is_post_type_hierarchical() && empty($pages) && post_type_supports() && ->get_help_tabs() | 122–123 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() && !->get_help_tabs() | 124–125 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs() |
is_post_type_hierarchical() && !empty($pages) && post_type_supports() && ->get_help_tabs() | 129–130 | is_post_type_hierarchical(), __(), apply_filters(), wp_dropdown_pages(), _e(), get_page_templates(), get_option(), _e(), do_action(), __(), apply_filters(), esc_html(), page_template_dropdown(), post_type_supports(), _e(), esc_attr(), do_action(), get_current_screen(), ->get_help_tabs(), _e() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 131 | 22–130 | 8 | |
| 8.5 | 131 | 22–130 | 8 | |
| 8.4 | 131 | 22–130 | 8 | |
| 8.3 | 131 | 22–130 | 8 | |
| 8.2 | 131 | 22–130 | 8 | |
| 8.1 | 131 | 22–130 | 8 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 132 | 22–131 | 8 |
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 · 4
4 hooks fire while page_attributes_meta_box() runs, in this order:
- apply_filters( page_attributes_dropdown_pages_args )filterline 1025 (+22 into the body)
Filters the arguments used to generate a Pages drop-down element.
- do_action( page_attributes_meta_box_template )actionline 1049 (+46 into the body)
Fires immediately after the label inside the 'Template' section of the 'Page Attributes' meta box.
- apply_filters( default_page_template_title )filterline 1063 (+60 into the body)
Filters the title of the default page template displayed in the drop-down.
- do_action( page_attributes_misc_attributes )actionline 1080 (+77 into the body)
Fires before the help hint text in the 'Page Attributes' meta box.
Uses · 14
- is_post_type_hierarchical()Determines whether the post type is hierarchical.
- __()Retrieves the translation of $text.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_dropdown_pages()Retrieves or displays a list of pages as a dropdown (select list).
- _e()Displays translated text.
- get_page_templates()Gets the page templates available in this theme.
- get_option()Retrieves an option value based on an option name.
- do_action()Calls the callback functions that have been added to an action hook.
- esc_html()Escaping for HTML blocks.
- page_template_dropdown()Prints out option HTML elements for the page templates drop-down.
- post_type_supports()Checks a post type's support for a given feature.
- esc_attr()Escaping for HTML attributes.
Show all 14
- get_current_screen()Get the current screen object
- get_current_screen()::get_help_tabs()
Source code
function page_attributes_meta_box( $post ) { if ( is_post_type_hierarchical( $post->post_type ) ) : $dropdown_args = array( 'post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __( '(no parent)' ), 'sort_column' => 'menu_order, post_title', 'echo' => 0, ); /** * Filters the arguments used to generate a Pages drop-down element. * * @since 3.3.0 * * @see wp_dropdown_pages() * * @param array $dropdown_args Array of arguments used to generate the pages drop-down. * @param WP_Post $post The current post. */ $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); $pages = wp_dropdown_pages( $dropdown_args ); if ( ! empty( $pages ) ) : ?><p class="post-attributes-label-wrapper parent-id-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p> <?php echo $pages; ?> <?php endif; // End empty pages check. endif; // End hierarchical check. if ( count( get_page_templates( $post ) ) > 0 && (int) get_option( 'page_for_posts' ) !== $post->ID ) : $template = ! empty( $post->page_template ) ? $post->page_template : false; ?><p class="post-attributes-label-wrapper page-template-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label> <?php /** * Fires immediately after the label inside the 'Template' section * of the 'Page Attributes' meta box. * * @since 4.4.0 * * @param string|false $template The template used for the current post. * @param WP_Post $post The current post. */ do_action( 'page_attributes_meta_box_template', $template, $post ); ?></p><select name="page_template" id="page_template"> <?php /** * Filters the title of the default page template displayed in the drop-down. * * @since 4.1.0 * * @param string $label The display value for the default page template title. * @param string $context Where the option label is displayed. Possible values * include 'meta-box' or 'quick-edit'. */ $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'meta-box' ); ?><option value="default"><?php echo esc_html( $default_title ); ?></option> <?php page_template_dropdown( $template, $post->post_type ); ?></select><?php endif; ?> <?php if ( post_type_supports( $post->post_type, 'page-attributes' ) ) : ?><p class="post-attributes-label-wrapper menu-order-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /> <?php /** * Fires before the help hint text in the 'Page Attributes' meta box. * * @since 4.9.0 * * @param WP_Post $post The current post. */ do_action( 'page_attributes_misc_attributes', $post ); ?> <?php if ( 'page' === $post->post_type && get_current_screen()->get_help_tabs() ) : ?>Changelog
Introduced in 2.7.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/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.