On this page
WP_Community_Events::get_events_transient_key( array $location ): string|false
Generates a transient key based on user location.
Description
This could be reduced to a one-liner in the calling functions, but it’s intentionally a separate function because it’s called from multiple functions, and having it abstracted keeps the logic consistent and DRY, which is less prone to errors.
Parameters
$locationarray Required-
Should contain
'latitude'and'longitude'indexes.
Return
string|false Transient key on success, false on failure.
Source
File: wp-admin/includes/class-wp-community-events.php. View all references
protected function get_events_transient_key( $location ) {
$key = false;
if ( isset( $location['ip'] ) ) {
$key = 'community-events-' . md5( $location['ip'] );
} elseif ( isset( $location['latitude'], $location['longitude'] ) ) {
$key = 'community-events-' . md5( $location['latitude'] . $location['longitude'] );
}
return $key;
}
Related
Used By
| Used By | Description |
|---|---|
| WP_Community_Events::cache_events() wp-admin/includes/class-wp-community-events.php | Caches an array of events data from the Events API. |
| WP_Community_Events::get_cached_events() wp-admin/includes/class-wp-community-events.php | Gets cached events. |
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/get_events_transient_key