WordPress.org

Make WordPress Core

Ticket #8593: 8593.2.patch

File 8593.2.patch, 4.5 KB (added by hakre, 4 years ago)

wp_requested_url()

  • wp-includes/canonical.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-trunk bare
     
    4242 
    4343        if ( !$requested_url ) { 
    4444                // build the URL in the address bar 
    45                 $requested_url  = is_ssl() ? 'https://' : 'http://'; 
    46                 $requested_url .= $_SERVER['HTTP_HOST']; 
    47                 $requested_url .= $_SERVER['REQUEST_URI']; 
     45                $requested_url = wp_requested_url(); 
    4846        } 
    4947 
    5048        $original = @parse_url($requested_url); 
  • wp-includes/functions.php

     
    35963596        if ( defined('WP_SITEURL') && '' != WP_SITEURL ) { 
    35973597                $url = WP_SITEURL; 
    35983598        } else { 
    3599                 $schema = is_ssl() ? 'https://' : 'http://'; 
    3600                 $url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 
     3599                $url = wp_requested_url(); 
     3600                $url = preg_replace( '|/wp-admin/.*|i', '', $url ); 
    36013601        } 
    36023602        return rtrim($url, '/'); 
    36033603} 
    36043604 
    36053605/** 
     3606 * Get the requested URL of the site 
     3607 *  
     3608 * @since 3.2 
     3609 * @param bool $ssl Optional. Override SSL property of the request, setting it to non-SSL or SSL explicitly 
     3610 * @return string requested URL 
     3611 */ 
     3612function wp_requested_url( $ssl = null ) { 
     3613        $ssl = ( null === $ssl ) ? is_ssl() : $ssl; 
     3614        $scheme = $ssl ? 'https' : 'http'; 
     3615        $default_port = $ssl ? '443' : '80'; 
     3616        list( $host, $port ) = explode( ':', $_SERVER['HTTP_HOST'] . ":$default_port" ); 
     3617        $host .= ( $port == $default_port ? '' : ":$port" ); 
     3618        return "$scheme://$host" . $_SERVER['REQUEST_URI']; 
     3619} 
     3620 
     3621/** 
    36063622 * Suspend cache invalidation. 
    36073623 * 
    36083624 * Turns cache invalidation on and off.  Useful during imports where you don't wont to do invalidations 
  • wp-admin/setup-config.php

     
    194194                 * @ignore 
    195195                 */ 
    196196                function get_bloginfo() { 
    197                         return ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . str_replace( $_SERVER['PHP_SELF'], '/wp-admin/setup-config.php', '' ) ); 
     197                        return str_replace( wp_requested_url(), '/wp-admin/setup-config.php', '' ); 
    198198                } 
    199199                /**#@-*/ 
    200200                $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); 
  • wp-login.php

     
    1313 
    1414// Redirect to https login if forced to use SSL 
    1515if ( force_ssl_admin() && !is_ssl() ) { 
    16         if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { 
    17                 wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI'])); 
    18                 exit(); 
    19         } else { 
    20                 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 
    21                 exit(); 
    22         } 
     16        wp_redirect( wp_requested_url( true ) ); 
     17        exit(); 
    2318} 
    2419 
    2520/** 
     
    357352        if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) 
    358353                $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); 
    359354 
    360         $schema = is_ssl() ? 'https://' : 'http://'; 
    361         if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') ) 
    362                 update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) ); 
     355        $new_siteurl = dirname( wp_requested_url() ); 
     356        if ( $new_siteurl != get_option('siteurl') ) 
     357                update_option('siteurl', $new_siteurl ); 
     358        unset($new_siteurl); 
    363359} 
    364360 
    365361//Set a cookie now to see if they are supported by the browser. 
  • wp-admin/includes/class-wp-list-table.php

     
    475475 
    476476                $current = $this->get_pagenum(); 
    477477 
    478                 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
     478                $current_url = wp_requested_url(); 
    479479 
    480480                $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); 
    481481 
     
    631631 
    632632                list( $columns, $hidden, $sortable ) = $this->get_column_info(); 
    633633 
    634                 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
     634                $current_url = wp_requested_url(); 
    635635                $current_url = remove_query_arg( 'paged', $current_url ); 
    636636 
    637637                if ( isset( $_GET['orderby'] ) )