_wp_customize_include()
- Since
- 3.4.0
- Source
wp-includes/theme.php:3529
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
- Scaling
- Constant
- Instructions
- 8–114
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 125.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls it makes |
|---|---|---|
!is_admin() | 8–22 | is_admin() |
is_admin() | 14–28 | is_admin(), basename() |
!is_admin() && empty($input_vars) && !isset($input_vars) | 65–89 | is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), compact() |
!is_admin() | 71–95 | is_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–95 | is_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–96 | is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), wp_unslash(), compact() |
!is_admin() && isset($input_vars) | 77–101 | is_admin(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), sanitize_key(), sanitize_key(), wp_doing_ajax(), compact() |
is_admin() | 77–101 | is_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–102 | is_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–102 | is_admin(), basename(), wp_array_slice_assoc(), wp_array_slice_assoc(), array_merge(), wp_doing_ajax(), wp_unslash(), compact() |
is_admin() && isset($input_vars) | 83–107 | is_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–108 | is_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–108 | is_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–114 | is_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 125 | 8–114 | 16 | |
| 8.5 | 125 | 8–114 | 16 | |
| 8.4 | 125 | 8–114 | 16 | |
| 8.3 | 125 | 8–114 | 16 | |
| 8.2 | 125 | 8–114 | 16 | |
| 8.1 | 125 | 8–114 | 16 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 126 | 8–115 | 16 |
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
- is_admin()Determines whether the current request is for an administrative interface page.
- wp_array_slice_assoc()Extracts a slice of an array, given a list of keys.
- sanitize_key()Sanitizes a string key.
- wp_doing_ajax()Determines whether the current request is a WordPress Ajax request.
- wp_unslash()Removes slashes from a string or recursively removes slashes from strings within an array.
- WP_Customize_Manager::__construct()Constructor.
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.
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.