/**
* Caches an array of events data from the Events API.
*
* @since 4.8.0
*
* @param array $events Response body from the API request.
* @param int|false $expiration Optional. Amount of time to cache the events. Defaults to false.
* @return bool true if events were cached; false if not.
*/
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;
} /**
* Gets cached events.
*
* @since 4.8.0
* @since 5.5.2 Response no longer contains formatted date field. They're added
* in `wp.communityEvents.populateDynamicEventFields()` now.
*
* @return array|false An array containing `location` and `events` items
* on success, false on failure.
*/