WordPress at Your Fingertips
function is not described

WP_Widget::is_preview() public WP 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.

{} It's a 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

Code of WP_Widget::is_preview() WP 5.8.3

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