WP_Customize_Manager::customize_preview_settings()
- Since
- 3.4.0
- Source
wp-includes/class-wp-customize-manager.php:2116
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
- Scaling
- Scales with input
- Instructions
- 142–157
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 243.
Nothing here hands control to plugin code.
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.
| When | Instructions | Calls 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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 241 | 141–155 | 22 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 243 | 142–157 | 22 | |
| 8.4 | 243 | 142–157 | 22 | |
| 8.3 | 243 | 142–157 | 22 | |
| 8.2 | 243 | 142–157 | 22 | |
| 8.1 | 243 | 142–157 | 22 | |
| 7.4 | 243 | 142–157 | 22 |
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
- home_url()Retrieves the URL for the current site where the front end is accessible.
- sanitize_url()Sanitizes a URL for database or redirect usage.
- wp_unslash()Removes slashes from a string or recursively removes slashes from strings within an array.
- remove_query_arg()Removes an item or items from a query string.
- wp_parse_url()A wrapper for PHP's parse_url() function that handles consistency in the return values across PHP versions.
- switch_to_user_locale()Switches the translations according to the given user's locale.
- get_current_user_id()Gets the current user's ID.
- __()Retrieves the translation of $text.
- restore_previous_locale()Restores the translations according to the previous locale.
- wp_is_block_theme()Returns whether the active theme is a block-based theme or not.
- current_user_can()Returns whether the current user has the specified capability.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
Show all 23
- wp_print_inline_script_tag()Prints an inline script tag.
- wp_remove_surrounding_empty_script_tags()Removes leading and trailing _empty_ script tags.
- WP_Customize_Manager::unsanitized_post_values()Gets dirty pre-sanitized setting values in the current customized state.
- WP_Customize_Manager::validate_setting_values()Validates setting values.
- WP_Customize_Manager::get_allowed_urls()Gets URLs allowed to be previewed.
- WP_Customize_Manager::changeset_uuid()Gets the changeset UUID.
- WP_Customize_Manager::autosaved()Gets whether data from a changeset's autosaved revision should be loaded if it exists.
- WP_Customize_Manager::get_stylesheet()Retrieves the stylesheet name of the previewed theme.
- WP_Customize_Manager::is_theme_active()Checks if the current theme is active.
- WP_Customize_Manager::is_cross_domain()Determines whether the admin and the frontend are on different domains.
- WP_Customize_Manager::get_nonces()Gets nonces for the Customizer.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 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.