WC_Widget::cache_widget( array $args, string $content )

Cache the widget.


Description Description


Parameters Parameters

$args

(Required) Arguments.

$content

(Required) Content.


Top ↑

Return Return

(string) the content that was cached


Top ↑

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


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.