Make WordPress Core

Changeset 16987


Ignore:
Timestamp:
12/16/2010 07:58:57 AM (16 years ago)
Author:
nacin
Message:

Add scheme arguments to get_blogaddress_by_domain and get_blogaddress_by_id. props adambackstrom for initial patch, fixes #14867.

File:
1 edited

Legend:

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

    r16938 r16987  
    3131 *
    3232 * @param int $blog_id Blog ID
     33 * @param  string $scheme Optional. Scheme to give the URL. Currently 'http', 'https'
    3334 * @return string
    3435 */
    35 function get_blogaddress_by_id( $blog_id ) {
     36function get_blogaddress_by_id( $blog_id, $scheme = null ) {
     37        if ( ! in_array( $scheme, array( 'http', 'https' ) ) )
     38                $scheme = is_ssl() ? 'https' : 'http';
     39
    3640        $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
    37         return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
     41        return esc_url( "$scheme://" . $bloginfo->domain . $bloginfo->path );
    3842}
    3943
    … …  
    6872 * @param string $domain
    6973 * @param string $path
     74 * @param  string $scheme Optional. Scheme to give the URL. Currently 'http', 'https'
    7075 * @return string
    7176 */
    72 function get_blogaddress_by_domain( $domain, $path ) {
     77function get_blogaddress_by_domain( $domain, $path, $scheme = null ) {
     78        if ( ! in_array( $scheme, array( 'http', 'https' ) ) )
     79                $scheme = is_ssl() ? 'https' : 'http';
     80
    7381        if ( is_subdomain_install() ) {
    74                 $url = "http://".$domain.$path;
     82                $url = "$scheme://" . $domain.$path;
    7583        } else {
    7684                if ( $domain != $_SERVER['HTTP_HOST'] ) {
    7785                        $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
    78                         $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
     86                        $url = "$scheme://" . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
    7987                        // we're not installing the main blog
    8088                        if ( $blogname != 'www.' )
    8189                                $url .= $blogname . '/';
    8290                } else { // main blog
    83                         $url = 'http://' . $domain . $path;
     91                        $url = "$scheme://" . $domain . $path;
    8492                }
    8593        }
Note: See TracChangeset for help on using the changeset viewer.