WP_Community_Events::cache_events()protectedWP 4.8.0

Caches an array of events data from the Events API.

Метод класса: WP_Community_Events{}

Хуков нет.

Возвращает

true|false. true if events were cached; false if not.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->cache_events( $events, $expiration );
$events(массив) (обязательный)
Response body from the API request.
$expiration(int|false)
Amount of time to cache the events.
По умолчанию: false

Список изменений

С версии 4.8.0 Введена.

Код WP_Community_Events::cache_events() WP 6.5.2

protected function cache_events( $events, $expiration = false ) {
	$set              = false;
	$transient_key    = $this->get_events_transient_key( $events['location'] );
	$cache_expiration = $expiration ? absint( $expiration ) : HOUR_IN_SECONDS * 12;

	if ( $transient_key ) {
		$set = set_site_transient( $transient_key, $events, $cache_expiration );
	}

	return $set;
}