is_preview() ) { $cache = wp_cache_get( 'widget_recent_posts', '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; } ob_start(); $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' ); /** 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; $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; /** * Filter the arguments for the Recent Posts widget. * * @since 3.4.0 * * @see WP_Query::get_posts() * * @param array $args An array of arguments used to retrieve the recent posts. */ $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ( $r->have_posts() ) : ?> is_preview() ) { $cache[ $args['widget_id'] ][ $lang ] = ob_get_flush(); #modified# wp_cache_set( 'widget_recent_posts', $cache, 'widget' ); } else { ob_end_flush(); } } }