get_network_option

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

WordPress Version: 6.2

/**
 * Retrieves a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $network_id    ID of the network. Can be null to default to the current network ID.
 * @param string $option        Name of the option to retrieve. Expected to not be SQL-escaped.
 * @param mixed  $default_value Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default_value = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters the value of an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Returning a value other than false from the filter will short-circuit retrieval
     * and return that value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     * @since 4.9.0 The `$default_value` parameter was added.
     *
     * @param mixed  $pre_option    The value to return instead of the option value. This differs from
     *                              `$default_value`, which is used as the fallback value in the event
     *                              the option doesn't exist elsewhere in get_network_option().
     *                              Default false (to skip past the short-circuit).
     * @param string $option        Option name.
     * @param int    $network_id    ID of the network.
     * @param mixed  $default_value The fallback value to return if the option does not exist.
     *                              Default false.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id, $default_value);
    if (false !== $pre) {
        return $pre;
    }
    // Prevent non-existent options from triggering multiple queries.
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (is_array($notoptions) && isset($notoptions[$option])) {
        /**
         * Filters the value of a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default_value The value to return if the site option does not exist
         *                              in the database.
         * @param string $option        Option name.
         * @param int    $network_id    ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default_value, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default_value = apply_filters('default_site_option_' . $option, $default_value, $option, $network_id);
        $value = get_option($option, $default_value);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default_value, $option, $network_id);
            }
        }
    }
    if (!is_array($notoptions)) {
        $notoptions = array();
        wp_cache_set($notoptions_key, $notoptions, 'site-options');
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 6.1

/**
 * Retrieves a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
 * @param string $option     Name of the option to retrieve. Expected to not be SQL-escaped.
 * @param mixed  $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters the value of an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Returning a value other than false from the filter will short-circuit retrieval
     * and return that value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     * @since 4.9.0 The `$default` parameter was added.
     *
     * @param mixed  $pre_option The value to return instead of the option value. This differs
     *                           from `$default`, which is used as the fallback value in the event
     *                           the option doesn't exist elsewhere in get_network_option().
     *                           Default false (to skip past the short-circuit).
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     * @param mixed  $default    The fallback value to return if the option does not exist.
     *                           Default false.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id, $default);
    if (false !== $pre) {
        return $pre;
    }
    // Prevent non-existent options from triggering multiple queries.
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (is_array($notoptions) && isset($notoptions[$option])) {
        /**
         * Filters the value of a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default    The value to return if the site option does not exist
         *                           in the database.
         * @param string $option     Option name.
         * @param int    $network_id ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
            }
        }
    }
    if (!is_array($notoptions)) {
        $notoptions = array();
        wp_cache_set($notoptions_key, $notoptions, 'site-options');
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 5.5

/**
 * Retrieves a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
 * @param string $option     Name of the option to retrieve. Expected to not be SQL-escaped.
 * @param mixed  $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters the value of an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Returning a truthy value from the filter will effectively short-circuit retrieval
     * and return the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     * @since 4.9.0 The `$default` parameter was added.
     *
     * @param mixed  $pre_option The value to return instead of the option value. This differs
     *                           from `$default`, which is used as the fallback value in the event
     *                           the option doesn't exist elsewhere in get_network_option().
     *                           Default false (to skip past the short-circuit).
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     * @param mixed  $default    The fallback value to return if the option does not exist.
     *                           Default false.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id, $default);
    if (false !== $pre) {
        return $pre;
    }
    // Prevent non-existent options from triggering multiple queries.
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (is_array($notoptions) && isset($notoptions[$option])) {
        /**
         * Filters a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default    The value to return if the site option does not exist
         *                           in the database.
         * @param string $option     Option name.
         * @param int    $network_id ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
            }
        }
    }
    if (!is_array($notoptions)) {
        $notoptions = array();
        wp_cache_set($notoptions_key, $notoptions, 'site-options');
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 5.4

/**
 * Retrieves a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Passing a truthy value to the filter will effectively short-circuit retrieval,
     * returning the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     * @since 4.9.0 The `$default` parameter was added.
     *
     * @param mixed  $pre_option The value to return instead of the option value. This differs from
     *                           `$default`, which is used as the fallback value in the event the
     *                           option doesn't exist elsewhere in get_network_option(). Default
     *                           is false (to skip past the short-circuit).
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     * @param mixed  $default    The fallback value to return if the option does not exist.
     *                           Default is false.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id, $default);
    if (false !== $pre) {
        return $pre;
    }
    // Prevent non-existent options from triggering multiple queries.
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (is_array($notoptions) && isset($notoptions[$option])) {
        /**
         * Filters a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default    The value to return if the site option does not exist
         *                           in the database.
         * @param string $option     Option name.
         * @param int    $network_id ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
            }
        }
    }
    if (!is_array($notoptions)) {
        $notoptions = array();
        wp_cache_set($notoptions_key, $notoptions, 'site-options');
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 5.1

/**
 * Retrieve a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Passing a truthy value to the filter will effectively short-circuit retrieval,
     * returning the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     * @since 4.9.0 The `$default` parameter was added.
     *
     * @param mixed  $pre_option The value to return instead of the option value. This differs from
     *                           `$default`, which is used as the fallback value in the event the
     *                           option doesn't exist elsewhere in get_network_option(). Default
     *                           is false (to skip past the short-circuit).
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     * @param mixed  $default    The fallback value to return if the option does not exist.
     *                           Default is false.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id, $default);
    if (false !== $pre) {
        return $pre;
    }
    // prevent non-existent options from triggering multiple queries
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (is_array($notoptions) && isset($notoptions[$option])) {
        /**
         * Filters a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default    The value to return if the site option does not exist
         *                           in the database.
         * @param string $option     Option name.
         * @param int    $network_id ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row instead of get_var because of funkiness with 0, false, null values
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
            }
        }
    }
    if (!is_array($notoptions)) {
        $notoptions = array();
        wp_cache_set($notoptions_key, $notoptions, 'site-options');
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 4.9

/**
 * Retrieve a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb
 *
 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Passing a truthy value to the filter will effectively short-circuit retrieval,
     * returning the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     * @since 4.9.0 The `$default` parameter was added.
     *
     * @param mixed  $pre_option The value to return instead of the option value. This differs from
     *                           `$default`, which is used as the fallback value in the event the
     *                           option doesn't exist elsewhere in get_network_option(). Default
     *                           is false (to skip past the short-circuit).
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     * @param mixed  $default    The fallback value to return if the option does not exist.
     *                           Default is false.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id, $default);
    if (false !== $pre) {
        return $pre;
    }
    // prevent non-existent options from triggering multiple queries
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (isset($notoptions[$option])) {
        /**
         * Filters a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default    The value to return if the site option does not exist
         *                           in the database.
         * @param string $option     Option name.
         * @param int    $network_id ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row instead of get_var because of funkiness with 0, false, null values
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
            }
        }
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 4.7

/**
 * Retrieve a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb $wpdb
 *
 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id) {
        $network_id = get_current_network_id();
    }
    /**
     * Filters an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Passing a truthy value to the filter will effectively short-circuit retrieval,
     * returning the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $pre_option The default value to return if the option does not exist.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    $pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id);
    if (false !== $pre) {
        return $pre;
    }
    // prevent non-existent options from triggering multiple queries
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (isset($notoptions[$option])) {
        /**
         * Filters a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         * @since 4.7.0 The `$network_id` parameter was added.
         *
         * @param mixed  $default    The value to return if the site option does not exist
         *                           in the database.
         * @param string $option     Option name.
         * @param int    $network_id ID of the network.
         */
        return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row instead of get_var because of funkiness with 0, false, null values
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option, $network_id);
            }
        }
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added.
     * @since 4.7.0 The `$network_id` parameter was added.
     *
     * @param mixed  $value      Value of network option.
     * @param string $option     Option name.
     * @param int    $network_id ID of the network.
     */
    return apply_filters("site_option_{$option}", $value, $option, $network_id);
}

