WC_Rate_Limiter::retried_too_soon()public staticWC 1.0

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 8.7.0

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