WP_Recovery_Mode_Key_Service::generate_and_store_recovery_mode_key()publicWP 5.2.0

Creates a recovery mode key.

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

Хуки из метода

Возвращает

Строку. Recovery mode key.

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

$WP_Recovery_Mode_Key_Service = new WP_Recovery_Mode_Key_Service();
$WP_Recovery_Mode_Key_Service->generate_and_store_recovery_mode_key( $token );
$token(строка) (обязательный)
A token generated by {@see generate_recovery_mode_token()}.

Заметки

  • Global. PasswordHash. $wp_hasher Portable PHP password hashing framework instance.

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

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

Код WP_Recovery_Mode_Key_Service::generate_and_store_recovery_mode_key() WP 6.6.2

public function generate_and_store_recovery_mode_key( $token ) {

	global $wp_hasher;

	$key = wp_generate_password( 22, false );

	if ( empty( $wp_hasher ) ) {
		require_once ABSPATH . WPINC . '/class-phpass.php';
		$wp_hasher = new PasswordHash( 8, true );
	}

	$hashed = $wp_hasher->HashPassword( $key );

	$records = $this->get_keys();

	$records[ $token ] = array(
		'hashed_key' => $hashed,
		'created_at' => time(),
	);

	$this->update_keys( $records );

	/**
	 * Fires when a recovery mode key is generated.
	 *
	 * @since 5.2.0
	 *
	 * @param string $token The recovery data token.
	 * @param string $key   The recovery mode key.
	 */
	do_action( 'generate_recovery_mode_key', $token, $key );

	return $key;
}