Make WordPress Core

Ticket #42888: 42888.diff

File 42888.diff, 1.6 KB (added by audrasjb, 7 years ago)

42888-show-password-button

  • src/wp-login.php

    diff --git a/src/wp-login.php b/src/wp-login.php
    index 6415b15..ba4a175 100644
    a b switch ( $action ) { 
    10291029        </p>
    10301030        <p>
    10311031                <label for="user_pass"><?php _e( 'Password' ); ?><br />
    1032                 <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
     1032                        <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" />
     1033                        <button type="button" id="wp-show-login-pass" aria-label="<?php esc_attr_e( 'Show/hide password' ) ; ?>">
     1034                                <span id="wp-show-login-pass-icon" class="dashicons dashicons-hidden"></span>
     1035                        </button>
     1036                </label>
    10331037        </p>
    10341038        <?php
    10351039        /**
    switch ( $action ) { 
    11171121        } catch(e){}
    11181122        }());
    11191123        <?php } ?>
     1124        window.onload = function ( ) {
     1125                var show_pass = document.querySelector( '#wp-show-login-pass' );
     1126                show_pass.onclick = function (e) {
     1127                        var ev = e || window.event;
     1128                        var pass = document.querySelector( '#user_pass' );
     1129                        var icon = document.querySelector( '#wp-show-login-pass-icon' );
     1130                        if ( pass.getAttribute( 'type' ) !== 'password' ) {
     1131                                pass.setAttribute( 'type', 'password' );
     1132                                icon.setAttribute( 'class', 'dashicons dashicons-hidden' );
     1133                        } else {
     1134                                pass.setAttribute( 'type', 'text' );
     1135                                icon.setAttribute( 'class', 'dashicons dashicons-visibility' );
     1136                        }
     1137                }
     1138        }
    11201139        </script>
     1140        <style>
     1141        label[for="user_pass"] {
     1142                position: relative;
     1143        }
     1144        #wp-show-login-pass {
     1145                position: absolute;
     1146                top: 2em;
     1147                right: 1em;
     1148                border: 0 none;
     1149                background: none;
     1150        }
     1151        </style>
    11211152
    11221153        <?php
    11231154        login_footer();