WP_Widget::is_preview()publicWP 3.9.0

Determines whether the current request is inside the Customizer preview.

If true -- the current request is inside the Customizer preview, then the object cache gets suspended and widgets should check this to decide whether they should store anything persistently to the object cache, to transients, or anywhere else.

Method of the class: WP_Widget{}

No Hooks.

Return

true|false. True if within the Customizer preview, false if not.

Usage

$WP_Widget = new WP_Widget();
$WP_Widget->is_preview();

Notes

  • Global. WP_Customize_Manager. $wp_customize

Changelog

Since 3.9.0 Introduced.

WP_Widget::is_preview() code WP 6.5.2

public function is_preview() {
	global $wp_customize;
	return ( isset( $wp_customize ) && $wp_customize->is_preview() );
}