ACF
Updater::get_expiration
This function safely gets the expiration value from a response.
Метод класса: Updater{}
Хуков нет.
Возвращает
Int.
Использование
$Updater = new Updater(); $Updater->get_expiration( $response, $min, $max );
- $response(разное)
- The response from the server.
По умолчанию:false - $min(int)
- The minimum expiration limit.
По умолчанию:3 hours - $max(int)
- The maximum expiration limit.
По умолчанию:7 days
Список изменений
| С версии 5.6.9 | Введена. |
Код Updater::get_expiration() Updater::get expiration ACF 6.4.2
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;
}