WordPress.org

Make WordPress Core

Ticket #12735: fix-get_blogadd-net_site-site_path.patch

File fix-get_blogadd-net_site-site_path.patch, 4.9 KB (added by andreasnrb, 4 years ago)

Fixes get_blogaddress_*, network_site_url,get_site_url, get_home_url, adds site_path support, to currsite & ms-default-constants

  • 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

     
    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 ) { 
    2726        global $current_site; 
    2827 
    2928        if ( is_subdomain_install() ) { 
     29                if(strpos($current_site->domain,$blogname)!==false) 
     30                        return esc_url('http://'.$current_site->domain . $current_site->path);           
    3031                if ( $blogname == 'main' ) 
    3132                        $blogname = 'www'; 
    3233                return esc_url( 'http://' . $blogname . '.' . $current_site->domain . $current_site->path ); 
    3334        } else { 
     35                if(strpos($current_site->path,$blogname)!==false) 
     36                        return esc_url( 'http://' . $current_site->domain . $current_site->path); 
    3437                return esc_url( 'http://' . $current_site->domain . $current_site->path . $blogname . '/' ); 
    3538        } 
    3639} 
  • 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-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