WordPress Version: 6.3
/**
* Gets a full site URL, given a site name.
*
* @since MU (3.0.0)
*
* @param string $blogname Name of the subdomain or directory.
* @return string
*/
function get_blogaddress_by_name($blogname)
{
if (is_subdomain_install()) {
if ('main' === $blogname) {
$blogname = 'www';
}
$url = rtrim(network_home_url(), '/');
if (!empty($blogname)) {
$url = preg_replace('|^([^\.]+://)|', '${1}' . $blogname . '.', $url);
}
} else {
$url = network_home_url($blogname);
}
return esc_url($url . '/');
}