wppaste
WordPress

WP_Customize_Manager::customize_preview_settings()

Since
3.4.0
Source
wp-includes/class-wp-customize-manager.php:2116
Prints JavaScript settings for preview frame.

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_Manager::customize_preview_settings() 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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
142–157

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

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 one call costs · 8 distinct outcomes

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

WhenInstructionsCalls it makes
empty($value) && !current_user_can()142–147->unsanitized_post_values(), ->validate_setting_values(), home_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
empty($value) && !current_user_can()144–149->unsanitized_post_values(), ->validate_setting_values(), home_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), restore_previous_locale(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
empty($value) && current_user_can()145–150->unsanitized_post_values(), ->validate_setting_values(), home_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), ->get_nonces(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
!empty($value) && !current_user_can()147–152->unsanitized_post_values(), ->validate_setting_values(), wp_unslash(), sanitize_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
empty($value) && current_user_can()147–152->unsanitized_post_values(), ->validate_setting_values(), home_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), restore_previous_locale(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), ->get_nonces(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
!empty($value) && !current_user_can()149–154->unsanitized_post_values(), ->validate_setting_values(), wp_unslash(), sanitize_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), restore_previous_locale(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
!empty($value) && current_user_can()150–155->unsanitized_post_values(), ->validate_setting_values(), wp_unslash(), sanitize_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), ->get_nonces(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()
!empty($value) && current_user_can()152–157->unsanitized_post_values(), ->validate_setting_values(), wp_unslash(), sanitize_url(), remove_query_arg(), ->get_allowed_urls(), get_current_user_id(), switch_to_user_locale(), __(), __(), __(), restore_previous_locale(), ->changeset_uuid(), ->autosaved(), ->get_stylesheet(), ->is_theme_active(), wp_is_block_theme(), ->get_allowed_urls(), array_map(), array_unique(), ->is_cross_domain(), current_user_can(), ->get_nonces(), array_keys(), ob_start(), wp_json_encode(), ob_get_clean(), wp_remove_surrounding_empty_script_tags(), wp_print_inline_script_tag()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev241141–155222 fewer instructions than PHP 8.5
8.5243142–15722
8.4243142–15722
8.3243142–15722
8.2243142–15722
8.1243142–15722
7.4243142–15722

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

Show all 23

Source code

	public function customize_preview_settings() {		$post_values                 = $this->unsanitized_post_values( array( 'exclude_changeset' => true ) );		$setting_validities          = $this->validate_setting_values( $post_values );		$exported_setting_validities = array_map( array( $this, 'prepare_setting_validity_for_js' ), $setting_validities ); 		// Note that the REQUEST_URI is not passed into home_url() since this breaks subdirectory installations.		$self_url           = empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) );		$state_query_params = array(			'customize_theme',			'customize_changeset_uuid',			'customize_messenger_channel',		);		$self_url           = remove_query_arg( $state_query_params, $self_url ); 		$allowed_urls  = $this->get_allowed_urls();		$allowed_hosts = array();		foreach ( $allowed_urls as $allowed_url ) {			$parsed = wp_parse_url( $allowed_url );			if ( empty( $parsed['host'] ) ) {				continue;			}			$host = $parsed['host'];			if ( ! empty( $parsed['port'] ) ) {				$host .= ':' . $parsed['port'];			}			$allowed_hosts[] = $host;		} 		$switched_locale = switch_to_user_locale( get_current_user_id() );		$l10n            = array(			'shiftClickToEdit'  => __( 'Shift-click to edit this element.' ),			'linkUnpreviewable' => __( 'This link is not live-previewable.' ),			'formUnpreviewable' => __( 'This form is not live-previewable.' ),		);		if ( $switched_locale ) {			restore_previous_locale();		} 		$settings = array(			'changeset'         => array(				'uuid'      => $this->changeset_uuid(),				'autosaved' => $this->autosaved(),			),			'timeouts'          => array(				'selectiveRefresh' => 250,				'keepAliveSend'    => 1000,			),			'theme'             => array(				'stylesheet'   => $this->get_stylesheet(),				'active'       => $this->is_theme_active(),				'isBlockTheme' => wp_is_block_theme(),			),			'url'               => array(				'self'          => $self_url,				'allowed'       => array_map( 'sanitize_url', $this->get_allowed_urls() ),				'allowedHosts'  => array_unique( $allowed_hosts ),				'isCrossDomain' => $this->is_cross_domain(),			),			'channel'           => $this->messenger_channel,			'activePanels'      => array(),			'activeSections'    => array(),			'activeControls'    => array(),			'settingValidities' => $exported_setting_validities,			'nonce'             => current_user_can( 'customize' ) ? $this->get_nonces() : array(),			'l10n'              => $l10n,			'_dirty'            => array_keys( $post_values ),		); 		foreach ( $this->panels as $panel_id => $panel ) {			if ( $panel->check_capabilities() ) {				$settings['activePanels'][ $panel_id ] = $panel->active();				foreach ( $panel->sections as $section_id => $section ) {					if ( $section->check_capabilities() ) {						$settings['activeSections'][ $section_id ] = $section->active();					}				}			}		}		foreach ( $this->sections as $id => $section ) {			if ( $section->check_capabilities() ) {

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 7.1.0 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.