Make WordPress Core


Ignore:
Timestamp:
10/30/2015 02:01:32 AM (9 years ago)
Author:
johnbillion
Message:

Ensure that the scheme used in the URL returned by get_blogaddress_by_id() always reflects the blog's URL, instead of using http.

Props thomaswm
Fixes #14867

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-blogs.php

    r35170 r35446  
    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 );
     42
     43    if ( empty( $bloginfo ) ) {
     44        return '';
     45    }
     46
     47    $scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME );
     48    $scheme = empty( $scheme ) ? 'http' : $scheme;
     49
     50    return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path );
    4351}
    4452
     
    217225
    218226    switch_to_blog( $blog_id );
    219     $details->blogname      = get_option( 'blogname' );
    220     $details->siteurl       = get_option( 'siteurl' );
    221     $details->post_count    = get_option( 'post_count' );
     227    $details->blogname   = get_option( 'blogname' );
     228    $details->siteurl    = get_option( 'siteurl' );
     229    $details->post_count = get_option( 'post_count' );
     230    $details->home       = get_option( 'home' );
    222231    restore_current_blog();
    223232
Note: See TracChangeset for help on using the changeset viewer.