WordPress.org

Make WordPress Core

Changeset 21664


Ignore:
Timestamp:
08/30/12 13:33:00 (20 months ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-list-table.php

    r21323 r21664  
    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 ); 
     
    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 
  • trunk/wp-admin/includes/meta-boxes.php

    r21311 r21664  
    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' ); 
  • trunk/wp-admin/includes/plugin.php

    r21291 r21664  
    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 ); 
  • trunk/wp-includes/class-wp-editor.php

    r21576 r21664  
    212212                        foreach ( $mce_external_plugins as $name => $url ) { 
    213213 
    214                             if ( is_ssl() ) $url = str_replace('http://', 'https://', $url); 
     214                            $url = set_url_scheme( $url ); 
    215215 
    216216                            $plugins[] = '-' . $name; 
  • trunk/wp-includes/class-wp-xmlrpc-server.php

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

    r21652 r21664  
    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 
  • trunk/wp-includes/functions.php

    r21541 r21664  
    25862586function url_is_accessable_via_ssl($url) 
    25872587{ 
    2588     if (in_array('curl', get_loaded_extensions())) { 
    2589         $ssl = preg_replace( '/^http:\/\//', 'https://',  $url ); 
     2588    if ( in_array( 'curl', get_loaded_extensions() ) ) { 
     2589        $ssl = set_url_scheme( $url, 'https' ); 
    25902590 
    25912591        $ch = curl_init(); 
     
    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} 
  • trunk/wp-includes/link-template.php

    r21662 r21664  
    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 ) 
     
    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) ) { 
  • trunk/wp-includes/ms-functions.php

    r21628 r21664  
    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 
    1886  
    1887     $arrURL = parse_url( $url ); 
    1888  
    1889     if ( force_ssl_content() && is_ssl() ) { 
    1890         if ( 'http' === $arrURL['scheme'] ) 
    1891             $url = str_replace( $arrURL['scheme'], 'https', $url ); 
    1892     } 
     1888    if ( ! is_string( $url ) ) 
     1889        return get_bloginfo( 'url' ); // Return home blog url with proper scheme 
     1890 
     1891    if ( force_ssl_content() && is_ssl() ) 
     1892        $url = set_url_scheme( $url, 'https' ); 
    18931893 
    18941894    return $url; 
  • trunk/wp-includes/nav-menu-template.php

    r21559 r21664  
    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 ); 
  • 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); 
  • trunk/wp-includes/theme.php

    r21629 r21664  
    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 
  • trunk/wp-login.php

    r21507 r21664  
    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    } 
     
    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 
  • trunk/wp-signup.php

    r20556 r21664  
    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 { 
Note: See TracChangeset for help on using the changeset viewer.