get_network() WordPress Function

The get_network() function is used to get the network object for a given network ID.

get_network( WP_Network|int|null $network = null ) #

Retrieves network data given a network ID or network object.


Description

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


Top ↑

Parameters

$network

(WP_Network|int|null)(Optional) Network to retrieve. Default is the current network.

Default value: null


Top ↑

Return

(WP_Network|null) The network object or null if not found.


Top ↑

Source

File: wp-includes/ms-network.php

function get_network( $network = null ) {
	global $current_site;
	if ( empty( $network ) && isset( $current_site ) ) {
		$network = $current_site;
	}

	if ( $network instanceof WP_Network ) {
		$_network = $network;
	} elseif ( is_object( $network ) ) {
		$_network = new WP_Network( $network );
	} else {
		$_network = WP_Network::get_instance( $network );
	}

	if ( ! $_network ) {
		return null;
	}

	/**
	 * Fires after a network is retrieved.
	 *
	 * @since 4.6.0
	 *
	 * @param WP_Network $_network Network data.
	 */
	$_network = apply_filters( 'get_network', $_network );

	return $_network;
}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.