get_network
Retrieves network data given a network ID or network object.
Description
(WP_Network|null) get_network( (null) $network = null );
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.
Returns (WP_Network|null)
The network object or null if not found.
Parameters (1)
- 0. $network — Optional. (null) =>
null
- Network to retrieve. Default is the current network.
Usage
if ( !function_exists( 'get_network' ) ) { require_once ABSPATH . WPINC . '/ms-blogs.php'; } // Optional. Network to retrieve. Default is the current network. $network = null; // NOTICE! Understand what this does before running. $result = get_network($network);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/ms-blogs.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;
- }