wppaste
WordPress

_wp_customize_include()

Since
3.4.0
Source
wp-includes/theme.php:3529
Includes and instantiates the WP_Customize_Manager class.

Description

Loads the Customizer at plugins_loaded when accessing the customize.php admin page or when any request includes a wp_customize=on param or a customize_changeset param (a UUID). This param is a signal for whether to bootstrap the Customizer when WordPress is loading, especially in the Customizer preview or when making Customizer Ajax requests for widgets or menus.

Compatibility

WordPress
since 3.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_customize_include() 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
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
8–114

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()one call below _wp_customize_include()

What one call costs · 14 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost _wp_customize_include() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!is_admin()8–22is_admin()
is_admin()14–28is_admin(), basename()
!is_admin() && empty($input_vars) && !isset($input_vars)65–89is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), compact()
!is_admin()71–95is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), wp_doing_ajax(), compact()
is_admin() && empty($input_vars) && !isset($input_vars)71–95is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), compact()
!is_admin() && empty($input_vars) && !isset($input_vars) && wp_doing_ajax() && isset($value)75–96is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), wp_unslash(), compact()
!is_admin() && isset($input_vars)77–101is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), sanitize_key(), wp_doing_ajax(), compact()
is_admin()77–101is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), wp_doing_ajax(), compact()
!is_admin() && wp_doing_ajax() && isset($value)81–102is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), wp_doing_ajax(), wp_unslash(), compact()
is_admin() && empty($input_vars) && !isset($input_vars) && wp_doing_ajax() && isset($value)81–102is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), wp_unslash(), compact()
is_admin() && isset($input_vars)83–107is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), sanitize_key(), wp_doing_ajax(), compact()
!is_admin() && isset($input_vars) && wp_doing_ajax() && isset($value)87–108is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), sanitize_key(), wp_doing_ajax(), wp_unslash(), compact()
2 further outcomes, up to 114 instructions
is_admin() && wp_doing_ajax() && isset($value)87–108is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), wp_doing_ajax(), wp_unslash(), compact()
is_admin() && isset($input_vars) && wp_doing_ajax() && isset($value)93–114is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), sanitize_key(), wp_doing_ajax(), wp_unslash(), compact()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1258–11416
8.51258–11416
8.41258–11416
8.31258–11416
8.21258–11416
8.11258–114161 fewer instruction than PHP 7.4
7.41268–11516

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 · 6

Source code

function _wp_customize_include() { 	$is_customize_admin_page = ( is_admin() && 'customize.php' === basename( $_SERVER['PHP_SELF'] ) );	$should_include          = (		$is_customize_admin_page		||		( isset( $_REQUEST['wp_customize'] ) && 'on' === $_REQUEST['wp_customize'] )		||		( ! empty( $_GET['customize_changeset_uuid'] ) || ! empty( $_POST['customize_changeset_uuid'] ) )	); 	if ( ! $should_include ) {		return;	} 	/*	 * Note that wp_unslash() is not being used on the input vars because it is	 * called before wp_magic_quotes() gets called. Besides this fact, none of	 * the values should contain any characters needing slashes anyway.	 */	$keys       = array(		'changeset_uuid',		'customize_changeset_uuid',		'customize_theme',		'theme',		'customize_messenger_channel',		'customize_autosaved',	);	$input_vars = array_merge(		wp_array_slice_assoc( $_GET, $keys ),		wp_array_slice_assoc( $_POST, $keys )	); 	$theme             = null;	$autosaved         = null;	$messenger_channel = null; 	/*	 * Value false indicates UUID should be determined after_setup_theme	 * to either re-use existing saved changeset or else generate a new UUID if none exists.	 */	$changeset_uuid = false; 	/*	 * Set initially to false since defaults to true for back-compat;	 * can be overridden via the customize_changeset_branching filter.	 */	$branching = false; 	if ( $is_customize_admin_page && isset( $input_vars['changeset_uuid'] ) ) {		$changeset_uuid = sanitize_key( $input_vars['changeset_uuid'] );	} elseif ( ! empty( $input_vars['customize_changeset_uuid'] ) ) {		$changeset_uuid = sanitize_key( $input_vars['customize_changeset_uuid'] );	} 	// Note that theme will be sanitized via WP_Theme.	if ( $is_customize_admin_page && isset( $input_vars['theme'] ) ) {		$theme = $input_vars['theme'];	} elseif ( isset( $input_vars['customize_theme'] ) ) {		$theme = $input_vars['customize_theme'];	} 	if ( ! empty( $input_vars['customize_autosaved'] ) ) {		$autosaved = true;	} 	if ( isset( $input_vars['customize_messenger_channel'] ) ) {		$messenger_channel = sanitize_key( $input_vars['customize_messenger_channel'] );	} 	/*	 * Note that settings must be previewed even outside the customizer preview	 * and also in the customizer pane itself. This is to enable loading an existing	 * changeset into the customizer. Previewing the settings only has to be prevented	 * here in the case of a customize_save action because this will cause WP to think	 * there is nothing changed that needs to be saved.	 */	$is_customize_save_action = (		wp_doing_ajax()		&&

Changelog

Introduced in 3.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-includes/theme.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.