WordPress.org

Make WordPress Core

Ticket #27373: 27373.diff

File 27373.diff, 1.8 KB (added by nacin, 7 years ago)
  • src/wp-login.php

     
    755755        if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
    756756                $secure_cookie = false;
    757757
    758         // If cookies are disabled we can't log in even with a valid user+pass
    759         if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
    760                 $user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
    761         else
    762                 $user = wp_signon('', $secure_cookie);
     758        $user = wp_signon( '', $secure_cookie );
    763759
     760        if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
     761                if ( headers_sent() ) {
     762                        $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>.' ),
     763                                __( 'http://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) );
     764                } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) {
     765                        // If cookies are disabled we can't log in even with a valid user+pass
     766                        $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.' ),
     767                                __( 'http://codex.wordpress.org/Cookies' ) ) );
     768                }
     769        }
     770
    764771        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
    765772        /**
    766773         * Filter the login redirect URL.