mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-24 01:57:53 +01:00
Recent Comments Widget: a la [34464], this widget has the same mixed content issues. Remove the fragment caching. The comment queries are now split to scale. This was the only remaining widget with an HTML fragment cache.
Fixes #25556. Built from https://develop.svn.wordpress.org/trunk@34581 git-svn-id: http://core.svn.wordpress.org/trunk@34545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0405a03b5e
commit
8646c8b93c
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34580';
|
$wp_version = '4.4-alpha-34581';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
@ -23,10 +23,6 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
|||||||
|
|
||||||
if ( is_active_widget(false, false, $this->id_base) )
|
if ( is_active_widget(false, false, $this->id_base) )
|
||||||
add_action( 'wp_head', array($this, 'recent_comments_style') );
|
add_action( 'wp_head', array($this, 'recent_comments_style') );
|
||||||
|
|
||||||
add_action( 'comment_post', array($this, 'flush_widget_cache') );
|
|
||||||
add_action( 'edit_comment', array($this, 'flush_widget_cache') );
|
|
||||||
add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,34 +45,14 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function flush_widget_cache() {
|
|
||||||
wp_cache_delete('widget_recent_comments', 'widget');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param array $instance
|
* @param array $instance
|
||||||
*/
|
*/
|
||||||
public function widget( $args, $instance ) {
|
public function widget( $args, $instance ) {
|
||||||
$cache = array();
|
|
||||||
if ( ! $this->is_preview() ) {
|
|
||||||
$cache = wp_cache_get('widget_recent_comments', 'widget');
|
|
||||||
}
|
|
||||||
if ( ! is_array( $cache ) ) {
|
|
||||||
$cache = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! isset( $args['widget_id'] ) )
|
if ( ! isset( $args['widget_id'] ) )
|
||||||
$args['widget_id'] = $this->id;
|
$args['widget_id'] = $this->id;
|
||||||
|
|
||||||
if ( isset( $cache[ $args['widget_id'] ] ) ) {
|
|
||||||
echo $cache[ $args['widget_id'] ];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
|
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
|
||||||
@ -128,11 +104,6 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
|||||||
$output .= $args['after_widget'];
|
$output .= $args['after_widget'];
|
||||||
|
|
||||||
echo $output;
|
echo $output;
|
||||||
|
|
||||||
if ( ! $this->is_preview() ) {
|
|
||||||
$cache[ $args['widget_id'] ] = $output;
|
|
||||||
wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,12 +115,6 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
|||||||
$instance = $old_instance;
|
$instance = $old_instance;
|
||||||
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
||||||
$instance['number'] = absint( $new_instance['number'] );
|
$instance['number'] = absint( $new_instance['number'] );
|
||||||
$this->flush_widget_cache();
|
|
||||||
|
|
||||||
$alloptions = wp_cache_get( 'alloptions', 'options' );
|
|
||||||
if ( isset($alloptions['widget_recent_comments']) )
|
|
||||||
delete_option('widget_recent_comments');
|
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user