456 * |
486 * |
457 * @since 2.8.0 |
487 * @since 2.8.0 |
458 */ |
488 */ |
459 do_action( "login_form_{$action}" ); |
489 do_action( "login_form_{$action}" ); |
460 |
490 |
461 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); |
491 $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] ); |
462 $interim_login = isset($_REQUEST['interim-login']); |
492 $interim_login = isset( $_REQUEST['interim-login'] ); |
463 |
493 |
464 /** |
494 /** |
465 * Filters the separator used between login form navigation links. |
495 * Filters the separator used between login form navigation links. |
466 * |
496 * |
467 * @since 4.9.0 |
497 * @since 4.9.0 |
468 * |
498 * |
469 * @param string $login_link_separator The separator used between login form navigation links. |
499 * @param string $login_link_separator The separator used between login form navigation links. |
470 */ |
500 */ |
471 $login_link_separator = apply_filters( 'login_link_separator', ' | ' ); |
501 $login_link_separator = apply_filters( 'login_link_separator', ' | ' ); |
472 |
502 |
473 switch ($action) { |
503 switch ( $action ) { |
474 |
504 |
475 case 'postpass' : |
505 case 'postpass': |
476 if ( ! array_key_exists( 'post_password', $_POST ) ) { |
506 if ( ! array_key_exists( 'post_password', $_POST ) ) { |
|
507 wp_safe_redirect( wp_get_referer() ); |
|
508 exit(); |
|
509 } |
|
510 |
|
511 require_once ABSPATH . WPINC . '/class-phpass.php'; |
|
512 $hasher = new PasswordHash( 8, true ); |
|
513 |
|
514 /** |
|
515 * Filters the life span of the post password cookie. |
|
516 * |
|
517 * By default, the cookie expires 10 days from creation. To turn this |
|
518 * into a session cookie, return 0. |
|
519 * |
|
520 * @since 3.7.0 |
|
521 * |
|
522 * @param int $expires The expiry time, as passed to setcookie(). |
|
523 */ |
|
524 $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); |
|
525 $referer = wp_get_referer(); |
|
526 if ( $referer ) { |
|
527 $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) ); |
|
528 } else { |
|
529 $secure = false; |
|
530 } |
|
531 setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
532 |
477 wp_safe_redirect( wp_get_referer() ); |
533 wp_safe_redirect( wp_get_referer() ); |
478 exit(); |
534 exit(); |
479 } |
535 |
480 |
536 case 'logout': |
481 require_once ABSPATH . WPINC . '/class-phpass.php'; |
537 check_admin_referer( 'log-out' ); |
482 $hasher = new PasswordHash( 8, true ); |
538 |
483 |
539 $user = wp_get_current_user(); |
484 /** |
540 |
485 * Filters the life span of the post password cookie. |
541 wp_logout(); |
486 * |
542 |
487 * By default, the cookie expires 10 days from creation. To turn this |
543 if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
488 * into a session cookie, return 0. |
544 $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to']; |
489 * |
545 } else { |
490 * @since 3.7.0 |
546 $redirect_to = 'wp-login.php?loggedout=true'; |
491 * |
547 $requested_redirect_to = ''; |
492 * @param int $expires The expiry time, as passed to setcookie(). |
548 } |
493 */ |
549 |
494 $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); |
550 /** |
495 $referer = wp_get_referer(); |
551 * Filters the log out redirect URL. |
496 if ( $referer ) { |
552 * |
497 $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) ); |
553 * @since 4.2.0 |
498 } else { |
554 * |
499 $secure = false; |
555 * @param string $redirect_to The redirect destination URL. |
500 } |
556 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
501 setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
557 * @param WP_User $user The WP_User object for the user that's logging out. |
502 |
558 */ |
503 if ( $switched_locale ) { |
559 $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); |
504 restore_previous_locale(); |
560 wp_safe_redirect( $redirect_to ); |
505 } |
561 exit(); |
506 |
562 |
507 wp_safe_redirect( wp_get_referer() ); |
563 case 'lostpassword': |
508 exit(); |
564 case 'retrievepassword': |
509 |
565 if ( $http_post ) { |
510 case 'logout' : |
566 $errors = retrieve_password(); |
511 check_admin_referer('log-out'); |
567 if ( ! is_wp_error( $errors ) ) { |
512 |
568 $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
513 $user = wp_get_current_user(); |
569 wp_safe_redirect( $redirect_to ); |
514 |
570 exit(); |
515 wp_logout(); |
571 } |
516 |
572 } |
517 if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
573 |
518 $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to']; |
574 if ( isset( $_GET['error'] ) ) { |
519 } else { |
575 if ( 'invalidkey' == $_GET['error'] ) { |
520 $redirect_to = 'wp-login.php?loggedout=true'; |
576 $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); |
521 $requested_redirect_to = ''; |
577 } elseif ( 'expiredkey' == $_GET['error'] ) { |
522 } |
578 $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); |
523 |
579 } |
524 if ( $switched_locale ) { |
580 } |
525 restore_previous_locale(); |
581 |
526 } |
582 $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
527 |
583 /** |
528 /** |
584 * Filters the URL redirected to after submitting the lostpassword/retrievepassword form. |
529 * Filters the log out redirect URL. |
585 * |
530 * |
586 * @since 3.0.0 |
531 * @since 4.2.0 |
587 * |
532 * |
588 * @param string $lostpassword_redirect The redirect destination URL. |
533 * @param string $redirect_to The redirect destination URL. |
589 */ |
534 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
590 $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); |
535 * @param WP_User $user The WP_User object for the user that's logging out. |
591 |
536 */ |
592 /** |
537 $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); |
593 * Fires before the lost password form. |
538 wp_safe_redirect( $redirect_to ); |
594 * |
539 exit(); |
595 * @since 1.5.1 |
540 |
596 * @since 5.1.0 Added the `$errors` parameter. |
541 case 'lostpassword' : |
597 * |
542 case 'retrievepassword' : |
598 * @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid |
543 |
599 * credentials. Note that the error object may not contain any errors. |
544 if ( $http_post ) { |
600 */ |
545 $errors = retrieve_password(); |
601 do_action( 'lost_password', $errors ); |
546 if ( !is_wp_error($errors) ) { |
602 |
547 $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
603 login_header( __( 'Lost Password' ), '<p class="message">' . __( 'Please enter your username or email address. You will receive a link to create a new password via email.' ) . '</p>', $errors ); |
548 wp_safe_redirect( $redirect_to ); |
604 |
549 exit(); |
605 $user_login = ''; |
550 } |
606 |
551 } |
607 if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { |
552 |
608 $user_login = wp_unslash( $_POST['user_login'] ); |
553 if ( isset( $_GET['error'] ) ) { |
609 } |
554 if ( 'invalidkey' == $_GET['error'] ) { |
610 |
555 $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); |
611 ?> |
556 } elseif ( 'expiredkey' == $_GET['error'] ) { |
612 |
557 $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); |
613 <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> |
558 } |
|
559 } |
|
560 |
|
561 $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
562 /** |
|
563 * Filters the URL redirected to after submitting the lostpassword/retrievepassword form. |
|
564 * |
|
565 * @since 3.0.0 |
|
566 * |
|
567 * @param string $lostpassword_redirect The redirect destination URL. |
|
568 */ |
|
569 $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); |
|
570 |
|
571 /** |
|
572 * Fires before the lost password form. |
|
573 * |
|
574 * @since 1.5.1 |
|
575 */ |
|
576 do_action( 'lost_password' ); |
|
577 |
|
578 login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors); |
|
579 |
|
580 $user_login = ''; |
|
581 |
|
582 if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { |
|
583 $user_login = wp_unslash( $_POST['user_login'] ); |
|
584 } |
|
585 |
|
586 ?> |
|
587 |
|
588 <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> |
|
589 <p> |
614 <p> |
590 <label for="user_login" ><?php _e( 'Username or Email Address' ); ?><br /> |
615 <label for="user_login" ><?php _e( 'Username or Email Address' ); ?><br /> |
591 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> |
616 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /></label> |
592 </p> |
617 </p> |
593 <?php |
618 <?php |
594 /** |
619 /** |
595 * Fires inside the lostpassword form tags, before the hidden fields. |
620 * Fires inside the lostpassword form tags, before the hidden fields. |
596 * |
621 * |
597 * @since 2.1.0 |
622 * @since 2.1.0 |
598 */ |
623 */ |
599 do_action( 'lostpassword_form' ); ?> |
624 do_action( 'lostpassword_form' ); |
600 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
625 ?> |
601 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Get New Password'); ?>" /></p> |
626 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
602 </form> |
627 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Get New Password' ); ?>" /></p> |
603 |
628 </form> |
604 <p id="nav"> |
629 |
605 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> |
630 <p id="nav"> |
606 <?php |
631 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
607 if ( get_option( 'users_can_register' ) ) : |
632 <?php |
608 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
633 if ( get_option( 'users_can_register' ) ) : |
609 |
634 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
610 echo esc_html( $login_link_separator ); |
635 |
611 |
636 echo esc_html( $login_link_separator ); |
612 /** This filter is documented in wp-includes/general-template.php */ |
637 |
613 echo apply_filters( 'register', $registration_url ); |
638 /** This filter is documented in wp-includes/general-template.php */ |
614 endif; |
639 echo apply_filters( 'register', $registration_url ); |
615 ?> |
640 endif; |
616 </p> |
641 ?> |
617 |
642 </p> |
618 <?php |
643 |
619 login_footer('user_login'); |
644 <?php |
620 |
645 login_footer( 'user_login' ); |
621 if ( $switched_locale ) { |
646 |
622 restore_previous_locale(); |
647 break; |
623 } |
648 |
624 |
649 case 'resetpass': |
625 break; |
650 case 'rp': |
626 |
651 list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
627 case 'resetpass' : |
652 $rp_cookie = 'wp-resetpass-' . COOKIEHASH; |
628 case 'rp' : |
653 if ( isset( $_GET['key'] ) ) { |
629 list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
654 $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); |
630 $rp_cookie = 'wp-resetpass-' . COOKIEHASH; |
655 setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
631 if ( isset( $_GET['key'] ) ) { |
656 wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); |
632 $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); |
657 exit; |
633 setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
658 } |
634 wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); |
659 |
635 exit; |
660 if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { |
636 } |
661 list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); |
637 |
662 $user = check_password_reset_key( $rp_key, $rp_login ); |
638 if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { |
663 if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { |
639 list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); |
664 $user = false; |
640 $user = check_password_reset_key( $rp_key, $rp_login ); |
665 } |
641 if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { |
666 } else { |
642 $user = false; |
667 $user = false; |
643 } |
668 } |
644 } else { |
669 |
645 $user = false; |
670 if ( ! $user || is_wp_error( $user ) ) { |
646 } |
671 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
647 |
672 if ( $user && $user->get_error_code() === 'expired_key' ) { |
648 if ( ! $user || is_wp_error( $user ) ) { |
673 wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
649 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
674 } else { |
650 if ( $user && $user->get_error_code() === 'expired_key' ) |
675 wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
651 wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
676 } |
652 else |
677 exit; |
653 wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
678 } |
654 exit; |
679 |
655 } |
680 $errors = new WP_Error(); |
656 |
681 |
657 $errors = new WP_Error(); |
682 if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] ) { |
658 |
683 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
659 if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) |
684 } |
660 $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
685 |
661 |
686 /** |
662 /** |
687 * Fires before the password reset procedure is validated. |
663 * Fires before the password reset procedure is validated. |
688 * |
664 * |
689 * @since 3.5.0 |
665 * @since 3.5.0 |
690 * |
666 * |
691 * @param object $errors WP Error object. |
667 * @param object $errors WP Error object. |
692 * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. |
668 * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. |
693 */ |
669 */ |
694 do_action( 'validate_password_reset', $errors, $user ); |
670 do_action( 'validate_password_reset', $errors, $user ); |
695 |
671 |
696 if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) { |
672 if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { |
697 reset_password( $user, $_POST['pass1'] ); |
673 reset_password($user, $_POST['pass1']); |
698 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
674 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
699 login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); |
675 login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); |
700 login_footer(); |
676 login_footer(); |
701 exit; |
677 exit; |
702 } |
678 } |
703 |
679 |
704 wp_enqueue_script( 'utils' ); |
680 wp_enqueue_script('utils'); |
705 wp_enqueue_script( 'user-profile' ); |
681 wp_enqueue_script('user-profile'); |
706 |
682 |
707 login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below.' ) . '</p>', $errors ); |
683 login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors ); |
708 |
684 |
709 ?> |
685 ?> |
710 <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
686 <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
|
687 <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> |
711 <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> |
688 |
712 |
689 <div class="user-pass1-wrap"> |
713 <div class="user-pass1-wrap"> |
690 <p> |
714 <p> |
691 <label for="pass1"><?php _e( 'New password' ) ?></label> |
715 <label for="pass1"><?php _e( 'New password' ); ?></label> |
692 </p> |
716 </p> |
693 |
717 |
694 <div class="wp-pwd"> |
718 <div class="wp-pwd"> |
695 <div class="password-input-wrapper"> |
719 <div class="password-input-wrapper"> |
696 <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" /> |
720 <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" /> |
697 <span class="button button-secondary wp-hide-pw hide-if-no-js"> |
721 <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js"> |
698 <span class="dashicons dashicons-hidden"></span> |
722 <span class="dashicons dashicons-hidden" aria-hidden="true"></span> |
699 </span> |
723 </button> |
700 </div> |
724 </div> |
701 <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> |
725 <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> |
702 </div> |
726 </div> |
703 <div class="pw-weak"> |
727 <div class="pw-weak"> |
704 <label> |
728 <label> |
707 </label> |
731 </label> |
708 </div> |
732 </div> |
709 </div> |
733 </div> |
710 |
734 |
711 <p class="user-pass2-wrap"> |
735 <p class="user-pass2-wrap"> |
712 <label for="pass2"><?php _e( 'Confirm new password' ) ?></label><br /> |
736 <label for="pass2"><?php _e( 'Confirm new password' ); ?></label><br /> |
713 <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /> |
737 <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /> |
714 </p> |
738 </p> |
715 |
739 |
716 <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> |
740 <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> |
717 <br class="clear" /> |
741 <br class="clear" /> |
718 |
742 |
719 <?php |
743 <?php |
720 /** |
744 /** |
721 * Fires following the 'Strength indicator' meter in the user password reset form. |
745 * Fires following the 'Strength indicator' meter in the user password reset form. |
722 * |
746 * |
723 * @since 3.9.0 |
747 * @since 3.9.0 |
724 * |
748 * |
725 * @param WP_User $user User object of the user whose password is being reset. |
749 * @param WP_User $user User object of the user whose password is being reset. |
726 */ |
750 */ |
727 do_action( 'resetpass_form', $user ); |
751 do_action( 'resetpass_form', $user ); |
728 ?> |
752 ?> |
729 <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
753 <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
730 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p> |
754 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" /></p> |
731 </form> |
755 </form> |
732 |
756 |
733 <p id="nav"> |
757 <p id="nav"> |
734 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
758 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
735 <?php |
759 <?php |
736 if ( get_option( 'users_can_register' ) ) : |
760 if ( get_option( 'users_can_register' ) ) : |
737 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
761 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
738 |
762 |
739 echo esc_html( $login_link_separator ); |
763 echo esc_html( $login_link_separator ); |
740 |
764 |
741 /** This filter is documented in wp-includes/general-template.php */ |
765 /** This filter is documented in wp-includes/general-template.php */ |
742 echo apply_filters( 'register', $registration_url ); |
766 echo apply_filters( 'register', $registration_url ); |
743 endif; |
767 endif; |
744 ?> |
768 ?> |
745 </p> |
769 </p> |
746 |
770 |
747 <?php |
771 <?php |
748 login_footer('user_pass'); |
772 login_footer( 'user_pass' ); |
749 |
773 |
750 if ( $switched_locale ) { |
774 break; |
751 restore_previous_locale(); |
775 |
752 } |
776 case 'register': |
753 |
777 if ( is_multisite() ) { |
754 break; |
778 /** |
755 |
779 * Filters the Multisite sign up URL. |
756 case 'register' : |
780 * |
757 if ( is_multisite() ) { |
781 * @since 3.0.0 |
758 /** |
782 * |
759 * Filters the Multisite sign up URL. |
783 * @param string $sign_up_url The sign up URL. |
|
784 */ |
|
785 wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); |
|
786 exit; |
|
787 } |
|
788 |
|
789 if ( ! get_option( 'users_can_register' ) ) { |
|
790 wp_redirect( site_url( 'wp-login.php?registration=disabled' ) ); |
|
791 exit(); |
|
792 } |
|
793 |
|
794 $user_login = ''; |
|
795 $user_email = ''; |
|
796 |
|
797 if ( $http_post ) { |
|
798 if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { |
|
799 $user_login = $_POST['user_login']; |
|
800 } |
|
801 |
|
802 if ( isset( $_POST['user_email'] ) && is_string( $_POST['user_email'] ) ) { |
|
803 $user_email = wp_unslash( $_POST['user_email'] ); |
|
804 } |
|
805 |
|
806 $errors = register_new_user( $user_login, $user_email ); |
|
807 if ( ! is_wp_error( $errors ) ) { |
|
808 $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
809 wp_safe_redirect( $redirect_to ); |
|
810 exit(); |
|
811 } |
|
812 } |
|
813 |
|
814 $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
815 /** |
|
816 * Filters the registration redirect URL. |
760 * |
817 * |
761 * @since 3.0.0 |
818 * @since 3.0.0 |
762 * |
819 * |
763 * @param string $sign_up_url The sign up URL. |
820 * @param string $registration_redirect The redirect destination URL. |
764 */ |
821 */ |
765 wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); |
822 $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); |
766 exit; |
823 login_header( __( 'Registration Form' ), '<p class="message register">' . __( 'Register For This Site' ) . '</p>', $errors ); |
767 } |
824 ?> |
768 |
825 <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate"> |
769 if ( !get_option('users_can_register') ) { |
|
770 wp_redirect( site_url('wp-login.php?registration=disabled') ); |
|
771 exit(); |
|
772 } |
|
773 |
|
774 $user_login = ''; |
|
775 $user_email = ''; |
|
776 |
|
777 if ( $http_post ) { |
|
778 if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { |
|
779 $user_login = $_POST['user_login']; |
|
780 } |
|
781 |
|
782 if ( isset( $_POST['user_email'] ) && is_string( $_POST['user_email'] ) ) { |
|
783 $user_email = wp_unslash( $_POST['user_email'] ); |
|
784 } |
|
785 |
|
786 $errors = register_new_user($user_login, $user_email); |
|
787 if ( !is_wp_error($errors) ) { |
|
788 $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
789 wp_safe_redirect( $redirect_to ); |
|
790 exit(); |
|
791 } |
|
792 } |
|
793 |
|
794 $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
795 /** |
|
796 * Filters the registration redirect URL. |
|
797 * |
|
798 * @since 3.0.0 |
|
799 * |
|
800 * @param string $registration_redirect The redirect destination URL. |
|
801 */ |
|
802 $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); |
|
803 login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); |
|
804 ?> |
|
805 <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate"> |
|
806 <p> |
826 <p> |
807 <label for="user_login"><?php _e('Username') ?><br /> |
827 <label for="user_login"><?php _e( 'Username' ); ?><br /> |
808 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label> |
828 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( wp_unslash( $user_login ) ); ?>" size="20" autocapitalize="off" /></label> |
809 </p> |
829 </p> |
810 <p> |
830 <p> |
811 <label for="user_email"><?php _e('Email') ?><br /> |
831 <label for="user_email"><?php _e( 'Email' ); ?><br /> |
812 <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label> |
832 <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label> |
813 </p> |
833 </p> |
814 <?php |
834 <?php |
815 /** |
835 /** |
816 * Fires following the 'Email' field in the user registration form. |
836 * Fires following the 'Email' field in the user registration form. |
817 * |
837 * |
818 * @since 2.1.0 |
838 * @since 2.1.0 |
819 */ |
839 */ |
820 do_action( 'register_form' ); |
840 do_action( 'register_form' ); |
821 ?> |
841 ?> |
822 <p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p> |
842 <p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p> |
823 <br class="clear" /> |
843 <br class="clear" /> |
824 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
844 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
825 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Register'); ?>" /></p> |
845 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Register' ); ?>" /></p> |
826 </form> |
846 </form> |
827 |
847 |
828 <p id="nav"> |
848 <p id="nav"> |
829 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
849 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
830 <?php echo esc_html( $login_link_separator ); ?> |
850 <?php echo esc_html( $login_link_separator ); ?> |
831 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
851 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
832 </p> |
852 </p> |
833 |
853 |
834 <?php |
854 <?php |
835 login_footer('user_login'); |
855 login_footer( 'user_login' ); |
836 |
856 |
837 if ( $switched_locale ) { |
857 break; |
838 restore_previous_locale(); |
858 |
839 } |
859 case 'confirmaction': |
840 |
860 if ( ! isset( $_GET['request_id'] ) ) { |
841 break; |
861 wp_die( __( 'Missing request ID.' ) ); |
842 |
862 } |
843 case 'confirmaction' : |
863 |
844 if ( ! isset( $_GET['request_id'] ) ) { |
864 if ( ! isset( $_GET['confirm_key'] ) ) { |
845 wp_die( __( 'Invalid request.' ) ); |
865 wp_die( __( 'Missing confirm key.' ) ); |
846 } |
866 } |
847 |
867 |
848 $request_id = (int) $_GET['request_id']; |
868 $request_id = (int) $_GET['request_id']; |
849 |
869 $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); |
850 if ( isset( $_GET['confirm_key'] ) ) { |
870 $result = wp_validate_user_request_key( $request_id, $key ); |
851 $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); |
871 |
852 $result = wp_validate_user_request_key( $request_id, $key ); |
872 if ( is_wp_error( $result ) ) { |
853 } else { |
873 wp_die( $result ); |
854 $result = new WP_Error( 'invalid_key', __( 'Invalid key' ) ); |
874 } |
855 } |
875 |
856 |
876 /** |
857 if ( is_wp_error( $result ) ) { |
877 * Fires an action hook when the account action has been confirmed by the user. |
858 wp_die( $result ); |
878 * |
859 } |
879 * Using this you can assume the user has agreed to perform the action by |
860 |
880 * clicking on the link in the confirmation email. |
861 /** |
881 * |
862 * Fires an action hook when the account action has been confirmed by the user. |
882 * After firing this action hook the page will redirect to wp-login a callback |
863 * |
883 * redirects or exits first. |
864 * Using this you can assume the user has agreed to perform the action by |
884 * |
865 * clicking on the link in the confirmation email. |
885 * @since 4.9.6 |
866 * |
886 * |
867 * After firing this action hook the page will redirect to wp-login a callback |
887 * @param int $request_id Request ID. |
868 * redirects or exits first. |
888 */ |
869 * |
889 do_action( 'user_request_action_confirmed', $request_id ); |
870 * @param int $request_id Request ID. |
890 |
871 */ |
891 $message = _wp_privacy_account_request_confirmed_message( $request_id ); |
872 do_action( 'user_request_action_confirmed', $request_id ); |
892 |
873 |
893 login_header( __( 'User action confirmed.' ), $message ); |
874 $message = _wp_privacy_account_request_confirmed_message( $request_id ); |
894 login_footer(); |
875 |
895 exit; |
876 login_header( __( 'User action confirmed.' ), $message ); |
896 |
877 login_footer(); |
897 case 'login': |
878 exit; |
898 default: |
879 |
899 $secure_cookie = ''; |
880 case 'login' : |
900 $customize_login = isset( $_REQUEST['customize-login'] ); |
881 default: |
901 if ( $customize_login ) { |
882 $secure_cookie = ''; |
902 wp_enqueue_script( 'customize-base' ); |
883 $customize_login = isset( $_REQUEST['customize-login'] ); |
903 } |
884 if ( $customize_login ) |
904 |
885 wp_enqueue_script( 'customize-base' ); |
905 // If the user wants SSL but the session is not SSL, force a secure cookie. |
886 |
906 if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) { |
887 // If the user wants ssl but the session is not ssl, force a secure cookie. |
907 $user_name = sanitize_user( $_POST['log'] ); |
888 if ( !empty($_POST['log']) && !force_ssl_admin() ) { |
908 $user = get_user_by( 'login', $user_name ); |
889 $user_name = sanitize_user($_POST['log']); |
909 |
890 $user = get_user_by( 'login', $user_name ); |
910 if ( ! $user && strpos( $user_name, '@' ) ) { |
891 |
911 $user = get_user_by( 'email', $user_name ); |
892 if ( ! $user && strpos( $user_name, '@' ) ) { |
912 } |
893 $user = get_user_by( 'email', $user_name ); |
913 |
894 } |
914 if ( $user ) { |
895 |
915 if ( get_user_option( 'use_ssl', $user->ID ) ) { |
896 if ( $user ) { |
916 $secure_cookie = true; |
897 if ( get_user_option('use_ssl', $user->ID) ) { |
917 force_ssl_admin( true ); |
898 $secure_cookie = true; |
918 } |
899 force_ssl_admin(true); |
919 } |
900 } |
920 } |
901 } |
921 |
902 } |
922 if ( isset( $_REQUEST['redirect_to'] ) ) { |
903 |
923 $redirect_to = $_REQUEST['redirect_to']; |
904 if ( isset( $_REQUEST['redirect_to'] ) ) { |
924 // Redirect to HTTPS if user wants SSL. |
905 $redirect_to = $_REQUEST['redirect_to']; |
925 if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) ) { |
906 // Redirect to https if user wants ssl |
926 $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to ); |
907 if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) |
927 } |
908 $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
928 } else { |
909 } else { |
929 $redirect_to = admin_url(); |
910 $redirect_to = admin_url(); |
930 } |
911 } |
931 |
912 |
932 $reauth = empty( $_REQUEST['reauth'] ) ? false : true; |
913 $reauth = empty($_REQUEST['reauth']) ? false : true; |
933 |
914 |
934 $user = wp_signon( array(), $secure_cookie ); |
915 $user = wp_signon( array(), $secure_cookie ); |
935 |
916 |
936 if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { |
917 if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { |
937 if ( headers_sent() ) { |
918 if ( headers_sent() ) { |
938 $user = new WP_Error( |
919 /* translators: 1: Browser cookie documentation URL, 2: Support forums URL */ |
939 'test_cookie', |
920 $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), |
940 sprintf( |
921 __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) ); |
941 /* translators: 1: Browser cookie documentation URL, 2: Support forums URL */ |
922 } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { |
942 __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), |
923 // If cookies are disabled we can't log in even with a valid user+pass |
943 __( 'https://wordpress.org/support/article/cookies/' ), |
924 /* translators: 1: Browser cookie documentation URL */ |
944 __( 'https://wordpress.org/support/' ) |
925 $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), |
945 ) |
926 __( 'https://codex.wordpress.org/Cookies' ) ) ); |
946 ); |
927 } |
947 } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { |
928 } |
948 // If cookies are disabled we can't log in even with a valid user+pass |
929 |
949 $user = new WP_Error( |
930 $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
950 'test_cookie', |
931 /** |
951 sprintf( |
932 * Filters the login redirect URL. |
952 /* translators: %s: Browser cookie documentation URL */ |
933 * |
953 __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), |
934 * @since 3.0.0 |
954 __( 'https://wordpress.org/support/article/cookies/#enable-cookies-in-your-browser' ) |
935 * |
955 ) |
936 * @param string $redirect_to The redirect destination URL. |
956 ); |
937 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
957 } |
938 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
958 } |
939 */ |
959 |
940 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
960 $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
941 |
961 /** |
942 if ( !is_wp_error($user) && !$reauth ) { |
962 * Filters the login redirect URL. |
943 if ( $interim_login ) { |
963 * |
944 $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; |
964 * @since 3.0.0 |
945 $interim_login = 'success'; |
965 * |
946 login_header( '', $message ); ?> |
966 * @param string $redirect_to The redirect destination URL. |
947 </div> |
967 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
948 <?php |
968 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
949 /** This action is documented in wp-login.php */ |
969 */ |
950 do_action( 'login_footer' ); ?> |
970 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
951 <?php if ( $customize_login ) : ?> |
971 |
|
972 if ( ! is_wp_error( $user ) && ! $reauth ) { |
|
973 if ( $interim_login ) { |
|
974 $message = '<p class="message">' . __( 'You have logged in successfully.' ) . '</p>'; |
|
975 $interim_login = 'success'; |
|
976 login_header( '', $message ); |
|
977 ?> |
|
978 </div> |
|
979 <?php |
|
980 /** This action is documented in wp-login.php */ |
|
981 do_action( 'login_footer' ); |
|
982 ?> |
|
983 <?php if ( $customize_login ) : ?> |
952 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> |
984 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> |
953 <?php endif; ?> |
985 <?php endif; ?> |
954 </body></html> |
986 </body></html> |
955 <?php exit; |
987 <?php |
956 } |
988 exit; |
957 |
989 } |
958 if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
990 |
959 // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
991 if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
960 if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) |
992 // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
961 $redirect_to = user_admin_url(); |
993 if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) ) { |
962 elseif ( is_multisite() && !$user->has_cap('read') ) |
994 $redirect_to = user_admin_url(); |
963 $redirect_to = get_dashboard_url( $user->ID ); |
995 } elseif ( is_multisite() && ! $user->has_cap( 'read' ) ) { |
964 elseif ( !$user->has_cap('edit_posts') ) |
996 $redirect_to = get_dashboard_url( $user->ID ); |
965 $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url(); |
997 } elseif ( ! $user->has_cap( 'edit_posts' ) ) { |
966 |
998 $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url(); |
967 wp_redirect( $redirect_to ); |
999 } |
|
1000 |
|
1001 wp_redirect( $redirect_to ); |
|
1002 exit(); |
|
1003 } |
|
1004 wp_safe_redirect( $redirect_to ); |
968 exit(); |
1005 exit(); |
969 } |
1006 } |
970 wp_safe_redirect($redirect_to); |
1007 |
971 exit(); |
1008 $errors = $user; |
972 } |
1009 // Clear errors if loggedout is set. |
973 |
1010 if ( ! empty( $_GET['loggedout'] ) || $reauth ) { |
974 $errors = $user; |
1011 $errors = new WP_Error(); |
975 // Clear errors if loggedout is set. |
1012 } |
976 if ( !empty($_GET['loggedout']) || $reauth ) |
1013 |
977 $errors = new WP_Error(); |
1014 if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) { |
978 |
1015 $errors = new WP_Error( '', '' ); |
979 if ( $interim_login ) { |
1016 } |
980 if ( ! $errors->get_error_code() ) |
1017 |
981 $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' ); |
1018 if ( $interim_login ) { |
982 } else { |
1019 if ( ! $errors->has_errors() ) { |
983 // Some parts of this script use the main login form to display a message |
1020 $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' ); |
984 if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) |
1021 } |
985 $errors->add('loggedout', __('You are now logged out.'), 'message'); |
1022 } else { |
986 elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
1023 // Some parts of this script use the main login form to display a message. |
987 $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
1024 if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) { |
988 elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
1025 $errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' ); |
989 $errors->add('confirm', __('Check your email for the confirmation link.'), 'message'); |
1026 } elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) { |
990 elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
1027 $errors->add( 'registerdisabled', __( 'User registration is currently not allowed.' ) ); |
991 $errors->add('newpass', __('Check your email for your new password.'), 'message'); |
1028 } elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] ) { |
992 elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
1029 $errors->add( 'confirm', __( 'Check your email for the confirmation link.' ), 'message' ); |
993 $errors->add('registered', __('Registration complete. Please check your email.'), 'message'); |
1030 } elseif ( isset( $_GET['checkemail'] ) && 'newpass' == $_GET['checkemail'] ) { |
994 elseif ( strpos( $redirect_to, 'about.php?updated' ) ) |
1031 $errors->add( 'newpass', __( 'Check your email for your new password.' ), 'message' ); |
995 $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
1032 } elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] ) { |
996 } |
1033 $errors->add( 'registered', __( 'Registration complete. Please check your email.' ), 'message' ); |
997 |
1034 } elseif ( strpos( $redirect_to, 'about.php?updated' ) ) { |
998 /** |
1035 $errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
999 * Filters the login page errors. |
1036 } elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) { |
1000 * |
1037 $errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' ); |
1001 * @since 3.6.0 |
1038 } |
1002 * |
1039 } |
1003 * @param object $errors WP Error object. |
1040 |
1004 * @param string $redirect_to Redirect destination URL. |
1041 /** |
1005 */ |
1042 * Filters the login page errors. |
1006 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
1043 * |
1007 |
1044 * @since 3.6.0 |
1008 // Clear any stale cookies. |
1045 * |
1009 if ( $reauth ) |
1046 * @param object $errors WP Error object. |
1010 wp_clear_auth_cookie(); |
1047 * @param string $redirect_to Redirect destination URL. |
1011 |
1048 */ |
1012 login_header(__('Log In'), '', $errors); |
1049 $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
1013 |
1050 |
1014 if ( isset($_POST['log']) ) |
1051 // Clear any stale cookies. |
1015 $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
1052 if ( $reauth ) { |
1016 $rememberme = ! empty( $_POST['rememberme'] ); |
1053 wp_clear_auth_cookie(); |
1017 |
1054 } |
1018 if ( ! empty( $errors->errors ) ) { |
1055 |
1019 $aria_describedby_error = ' aria-describedby="login_error"'; |
1056 login_header( __( 'Log In' ), '', $errors ); |
1020 } else { |
1057 |
1021 $aria_describedby_error = ''; |
1058 if ( isset( $_POST['log'] ) ) { |
1022 } |
1059 $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : ''; |
1023 ?> |
1060 } |
1024 |
1061 $rememberme = ! empty( $_POST['rememberme'] ); |
1025 <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> |
1062 |
|
1063 if ( $errors->has_errors() ) { |
|
1064 $aria_describedby_error = ' aria-describedby="login_error"'; |
|
1065 } else { |
|
1066 $aria_describedby_error = ''; |
|
1067 } |
|
1068 ?> |
|
1069 |
|
1070 <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> |
1026 <p> |
1071 <p> |
1027 <label for="user_login"><?php _e( 'Username or Email Address' ); ?><br /> |
1072 <label for="user_login"><?php _e( 'Username or Email Address' ); ?><br /> |
1028 <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> |
1073 <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /></label> |
1029 </p> |
1074 </p> |
1030 <p> |
1075 <p> |
1031 <label for="user_pass"><?php _e( 'Password' ); ?><br /> |
1076 <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> |
1077 <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label> |
1033 </p> |
1078 </p> |
1034 <?php |
1079 <?php |
1035 /** |
1080 /** |
1036 * Fires following the 'Password' field in the login form. |
1081 * Fires following the 'Password' field in the login form. |
1037 * |
1082 * |
1038 * @since 2.1.0 |
1083 * @since 2.1.0 |
1039 */ |
1084 */ |
1040 do_action( 'login_form' ); |
1085 do_action( 'login_form' ); |
1041 ?> |
1086 ?> |
1042 <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_html_e( 'Remember Me' ); ?></label></p> |
1087 <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_html_e( 'Remember Me' ); ?></label></p> |
1043 <p class="submit"> |
1088 <p class="submit"> |
1044 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> |
1089 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In' ); ?>" /> |
1045 <?php if ( $interim_login ) { ?> |
1090 <?php if ( $interim_login ) { ?> |
1046 <input type="hidden" name="interim-login" value="1" /> |
1091 <input type="hidden" name="interim-login" value="1" /> |
1047 <?php } else { ?> |
1092 <?php } else { ?> |
1048 <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
1093 <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
1049 <?php } ?> |
1094 <?php } ?> |
1050 <?php if ( $customize_login ) : ?> |
1095 <?php if ( $customize_login ) : ?> |
1051 <input type="hidden" name="customize-login" value="1" /> |
1096 <input type="hidden" name="customize-login" value="1" /> |
1052 <?php endif; ?> |
1097 <?php endif; ?> |
1053 <input type="hidden" name="testcookie" value="1" /> |
1098 <input type="hidden" name="testcookie" value="1" /> |
1054 </p> |
1099 </p> |
1055 </form> |
1100 </form> |
1056 |
1101 |
1057 <?php if ( ! $interim_login ) { ?> |
1102 <?php if ( ! $interim_login ) { ?> |
1058 <p id="nav"> |
1103 <p id="nav"> |
1059 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : |
1104 <?php |
1060 if ( get_option( 'users_can_register' ) ) : |
1105 if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : |
1061 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
1106 if ( get_option( 'users_can_register' ) ) : |
1062 |
1107 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
1063 /** This filter is documented in wp-includes/general-template.php */ |
1108 |
1064 echo apply_filters( 'register', $registration_url ); |
1109 /** This filter is documented in wp-includes/general-template.php */ |
1065 |
1110 echo apply_filters( 'register', $registration_url ); |
1066 echo esc_html( $login_link_separator ); |
1111 |
1067 endif; |
1112 echo esc_html( $login_link_separator ); |
|
1113 endif; |
|
1114 ?> |
|
1115 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
|
1116 <?php endif; ?> |
|
1117 </p> |
|
1118 <?php } ?> |
|
1119 |
|
1120 <script type="text/javascript"> |
|
1121 function wp_attempt_focus(){ |
|
1122 setTimeout( function(){ try{ |
|
1123 <?php if ( $user_login ) { ?> |
|
1124 d = document.getElementById('user_pass'); |
|
1125 d.value = ''; |
|
1126 <?php } else { ?> |
|
1127 d = document.getElementById('user_login'); |
|
1128 <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> |
|
1129 if( d.value != '' ) |
|
1130 d.value = ''; |
|
1131 <?php |
|
1132 } |
|
1133 } |
1068 ?> |
1134 ?> |
1069 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
1135 d.focus(); |
1070 <?php endif; ?> |
1136 d.select(); |
1071 </p> |
1137 } catch(e){} |
1072 <?php } ?> |
1138 }, 200); |
1073 |
1139 } |
1074 <script type="text/javascript"> |
1140 |
1075 function wp_attempt_focus(){ |
1141 <?php |
1076 setTimeout( function(){ try{ |
1142 /** |
1077 <?php if ( $user_login ) { ?> |
1143 * Filters whether to print the call to `wp_attempt_focus()` on the login screen. |
1078 d = document.getElementById('user_pass'); |
1144 * |
1079 d.value = ''; |
1145 * @since 4.8.0 |
1080 <?php } else { ?> |
1146 * |
1081 d = document.getElementById('user_login'); |
1147 * @param bool $print Whether to print the function call. Default true. |
1082 <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> |
1148 */ |
1083 if( d.value != '' ) |
1149 if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) { |
1084 d.value = ''; |
1150 ?> |
1085 <?php |
1151 wp_attempt_focus(); |
1086 } |
1152 <?php } ?> |
1087 }?> |
1153 if(typeof wpOnload=='function')wpOnload(); |
1088 d.focus(); |
1154 <?php if ( $interim_login ) { ?> |
1089 d.select(); |
1155 (function(){ |
1090 } catch(e){} |
1156 try { |
1091 }, 200); |
1157 var i, links = document.getElementsByTagName('a'); |
1092 } |
1158 for ( i in links ) { |
1093 |
1159 if ( links[i].href ) |
1094 <?php |
1160 links[i].target = '_blank'; |
1095 /** |
1161 } |
1096 * Filters whether to print the call to `wp_attempt_focus()` on the login screen. |
1162 } catch(e){} |
1097 * |
1163 }()); |
1098 * @since 4.8.0 |
1164 <?php } ?> |
1099 * |
1165 </script> |
1100 * @param bool $print Whether to print the function call. Default true. |
1166 |
1101 */ |
1167 <?php |
1102 if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) { ?> |
1168 login_footer(); |
1103 wp_attempt_focus(); |
1169 |
1104 <?php } ?> |
1170 break; |
1105 if(typeof wpOnload=='function')wpOnload(); |
1171 } // End action switch. |
1106 <?php if ( $interim_login ) { ?> |
|
1107 (function(){ |
|
1108 try { |
|
1109 var i, links = document.getElementsByTagName('a'); |
|
1110 for ( i in links ) { |
|
1111 if ( links[i].href ) |
|
1112 links[i].target = '_blank'; |
|
1113 } |
|
1114 } catch(e){} |
|
1115 }()); |
|
1116 <?php } ?> |
|
1117 </script> |
|
1118 |
|
1119 <?php |
|
1120 login_footer(); |
|
1121 |
|
1122 if ( $switched_locale ) { |
|
1123 restore_previous_locale(); |
|
1124 } |
|
1125 |
|
1126 break; |
|
1127 } // end action switch |
|