WC_Widget::cache_widget
Cache the widget.
Method of the class: WC_Widget{}
No Hooks.
Returns
String. the content that was cached
Usage
$WC_Widget = new WC_Widget(); $WC_Widget->cache_widget( $args, $content );
- $args(array) (required)
- Arguments.
- $content(string) (required)
- Content.
WC_Widget::cache_widget() WC Widget::cache widget code WC 10.5.0
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;
}