Make WordPress Core


Ignore:
Timestamp:
08/30/2012 01:33:00 PM (12 years ago)
Author:
ryan
Message:

Use set_url_scheme(). Props johnbillion, MarcusPope. see #19037 #20759

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable.php

    r21563 r21664  
    749749    // If https is required and request is http, redirect
    750750    if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
    751         if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
    752             wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
     751        if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
     752            wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
    753753            exit();
    754754        } else {
    755             wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     755            wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    756756            exit();
    757757        }
     
    768768        // If the user wants ssl but the session is not ssl, redirect.
    769769        if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
    770             if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
    771                 wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
     770            if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
     771                wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
    772772                exit();
    773773            } else {
    774                 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     774                wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    775775                exit();
    776776            }
     
    783783    nocache_headers();
    784784
    785     if ( is_ssl() )
    786         $proto = 'https://';
    787     else
    788         $proto = 'http://';
    789 
    790     $redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     785    $redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    791786
    792787    $login_url = wp_login_url($redirect, true);
Note: See TracChangeset for help on using the changeset viewer.