WC_Widget::cache_widget( array $args, string $content )
Cache the widget.
Description Description
Parameters Parameters
- $args
-
(Required) Arguments.
- $content
-
(Required) Content.
Return Return
(string) the content that was cached
Source Source
File: includes/abstracts/abstract-wc-widget.php
public function cache_widget( $args, $content ) {
// Don't set any cache if widget_id doesn't exist.
if ( empty( $args['widget_id'] ) ) {
return $content;
}
$cache = wp_cache_get( $this->get_widget_id_for_cache( $this->widget_id ), 'widget' );
if ( ! is_array( $cache ) ) {
$cache = array();
}
$cache[ $this->get_widget_id_for_cache( $args['widget_id'] ) ] = $content;
wp_cache_set( $this->get_widget_id_for_cache( $this->widget_id ), $cache, 'widget' );
return $content;
}