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.

Метод класса: WP_Widget{}

Хуков нет.

Возвращает

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

Использование

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

Заметки

  • Global. WP_Customize_Manager. $wp_customize

Список изменений

С версии 3.9.0 Введена.

Код WP_Widget::is_preview() WP 6.5.2

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