get_main_site_id

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

WordPress Version: 4.9

/**
 * Gets the main site ID.
 *
 * @since 4.9.0
 *
 * @param int $network_id Optional. The ID of the network for which to get the main site.
 *                        Defaults to the current network.
 * @return int The ID of the main site.
 */
function get_main_site_id($network_id = null)
{
    if (!is_multisite()) {
        return get_current_blog_id();
    }
    $network = get_network($network_id);
    if (!$network) {
        return 0;
    }
    return $network->site_id;
}