WP_Application_Passwords::check_passwordpublic staticWP 6.8.0

Checks a plaintext application password against a hashed password.

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

Хуков нет.

Возвращает

true|false. Whether the password matches the hashed password.

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

$result = WP_Application_Passwords::check_password( string $password, $hash ): bool;
string $password(обязательный)

.

Иммет атрибут #[\SensitiveParameter], который скрывает значение параметра из логов. Используется для защиты чувствительных данных (например, паролей). Документация.

$hash(строка) (обязательный)
Hash of the password to check against.

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

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

Код WP_Application_Passwords::check_password() WP 6.9

public static function check_password(
	#[\SensitiveParameter]
	string $password,
	string $hash
): bool {
	if ( ! str_starts_with( $hash, '$generic$' ) ) {
		/*
		 * If the hash doesn't start with `$generic$`, it is a hash created with `wp_hash_password()`.
		 * This is the case for application passwords created before 6.8.0.
		 */
		return wp_check_password( $password, $hash );
	}

	return wp_verify_fast_hash( $password, $hash );
}