- /** Generate the actual widget content.
- * Just finds the instance and calls widget().
- * Do NOT over-ride this function. */
- function display_callback( $args, $widget_args = 1 ) {
- if ( is_numeric($widget_args) )
+ /**
+ * Determine 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.
+ *
+ * @since 3.9.0
+ * @access public
+ *
+ * @global WP_Customize_Manager $wp_customize
+ *
+ * @return bool True if within the Customizer preview, false if not.
+ */
+ public function is_preview() {
+ global $wp_customize;
+ return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ;
+ }
+
+ /**
+ * Generate the actual widget content (Do NOT override).
+ *
+ * Finds the instance and calls {@see WP_Widget::widget()}.
+ *
+ * @since 2.8.0
+ * @access public
+ *
+ * @param array $args Display arguments. See {@see WP_Widget::widget()} for information
+ * on accepted arguments.
+ * @param int|array $widget_args {
+ * Optional. Internal order number of the widget instance, or array of multi-widget arguments.
+ * Default 1.
+ *
+ * @type int $number Number increment used for multiples of the same widget.
+ * }
+ */
+ public function display_callback( $args, $widget_args = 1 ) {
+ if ( is_numeric( $widget_args ) ) {