get_current_network_id

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

WordPress Version: 4.7

/**
 * Retrieves the current network ID.
 *
 * @since 4.6.0
 *
 * @return int The ID of the current network.
 */
function get_current_network_id()
{
    if (!is_multisite()) {
        return 1;
    }
    $current_network = get_network();
    if (!isset($current_network->id)) {
        return get_main_network_id();
    }
    return absint($current_network->id);
}

WordPress Version: 4.6

/**
 * Retrieves the current network ID.
 *
 * @since 4.6.0
 *
 * @global WP_Network $current_site The current network.
 *
 * @return int The ID of the current network.
 */
function get_current_network_id()
{
    if (!is_multisite()) {
        return 1;
    }
    $current_site = get_current_site();
    if (!isset($current_site->id)) {
        return get_main_network_id();
    }
    return absint($current_site->id);
}