返回介绍

get_site()

发布于 2017-09-11 00:10:53 字数 2990 浏览 949 评论 0 收藏 0

get_site( WP_Site|int|null $site = null )

Retrieves site data given a site ID or site object.


description

Site data will be cached and returned after being passed through a filter. If the provided site is empty, the current site global will be used.


参数

$site

(WP_Site|int|null) (Optional) Site to retrieve. Default is the current site.

Default value: null


返回值

(WP_Site|null) The site object or null if not found.


源代码

File: wp-includes/ms-blogs.php

function get_site( $site = null ) {
	if ( empty( $site ) ) {
		$site = get_current_blog_id();
	}

	if ( $site instanceof WP_Site ) {
		$_site = $site;
	} elseif ( is_object( $site ) ) {
		$_site = new WP_Site( $site );
	} else {
		$_site = WP_Site::get_instance( $site );
	}

	if ( ! $_site ) {
		return null;
	}

	/**
	 * Fires after a site is retrieved.
	 *
	 * @since 4.6.0
	 *
	 * @param WP_Site $_site Site data.
	 */
	$_site = apply_filters( 'get_site', $_site );

	return $_site;
}

更新日志

Versiondescription
4.6.0Introduced.

相关函数

Uses

  • wp-includes/ms-blogs.php: get_site
  • wp-includes/class-wp-site.php: WP_Site::__construct()
  • wp-includes/class-wp-site.php: WP_Site::get_instance()
  • wp-includes/load.php: get_current_blog_id()
  • wp-includes/plugin.php: apply_filters()

Used By

  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::create_item()
  • wp-includes/class-wp-site-query.php: WP_Site_Query::get_sites()
  • wp-admin/includes/ms.php: wpmu_delete_blog()
  • wp-includes/user.php: is_user_member_of_blog()
  • wp-includes/ms-deprecated.php: wp_get_sites()
  • wp-includes/ms-functions.php: get_active_blog_for_user()
  • wp-includes/ms-functions.php: add_user_to_blog()
  • wp-includes/ms-load.php: ms_site_check()
  • wp-includes/ms-deprecated.php: get_dashboard_blog()
  • wp-includes/ms-blogs.php: get_blog_status()
  • wp-includes/ms-blogs.php: refresh_blog_details()
  • wp-includes/ms-blogs.php: update_blog_details()
  • wp-includes/ms-blogs.php: get_blogaddress_by_id()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::_multisite_getUsersBlogs()
  • Show 9 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文