WP_Screen::render_meta_boxes_preferences()
- Since
- 4.4.0
- Source
wp-admin/includes/class-wp-screen.php:1110
Compatibility
- WordPress
- since 4.4.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 WP_Screen::render_meta_boxes_preferences() 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
- Moderate
- Scaling
- Constant
- Instructions
- 5–72
- Plugin surface
- None
- Called by
- 1
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 88.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()one call below WP_Screen::render_meta_boxes_preferences() - cacheobject cache
wp_cache_get()one call below WP_Screen::render_meta_boxes_preferences() - serializeserialisation
maybe_unserialize()one call below WP_Screen::render_meta_boxes_preferences()
Further down the call graph this can also reach query 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 WP_Screen::render_meta_boxes_preferences() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($wp_meta_boxes) | 5 | none |
isset($wp_meta_boxes) | 26 | _e(), _e(), _e(), meta_box_prefs() |
isset($wp_meta_boxes) && !has_action() | 30 | _e(), _e(), _e(), meta_box_prefs(), has_action() |
isset($wp_meta_boxes) && has_action() && !current_user_can() | 34 | _e(), _e(), _e(), meta_box_prefs(), has_action(), current_user_can() |
isset($wp_meta_boxes) && has_action() && current_user_can() && !isset($value) && $welcome_checked !== 2 | 63 | _e(), _e(), _e(), meta_box_prefs(), has_action(), current_user_can(), get_current_user_id(), get_user_meta(), checked(), _x() |
isset($wp_meta_boxes) && has_action() && current_user_can() && isset($value) | 66–67 | _e(), _e(), _e(), meta_box_prefs(), has_action(), current_user_can(), get_current_user_id(), update_user_meta(), checked(), _x() |
isset($wp_meta_boxes) && has_action() && current_user_can() && !isset($value) && $welcome_checked === 2 | 71–72 | _e(), _e(), _e(), meta_box_prefs(), has_action(), current_user_can(), get_current_user_id(), get_user_meta(), wp_get_current_user(), get_option(), checked(), _x() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 88 instructions, 5–72 executed per call, 8 branches. The work does not change between versions.
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 · 11
- _e()Displays translated text.
- meta_box_prefs()Prints the meta box preferences for screen meta.
- has_action()Checks if any action has been registered for a hook.
- current_user_can()Returns whether the current user has the specified capability.
- update_user_meta()Updates user meta field based on user ID.
- get_current_user_id()Gets the current user's ID.
- get_user_meta()Retrieves user meta field for a user.
- wp_get_current_user()Retrieves the current user object.
- get_option()Retrieves an option value based on an option name.
- checked()Outputs the HTML checked attribute.
- _x()Retrieves translated string with gettext context.
Used by · 1
- WP_Screen::render_screen_options()Renders the screen options tab.
Source code
public function render_meta_boxes_preferences() { global $wp_meta_boxes; if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) { return; } ?> <fieldset class="metabox-prefs"> <legend><?php _e( 'Screen elements' ); ?></legend> <p> <?php _e( 'Some screen elements can be shown or hidden by using the checkboxes.' ); ?> <?php _e( 'Expand or collapse the elements by clicking on their headings, and arrange them by dragging their headings or by clicking on the up and down arrows.' ); ?> </p> <div class="metabox-prefs-container"> <?php meta_box_prefs( $this ); if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { if ( isset( $_GET['welcome'] ) ) { $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); } else { $welcome_checked = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); if ( 2 === $welcome_checked && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) { $welcome_checked = false; } } echo '<label for="wp_welcome_panel-hide">'; echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; } ?> </div> </fieldset> <?php }Changelog
Introduced in 4.4.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/class-wp-screen.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.