Make WordPress Core

Ticket #14867: 14867.2.diff

File 14867.2.diff, 1.1 KB (added by thomaswm, 10 years ago)

Derive scheme from site's home URL

  • wp-includes/ms-blogs.php

     
    3838 * @return string Full URL of the blog if found. Empty string if not.
    3939 */
    4040function get_blogaddress_by_id( $blog_id ) {
    41         $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
    42         return ( $bloginfo ) ? esc_url( 'http://' . $bloginfo->domain . $bloginfo->path ) : '';
     41        $bloginfo = get_blog_details( (int) $blog_id, true ); // get all details
     42        if ( empty( $bloginfo ) ) {
     43                return '';
     44        }
     45       
     46        // Derive the site's scheme from its home URL
     47        $scheme = parse_url( $bloginfo->homeurl, PHP_URL_SCHEME );
     48        $scheme = empty( $scheme ) ? 'http' : $scheme;
     49        return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path ) : '';
    4350}
    4451
    4552/**
     
    218225        switch_to_blog( $blog_id );
    219226        $details->blogname              = get_option( 'blogname' );
    220227        $details->siteurl               = get_option( 'siteurl' );
     228        $details->homeurl               = get_option( 'home' );
    221229        $details->post_count    = get_option( 'post_count' );
    222230        restore_current_blog();
    223231