WP_Community_Events::get_events_transient_key
Generates a transient key based on user location.
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.
Method of the class: WP_Community_Events{}
No Hooks.
Returns
String|false. Transient key on success, false on failure.
Usage
// protected - for code of main (parent) or child class $result = $this->get_events_transient_key( $location );
- $location(array) (required)
- Should contain
'latitude'and'longitude'indexes.
Changelog
| Since 4.8.0 | Introduced. |
WP_Community_Events::get_events_transient_key() WP Community Events::get events transient key code WP 6.9.1
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;
}