WC_Widget::get_cached_widget
Get cached widget.
Method of the class: WC_Widget{}
No Hooks.
Returns
true|false. true if the widget is cached otherwise false
Usage
$WC_Widget = new WC_Widget(); $WC_Widget->get_cached_widget( $args );
- $args(array) (required)
- Arguments.
WC_Widget::get_cached_widget() WC Widget::get cached widget code WC 10.8.1
public function get_cached_widget( $args ) {
// Don't get cache if widget_id doesn't exists.
if ( empty( $args['widget_id'] ) ) {
return false;
}
$cache = wp_cache_get( $this->get_widget_id_for_cache( $this->widget_id ), 'widget' );
if ( ! is_array( $cache ) ) {
$cache = array();
}
if ( isset( $cache[ $this->get_widget_id_for_cache( $args['widget_id'] ) ] ) ) {
echo $cache[ $this->get_widget_id_for_cache( $args['widget_id'] ) ]; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
return true;
}
return false;
}