ACF

Updater::get_expirationpublicACF 5.6.9

This function safely gets the expiration value from a response.

Method of the class: Updater{}

No Hooks.

Returns

Int.

Usage

$Updater = new Updater();
$Updater->get_expiration( $response, $min, $max );
$response(mixed)
The response from the server.
Default: false
$min(int)
The minimum expiration limit.
Default: 3 hours
$max(int)
The maximum expiration limit.
Default: 7 days

Changelog

Since 5.6.9 Introduced.

Updater::get_expiration() code ACF 6.8.8

public function get_expiration( $response = false, $min = 10800, $max = 604800 ) {
	$expiration = 0;

	// Check possible error conditions.
	if ( is_wp_error( $response ) || is_string( $response ) ) {
		return 15 * MINUTE_IN_SECONDS;
	}

	// Use the server requested expiration if present.
	if ( is_array( $response ) && isset( $response['expiration'] ) ) {
		$expiration = (int) $response['expiration'];
	}

	// Use the minimum if neither check matches, or ensure the server expiration isn't lower than our minimum.
	if ( $expiration < $min ) {
		return $min;
	}

	// Ensure the server expiration isn't higher than our max.
	if ( $expiration > $max ) {
		return $max;
	}

	return $expiration;
}