| @@ -1,18 +1,33 @@ | ||
| 1 | 1 | <?php |
| 2 | -$errors = new \WP_Error(); | |
| 2 | +/** | |
| 3 | + * This template is used to display reset password form. | |
| 4 | + * | |
| 5 | + * @package WP_Defender | |
| 6 | + */ | |
| 3 | 7 | |
| 4 | -if ( isset( $_POST['pass1'], $_POST['pass2'] ) && $_POST['pass1'] !== $_POST['pass2'] ) { | |
| 5 | - $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.', 'wpdef' ) ); | |
| 8 | +$error_object = new WP_Error(); | |
| 9 | + | |
| 10 | +$post_data = defender_get_data_from_request( null, 'p' ); | |
| 11 | +if ( isset( $post_data['pass1'], $post_data['pass2'] ) && $post_data['pass1'] !== $post_data['pass2'] ) { | |
| 12 | + $error_object->add( 'password_reset_mismatch', esc_html__( 'The passwords do not match.', 'defender-security' ) ); | |
| 6 | 13 | } |
| 7 | -if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) { | |
| 8 | - reset_password( $user, $_POST['pass1'] ); | |
| 9 | - login_header( __( 'Password Reset', 'wpdef' ), '<p class="message reset-pass">' . __( 'Your password has been reset.', 'wpdef' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in', 'wpdef' ) . '</a></p>' ); | |
| 14 | +if ( ( ! $error_object->has_errors() ) && isset( $post_data['pass1'] ) && is_string( $post_data['pass1'] ) && '' !== trim( $post_data['pass1'] ) ) { | |
| 15 | + reset_password( $user, $post_data['pass1'] ); | |
| 16 | + login_header( | |
| 17 | + esc_html__( 'Password Reset', 'defender-security' ), | |
| 18 | + sprintf( | |
| 19 | + '<p class="message reset-pass">%1$s <a href="%2$s">%3$s</a></p>', | |
| 20 | + esc_html__( 'Your password has been reset.', 'defender-security' ), | |
| 21 | + esc_url( wp_login_url() ), | |
| 22 | + esc_html__( 'Log in', 'defender-security' ) | |
| 23 | + ) | |
| 24 | + ); | |
| 10 | 25 | login_footer(); |
| 11 | 26 | exit; |
| 12 | 27 | } |
| 13 | 28 | |
| 14 | -do_action( 'validate_password_reset', $errors, $user ); | |
| 29 | +do_action( 'validate_password_reset', $error_object, $user ); | |
| 15 | 30 | $login_link_separator = apply_filters( 'login_link_separator', ' | ' ); |
| 16 | 31 | |
| 17 | 32 | wp_enqueue_script( 'utils' ); |
| 18 | 33 | wp_enqueue_script( 'user-profile' ); |
| @@ -17,56 +32,72 @@ | ||
| 17 | 32 | wp_enqueue_script( 'utils' ); |
| 18 | 33 | wp_enqueue_script( 'user-profile' ); |
| 19 | 34 | |
| 20 | 35 | do_action( 'wd_password_change_form', $user ); |
| 21 | -login_header( __( 'Reset Password', 'wpdef' ), '<p class="message reset-pass">' . __( 'Enter your new password below or generate one.', 'wpdef' ) . '</p>', $errors ); | |
| 36 | +login_header( | |
| 37 | + esc_html__( 'Reset Password', 'defender-security' ), | |
| 38 | + '<p class="message reset-pass">' . esc_html__( 'Enter your new password below or generate one.', 'defender-security' ) . '</p>', | |
| 39 | + $error_object | |
| 40 | +); | |
| 22 | 41 | ?> |
| 23 | -<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> | |
| 24 | - <input type="hidden" id="user_login" value="<?php echo esc_attr( $user->user_login ); ?>" autocomplete="off" /> | |
| 25 | - <div class="user-pass1-wrap"> | |
| 26 | - <p><label for="pass1"><?php _e( 'New Password', 'wpdef' ); ?></label></p> | |
| 27 | - </div> | |
| 42 | + <form name="resetpassform" id="resetpassform" | |
| 43 | + action="<?php echo esc_url_raw( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" | |
| 44 | + method="post" autocomplete="off"> | |
| 45 | + <input type="hidden" id="user_login" value="<?php echo esc_attr( $user->user_login ); ?>" autocomplete="off"/> | |
| 46 | + <div class="user-pass1-wrap"> | |
| 47 | + <p><label for="pass1"><?php esc_attr_e( 'New Password', 'defender-security' ); ?></label></p> | |
| 48 | + </div> | |
| 28 | 49 | |
| 29 | - <div class="wp-pwd"> | |
| 30 | - <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="off" aria-describedby="pass-strength-result" /> | |
| 50 | + <div class="wp-pwd"> | |
| 51 | + <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" | |
| 52 | + name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="off" | |
| 53 | + aria-describedby="pass-strength-result"/> | |
| 31 | 54 | |
| 32 | - <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> | |
| 33 | - <span class="dashicons dashicons-hidden" aria-hidden="true"></span> | |
| 34 | - </button> | |
| 35 | - <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator', 'wpdef' ); ?></div> | |
| 36 | - </div> | |
| 37 | - <div class="pw-weak"> | |
| 38 | - <input type="checkbox" name="pw_weak" id="pw-weak" class="pw-checkbox" /> | |
| 39 | - <label for="pw-weak"><?php _e( 'Confirm use of weak password', 'wpdef' ); ?></label> | |
| 40 | - </div> | |
| 55 | + <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" | |
| 56 | + aria-label="<?php esc_attr_e( 'Hide password', 'defender-security' ); ?>"> | |
| 57 | + <span class="dashicons dashicons-hidden" aria-hidden="true"></span> | |
| 58 | + </button> | |
| 59 | + <div id="pass-strength-result" class="hide-if-no-js" | |
| 60 | + aria-live="polite"><?php esc_attr_e( 'Strength indicator', 'defender-security' ); ?></div> | |
| 61 | + </div> | |
| 62 | + <div class="pw-weak"> | |
| 63 | + <input type="checkbox" name="pw_weak" id="pw-weak" class="pw-checkbox"/> | |
| 64 | + <label for="pw-weak"><?php esc_attr_e( 'Confirm use of weak password', 'defender-security' ); ?></label> | |
| 65 | + </div> | |
| 41 | 66 | |
| 42 | - <p class="user-pass2-wrap"> | |
| 43 | - <label for="pass2"><?php _e( 'Confirm new password', 'wpdef' ); ?></label><br/> | |
| 44 | - <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off"/> | |
| 45 | - </p> | |
| 67 | + <p class="user-pass2-wrap"> | |
| 68 | + <label for="pass2"><?php esc_attr_e( 'Confirm new password', 'defender-security' ); ?></label><br/> | |
| 69 | + <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off"/> | |
| 70 | + </p> | |
| 46 | 71 | |
| 47 | - <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> | |
| 48 | - <br class="clear"/> | |
| 49 | - <?php | |
| 50 | - do_action( 'resetpass_form', $user ); | |
| 51 | - ?> | |
| 72 | + <p class="description indicator-hint"><?php echo esc_html( wp_get_password_hint() ); ?></p> | |
| 73 | + <br class="clear"/> | |
| 74 | + <?php | |
| 75 | + do_action( 'resetpass_form', $user ); | |
| 76 | + ?> | |
| 52 | 77 | |
| 53 | - <p class="submit reset-pass-submit"> | |
| 54 | - <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="true"><?php _e( 'Generate Password', 'wpdef' ); ?></button> | |
| 55 | - <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Save Password', 'wpdef' ); ?>" /> | |
| 56 | - </p> | |
| 57 | -</form> | |
| 78 | + <p class="submit reset-pass-submit"> | |
| 79 | + <button type="button" class="button wp-generate-pw hide-if-no-js" | |
| 80 | + aria-expanded="true"><?php esc_attr_e( 'Generate Password', 'defender-security' ); ?></button> | |
| 81 | + <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" | |
| 82 | + value="<?php esc_attr_e( 'Save Password', 'defender-security' ); ?>"/> | |
| 83 | + </p> | |
| 84 | + </form> | |
| 58 | 85 | <p id="nav"> |
| 59 | - <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in', 'wpdef' ); ?></a> | |
| 86 | + <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php esc_attr_e( 'Log in', 'defender-security' ); ?></a> | |
| 60 | 87 | <?php |
| 61 | 88 | |
| 62 | 89 | if ( get_option( 'users_can_register' ) ) { |
| 63 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register', 'wpdef' ) ); | |
| 90 | + $registration_url = sprintf( | |
| 91 | + '<a href="%s">%s</a>', | |
| 92 | + esc_url( wp_registration_url() ), | |
| 93 | + esc_html__( 'Register', 'defender-security' ) | |
| 94 | + ); | |
| 64 | 95 | |
| 65 | 96 | echo esc_html( $login_link_separator ); |
| 66 | 97 | |
| 67 | 98 | /** This filter is documented in wp-includes/general-template.php */ |
| 68 | - echo apply_filters( 'register', $registration_url ); | |
| 99 | + echo esc_url_raw( apply_filters( 'register', $registration_url ) ); | |
| 69 | 100 | } |
| 70 | 101 | |
| 71 | 102 | ?> |
| 72 | 103 | </p> |