get_blogaddress_by_id

The timeline below displays how wordpress function get_blogaddress_by_id has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Gets a full site URL, given a site ID.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id Site ID.
 * @return string Full site URL if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_site((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 6.2

/**
 * Gets a full blog URL, given a blog ID.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id Blog ID.
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_site((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 5.5

/**
 * Get a full blog URL, given a blog ID.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id Blog ID.
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_site((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 5.3

/**
 * Get a full blog URL, given a blog id.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id Blog ID.
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_site((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 4.9

/**
 * Get a full blog URL, given a blog id.
 *
 * @since MU (3.0.0)
 *
 * @param int $blog_id Blog ID
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_site((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 4.7

/**
 * Get a full blog URL, given a blog id.
 *
 * @since MU
 *
 * @param int $blog_id Blog ID
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_site((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 4.4

/**
 * Get a full blog URL, given a blog id.
 *
 * @since MU
 *
 * @param int $blog_id Blog ID
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_blog_details((int) $blog_id);
    if (empty($bloginfo)) {
        return '';
    }
    $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME);
    $scheme = empty($scheme) ? 'http' : $scheme;
    return esc_url($scheme . '://' . $bloginfo->domain . $bloginfo->path);
}

WordPress Version: 4.2

/**
 * Get a full blog URL, given a blog id.
 *
 * @since MU
 *
 * @param int $blog_id Blog ID
 * @return string Full URL of the blog if found. Empty string if not.
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_blog_details((int) $blog_id, false);
    // only get bare details!
    return $bloginfo ? esc_url('http://' . $bloginfo->domain . $bloginfo->path) : '';
}

WordPress Version: 3.7

/**
 * Get a full blog URL, given a blog id.
 *
 * @since MU
 *
 * @param int $blog_id Blog ID
 * @return string
 */
function get_blogaddress_by_id($blog_id)
{
    $bloginfo = get_blog_details((int) $blog_id, false);
    // only get bare details!
    return esc_url('http://' . $bloginfo->domain . $bloginfo->path);
}