WC_Widget::cache_widget()publicWC 1.0

Cache the widget.

Метод класса: WC_Widget{}

Хуков нет.

Возвращает

Строку. the content that was cached

Использование

$WC_Widget = new WC_Widget();
$WC_Widget->cache_widget( $args, $content );
$args(массив) (обязательный)
Arguments.
$content(строка) (обязательный)
Content.

Код WC_Widget::cache_widget() WC 8.7.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;
}