WordPress Version: 4.6

/**
 * Retrieve a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb   $wpdb
 * @global object $current_site
 *
 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb, $current_site;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id && is_multisite()) {
        $network_id = $current_site->id;
    }
    /**
     * Filters an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Passing a truthy value to the filter will effectively short-circuit retrieval,
     * returning the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added
     *
     * @param mixed  $pre_option The default value to return if the option does not exist.
     * @param string $option     Option name.
     */
    $pre = apply_filters('pre_site_option_' . $option, false, $option);
    if (false !== $pre) {
        return $pre;
    }
    // prevent non-existent options from triggering multiple queries
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (isset($notoptions[$option])) {
        /**
         * Filters a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         *
         * @param mixed  $default The value to return if the site option does not exist
         *                        in the database.
         * @param string $option  Option name.
         */
        return apply_filters('default_site_option_' . $option, $default, $option);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row instead of get_var because of funkiness with 0, false, null values
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option);
            }
        }
    }
    /**
     * Filters the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added
     *
     * @param mixed  $value  Value of network option.
     * @param string $option Option name.
     */
    return apply_filters('site_option_' . $option, $value, $option);
}

WordPress Version: 4.4

/**
 * Retrieve a network's option value based on the option name.
 *
 * @since 4.4.0
 *
 * @see get_option()
 *
 * @global wpdb   $wpdb
 * @global object $current_site
 *
 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
 * @return mixed Value set for the option.
 */
