Make WordPress Core

Ticket #19037: 19037.diff

File 19037.diff, 11.7 KB (added by ryan, 13 years ago)

Partial refresh

  • wp-signup.php

     
    390390if ( $active_signup == 'none' ) {
    391391        _e( 'Registration has been disabled.' );
    392392} elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
    393         if ( is_ssl() )
    394                 $proto = 'https://';
    395         else
    396                 $proto = 'http://';
    397         $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode($proto . $_SERVER['HTTP_HOST'] . '/wp-signup.php' ));
     393        $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . '/wp-signup.php' ) ) );
    398394        echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
    399395} else {
    400396        $stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
  • wp-login.php

     
    1212require( dirname(__FILE__) . '/wp-load.php' );
    1313
    1414// Redirect to https login if forced to use SSL
    15 if ( force_ssl_admin() && !is_ssl() ) {
     15if ( force_ssl_admin() && ! is_ssl() ) {
    1616        if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
    17                 wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
     17                wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
    1818                exit();
    1919        } else {
    20                 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     20                wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    2121                exit();
    2222        }
    2323}
     
    365365        if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
    366366                $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
    367367
    368         $schema = is_ssl() ? 'https://' : 'http://';
    369         if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') )
    370                 update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
     368        $url = dirname( set_url_scheme( 'http://' .  $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) );
     369        if ( $url != get_option( 'siteurl' ) )
     370                update_option( 'siteurl', $url );
    371371}
    372372
    373373//Set a cookie now to see if they are supported by the browser.
  • wp-includes/nav-menu-template.php

     
    358358                // if the menu item corresponds to the currently-requested URL
    359359                } elseif ( 'custom' == $menu_item->object ) {
    360360                        $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
    361                         $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_root_relative_current;
     361                        $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
    362362                        $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
    363363                        $item_url = untrailingslashit( $raw_item_url );
    364364                        $_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) );
  • wp-includes/theme.php

     
    891891        if ( is_random_header_image() )
    892892                $url = get_random_header_image();
    893893
    894         if ( is_ssl() )
    895                 $url = str_replace( 'http://', 'https://', $url );
    896         else
    897                 $url = str_replace( 'https://', 'http://', $url );
    898 
    899         return esc_url_raw( $url );
     894        return esc_url_raw( set_url_scheme( $url ) );
    900895}
    901896
    902897/**
  • wp-includes/functions.php

     
    29332933 * @return string
    29342934 */
    29352935function wp_guess_url() {
    2936         if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
     2936        if ( defined('WP_SITEURL') && '' != WP_SITEURL )
    29372937                $url = WP_SITEURL;
    2938         } else {
    2939                 $schema = is_ssl() ? 'https://' : 'http://';
    2940                 $url = preg_replace('#/(wp-admin/.*|wp-login.php)#i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    2941         }
     2938        else
     2939                $url = set_url_scheme( preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
     2940
    29422941        return rtrim($url, '/');
    29432942}
    29442943
  • wp-includes/class-wp-xmlrpc-server.php

     
    32213221                global $current_blog;
    32223222                $domain = $current_blog->domain;
    32233223                $path = $current_blog->path . 'xmlrpc.php';
    3224                 $protocol = is_ssl() ? 'https' : 'http';
    32253224
    3226                 $rpc = new IXR_Client("$protocol://{$domain}{$path}");
     3225                $rpc = new IXR_Client( set_url_scheme( "http://{$domain}{$path}" ) );
    32273226                $rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
    32283227                $blogs = $rpc->getResponse();
    32293228
  • wp-includes/link-template.php

     
    20492049 * @return string Content url link with optional path appended.
    20502050*/
    20512051function content_url($path = '') {
    2052         $url = WP_CONTENT_URL;
    2053         if ( 0 === strpos($url, 'http') && is_ssl() )
    2054                 $url = str_replace( 'http://', 'https://', $url );
     2052        $url = set_url_scheme( WP_CONTENT_URL );
    20552053
    20562054        if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
    20572055                $url .= '/' . ltrim($path, '/');
     
    20832081        else
    20842082                $url = WP_PLUGIN_URL;
    20852083
    2086         if ( 0 === strpos($url, 'http') && is_ssl() )
    2087                 $url = str_replace( 'http://', 'https://', $url );
     2084       
     2085        $url = set_url_scheme( $url );
    20882086
    20892087        if ( !empty($plugin) && is_string($plugin) ) {
    20902088                $folder = dirname(plugin_basename($plugin));
  • wp-includes/pluggable.php

     
    748748
    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                }
    758758        }
     
    767767
    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                        }
    777777                }
     
    782782        // The cookie is no good so force login
    783783        nocache_headers();
    784784
    785         if ( is_ssl() )
    786                 $proto = 'https://';
    787         else
    788                 $proto = 'http://';
     785        $redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    789786
    790         $redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    791 
    792787        $login_url = wp_login_url($redirect, true);
    793788
    794789        wp_redirect($login_url);
  • wp-includes/feed.php

     
    488488 */
    489489function self_link() {
    490490        $host = @parse_url(home_url());
    491         $host = $host['host'];
    492         echo esc_url(
    493                 ( is_ssl() ? 'https' : 'http' ) . '://'
    494                 . $host
    495                 . stripslashes($_SERVER['REQUEST_URI'])
    496                 );
     491        echo esc_url( set_url_scheme( 'http://' . $host['host'] . stripslashes($_SERVER['REQUEST_URI']) ) );
    497492}
    498493
    499494/**
  • wp-includes/ms-functions.php

     
    18751875}
    18761876
    18771877/**
    1878  * Formats an String URL to use HTTPS if HTTP is found.
     1878 * Formats a URL to use https.
     1879 *
    18791880 * Useful as a filter.
    18801881 *
    18811882 * @since 2.8.5
    1882  **/
     1883 *
     1884 * @param string URL
     1885 * @return string URL with https as the scheme
     1886 */
    18831887function filter_SSL( $url ) {
    1884         if ( !is_string( $url ) )
    1885                 return get_bloginfo( 'url' ); //return home blog url with proper scheme
     1888        if ( ! is_string( $url ) )
     1889                return get_bloginfo( 'url' ); // Return home blog url with proper scheme
    18861890
    1887         $arrURL = parse_url( $url );
     1891        if ( force_ssl_content() && is_ssl() )
     1892                $url = set_url_scheme( $url, 'https' );
    18881893
    1889         if ( force_ssl_content() && is_ssl() ) {
    1890                 if ( 'http' === $arrURL['scheme'] )
    1891                         $url = str_replace( $arrURL['scheme'], 'https', $url );
    1892         }
    1893 
    18941894        return $url;
    18951895}
    18961896
  • wp-admin/includes/plugin.php

     
    903903
    904904        if ( empty($icon_url) )
    905905                $icon_url = esc_url( admin_url( 'images/generic.png' ) );
    906         elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
    907                 $icon_url = 'https://' . substr($icon_url, 7);
     906        else
     907                $icon_url = set_url_scheme( $icon_url );
    908908
    909909        $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
    910910
  • wp-admin/includes/class-wp-list-table.php

     
    490490
    491491                $current = $this->get_pagenum();
    492492
    493                 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     493                $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    494494
    495495                $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
    496496
     
    651651
    652652                list( $columns, $hidden, $sortable ) = $this->get_column_info();
    653653
    654                 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     654                $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    655655                $current_url = remove_query_arg( 'paged', $current_url );
    656656
    657657                if ( isset( $_GET['orderby'] ) )
  • wp-admin/includes/meta-boxes.php

     
    4141        $preview_link = esc_url( get_permalink( $post->ID ) );
    4242        $preview_button = __( 'Preview Changes' );
    4343} else {
    44         $preview_link = get_permalink( $post->ID );
    45         if ( is_ssl() )
    46                 $preview_link = str_replace( 'http://', 'https://', $preview_link );
     44        $preview_link = set_url_scheme( get_permalink( $post->ID ) );
    4745        $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
    4846        $preview_button = __( 'Preview' );
    4947}