Changeset 27966
- Timestamp:
- 04/06/2014 06:47:46 PM (11 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-widgets.php
r27697 r27966 661 661 662 662 function widget($args, $instance) { 663 $cache = wp_cache_get('widget_recent_posts', 'widget'); 664 665 if ( !is_array($cache) ) 663 $cache = array(); 664 if ( ! $this->is_preview() ) { 665 $cache = wp_cache_get( 'widget_recent_posts', 'widget' ); 666 } 667 668 if ( ! is_array( $cache ) ) { 666 669 $cache = array(); 667 668 if ( ! isset( $args['widget_id'] ) ) 670 } 671 672 if ( ! isset( $args['widget_id'] ) ) { 669 673 $args['widget_id'] = $this->id; 674 } 670 675 671 676 if ( isset( $cache[ $args['widget_id'] ] ) ) { … … 724 729 endif; 725 730 726 $cache[$args['widget_id']] = ob_get_flush(); 727 wp_cache_set('widget_recent_posts', $cache, 'widget'); 731 if ( ! $this->is_preview() ) { 732 $cache[ $args['widget_id'] ] = ob_get_flush(); 733 wp_cache_set( 'widget_recent_posts', $cache, 'widget' ); 734 } else { 735 ob_flush(); 736 } 728 737 } 729 738 … … 808 817 global $comments, $comment; 809 818 810 $cache = wp_cache_get('widget_recent_comments', 'widget'); 811 812 if ( ! is_array( $cache ) ) 819 $cache = array(); 820 if ( ! $this->is_preview() ) { 821 $cache = wp_cache_get('widget_recent_comments', 'widget'); 822 } 823 if ( ! is_array( $cache ) ) { 813 824 $cache = array(); 825 } 814 826 815 827 if ( ! isset( $args['widget_id'] ) ) … … 866 878 867 879 echo $output; 868 $cache[$args['widget_id']] = $output; 869 wp_cache_set('widget_recent_comments', $cache, 'widget'); 880 881 if ( ! $this->is_preview() ) { 882 $cache[ $args['widget_id'] ] = $output; 883 wp_cache_set( 'widget_recent_comments', $cache, 'widget' ); 884 } 870 885 } 871 886 -
trunk/src/wp-includes/widgets.php
r27870 r27966 162 162 function _get_form_callback() { 163 163 return array($this, 'form_callback'); 164 } 165 166 /** 167 * Determine if we're in the Customizer; if true, then the object cache gets 168 * suspended and widgets should check this to decide whether they should 169 * store anything persistently to the object cache, to transients, or 170 * anywhere else. 171 * 172 * @since 3.9.0 173 * 174 * @return bool True if Customizer is on, false if not. 175 */ 176 function is_preview() { 177 global $wp_customize; 178 return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ; 164 179 } 165 180 … … 190 205 */ 191 206 $instance = apply_filters( 'widget_display_callback', $instance, $this, $args ); 192 if ( false !== $instance ) 193 $this->widget($args, $instance); 207 208 if ( false === $instance ) { 209 return; 210 } 211 212 $was_cache_addition_suspended = wp_suspend_cache_addition(); 213 if ( $this->is_preview() && ! $was_cache_addition_suspended ) { 214 wp_suspend_cache_addition( true ); 215 } 216 217 $this->widget( $args, $instance ); 218 219 if ( $this->is_preview() ) { 220 wp_suspend_cache_addition( $was_cache_addition_suspended ); 221 } 194 222 } 195 223 } … … 242 270 $old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array(); 243 271 244 $instance = $this->update($new_instance, $old_instance); 272 $was_cache_addition_suspended = wp_suspend_cache_addition(); 273 if ( $this->is_preview() && ! $was_cache_addition_suspended ) { 274 wp_suspend_cache_addition( true ); 275 } 276 277 $instance = $this->update( $new_instance, $old_instance ); 278 279 if ( $this->is_preview() ) { 280 wp_suspend_cache_addition( $was_cache_addition_suspended ); 281 } 245 282 246 283 /** … … 258 295 */ 259 296 $instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this ); 260 if ( false !== $instance ) 297 if ( false !== $instance ) { 261 298 $all_instances[$number] = $instance; 299 } 262 300 263 301 break; // run only once
Note: See TracChangeset
for help on using the changeset viewer.