Merge pull request #15416 from woocommerce/fix/15407

Correctly append cache
This commit is contained in:
Claudio Sanches 2017-06-02 12:18:55 -03:00 committed by GitHub
commit 46846ed4e0
1 changed files with 9 additions and 2 deletions

View File

@ -73,7 +73,6 @@ abstract class WC_Widget extends WP_Widget {
* @return bool true if the widget is cached otherwise false
*/
public function get_cached_widget( $args ) {
$cache = wp_cache_get( apply_filters( 'woocommerce_cached_widget_id', $this->widget_id ), 'widget' );
if ( ! is_array( $cache ) ) {
@ -96,7 +95,15 @@ abstract class WC_Widget extends WP_Widget {
* @return string the content that was cached
*/
public function cache_widget( $args, $content ) {
wp_cache_set( apply_filters( 'woocommerce_cached_widget_id', $this->widget_id ), array( $args['widget_id'] => $content ), 'widget' );
$cache = wp_cache_get( apply_filters( 'woocommerce_cached_widget_id', $this->widget_id ), 'widget' );
if ( ! is_array( $cache ) ) {
$cache = array();
}
$cache[ $args['widget_id'] ] = $content;
wp_cache_set( apply_filters( 'woocommerce_cached_widget_id', $this->widget_id ), $cache, 'widget' );
return $content;
}