<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[49248] trunk/src: Users: improve password generation feature.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/49248">49248</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/49248","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>adamsilverstein</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-10-20 18:24:40 +0000 (Tue, 20 Oct 2020)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Users: improve password generation feature.

On the user edit screen improve handling and clarify language: rename the "Generate Password" and "Show password" buttons to "Set New Password". Clicking it always generates a password. Also: improve inline code comments and descriptions.

Props afercia, bookdude13, michaelarestad, pento.
Fixes <a href="https://core.trac.wordpress.org/ticket/42852">#42852</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadminuserprofilejs">trunk/src/js/_enqueues/admin/user-profile.js</a></li>
<li><a href="#trunksrcwpadmincssformscss">trunk/src/wp-admin/css/forms.css</a></li>
<li><a href="#trunksrcwpadminusereditphp">trunk/src/wp-admin/user-edit.php</a></li>
<li><a href="#trunksrcwpadminusernewphp">trunk/src/wp-admin/user-new.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadminuserprofilejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/user-profile.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/user-profile.js      2020-10-20 18:24:33 UTC (rev 49247)
+++ trunk/src/js/_enqueues/admin/user-profile.js        2020-10-20 18:24:40 UTC (rev 49248)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,27 +14,30 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $toggleButton,
</span><span class="cx" style="display: block; padding: 0 10px">                $submitButtons,
</span><span class="cx" style="display: block; padding: 0 10px">                $submitButton,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                currentPass;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         currentPass,
+               $passwordWrapper;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function generatePassword() {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( typeof zxcvbn !== 'function' ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        setTimeout( generatePassword, 50 );
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                } else if ( ! $pass1.val() ) {
-                       // zxcvbn loaded before user entered password.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         } else if ( ! $pass1.val() || $passwordWrapper.hasClass( 'is-open' ) ) {
+                       // zxcvbn loaded before user entered password, or generating new password.
</ins><span class="cx" style="display: block; padding: 0 10px">                         $pass1.val( $pass1.data( 'pw' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                        $pass1.trigger( 'pwupdate' );
</span><span class="cx" style="display: block; padding: 0 10px">                        showOrHideWeakPasswordCheckbox();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                }
-               else {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         } else {
</ins><span class="cx" style="display: block; padding: 0 10px">                         // zxcvbn loaded after the user entered password, check strength.
</span><span class="cx" style="display: block; padding: 0 10px">                        check_pass_strength();
</span><span class="cx" style="display: block; padding: 0 10px">                        showOrHideWeakPasswordCheckbox();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Install screen.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Show the password not masked if admin_password hasn't been posted yet.
</ins><span class="cx" style="display: block; padding: 0 10px">                         $pass1.attr( 'type', 'text' );
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Otherwise, mask the password.
</ins><span class="cx" style="display: block; padding: 0 10px">                         $toggleButton.trigger( 'click' );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,6 +59,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        currentPass = $pass1.val();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Refresh password strength area.
</ins><span class="cx" style="display: block; padding: 0 10px">                         $pass1.removeClass( 'short bad good strong' );
</span><span class="cx" style="display: block; padding: 0 10px">                        showOrHideWeakPasswordCheckbox();
</span><span class="cx" style="display: block; padding: 0 10px">                } );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,18 +88,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $pass1.attr( 'type', 'password' );
</span><span class="cx" style="display: block; padding: 0 10px">                                resetToggle( true );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-                       $pass1.focus();
-
-                       if ( ! _.isUndefined( $pass1[0].setSelectionRange ) ) {
-                               $pass1[0].setSelectionRange( 0, 100 );
-                       }
</del><span class="cx" style="display: block; padding: 0 10px">                 });
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function bindPasswordForm() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                var $passwordWrapper,
-                       $generateButton,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         var $generateButton,
</ins><span class="cx" style="display: block; padding: 0 10px">                         $cancelButton;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,7 +120,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $pass1 = $( '#user_pass' );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /**
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
</ins><span class="cx" style="display: block; padding: 0 10px">                  * Fix a LastPass mismatch issue, LastPass only changes pass2.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * This fixes the issue by copying any changes from the hidden
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -149,57 +146,59 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                bindToggleButton();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( $generateButton.length ) {
-                       $passwordWrapper.hide();
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Generate the first password and cache it, but don't set it yet.
+               wp.ajax.post( 'generate-password' )
+                       .done( function( data ) {
+                               // Cache password.
+                               $pass1.data( 'pw', data );
+                       } );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $generateButton.show();
</span><span class="cx" style="display: block; padding: 0 10px">                $generateButton.on( 'click', function () {
</span><span class="cx" style="display: block; padding: 0 10px">                        updateLock = true;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $generateButton.hide();
-                       $passwordWrapper.show();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Make sure the password fields are shown.
+                       $generateButton.attr( 'aria-expanded', 'true' );
+                       $passwordWrapper
+                               .show()
+                               .addClass( 'is-open' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Enable the inputs when showing.
</span><span class="cx" style="display: block; padding: 0 10px">                        $pass1.attr( 'disabled', false );
</span><span class="cx" style="display: block; padding: 0 10px">                        $pass2.attr( 'disabled', false );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( $pass1.val().length === 0 ) {
-                               generatePassword();
-                       }
-               } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Set the password to the generated value.
+                       generatePassword();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $cancelButton = $pass1Row.find( 'button.wp-cancel-pw' );
-               $cancelButton.on( 'click', function () {
-                       updateLock = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Show generated password in plaintext by default.
+                       resetToggle ( false );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Clear any entered password.
-                       $pass1.val( '' );
-
-                       // Generate a new password.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Generate the next password and cache.
</ins><span class="cx" style="display: block; padding: 0 10px">                         wp.ajax.post( 'generate-password' )
</span><span class="cx" style="display: block; padding: 0 10px">                                .done( function( data ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                        $pass1.data( 'pw', data );
</span><span class="cx" style="display: block; padding: 0 10px">                                } );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                } );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $generateButton.show().focus();
-                       $passwordWrapper.hide();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $cancelButton = $pass1Row.find( 'button.wp-cancel-pw' );
+               $cancelButton.on( 'click', function () {
+                       updateLock = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $weakRow.hide( 0, function () {
-                               $weakCheckbox.removeProp( 'checked' );
-                       } );
-
</del><span class="cx" style="display: block; padding: 0 10px">                         // Disable the inputs when hiding to prevent autofill and submission.
</span><span class="cx" style="display: block; padding: 0 10px">                        $pass1.prop( 'disabled', true );
</span><span class="cx" style="display: block; padding: 0 10px">                        $pass2.prop( 'disabled', true );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Clear password field and update the UI.
+                       $pass1.val( '' ).trigger( 'pwupdate' );
</ins><span class="cx" style="display: block; padding: 0 10px">                         resetToggle( false );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) {
-                               // Clear password field to prevent update.
-                               $pass1.val( '' ).trigger( 'pwupdate' );
-                               $submitButtons.prop( 'disabled', false );
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Hide password controls.
+                       $passwordWrapper
+                               .hide()
+                               .removeClass( 'is-open' );
+
+                       // Stop an empty password from being submitted as a change.
+                       $submitButtons.prop( 'disabled', false );
</ins><span class="cx" style="display: block; padding: 0 10px">                 } );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $pass1Row.closest( 'form' ).on( 'submit', function () {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -399,7 +398,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        window.generatePassword = generatePassword;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /* Warn the user if password was generated but not saved */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Warn the user if password was generated but not saved.
</ins><span class="cx" style="display: block; padding: 0 10px">         $( window ).on( 'beforeunload', function () {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( true === updateLock ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return __( 'Your new password has not been saved.' );
</span></span></pre></div>
<a id="trunksrcwpadmincssformscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/forms.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/forms.css  2020-10-20 18:24:33 UTC (rev 49247)
+++ trunk/src/wp-admin/css/forms.css    2020-10-20 18:24:40 UTC (rev 49248)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -533,6 +533,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">        margin: 0 0 1em;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wp-generate-pw {
+       margin-top: 1em;
+}
+
+.wp-pwd {
+       margin-top: 1em;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #misc-publishing-actions label {
</span><span class="cx" style="display: block; padding: 0 10px">        vertical-align: baseline;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminusereditphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/user-edit.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/user-edit.php  2020-10-20 18:24:33 UTC (rev 49247)
+++ trunk/src/wp-admin/user-edit.php    2020-10-20 18:24:40 UTC (rev 49248)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -632,7 +632,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
</span><span class="cx" style="display: block; padding: 0 10px">        <td>
</span><span class="cx" style="display: block; padding: 0 10px">                <input class="hidden" value=" " /><!-- #24364 workaround -->
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button>
</ins><span class="cx" style="display: block; padding: 0 10px">                 <div class="wp-pwd hide-if-js">
</span><span class="cx" style="display: block; padding: 0 10px">                        <span class="password-input-wrapper">
</span><span class="cx" style="display: block; padding: 0 10px">                                <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -641,7 +641,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="text"><?php _e( 'Hide' ); ?></span>
</span><span class="cx" style="display: block; padding: 0 10px">                        </button>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel' ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px">                                 <span class="dashicons dashicons-no" aria-hidden="true"></span>
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="text"><?php _e( 'Cancel' ); ?></span>
</span><span class="cx" style="display: block; padding: 0 10px">                        </button>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -652,8 +652,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <tr class="user-pass2-wrap hide-if-js">
</span><span class="cx" style="display: block; padding: 0 10px">        <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
</span><span class="cx" style="display: block; padding: 0 10px">        <td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
-       <p class="description"><?php _e( 'Type your new password again.' ); ?></p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" aria-describedby="pass2-desc" />
+       <?php if ( IS_PROFILE_PAGE ) : ?>
+               <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
+       <?php else : ?>
+               <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p>
+       <?php endif; ?>
</ins><span class="cx" style="display: block; padding: 0 10px">         </td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr class="pw-weak">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -661,7 +665,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        <td>
</span><span class="cx" style="display: block; padding: 0 10px">                <label>
</span><span class="cx" style="display: block; padding: 0 10px">                        <input type="checkbox" name="pw_weak" class="pw-checkbox" />
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span>
</ins><span class="cx" style="display: block; padding: 0 10px">                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">        </td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span></span></pre></div>
<a id="trunksrcwpadminusernewphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/user-new.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/user-new.php   2020-10-20 18:24:33 UTC (rev 49247)
+++ trunk/src/wp-admin/user-new.php     2020-10-20 18:24:40 UTC (rev 49248)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -560,8 +560,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                </th>
</span><span class="cx" style="display: block; padding: 0 10px">                <td>
</span><span class="cx" style="display: block; padding: 0 10px">                        <input class="hidden" value=" " /><!-- #24364 workaround -->
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button>
-                       <div class="wp-pwd hide-if-js">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate password' ); ?></button>
+                       <div class="wp-pwd">
</ins><span class="cx" style="display: block; padding: 0 10px">                                 <?php $initial_password = wp_generate_password( 24 ); ?>
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="password-input-wrapper">
</span><span class="cx" style="display: block; padding: 0 10px">                                        <input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -570,10 +570,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
</span><span class="cx" style="display: block; padding: 0 10px">                                        <span class="text"><?php _e( 'Hide' ); ?></span>
</span><span class="cx" style="display: block; padding: 0 10px">                                </button>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
-                                       <span class="dashicons dashicons-no" aria-hidden="true"></span>
-                                       <span class="text"><?php _e( 'Cancel' ); ?></span>
-                               </button>
</del><span class="cx" style="display: block; padding: 0 10px">                                 <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
</span><span class="cx" style="display: block; padding: 0 10px">                        </div>
</span><span class="cx" style="display: block; padding: 0 10px">                </td>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -581,7 +577,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        <tr class="form-field form-required user-pass2-wrap hide-if-js">
</span><span class="cx" style="display: block; padding: 0 10px">                <th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
</span><span class="cx" style="display: block; padding: 0 10px">                <td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                <input name="pass2" type="password" id="pass2" autocomplete="off" />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         <input name="pass2" type="password" id="pass2" autocomplete="off" aria-describedby="pass2-desc" />
+               <p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p>
</ins><span class="cx" style="display: block; padding: 0 10px">                 </td>
</span><span class="cx" style="display: block; padding: 0 10px">        </tr>
</span><span class="cx" style="display: block; padding: 0 10px">        <tr class="pw-weak">
</span></span></pre>
</div>
</div>

</body>
</html>