WP_Widget::is_preview() WordPress Method

The WP_Widget::is_preview() method allows you to check if the current widget is in preview mode. Preview mode is a special mode that is used when you are customizing a widget on the frontend of your site. This method will return true if the widget is in preview mode, and false if it is not.

WP_Widget::is_preview() #

Determines whether the current request is inside the Customizer preview.


Description

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.


Top ↑

Return

(bool) True if within the Customizer preview, false if not.


Top ↑

Source

File: wp-includes/class-wp-widget.php

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


Top ↑

Changelog

Changelog
VersionDescription
3.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.