WP_Community_Events::get_events_transient_key

Advertisement

Summery Summery

Generates a transient key based on user location.

Syntax Syntax

WP_Community_Events::get_events_transient_key( array $location )

Description 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 Parameters

$location

(array) (Required) Should contain 'latitude' and 'longitude' indexes.

Return Return

(bool|string) false on failure, or a string on success.

Source Source

File: wp-admin/includes/class-wp-community-events.php

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

Advertisement

Changelog Changelog

Changelog
Version Description
4.8.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.