On this page
WP_Community_Events::cache_events( array $events, int|false $expiration = false ): bool
Caches an array of events data from the Events API.
Parameters
$eventsarray Required-
Response body from the API request.
$expirationint|false Optional-
Amount of time to cache the events. Defaults to false.
Default:
false
Return
bool true if events were cached; false if not.
Source
File: wp-admin/includes/class-wp-community-events.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Community_Events::get_events_transient_key() wp-admin/includes/class-wp-community-events.php | Generates a transient key based on user location. |
| set_site_transient() wp-includes/option.php | Sets/updates the value of a site transient. |
| absint() wp-includes/functions.php | Converts a value to non-negative integer. |
Used By
| Used By | Description |
|---|---|
| WP_Community_Events::get_events() wp-admin/includes/class-wp-community-events.php | Gets data about events near a particular location. |
Changelog
| Version | Description |
|---|---|
| 4.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_community_events/cache_events