Make WordPress Core

Ticket #12735: 12735.1.patch

File 12735.1.patch, 5.8 KB (added by andreasnrb, 14 years ago)

Fixes get_blogaddress_*, network_site_url,get_site_url, get_home_url, adds site_path support, to currsite & ms-default-constants, fixes bug in previous patch and adds site url support to wpmu blog creation

  • wp-includes/link-template.php

     
    19001900        if ( empty($blog_id) || !is_multisite() )
    19011901                $url = get_option('siteurl');
    19021902        else
    1903                 $url = untrailingslashit(get_blogaddress_by_id($blog_id));
     1903                $url = untrailingslashit(get_blog_option($blog_id,'siteurl'));
    19041904
    19051905        $url = str_replace( 'http://', "{$scheme}://", $url );
    19061906
     
    20532053                        $scheme = ( is_ssl() ? 'https' : 'http' );
    20542054        }
    20552055
    2056         $url = 'http://' . $current_site->domain . $current_site->path;
     2056        $url = 'http://' . $current_site->domain . $current_site->site_path;
    20572057
    20582058        $url = str_replace( 'http://', "{$scheme}://", $url );
    20592059
  • wp-includes/ms-blogs.php

     
    2727        global $current_site;
    2828
    2929        if ( is_subdomain_install() ) {
     30                if(strpos($current_site->domain,$blogname)!==false)
     31                        return esc_url('http://'.$current_site->domain . $current_site->path);         
    3032                if ( $blogname == 'main' )
    3133                        $blogname = 'www';
    3234                return esc_url( 'http://' . $blogname . '.' . $current_site->domain . $current_site->path );
    3335        } else {
     36                if(strpos($current_site->path,$blogname)!==false)
     37                        return esc_url( 'http://' . $current_site->domain . $current_site->path);
    3438                return esc_url( 'http://' . $current_site->domain . $current_site->path . $blogname . '/' );
    3539        }
    3640}
  • wp-includes/ms-default-constants.php

     
    4646         * @since 1.5.0
    4747         */
    4848        if ( !defined( 'SITECOOKIEPATH' ) )
    49                 define( 'SITECOOKIEPATH', $current_site->path );
     49                define( 'SITECOOKIEPATH', $current_site->site_path );
    5050
    5151        /**
    5252         * @since 2.6.0
  • wp-includes/ms-functions.php

     
    909909
    910910// Install an empty blog.  wpdb should already be switched.
    911911function install_blog($blog_id, $blog_title = '') {
    912         global $wpdb, $table_prefix, $wp_roles;
     912        global $wpdb, $table_prefix, $wp_roles,$current_site;
    913913        $wpdb->suppress_errors();
    914914
    915915        // Cast for security
     
    923923        $wpdb->suppress_errors(false);
    924924
    925925        $url = get_blogaddress_by_id($blog_id);
    926 
     926        $site_url=$url;
     927        if($current_site->path!=$current_site->site_path)
     928                $site_url=trim($url,'/').'/'.trim($current_site->site_path,'/').'/';
    927929        // Set everything up
    928930        make_db_current_silent();
    929931        populate_options();
     
    931933        $wp_roles->_init();
    932934
    933935        // fix url.
    934         update_option('siteurl', $url);
     936        update_option('siteurl', $site_url);
    935937        update_option('home', $url);
    936         update_option('fileupload_url', $url . "files" );
     938        update_option('fileupload_url', $site_url . "files" );
    937939        update_option('upload_path', "wp-content/blogs.dir/" . $blog_id . "/files");
    938940        update_option('blogname', stripslashes( $blog_title ) );
    939941        update_option('admin_email', '');
  • wp-includes/ms-load.php

     
    9696 * @return object $current_site object
    9797 */
    9898function wpmu_current_site() {
    99         global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
     99        global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain,$site_path;
    100100        if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
    101                 $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
     101                $site_path = defined('PATH_WP_INSTALL') ? PATH_WP_INSTALL:PATH_CURRENT_SITE;
     102                $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;               
    102103                $current_site->domain = DOMAIN_CURRENT_SITE;
    103104                $current_site->path   = $path = PATH_CURRENT_SITE;
     105                $current_site->site_path=$site_path;
    104106                if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
    105107                        $current_site->blog_id = BLOG_ID_CURRENT_SITE;
    106108                elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
     
    126128                $current_site = $sites[0];
    127129                wp_load_core_site_options( $current_site->id );
    128130                $path = $current_site->path;
     131                $site_path = defined('PATH_WP_INSTALL') ? PATH_WP_INSTALL:$path;
    129132                $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
    130133                $current_site = get_current_site_name( $current_site );
    131134                if ( substr( $current_site->domain, 0, 4 ) == 'www.' )
    132135                        $current_site->cookie_domain = substr( $current_site->domain, 4 );
     136                $current_site->site_path=$site_path;
    133137                wp_cache_set( 'current_site', $current_site, 'site-options' );
    134138                return $current_site;
    135139        }
     
    149153
    150154        if ( $current_site ) {
    151155                $path = $current_site->path;
     156                $site_path = defined('PATH_WP_INSTALL') ? PATH_WP_INSTALL:$path;               
    152157                $current_site->cookie_domain = $cookie_domain;
     158                $current_site->site_path=$site_path;
    153159                return $current_site;
    154160        }
    155161
     
    158164                $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
    159165                if ( $current_site ) {
    160166                        $current_site->cookie_domain = $current_site->domain;
     167                        $site_path = defined('PATH_WP_INSTALL') ? PATH_WP_INSTALL:$current_site->path;                 
     168                        $current_site->site_path=$site_path;                   
    161169                        return $current_site;
    162170                }
    163171
     
    166174
    167175        if ( $current_site || defined( 'WP_INSTALLING' ) ) {
    168176                $path = '/';
     177                $site_path = defined('PATH_WP_INSTALL') ? PATH_WP_INSTALL:$path;               
     178                $current_site->site_path=$site_path;
    169179                return $current_site;
    170180        }
    171181