is_preview() ) { $cache = wp_cache_get('widget_recent_comments', 'widget'); } if ( ! is_array( $cache ) ) { $cache = array(); } if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; $lang = pll_current_language(); #added if ( isset( $cache[ $args['widget_id'] ] [$lang] ) ) { #modified# echo $cache[ $args['widget_id'] ] [$lang]; #modified# return; } $output = ''; $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' ); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; if ( ! $number ) $number = 5; /** * Filter the arguments for the Recent Comments widget. * * @since 3.4.0 * * @see get_comments() * * @param array $comment_args An array of arguments used to retrieve the recent comments. */ $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) ); $output .= $args['before_widget']; if ( $title ) { $output .= $args['before_title'] . $title . $args['after_title']; } $output .= ''; $output .= $args['after_widget']; echo $output; if ( ! $this->is_preview() ) { $cache[ $args['widget_id'] ] [$lang] = $output; #modified# wp_cache_set( 'widget_recent_comments', $cache, 'widget' ); } } /* * backward compatibility with WP < 3.9 * * @since 1.5 * * @return bool */ function is_preview() { return version_compare($GLOBALS['wp_version'], '3.9', '<') ? false : parent::is_preview(); } }