WC_Widget::get_cached_widget()publicWC 1.0

Get cached widget.

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

Хуков нет.

Возвращает

true|false. true if the widget is cached otherwise false

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

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

Код WC_Widget::get_cached_widget() WC 8.7.0

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;
}