wppaste
WordPress

WP_Customize_Manager::__construct( array $args = array() )

Since
3.4.0, 4.7.0
Source
wp-includes/class-wp-customize-manager.php:262
Constructor.

Compatibility

WordPress
since 4.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

$argsarrayoptional
Args.Default: array()
  • $changeset_uuidnull|string|false

    Changeset UUID, the post_name for the customize_changeset post containing the customized state. Defaults to null resulting in a UUID to be immediately generated. If false is provided, then then the changeset UUID will be determined during after_setup_theme: when the customize_changeset_branching filter returns false, then the default UUID will be that of the most recent customize_changeset post that has a status other than 'auto-draft', 'publish', or 'trash'. Otherwise, if changeset branching is enabled, then a random UUID will be used.
  • $themestring

    Theme to be previewed (for theme switch). Defaults to customize_theme or theme query params.
  • $messenger_channelstring

    Messenger channel. Defaults to customize_messenger_channel query param.
  • $settings_previewedbool

    If settings should be previewed. Defaults to true.
  • $branchingbool

    If changeset branching is allowed; otherwise, changesets are linear. Defaults to true.
  • $autosavedbool

    If data from a changeset's autosaved revision should be loaded if it exists. Defaults to false.

Performance profile

How much work a call to WP_Customize_Manager::__construct() 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

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

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
407–456

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

Plugin surface
1 hook

Third-party callbacks on 'customize_loaded_components' run inside this call, and their cost is not bounded by anything here.

Called by
2

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

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()one call below WP_Customize_Manager::__construct()

Further down the call graph this can also reach cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 6 distinct outcomes

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

WhenInstructionsCalls it makes
isset($args) && !current_user_can()407–443array_fill_keys(), array_merge(), wp_is_block_theme(), get_stylesheet(), validate_file(), wp_get_theme(), apply_filters(), remove_action(), remove_action(), remove_action(), remove_action(), current_user_can(), current_user_can()
isset($args) && current_user_can()410–446array_fill_keys(), array_merge(), wp_is_block_theme(), get_stylesheet(), validate_file(), wp_get_theme(), apply_filters(), remove_action(), remove_action(), remove_action(), remove_action(), current_user_can(), add_action()
isset($args)414–450array_fill_keys(), array_merge(), wp_is_block_theme(), get_stylesheet(), validate_file(), wp_get_theme(), apply_filters(), remove_action(), remove_action(), remove_action(), remove_action(), current_user_can(), current_user_can(), add_action()
isset($value) && !current_user_can()421–449array_fill_keys(), array_merge(), wp_unslash(), sanitize_key(), wp_is_block_theme(), get_stylesheet(), validate_file(), wp_get_theme(), apply_filters(), remove_action(), remove_action(), remove_action(), remove_action(), current_user_can(), current_user_can()
isset($value) && current_user_can()424–452array_fill_keys(), array_merge(), wp_unslash(), sanitize_key(), wp_is_block_theme(), get_stylesheet(), validate_file(), wp_get_theme(), apply_filters(), remove_action(), remove_action(), remove_action(), remove_action(), current_user_can(), add_action()
isset($value)428–456array_fill_keys(), array_merge(), wp_unslash(), sanitize_key(), wp_is_block_theme(), get_stylesheet(), validate_file(), wp_get_theme(), apply_filters(), remove_action(), remove_action(), remove_action(), remove_action(), current_user_can(), current_user_can(), add_action()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev490407–45615
8.5490407–45615
8.4490407–456156 fewer instructions than PHP 8.3
8.3496413–46215
8.2496413–46215
8.1496413–462151 fewer instruction than PHP 7.4
7.4497413–46215

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

One hook fires while WP_Customize_Manager::__construct() runs, in this order:

  1. apply_filters( customize_loaded_components )filterline 359 (+97 into the body)

    Filters the core Customizer components to load.

Uses · 15

Show all 15

Used by · 2

Source code

	public function __construct( $args = array() ) { 		$args = array_merge(			array_fill_keys( array( 'changeset_uuid', 'theme', 'messenger_channel', 'settings_previewed', 'autosaved', 'branching' ), null ),			$args		); 		// Note that the UUID format will be validated in the setup_theme() method.		if ( ! isset( $args['changeset_uuid'] ) ) {			$args['changeset_uuid'] = wp_generate_uuid4();		} 		/*		 * The theme and messenger_channel should be supplied via $args,		 * but they are also looked at in the $_REQUEST global here for back-compat.		 */		if ( ! isset( $args['theme'] ) ) {			if ( isset( $_REQUEST['customize_theme'] ) ) {				$args['theme'] = wp_unslash( $_REQUEST['customize_theme'] );			} elseif ( isset( $_REQUEST['theme'] ) ) { // Deprecated.				$args['theme'] = wp_unslash( $_REQUEST['theme'] );			}		}		if ( ! isset( $args['messenger_channel'] ) && isset( $_REQUEST['customize_messenger_channel'] ) ) {			$args['messenger_channel'] = sanitize_key( wp_unslash( $_REQUEST['customize_messenger_channel'] ) );		} 		// Do not load 'widgets' component if a block theme is activated.		if ( ! wp_is_block_theme() ) {			$this->components[] = 'widgets';		} 		$this->original_stylesheet = get_stylesheet();		$this->theme               = wp_get_theme( 0 === validate_file( $args['theme'] ) ? $args['theme'] : null );		$this->messenger_channel   = $args['messenger_channel'];		$this->_changeset_uuid     = $args['changeset_uuid']; 		foreach ( array( 'settings_previewed', 'autosaved', 'branching' ) as $key ) {			if ( isset( $args[ $key ] ) ) {				$this->$key = (bool) $args[ $key ];			}		} 		require_once ABSPATH . WPINC . '/class-wp-customize-setting.php';		require_once ABSPATH . WPINC . '/class-wp-customize-panel.php';		require_once ABSPATH . WPINC . '/class-wp-customize-section.php';		require_once ABSPATH . WPINC . '/class-wp-customize-control.php'; 		require_once ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-code-editor-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php'; 		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php'; 		require_once ABSPATH . WPINC . '/customize/class-wp-customize-themes-panel.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php'; 		require_once ABSPATH . WPINC . '/customize/class-wp-customize-custom-css-setting.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-filter-setting.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-setting.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-setting.php';		require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-setting.php';

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.

4.7.0
Added $args parameter.from the docblock
3.4.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/class-wp-customize-manager.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.