get_site

Advertisement

Summery Summery

Retrieves site data given a site ID or site object.

Syntax Syntax

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

Description 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.

Parameters Parameters

$site

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

Default value: null

Return Return

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

Source Source

File: wp-includes/ms-site.php

 * If the provided site is empty, the current site global will be used.
 *
 * @since 4.6.0
 *
 * @param WP_Site|int|null $site Optional. Site to retrieve. Default is the current site.
 * @return WP_Site|null The site object or null if not found.
 */
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

Advertisement

Changelog Changelog

Changelog
Version Description
4.6.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.