is_main_site()
is_main_site( int $site_id = null, int $network_id = nu…
is_main_site( int $site_id = null, int $network_id = null )
确定站点是否为当前网络的主站点。
Determine whether a site is the main site of the current network.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 | 
|---|---|---|---|
| $site_id | (int) | 可选 | 要测试的站点ID。默认为当前站点。 | 
| $network_id | (int) | 可选 | 要检查的网络的网络ID。默认为当前网络。 | 
返回(Return)
(bool)如果$site_id是网络的主站点,或者如果不运行多站点,则为True。
源码(Source)
/**
 * Determine whether a site is the main site of the current network.
 *
 * @since 3.0.0
 *
 * @global object $current_site
 *
 * @param int $site_id Optional. Site ID to test. Defaults to current site.
 *                     Defaults to current site.
 * @return bool True if $site_id is the main site of the network, or if not
 *              running Multisite.
 */
function is_main_site( $site_id = null ) {
	// This is the current network's information; 'site' is old terminology.
	global $current_site;
	if ( ! is_multisite() )
		return true;
	if ( ! $site_id )
		$site_id = get_current_blog_id();
	return (int) $site_id === (int) $current_site->blog_id;
}| 更新版本 | 源码位置 | 使用 | 被使用 | 
|---|---|---|---|
| 4.9.0 | wp-includes/functions.php:5453 | 16 | 3 | 
笔记(Notes)
例子
类别:WordPress 函数手册、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。






还没有任何评论,赶紧来占个楼吧!