WP_Recovery_Mode_Key_Service::generate_and_store_recovery_mode_key
Creates a recovery mode key.
Method of the class: WP_Recovery_Mode_Key_Service{}
Hooks from the method
Returns
String. Recovery mode key.
Usage
$WP_Recovery_Mode_Key_Service = new WP_Recovery_Mode_Key_Service(); $WP_Recovery_Mode_Key_Service->generate_and_store_recovery_mode_key( $token );
- $token(string) (required)
- A token generated by {@see generate_recovery_mode_token()}.
Changelog
| Since 5.2.0 | Introduced. |
| Since 6.8.0 | The stored key is now hashed using wp_fast_hash() instead of phpass. |
WP_Recovery_Mode_Key_Service::generate_and_store_recovery_mode_key() WP Recovery Mode Key Service::generate and store recovery mode key code WP 6.9
public function generate_and_store_recovery_mode_key( $token ) {
$key = wp_generate_password( 22, false );
$records = $this->get_keys();
$records[ $token ] = array(
'hashed_key' => wp_fast_hash( $key ),
'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;
}