Make WordPress Core

Changeset 55974


Ignore:
Timestamp:
06/22/2023 12:30:41 AM (3 years ago)
Author:
joedolson
Message:

Administration: Hide password in options/writing.

Hide the password for the "Post via e-mail" settings in writing options. Use the same password hiding mechanisms in use elsewhere in core.

Props mastrup, denis-de-bernardy, ryan, brookedot, wojtek.szkutnik, dd32, sabreuse, sergeybiryukov, costdev, peterwilsoncc, zgrkaralar, clorith, renyot, sabernhardt, boniu91, ironprogrammer, bgoewert.
Fixes #9883.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/user-profile.js

    r53122 r55974  
    5353
    5454                // Focus the password field.
    55                 $( $pass1 ).trigger( 'focus' );
     55                if ( 'mailserver_pass' !== $pass1.prop('id' ) ) {
     56                        $( $pass1 ).trigger( 'focus' );
     57                }
    5658        }
    5759
     
    172174                        $cancelButton;
    173175
    174                 $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap, .reset-pass-submit' );
     176                $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap, .mailserver-pass-wrap, .reset-pass-submit' );
    175177
    176178                // Hide the confirm password field when JavaScript support is enabled.
     
    189191                } );
    190192
    191                 $pass1 = $('#pass1');
     193                $pass1 = $('#pass1, #mailserver_pass');
    192194                if ( $pass1.length ) {
    193195                        bindPass1();
     
    315317
    316318        function showOrHideWeakPasswordCheckbox() {
    317                 var passStrength = $('#pass-strength-result')[0];
    318 
    319                 if ( passStrength.className ) {
    320                         $pass1.addClass( passStrength.className );
    321                         if ( $( passStrength ).is( '.short, .bad' ) ) {
    322                                 if ( ! $weakCheckbox.prop( 'checked' ) ) {
    323                                         $submitButtons.prop( 'disabled', true );
     319                var passStrengthResult = $('#pass-strength-result');
     320
     321                if ( passStrengthResult.length ) {
     322                        var passStrength = passStrengthResult[0];
     323
     324                        if ( passStrength.className ) {
     325                                $pass1.addClass( passStrength.className );
     326                                if ( $( passStrength ).is( '.short, .bad' ) ) {
     327                                        if ( ! $weakCheckbox.prop( 'checked' ) ) {
     328                                                $submitButtons.prop( 'disabled', true );
     329                                        }
     330                                        $weakRow.show();
     331                                } else {
     332                                        if ( $( passStrength ).is( '.empty' ) ) {
     333                                                $submitButtons.prop( 'disabled', true );
     334                                                $weakCheckbox.prop( 'checked', false );
     335                                        } else {
     336                                                $submitButtons.prop( 'disabled', false );
     337                                        }
     338                                        $weakRow.hide();
    324339                                }
    325                                 $weakRow.show();
    326                         } else {
    327                                 if ( $( passStrength ).is( '.empty' ) ) {
    328                                         $submitButtons.prop( 'disabled', true );
    329                                         $weakCheckbox.prop( 'checked', false );
    330                                 } else {
    331                                         $submitButtons.prop( 'disabled', false );
    332                                 }
    333                                 $weakRow.hide();
    334340                        }
    335341                }
  • trunk/src/wp-admin/css/forms.css

    r55689 r55974  
    552552.wp-pwd {
    553553        margin-top: 1em;
     554        position: relative;
     555}
     556
     557.mailserver-pass-wrap .wp-pwd {
     558        display: inline-block;
     559        margin-top: 0;
     560}
     561
     562/* rtl:ignore */
     563#mailserver_pass {
     564        direction: ltr;
     565        padding-right: 2.5rem;
     566}
     567
     568/* rtl:ignore */
     569.mailserver-pass-wrap .button.wp-hide-pw {
     570        background: transparent;
     571        border: 1px solid transparent;
     572        box-shadow: none;
     573        font-size: 14px;
     574        line-height: 2;
     575        width: 2.5rem;
     576        min-width: 40px;
     577        margin: 0;
     578        padding: 0 9px;
     579        position: absolute;
     580        right: 0;
     581        top: 0;
     582}
     583
     584.mailserver-pass-wrap .button.wp-hide-pw:hover {
     585        background: transparent;
     586        border-color: transparent;
     587}
     588
     589.mailserver-pass-wrap .button.wp-hide-pw:focus {
     590        background: transparent;
     591        border-color: #3582c4;
     592        border-radius: 4px;
     593        box-shadow: 0 0 0 1px #3582c4;
     594        /* Only visible in Windows High Contrast mode */
     595        outline: 2px solid transparent;
     596}
     597
     598.mailserver-pass-wrap .button.wp-hide-pw:active {
     599        background: transparent;
     600        box-shadow: none;
     601        transform: none;
    554602}
    555603
  • trunk/src/wp-admin/options-writing.php

    r55904 r55974  
    5454        '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
    5555);
     56
     57wp_enqueue_script( 'user-profile' );
    5658
    5759require_once ABSPATH . 'wp-admin/admin-header.php';
     
    169171<td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option( 'mailserver_login' ); ?>" class="regular-text ltr" /></td>
    170172</tr>
    171 <tr>
    172 <th scope="row"><label for="mailserver_pass"><?php _e( 'Password' ); ?></label></th>
    173 <td>
    174 <input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option( 'mailserver_pass' ); ?>" class="regular-text ltr" />
    175 </td>
     173<tr class="mailserver-pass-wrap">
     174        <th scope="row">
     175                <label for="mailserver_pass">
     176                        <?php _e( 'Password' ); ?>
     177                </label>
     178        </th>
     179        <td>
     180                <input type="hidden" value=" " /><!-- #24364 workaround -->
     181                <span class="wp-pwd">
     182                        <input type="text" name="mailserver_pass" id="mailserver_pass" class="regular-text ltr" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( get_option( 'mailserver_pass' ) ); ?>" />
     183                        <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" data-start-masked="1" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
     184                                <span class="dashicons dashicons-visibility" aria-hidden="true"></span>
     185                        </button>
     186                </span>
     187        </td>
    176188</tr>
    177189<tr>
Note: See TracChangeset for help on using the changeset viewer.