WordPress at Your Fingertips
function is not described

WP_Community_Events::cache_events() protected WP 4.8.0

Caches an array of events data from the Events API.

{} It's a method of the class: WP_Community_Events{}

No Hooks.

Return

true|false. true if events were cached; false if not.

Usage

// protected - for code of main (parent) or child class
$result = $this->cache_events( $events, $expiration );
$events(array) (required)
Response body from the API request.
$expiration(int|false)
Amount of time to cache the events.
Default: false

Changelog

Since 4.8.0 Introduced.

Code of WP_Community_Events::cache_events() WP 5.8.2

protected function cache_events( $events, $expiration = false ) {
	$set              = false;
	$transient_key    = $this->get_events_transient_key( $events['location'] );
	$cache_expiration = $expiration ? absint( $expiration ) : HOUR_IN_SECONDS * 12;

	if ( $transient_key ) {
		$set = set_site_transient( $transient_key, $events, $cache_expiration );
	}

	return $set;
}