get_network

The timeline below displays how wordpress function get_network has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.1

/**
 * Network API
 *
 * @package WordPress
 * @subpackage Multisite
 * @since 5.1.0
 */
/**
 * Retrieves network data given a network ID or network object.
 *
 * 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.
 *
 * @since 4.6.0
 *
 * @global WP_Network $current_site
 *
 * @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network.
 * @return WP_Network|null The network object or null if not found.
 */
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;
}

WordPress Version: 4.6

/**
 * Retrieves network data given a network ID or network object.
 *
 * 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.
 *
 * @since 4.6.0
 *
 * @global WP_Network $current_site
 *
 * @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network.
 * @return WP_Network|null The network object or null if not found.
 */
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;
}