function get_network_option($network_id, $option, $default = false)
{
    global $wpdb, $current_site;
    if ($network_id && !is_numeric($network_id)) {
        return false;
    }
    $network_id = (int) $network_id;
    // Fallback to the current network if a network ID is not specified.
    if (!$network_id && is_multisite()) {
        $network_id = $current_site->id;
    }
    /**
     * Filter an existing network option before it is retrieved.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * Passing a truthy value to the filter will effectively short-circuit retrieval,
     * returning the passed value instead.
     *
     * @since 2.9.0 As 'pre_site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added
     *
     * @param mixed  $pre_option The default value to return if the option does not exist.
     * @param string $option     Option name.
     */
    $pre = apply_filters('pre_site_option_' . $option, false, $option);
    if (false !== $pre) {
        return $pre;
    }
    // prevent non-existent options from triggering multiple queries
    $notoptions_key = "{$network_id}:notoptions";
    $notoptions = wp_cache_get($notoptions_key, 'site-options');
    if (isset($notoptions[$option])) {
        /**
         * Filter a specific default network option.
         *
         * The dynamic portion of the hook name, `$option`, refers to the option name.
         *
         * @since 3.4.0
         * @since 4.4.0 The `$option` parameter was added.
         *
         * @param mixed  $default The value to return if the site option does not exist
         *                        in the database.
         * @param string $option  Option name.
         */
        return apply_filters('default_site_option_' . $option, $default, $option);
    }
    if (!is_multisite()) {
        /** This filter is documented in wp-includes/option.php */
        $default = apply_filters('default_site_option_' . $option, $default, $option);
        $value = get_option($option, $default);
    } else {
        $cache_key = "{$network_id}:{$option}";
        $value = wp_cache_get($cache_key, 'site-options');
        if (!isset($value) || false === $value) {
            $row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
            // Has to be get_row instead of get_var because of funkiness with 0, false, null values
            if (is_object($row)) {
                $value = $row->meta_value;
                $value = maybe_unserialize($value);
                wp_cache_set($cache_key, $value, 'site-options');
            } else {
                if (!is_array($notoptions)) {
                    $notoptions = array();
                }
                $notoptions[$option] = true;
                wp_cache_set($notoptions_key, $notoptions, 'site-options');
                /** This filter is documented in wp-includes/option.php */
                $value = apply_filters('default_site_option_' . $option, $default, $option);
            }
        }
    }
    /**
     * Filter the value of an existing network option.
     *
     * The dynamic portion of the hook name, `$option`, refers to the option name.
     *
     * @since 2.9.0 As 'site_option_' . $key
     * @since 3.0.0
     * @since 4.4.0 The `$option` parameter was added
     *
     * @param mixed  $value  Value of network option.
     * @param string $option Option name.
     */
    return apply_filters('site_option_' . $option, $value, $option);
}