Merge pull request #15416 from woocommerce/fix/15407
Correctly append cache
This commit is contained in:
commit
46846ed4e0
|
@ -73,7 +73,6 @@ abstract class WC_Widget extends WP_Widget {
|
||||||
* @return bool true if the widget is cached otherwise false
|
* @return bool true if the widget is cached otherwise false
|
||||||
*/
|
*/
|
||||||
public function get_cached_widget( $args ) {
|
public function get_cached_widget( $args ) {
|
||||||
|
|
||||||
$cache = wp_cache_get( apply_filters( 'woocommerce_cached_widget_id', $this->widget_id ), 'widget' );
|
$cache = wp_cache_get( apply_filters( 'woocommerce_cached_widget_id', $this->widget_id ), 'widget' );
|
||||||
|
|
||||||
if ( ! is_array( $cache ) ) {
|
if ( ! is_array( $cache ) ) {
|
||||||
|
@ -96,7 +95,15 @@ abstract class WC_Widget extends WP_Widget {
|
||||||
* @return string the content that was cached
|
* @return string the content that was cached
|
||||||
*/
|
*/
|
||||||
public function cache_widget( $args, $content ) {
|
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;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue