WordPress.org

Make WordPress Core

Ticket #39638: 39638.diff

File 39638.diff, 2.8 KB (added by xkon, 3 months ago)
  • src/js/_enqueues/admin/user-profile.js

     
    9595                var $generateButton,
    9696                        $cancelButton;
    9797
    98                 $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' );
     98                $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap, .reset-pass-submit' );
    9999
    100100                // Hide the confirm password field when JavaScript support is enabled.
    101101                $('.user-pass2-wrap').hide();
     
    398398                }
    399399        } );
    400400
     401        /**
     402         * We need to call a generate password as soon as the Rest Password page is loaded
     403         * to avoid double clicking on the button to retrieve the first generated password.
     404         * Ticket: 39638
     405         */
     406        $( document ).ready( function() {
     407                if ( $( '.reset-pass-submit' ).length ) {
     408                        $( '.reset-pass-submit button.wp-generate-pw' ).trigger( 'click' );
     409                }
     410        });
     411
    401412})(jQuery);
  • src/wp-admin/admin-ajax.php

     
    163163        add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
    164164}
    165165
     166add_action( 'wp_ajax_nopriv_generate-password', 'wp_ajax_nopriv_generate_password' );
     167
    166168add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
    167169
    168170$action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : '';
  • src/wp-admin/includes/ajax-actions.php

     
    39773977}
    39783978
    39793979/**
     3980 * Ajax handler for generating a password in
     3981 * the no-privilege context.
     3982 *
     3983 * @since 5.7.0
     3984 */
     3985function wp_ajax_nopriv_generate_password() {
     3986        wp_send_json_success( wp_generate_password( 24 ) );
     3987}
     3988
     3989/**
    39803990 * Ajax handler for saving the user's WordPress.org username.
    39813991 *
    39823992 * @since 4.4.0
  • src/wp-login.php

     
    10411041
    10421042                        ?>
    10431043                        <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
    1044                         <p class="submit">
    1045                                 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" />
     1044                        <p class="submit reset-pass-submit">
     1045                                <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="true">Generate Password</button>
     1046                                <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password' ); ?>" />
    10461047                        </p>
    10471048                </form>
    10481049