Make WordPress Core

Ticket #12735: 12736&12735.patch

File 12736&12735.patch, 8.7 KB (added by andreasnrb, 14 years ago)

Fixes get_blogaddress_*, adds siteurl,homeurl to currents sites and get_blogs, fixes wrong linkage in my-sites and ms

  • wp-admin/includes/ms.php

     
    713713                                <?php foreach( (array) $all_blogs as $blog ) {
    714714                                        if ( $primary_blog == $blog->userblog_id )
    715715                                                $found = true;
    716                                         ?><option value='<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>>http://<?php echo $blog->domain.$blog->path ?></option><?php
     716                                        ?><option value='<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>><?php echo $blog->homeurl?></option><?php
    717717                                } ?>
    718718                        </select>
    719719                        <?php
  • wp-admin/my-sites.php

     
    6868                        $t = $t == 'border-right: 1px solid #ccc;' ? '' : 'border-right: 1px solid #ccc;';
    6969                        echo "<td valign='top' style='$t; width:50%'>";
    7070                        echo "<h3>{$user_blog->blogname}</h3>";
    71                         echo "<p>" . apply_filters( "myblogs_blog_actions", "<a href='{$user_blog->siteurl}'>" . __( 'Visit' ) . "</a> | <a href='{$user_blog->siteurl}/wp-admin/'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
     71                        echo "<p>" . apply_filters( "myblogs_blog_actions", "<a href='{$user_blog->homeurl}'>" . __( 'Visit' ) . "</a> | <a href='{$user_blog->siteurl}/wp-admin/'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
    7272                        echo apply_filters( 'myblogs_options', '', $user_blog );
    7373                        echo "</td>";
    7474                }
  • wp-includes/link-template.php

     
    18361836        if ( empty($blog_id) || !is_multisite() )
    18371837                $home = get_option('home');
    18381838        else
    1839                 $home = untrailingslashit(get_blogaddress_by_id($blog_id));
     1839                $home = get_blog_option($blog_id,'home');
    18401840
    18411841        $url = str_replace( 'http://', "$scheme://", $home );
    18421842
     
    18981898        if ( empty($blog_id) || !is_multisite() )
    18991899                $url = get_option('siteurl');
    19001900        else
    1901                 $url = untrailingslashit(get_blogaddress_by_id($blog_id));
    1902 
     1901                $url = get_blog_option($blog_id,'siteurl');
    19031902        $url = str_replace( 'http://', "{$scheme}://", $url );
    19041903
    19051904        if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
    19061905                $url .= '/' . ltrim($path, '/');
    1907 
    19081906        return apply_filters('site_url', $url, $path, $orig_scheme, $blog_id);
    19091907}
    19101908
  • wp-includes/ms-blogs.php

     
    1919}
    2020
    2121function get_blogaddress_by_id( $blog_id ) {
    22         $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
    23         return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
     22        return get_blog_option($blog_id,'home');
    2423}
    2524
    2625function get_blogaddress_by_name( $blogname ) {
     
    2928        if ( is_subdomain_install() ) {
    3029                if ( $blogname == 'main' )
    3130                        $blogname = 'www';
    32                 return esc_url( 'http://' . $blogname . '.' . $current_site->domain . $current_site->path );
     31                return esc_url( 'http://' . $blogname . '.' . trailingslashit($current_site->homeurl) );
    3332        } else {
    34                 return esc_url( 'http://' . $current_site->domain . $current_site->path . $blogname . '/' );
     33                return esc_url( 'http://' . trailingslashit($current_site->homeurl) . $blogname . '/' );
    3534        }
    3635}
    3736
    3837function get_blogaddress_by_domain( $domain, $path ){
    3938        if ( is_subdomain_install() ) {
    40                 $url = "http://".$domain.$path;
     39                $url = "http://".$domain;
    4140        } else {
    4241                if ( $domain != $_SERVER['HTTP_HOST'] ) {
    4342                        $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
     
    165164                wp_cache_set( $blog_id . $all, $details, 'blog-details' );
    166165                return $details;
    167166        }
    168 
     167        $details->homeurl               = get_blog_option( $blog_id, 'home');
    169168        $details->blogname              = get_blog_option( $blog_id, 'blogname' );
    170169        $details->siteurl               = get_blog_option( $blog_id, 'siteurl' );
    171170        $details->post_count    = get_blog_option( $blog_id, 'post_count' );
  • wp-includes/ms-functions.php

     
    6868                                $blogs[ $blog_id ]->path                        = $blog->path;
    6969                                $blogs[ $blog_id ]->site_id             = $blog->site_id;
    7070                                $blogs[ $blog_id ]->siteurl             = $blog->siteurl;
     71                                $blogs[ $blog_id ]->homeurl             = $blog->homeurl;                               
    7172                        }
    7273                }
    7374        }
  • 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,$sitepath;
     100        $sitepath = defined('PATH_WP_INSTALL') ? PATH_WP_INSTALL:'';
    100101        if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
    101102                $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->sitepath = $sitepath;
    104106                if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
    105107                        $current_site->blog_id = BLOG_ID_CURRENT_SITE;
    106108                elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
     
    111113                        $current_site->cookie_domain = substr( $current_site->domain, 4 );
    112114                else
    113115                        $current_site->cookie_domain = $current_site->domain;
    114 
     116                if(is_subdomain_install()){
     117                        $current_site->homeurl=$current_site->domain;
     118                        $current_site->siteurl=$current_site->domain.$current_site->sitepath;
     119                }else{
     120                        $current_site->homeurl=$current_site->domain.$current_site->path;
     121                        $current_site->siteurl=$current_site->domain.$current_site->path.$current_site->sitepath;                       
     122                }
    115123                wp_load_core_site_options( $current_site->id );
    116124
    117125                return $current_site;
     
    120128        $current_site = wp_cache_get( 'current_site', 'site-options' );
    121129        if ( $current_site )
    122130                return $current_site;
    123 
     131       
    124132        $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site
    125133        if ( 1 == count( $sites ) ) {
    126134                $current_site = $sites[0];
     
    130138                $current_site = get_current_site_name( $current_site );
    131139                if ( substr( $current_site->domain, 0, 4 ) == 'www.' )
    132140                        $current_site->cookie_domain = substr( $current_site->domain, 4 );
     141                $current_site->sitepath = $sitepath;                   
     142                if(is_subdomain_install()){
     143                        $current_site->homeurl=$current_site->domain;
     144                        $current_site->siteurl=$current_site->domain.$current_site->sitepath;
     145                }else{
     146                        $current_site->homeurl=$current_site->domain.$current_site->path;
     147                        $current_site->siteurl=$current_site->domain.$current_site->path.$current_site->sitepath;                       
     148                }               
    133149                wp_cache_set( 'current_site', $current_site, 'site-options' );
    134150                return $current_site;
    135151        }
     
    150166        if ( $current_site ) {
    151167                $path = $current_site->path;
    152168                $current_site->cookie_domain = $cookie_domain;
     169                $current_site->sitepath = $sitepath;   
     170                if(is_subdomain_install()){
     171                        $current_site->homeurl=$current_site->domain;
     172                        $current_site->siteurl=$current_site->domain.$current_site->sitepath;
     173                }else{
     174                        $current_site->homeurl=$current_site->domain.$current_site->path;
     175                        $current_site->siteurl=$current_site->domain.$current_site->path.$current_site->sitepath;                       
     176                }               
    153177                return $current_site;
    154178        }
    155179
     
    157181                $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
    158182                $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
    159183                if ( $current_site ) {
     184                        $current_site->sitepath = $sitepath;                   
    160185                        $current_site->cookie_domain = $current_site->domain;
     186                        $current_site->homeurl=$current_site->domain;
     187                        $current_site->siteurl=$current_site->domain.$current_site->sitepath;   
    161188                        return $current_site;
    162189                }
    163 
    164190                $current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $sitedomain) );
    165191        }
    166192
    167193        if ( $current_site || defined( 'WP_INSTALLING' ) ) {
    168                 $path = '/';
     194                $path = '/';   
     195                $current_site->sitepath = $sitepath;   
     196                if(is_subdomain_install()){
     197                        $current_site->homeurl=$current_site->domain;
     198                        $current_site->siteurl=$current_site->domain.$current_site->sitepath;
     199                }else{
     200                        $current_site->homeurl=$current_site->domain.$current_site->path;
     201                        $current_site->siteurl=$current_site->domain.$current_site->path.$current_site->sitepath;                       
     202                }       
    169203                return $current_site;
    170204        }
    171205