Automattic\WooCommerce\Internal\StockNotifications\Frontend

SignupRateLimiter::apply │ public static │ WC 11.2.0

Start the rate limit windows for the current sign-up attempt.

Метод класса: SignupRateLimiter{}

Хуков нет.

Возвращает

bool. True if every rate limit was applied.

Использование

$result = SignupRateLimiter::apply( $user_email ): bool;
$user_email(строка) (обязательный)
The e-mail address used to sign up.

Список изменений

С версии 11.2.0 Введена.

Код SignupRateLimiter::apply() WC 11.2.2

public static function apply( string $user_email ): bool {
	$applied_rate_limit_ids = array();

	foreach ( self::get_rate_limits( $user_email ) as $rate_limit_id => $delay ) {
		if ( ! WC_Rate_Limiter::set_rate_limit( $rate_limit_id, $delay ) ) {
			// Leave no partial window behind: a half-applied limit would block the
			// customer on an attempt that never went through. The failed limit is
			// cleared too, since set_rate_limit() caches the new expiry even when the
			// write itself fails.
			foreach ( array_merge( array( $rate_limit_id ), $applied_rate_limit_ids ) as $applied_rate_limit_id ) {
				WC_Rate_Limiter::set_rate_limit( $applied_rate_limit_id, -1 );
			}

			return false;
		}

		$applied_rate_limit_ids[] = $rate_limit_id;
	}

	return true;
}