'uuid' =>
wp_generate_uuid4(),
'app_id' =>
empty( $args['app_id'
] ) ? '' :
$args['app_id'
],
'name' =>
$args['name'
],
'password' =>
$hashed_password,
'created' =>
time(),
'last_used' => null,
'last_ip' => null,
);
$passwords =
static::
get_user_application_passwords( $user_id );
$passwords[] =
$new_item;
$saved =
static::
set_user_application_passwords( $user_id,
$passwords );
if ( !
$saved ) { return new WP_Error( 'db_error',
__( 'Could not save application password.'
) );
} $network_id =
get_main_network_id();
if ( !
get_network_option( $network_id, self::OPTION_KEY_IN_USE
) ) { update_network_option( $network_id, self::OPTION_KEY_IN_USE, true
);
} /**
* Fires when an application password is created.
*
* @since 5.6.0
*
* @param int $user_id The user ID.
* @param array $new_item {
* The details about the created password.
*
* @type string $uuid The unique identifier for the application password.
* @type string $app_id A UUID provided by the application to uniquely identify it.
* @type string $name The name of the application password.
* @type string $password A one-way hash of the password.
* @type int $created Unix timestamp of when the password was created.
* @type null $last_used Null.
* @type null $last_ip Null.
* }
* @param string $new_password The unhashed generated application password.
* @param array $args {
* Arguments used to create the application password.
*
* @type string $name The name of the application password.
* @type string $app_id A UUID provided by the application to uniquely identify it.
* }
*/