GC_Community_Events::cache_events()

最后更新于:2021-11-26 22:44:15

GC_Community_Events::cache_events( array$events, int|false$expiration=false)

Caches an array of events data from the Events API.

参数

$events

(array) (Required) Response body from the API request.

$expiration

(int|false) (Optional) Amount of time to cache the events. Defaults to false.

Default value: false

响应

(bool) true if events were cached; false if not.

源文件

文件: gc-admin/includes/class-gc-community-events.php

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