network_home_url

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

WordPress Version: 5.7

/**
 * Retrieves the home URL for the current network.
 *
 * Returns the home URL with the appropriate protocol, 'https' is_ssl()
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param string      $path   Optional. Path relative to the home URL. Default empty.
 * @param string|null $scheme Optional. Scheme to give the home URL context. Accepts
 *                            'http', 'https', or 'relative'. Default null.
 * @return string Home URL link with optional path appended.
 */
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_network = get_network();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'), true)) {
        $scheme = is_ssl() ? 'https' : 'http';
    }
    if ('relative' === $scheme) {
        $url = $current_network->path;
    } else {
        $url = set_url_scheme('http://' . $current_network->domain . $current_network->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filters the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 5.5

/**
 * Retrieves the home URL for the current network.
 *
 * Returns the home URL with the appropriate protocol, 'https' is_ssl()
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param string $path   Optional. Path relative to the home URL. Default empty.
 * @param string $scheme Optional. Scheme to give the home URL context. Accepts
 *                       'http', 'https', or 'relative'. Default null.
 * @return string Home URL link with optional path appended.
 */
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_network = get_network();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'), true)) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' === $scheme) {
        $url = $current_network->path;
    } else {
        $url = set_url_scheme('http://' . $current_network->domain . $current_network->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filters the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 4.7

/**
 * Retrieves the home URL for the current network.
 *
 * Returns the home URL with the appropriate protocol, 'https' is_ssl()
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param  string $path   Optional. Path relative to the home URL. Default empty.
 * @param  string $scheme Optional. Scheme to give the home URL context. Accepts
 *                        'http', 'https', or 'relative'. Default null.
 * @return string Home URL link with optional path appended.
 */
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_network = get_network();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_network->path;
    } else {
        $url = set_url_scheme('http://' . $current_network->domain . $current_network->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filters the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 4.6

/**
 * Retrieves the home URL for the current network.
 *
 * Returns the home URL with the appropriate protocol, 'https' is_ssl()
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param  string $path   Optional. Path relative to the home URL. Default empty.
 * @param  string $scheme Optional. Scheme to give the home URL context. Accepts
 *                        'http', 'https', or 'relative'. Default null.
 * @return string Home URL link with optional path appended.
 */
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_site = get_current_site();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_site->path;
    } else {
        $url = set_url_scheme('http://' . $current_site->domain . $current_site->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filters the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 4.5

/**
 * Retrieves the home url for the current network.
 *
 * Returns the home url with the appropriate protocol, 'https' {@see is_ssl()}
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param  string $path   Optional. Path relative to the home url. Default empty.
 * @param  string $scheme Optional. Scheme to give the home url context. Accepts
 *                        'http', 'https', or 'relative'. Default null.
 * @return string Home url link with optional path appended.
 */
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_site = get_current_site();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_site->path;
    } else {
        $url = set_url_scheme('http://' . $current_site->domain . $current_site->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filter the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 4.1

/**
 * Retrieves the home url for the current network.
 *
 * Returns the home url with the appropriate protocol, 'https' {@see is_ssl()}
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param  string $path   Optional. Path relative to the home url. Default empty.
 * @param  string $scheme Optional. Scheme to give the home url context. Accepts
 *                        'http', 'https', or 'relative'. Default null.
 * @return string Home url link with optional path appended.
*/
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_site = get_current_site();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_site->path;
    } else {
        $url = set_url_scheme('http://' . $current_site->domain . $current_site->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filter the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 3.9

/**
 * Retrieve the home url for the current network.
 *
 * Returns the home url with the appropriate protocol, 'https' if
 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
 * overridden.
 *
 * @since 3.0.0
 *
 * @param  string $path   (optional) Path relative to the home url.
 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
 * @return string Home url link with optional path appended.
*/
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_site = get_current_site();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_site->path;
    } else {
        $url = set_url_scheme('http://' . $current_site->domain . $current_site->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    /**
     * Filter the network home URL.
     *
     * @since 3.0.0
     *
     * @param string      $url         The complete network home URL including scheme and path.
     * @param string      $path        Path relative to the network home URL. Blank string
     *                                 if no path is specified.
     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
     *                                 'relative' or null.
     */
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 3.8

/**
 * Retrieve the home url for the current network.
 *
 * Returns the home url with the appropriate protocol, 'https' if
 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
 * overridden.
 *
 * @package WordPress
 * @since 3.0.0
 *
 * @param  string $path   (optional) Path relative to the home url.
 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
 * @return string Home url link with optional path appended.
*/
function network_home_url($path = '', $scheme = null)
{
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $current_site = get_current_site();
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_site->path;
    } else {
        $url = set_url_scheme('http://' . $current_site->domain . $current_site->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}

WordPress Version: 3.7

/**
 * Retrieve the home url for the current network.
 *
 * Returns the home url with the appropriate protocol, 'https' if
 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
 * overridden.
 *
 * @package WordPress
 * @since 3.0.0
 *
 * @param  string $path   (optional) Path relative to the home url.
 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
 * @return string Home url link with optional path appended.
*/
function network_home_url($path = '', $scheme = null)
{
    global $current_site;
    if (!is_multisite()) {
        return home_url($path, $scheme);
    }
    $orig_scheme = $scheme;
    if (!in_array($scheme, array('http', 'https', 'relative'))) {
        $scheme = (is_ssl() && !is_admin()) ? 'https' : 'http';
    }
    if ('relative' == $scheme) {
        $url = $current_site->path;
    } else {
        $url = set_url_scheme('http://' . $current_site->domain . $current_site->path, $scheme);
    }
    if ($path && is_string($path)) {
        $url .= ltrim($path, '/');
    }
    return apply_filters('network_home_url', $url, $path, $orig_scheme);
}