Making WordPress.org


Ignore:
Timestamp:
12/16/2021 04:11:41 AM (5 years ago)
Author:
dd32
Message:

Login: Add a 'show password' / 'hide password' button to password inputs, for consistency with wp-login.php.

Fixes #5850.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/login.php

    r11379 r11380  
    2929        <p class="login-password">
    3030                <label for="user_pass"><?php _e( 'Password', 'wporg-login' ); ?></label>
    31                 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" />
     31                <span class="wp-pwd" style="display:block;">
     32                        <input type="password" name="pwd" id="user_pass" class="input password-input" value="" size="20" />
     33                        <button type="button" id="wp-hide-pw" class="button button-secondary wp-hide-pw hide-if-no-js" aria-label="<?php esc_attr_e( 'Show password', 'wporg-login' ); ?>">
     34                                <span class="dashicons dashicons-visibility" aria-hidden="true"></span>
     35                        </button>
     36                </span>
    3237        </p>
    3338        <p class="login-remember"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" /> <?php _e( 'Remember Me', 'wporg-login' ); ?></label></p>
     
    5257                d.focus();
    5358                d.select();
     59
     60                var h = document.getElementById( 'wp-hide-pw' );
     61                h.onclick = function() {
     62                        var p = document.getElementById( 'user_pass' );
     63                        if ( p.type === 'password' ) {
     64                                p.type = 'text';
     65                                h.ariaLabel = <?php echo json_encode( __( 'Hide password', 'wporg-login' ) ); ?>;
     66                                h.children[0].className = 'dashicons dashicons-hidden';
     67                        } else {
     68                                p.type = 'password';
     69                                h.ariaLabel = <?php echo json_encode( __( 'Show password', 'wporg-login' ) ); ?>;
     70                                h.children[0].className = 'dashicons dashicons-visibility';
     71                        }
     72                }
    5473        } catch( e ){}
    5574}, 200 );
Note: See TracChangeset for help on using the changeset viewer.