Make WordPress Core

Ticket #49860: 49860.patch

File 49860.patch, 2.6 KB (added by ttodua, 5 years ago)
  • src/wp-includes/functions.php

    From 161766d0a2fd72b653b7fa5762c2ddffed044d9b Mon Sep 17 00:00:00 2001
    From: "T.Todua" <7117978+ttodua@users.noreply.github.com>
    Date: Thu, 9 Apr 2020 20:43:30 +0400
    Subject: [PATCH] update
    
    ---
     src/wp-includes/functions.php | 13 +++++++++++++
     src/wp-login.php              | 10 ++++++++--
     2 files changed, 21 insertions(+), 2 deletions(-)
    
    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index bc9f276b89..b38ce41abd 100644
    a b function wp_auth_check( $response ) { 
    65406540        return $response;
    65416541}
    65426542
     6543/**
     6544 * Check whether user registration is disabled and password reset is also disabled
     6545 * for existing users, and in this case, redirects to login page.
     6546 *
     6547 * @since 5.4.0
     6548 */
     6549function wp_redirect_if_disabled_registration_and_reset() {
     6550        if ( !get_option( 'users_can_register' ) && ! apply_filters( 'allow_password_reset_for_existing_users', true ) ) {
     6551                wp_safe_redirect( 'wp-login.php' );
     6552                exit();
     6553        }
     6554}
     6555
    65436556/**
    65446557 * Return RegEx body to liberally match an opening HTML tag.
    65456558 *
  • src/wp-login.php

    diff --git a/src/wp-login.php b/src/wp-login.php
    index 0b552ef326..b471822621 100644
    a b switch ( $action ) { 
    801801
    802802        case 'lostpassword':
    803803        case 'retrievepassword':
     804                wp_redirect_if_disabled_registration_and_reset();
     805               
    804806                if ( $http_post ) {
    805807                        $errors = retrieve_password();
    806808
    switch ( $action ) { 
    893895
    894896        case 'resetpass':
    895897        case 'rp':
     898                wp_redirect_if_disabled_registration_and_reset();
     899               
    896900                list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
    897901                $rp_cookie       = 'wp-resetpass-' . COOKIEHASH;
    898902
    switch ( $action ) { 
    13621366                ?>
    13631367
    13641368                <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
    1365                         <p>
     1369                        <p class="username-email">
    13661370                                <label for="user_login"><?php _e( 'Username or Email Address' ); ?></label>
    13671371                                <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" />
    13681372                        </p>
    switch ( $action ) { 
    14301434                                        }
    14311435
    14321436                                        ?>
    1433                                         <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
     1437                                        <?php if ( get_option( 'users_can_register' ) || apply_filters( 'allow_password_reset_for_existing_users', true ) ) : ?>
     1438                                                <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
     1439                                        <?php endif; ?>
    14341440                                        <?php
    14351441                                }
    14361442