WordPress.org

Make WordPress Core

Ticket #32510: html5-inputs-login.32510.diff

File html5-inputs-login.32510.diff, 7.4 KB (added by sanchothefat, 4 years ago)

Adds required attributes to the login / register / forgot pass form fields as well as autofocus on first form field in each case

  • src/wp-includes/general-template.php

    diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
    index f554e1f..4adb6bb 100644
    function wp_heartbeat_settings( $settings ) { 
    34753475
    34763476        return $settings;
    34773477}
     3478
     3479
  • src/wp-login.php

    diff --git src/wp-login.php src/wp-login.php
    index ea3afc6..e8140d7 100644
    case 'retrievepassword' : 
    527527<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
    528528        <p>
    529529                <label for="user_login" ><?php _e('Username or Email:') ?><br />
    530                 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label>
     530                <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" required="required" autofocus="autofocus" size="20" /></label>
    531531        </p>
    532532        <?php
    533533        /**
    case 'rp' : 
    625625
    626626                <div class="wp-pwd">
    627627                        <span class="password-input-wrapper">
    628                                 <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" />
     628                                <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input" required="required" size="20" value="" autocomplete="off" autofocus="autofocus" aria-describedby="pass-strength-result" />
    629629                        </span>
    630630                        <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div>
    631631                </div>
    case 'rp' : 
    633633
    634634        <p class="user-pass2-wrap">
    635635                <label for="pass2"><?php _e( 'Confirm new password' ) ?></label><br />
    636                 <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
     636                <input type="password" name="pass2" id="pass2" class="input" required="required" size="20" value="" autocomplete="off" />
    637637        </p>
    638638
    639639        <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
    case 'register' : 
    712712        login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
    713713?>
    714714
    715 <form name="registerform" id="registerform" action="<?php echo esc_url( wp_registration_url() ); ?>" method="post" novalidate="novalidate">
     715<form name="registerform" id="registerform" action="<?php echo esc_url( wp_registration_url() ); ?>" method="post">
    716716        <p>
    717717                <label for="user_login"><?php _e('Username') ?><br />
    718                 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label>
     718                <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" required="required" autofocus="autofocus" size="20" /></label>
    719719        </p>
    720720        <p>
    721721                <label for="user_email"><?php _e('Email') ?><br />
    722                 <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
     722                <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" required="required" size="25" /></label>
    723723        </p>
    724724        <?php
    725725        /**
    default: 
    881881<form name="loginform" id="loginform" action="<?php echo esc_url( wp_login_url() ); ?>" method="post">
    882882        <p>
    883883                <label for="user_login"><?php _e('Username') ?><br />
    884                 <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label>
     884                <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" autofocus="autofocus" required="required" size="20" /></label>
    885885        </p>
    886886        <p>
    887887                <label for="user_pass"><?php _e('Password') ?><br />
    888                 <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
     888                <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" required="required" size="20" /></label>
    889889        </p>
    890890        <?php
    891891        /**
  • src/wp-signup.php

    diff --git src/wp-signup.php src/wp-signup.php
    index 6852bb8..f983e35 100644
    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 
    108108        <?php }
    109109
    110110        if ( !is_subdomain_install() )
    111                 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
     111                echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" required="required" autofocus="autofocus" maxlength="60" /><br />';
    112112        else
    113                 echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
     113                echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" required="required" autofocus="autofocus" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
    114114
    115115        if ( !is_user_logged_in() ) {
    116116                if ( !is_subdomain_install() )
    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 
    126126        <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
    127127                <p class="error"><?php echo $errmsg ?></p>
    128128        <?php }
    129         echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
     129        echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" required="required" />';
    130130        ?>
    131131
    132132        <?php
    function show_user_form($user_name = '', $user_email = '', $errors = '') { 
    218218        if ( $errmsg = $errors->get_error_message('user_name') ) {
    219219                echo '<p class="error">'.$errmsg.'</p>';
    220220        }
    221         echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />';
     221        echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" required="required" autofocus="autofocus" maxlength="60" /><br />';
    222222        _e( '(Must be at least 4 characters, letters and numbers only.)' );
    223223        ?>
    224224
    function show_user_form($user_name = '', $user_email = '', $errors = '') { 
    226226        <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
    227227                <p class="error"><?php echo $errmsg ?></p>
    228228        <?php } ?>
    229         <input name="user_email" type="email" id="user_email" value="<?php  echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?>
     229        <input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" required="required" maxlength="200" /><br /><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)' ); ?>
    230230        <?php
    231231        if ( $errmsg = $errors->get_error_message('generic') ) {
    232232                echo '<p class="error">' . $errmsg . '</p>';