wppaste
WordPress

WP_Screen::render_meta_boxes_preferences()

Since
4.4.0
Source
wp-admin/includes/class-wp-screen.php:1108
Renders the meta boxes preferences.

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

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
5–72

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 88.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksapply_filters()one call below WP_Screen::render_meta_boxes_preferences()
  • cacheobject cachewp_cache_get()one call below WP_Screen::render_meta_boxes_preferences()
  • serializeserialisationmaybe_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.

WhenInstructionsCalls it makes
!isset($wp_meta_boxes)5none
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 !== 263_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 === 271–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

Used by · 1

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 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.