WP_Community_Events::cache_events() WordPress Method

The WP_Community_Events::cache_events() Wordpress method is used to cache the events that are fetched from the WordPress Community Events API. This is done so that the events can be retrieved faster and more efficiently.

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

Caches an array of events data from the Events API.


Parameters

$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


Top ↑

Return

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


Top ↑

Source

File: wp-admin/includes/class-wp-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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.