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.
Метод класса: WP_Community_Events{}
Хуков нет.
Возвращает
Строку|false
. Transient key on success, false on failure.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_events_transient_key( $location );
- $location(массив) (обязательный)
- Should contain 'latitude' and 'longitude' indexes.
Список изменений
С версии 4.8.0 | Введена. |
Код WP_Community_Events::get_events_transient_key() WP Community Events::get events transient key WP 6.6.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; }