diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index ce680ef4c4298..8506e38f5a390 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -60,6 +60,14 @@ if ( 'mailserver_pass' !== $pass1.prop('id' ) && ! $('#weblog_title').length ) { $( $pass1 ).trigger( 'focus' ); } + + if($( '.wp-generate-pw').length) { + // Generate the next password and cache. + wp.ajax.post( 'generate-password' ) + .done( function( data ) { + $pass1.data( 'pw', data ); + } ); + } } function bindPass1() { @@ -260,12 +268,6 @@ // Show generated password in plaintext by default. resetToggle ( false ); - - // Generate the next password and cache. - wp.ajax.post( 'generate-password' ) - .done( function( data ) { - $pass1.data( 'pw', data ); - } ); } ); $cancelButton = $pass1Row.find( 'button.wp-cancel-pw' ); @@ -529,16 +531,4 @@ return __( 'The changes you made will be lost if you navigate away from this page.' ); } }); - - /* - * We need to generate a password as soon as the Reset Password page is loaded, - * to avoid double clicking the button to retrieve the first generated password. - * See ticket #39638. - */ - $( function() { - if ( $( '.reset-pass-submit' ).length ) { - $( '.reset-pass-submit button.wp-generate-pw' ).trigger( 'click' ); - } - }); - })(jQuery);