Changeset 34581
- Timestamp:
- 09/26/2015 06:00:09 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets/class-wp-widget-recent-comments.php
r34514 r34581 24 24 if ( is_active_widget(false, false, $this->id_base) ) 25 25 add_action( 'wp_head', array($this, 'recent_comments_style') ); 26 27 add_action( 'comment_post', array($this, 'flush_widget_cache') );28 add_action( 'edit_comment', array($this, 'flush_widget_cache') );29 add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );30 26 } 31 27 … … 51 47 52 48 /** 53 * @access public54 */55 public function flush_widget_cache() {56 wp_cache_delete('widget_recent_comments', 'widget');57 }58 59 /**60 49 * @param array $args 61 50 * @param array $instance 62 51 */ 63 52 public function widget( $args, $instance ) { 64 $cache = array();65 if ( ! $this->is_preview() ) {66 $cache = wp_cache_get('widget_recent_comments', 'widget');67 }68 if ( ! is_array( $cache ) ) {69 $cache = array();70 }71 72 53 if ( ! isset( $args['widget_id'] ) ) 73 54 $args['widget_id'] = $this->id; 74 75 if ( isset( $cache[ $args['widget_id'] ] ) ) {76 echo $cache[ $args['widget_id'] ];77 return;78 }79 55 80 56 $output = ''; … … 129 105 130 106 echo $output; 131 132 if ( ! $this->is_preview() ) {133 $cache[ $args['widget_id'] ] = $output;134 wp_cache_set( 'widget_recent_comments', $cache, 'widget' );135 }136 107 } 137 108 … … 145 116 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 146 117 $instance['number'] = absint( $new_instance['number'] ); 147 $this->flush_widget_cache();148 149 $alloptions = wp_cache_get( 'alloptions', 'options' );150 if ( isset($alloptions['widget_recent_comments']) )151 delete_option('widget_recent_comments');152 153 118 return $instance; 154 119 }
Note: See TracChangeset
for help on using the changeset viewer.