WordPress.org

Make WordPress Core

Ticket #42053: 42053.diff

File 42053.diff, 2.5 KB (added by rnaby, 2 years ago)

The patch file for wp_login_form() which provides the patch to make username and password filed required if necessary.

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

     
    403403                'id_submit' => 'wp-submit',
    404404                'remember' => true,
    405405                'value_username' => '',
     406                // Set 'input_username_required' to true will make username input field required
     407                'input_username_required' => false,
     408                // Set 'input_password_required' to true will make password input field required
     409                'input_password_required' => false,
    406410                // Set 'value_remember' to true to default the "Remember me" checkbox to checked.
    407411                'value_remember' => false,
    408412        );
     
    455459         */
    456460        $login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
    457461
     462        // If username input field is required.
     463        $input_username_required = $args['input_username_required'] ? 'required' : '';
     464        // If password input field is required.
     465        $input_password_required = $args['input_password_required'] ? 'required' : '';
     466
    458467        $form = '
    459468                <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
    460469                        ' . $login_form_top . '
    461470                        <p class="login-username">
    462471                                <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
    463                                 <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
     472                                <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" ' . esc_attr( $input_username_required ) . '/>
    464473                        </p>
    465474                        <p class="login-password">
    466475                                <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
    467                                 <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
     476                                <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" ' . esc_attr( $input_password_required ) . '/>
    468477                        </p>
    469478                        ' . $login_form_middle . '
    470479                        ' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '