函数文档

get_current_site()

💡 云策文档标注

概述

get_current_site() 函数用于获取当前网络对象,返回包含网络属性的 WP_Network 实例。此函数源自 WordPress MU,名称基于旧术语,实际返回网络信息而非站点信息。

关键要点

  • 返回 WP_Network 对象,包含 id、domain、path 和 site_name 属性
  • 函数名基于旧术语,实际获取当前网络,而非当前站点
  • 相关函数:wpmu_current_site()、get_current_blog_id()、get_blog_details()
  • 自 MU (3.0.0) 版本引入

注意事项

注意:此函数名称中的“site”指旧术语中的网络,实际返回网络信息。要获取当前站点信息,请使用 get_current_blog_id() 或 get_blog_details()。


📄 原文内容

Gets the current network.

Description

Returns an object containing the ‘id’, ‘domain’, ‘path’, and ‘site_name’ properties of the network being viewed.

See also

Return

WP_Network The current network.

Source

function get_current_site() {
	global $current_site;
	return $current_site;
}

Changelog

Version Description
MU (3.0.0) Introduced.

User Contributed Notes

  1. Skip to note 2 content

    An importante note from the original Codex page:

    Note: get_current_site() was inherited from MU, and is named based on the old terminology which spoke of multiple “blogs” on a “site”. We now speak of multiple “sites” on a “network” instead, but some of the old terminology still lives on in some function names. This function returns information about the current network. To get information about the current site on the network, see get_current_blog_id() and get_blog_details() .