get_blogaddress_by_id()

最后更新于:2021-11-26 05:56:20

get_blogaddress_by_id( int$blog_id)

Get a full blog URL, given a blog ID.

参数

$blog_id

(int) (Required) Blog ID.

响应

(string) Full URL of the blog if found. Empty string if not.

源文件

文件: gc-includes/ms-blogs.php

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 );
}