is_customize_preview(): bool
- Since
- 4.0.0
- Source
wp-includes/theme.php:3842
Compatibility
- WordPress
- since 4.0.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.
Return value
bool- True if the site is being previewed in the Customizer, false otherwise.
Performance profile
How much work a call to is_customize_preview() 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
- 4–7
- Plugin surface
- None
- Called by
- 22
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 7.
Nothing here hands control to plugin code.
22 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost is_customize_preview() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!($wp_customize instanceof) | 4 | none |
$wp_customize instanceof | 7 | ->is_preview() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 7 instructions, 4–7 executed per call, 1 branch. The work does not change between versions.
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.
Used by · 22
- Twenty_Eleven_Ephemera_Widget::widget()Outputs the HTML for this widget.
- Twenty_Fourteen_Ephemera_Widget::__construct()Constructor.
- WP_Customize_Selective_Refresh::handle_render_partials_request()Handles the Ajax request to return the rendered partials for the requested placements.
- WP_Widget_Recent_Comments::__construct()Sets up a new Recent Comments widget instance.
- WP_Widget_Text::render_control_template_scripts()Renders form template scripts.
- _custom_background_cb()Default custom background callback.
- _wp_menu_item_classes_by_context()Adds the class property classes for the current context, if applicable.
- get_custom_header_markup()Retrieves the markup for a custom header.
- get_custom_logo()Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
- the_custom_header_markup()Prints the markup for a custom header.
- twenty_twenty_one_setup()Sets up theme defaults and registers support for various WordPress features.
- twentynineteen_colors_css_wrap()Displays custom color CSS in customizer and on frontend.
Show all 22
- twentyseventeen_body_classes()Adds custom classes to the array of body classes.
- twentyseventeen_colors_css_wrap()Displays custom color CSS.
- twentyseventeen_front_page_section()Displays a front page section.
- twentyseventeen_scripts()Enqueues scripts and styles.
- twentytwenty_body_classes()Adds conditional body classes.
- twentytwenty_theme_support()Sets up theme defaults and registers support for various WordPress features.
- wp_admin_bar_customize_menu()Adds the "Customize" link to the Toolbar.
- wp_custom_css_cb()Renders the Custom CSS style element.
- wp_enqueue_global_styles()Enqueues the global styles defined via theme.json.
- wp_site_icon()Displays site icon meta tags.
Source code
function is_customize_preview() { global $wp_customize; return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();}Changelog
Introduced in 4.0.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.9.7 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.