Yoast\WP\SEO\AI_Authorization\Application

Token_Manager::has_token_expired │ public │ Yoast 1.0

Устарела с версии 28.4. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

Checks whether the token has expired.

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

Хуков нет.

Возвращает

bool. Whether the token has expired.

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

$Token_Manager = new Token_Manager();
$Token_Manager->has_token_expired( $jwt ): bool;
$jwt(строка) (обязательный)
The JWT.

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

Устарела с 28.4

Код Token_Manager::has_token_expired() Yoast 28.9

public function has_token_expired( string $jwt ): bool {
	\_deprecated_function( __METHOD__, 'Yoast SEO 28.4' );
	$parts = \explode( '.', $jwt );
	if ( \count( $parts ) !== 3 ) {
		// Headers, payload and signature parts are not detected.
		return true;
	}

	// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- Reason: Decoding the payload of the JWT.
	$payload = \base64_decode( $parts[1] );
	$json    = \json_decode( $payload );
	if ( $json === null || ! isset( $json->exp ) ) {
		return true;
	}

	// Ensure exp is a valid numeric value.
	if ( ! \is_numeric( $json->exp ) ) {
		return true;
	}

	return $json->exp < \time();
}