WC_Rate_Limiter::retried_too_soon
Returns true if the action is not allowed to be run by the rate limiter yet, false otherwise.
Метод класса: WC_Rate_Limiter{}
Хуков нет.
Возвращает
true|false.
Использование
$result = WC_Rate_Limiter::retried_too_soon( $action_id );
- $action_id(строка) (обязательный)
- Identifier of the action.
Код WC_Rate_Limiter::retried_too_soon() WC Rate Limiter::retried too soon WC 10.3.4
public static function retried_too_soon( $action_id ) {
global $wpdb;
$next_try_allowed_at = self::get_cached( $action_id );
if ( false === $next_try_allowed_at ) {
$next_try_allowed_at = $wpdb->get_var(
$wpdb->prepare(
"
SELECT rate_limit_expiry
FROM {$wpdb->prefix}wc_rate_limits
WHERE rate_limit_key = %s
",
$action_id
)
);
self::set_cache( $action_id, $next_try_allowed_at );
}
// No record of action running, so action is allowed to run.
if ( null === $next_try_allowed_at ) {
return false;
}
// Before the next run is allowed, retry forbidden.
if ( time() <= $next_try_allowed_at ) {
return true;
}
// After the next run is allowed, retry allowed.
return false;
}