WordPress at Your Fingertips
function is not described

WP_Community_Events::get_events_transient_key() protected WP 4.8.0

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.

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

No Hooks.

Return

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.

Code of WP_Community_Events::get_events_transient_key() WP 5.8.2

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;
}