WordPress.org

Make WordPress Core

Ticket #7129: wp_guess_url.patch

File wp_guess_url.patch, 2.8 KB (added by sambauers, 10 years ago)
  • wp-includes/functions.php

     
    17931793        return $forced;
    17941794}
    17951795
     1796function wp_guess_url() {
     1797        if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
     1798                $url = WP_SITEURL;
     1799        } else {
     1800                $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
     1801                $url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     1802        }
     1803        return $url;
     1804}
     1805
    17961806?>
  • wp-includes/script-loader.php

     
    77require( ABSPATH . WPINC . '/functions.wp-styles.php' );
    88
    99function wp_default_scripts( &$scripts ) {
    10         $scripts->base_url = site_url();
     10        if (!$guessurl = site_url())
     11                $guessurl = wp_guess_url();
     12        $scripts->base_url = $guessurl;
    1113        $scripts->default_version = get_bloginfo( 'version' );
    1214
    1315        $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery'), '20080318' );
     
    203205}
    204206
    205207function wp_default_styles( &$styles ) {
    206         $styles->base_url = site_url();
     208        if (!$guessurl = site_url())
     209                $guessurl = wp_guess_url();
     210        $styles->base_url = $guessurl;
    207211        $styles->default_version = get_bloginfo( 'version' );
    208212        $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';
    209213
  • wp-admin/includes/schema.php

     
    153153
    154154function populate_options() {
    155155        global $wpdb, $wp_db_version;
    156 
    157         $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
    158         $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    159156       
     157        $guessurl = wp_guess_url();
     158       
    160159        do_action('populate_options');
    161160       
    162161        add_option('siteurl', $guessurl);
  • wp-admin/includes/upgrade.php

     
    1818        update_option('blogname', $blog_title);
    1919        update_option('admin_email', $user_email);
    2020        update_option('blog_public', $public);
    21         $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
    2221
    23         if ( defined('WP_SITEURL') && '' != WP_SITEURL )
    24                 $guessurl = WP_SITEURL;
    25         else
    26                 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    27 
     22        $guessurl = wp_guess_url();
    2823        update_option('siteurl', $guessurl);
    2924
    3025        // If not a public blog, don't ping.