wp_generate_uuid4 example


    public function __construct( $args = array() ) {

        $args = array_merge(
            array_fill_keys( array( 'changeset_uuid', 'theme', 'messenger_channel', 'settings_previewed', 'autosaved', 'branching' ), null ),
            $args
        );

        // Note that the UUID format will be validated in the setup_theme() method.         if ( ! isset( $args['changeset_uuid'] ) ) {
            $args['changeset_uuid'] = wp_generate_uuid4();
        }

        /* * The theme and messenger_channel should be supplied via $args, * but they are also looked at in the $_REQUEST global here for back-compat. */
        if ( ! isset( $args['theme'] ) ) {
            if ( isset( $_REQUEST['customize_theme'] ) ) {
                $args['theme'] = wp_unslash( $_REQUEST['customize_theme'] );
            } elseif ( isset( $_REQUEST['theme'] ) ) { // Deprecated.                 $args['theme'] = wp_unslash( $_REQUEST['theme'] );
            }
return new WP_Error( 'application_password_empty_name', __( 'An application name is required to create an application password.' ), array( 'status' => 400 ) );
        }

        if ( self::application_name_exists_for_user( $user_id$args['name'] ) ) {
            return new WP_Error( 'application_password_duplicate_name', __( 'Each application name should be unique.' ), array( 'status' => 409 ) );
        }

        $new_password    = wp_generate_password( static::PW_LENGTH, false );
        $hashed_password = wp_hash_password( $new_password );

        $new_item = array(
            '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 );

        
Home | Imprint | This part of the site doesn't use cookies.