is_preview() ){ return $instance; } //check if we need to cache this widget? if(isset($instance['wc_cache']) && $instance['wc_cache'] == true) return $instance; //simple timer to clock the widget rendring $timer_start = microtime(true); //create a uniqe transient ID for this widget instance $transient_name = $this->get_widget_key($instance,$args); //get the "cached version of the widget" if ( false === ( $cached_widget = get_transient( $transient_name ) ) ){ // It wasn't there, so render the widget and save it as a transient // start a buffer to capture the widget output ob_start(); //this renders the widget $widget->widget( $args, $instance ); //get rendered widget from buffer $cached_widget = ob_get_clean(); //save/cache the widget output as a transient set_transient( $transient_name, $cached_widget, $this->cache_time); } //output the widget echo $cached_widget; //output rendering time as an html comment echo ''; //after the widget was rendered and printed we return false to short-circuit the normal display of the widget return false; } /** * in_widget_form * this method displays a checkbox in the widget panel * * @param WP_Widget $t The widget instance, passed by reference. * @param null $return Return null if new fields are added. * @param array $instance An array of the widget's settings. * */ function in_widget_form($t,$return,$instance){ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'wc_cache' => null ) ); if ( !isset($instance['wc_cache']) ) $instance['wc_cache'] = null; ?>

/>