# network_home_url()

URL: https://chugunov.pro/api-wordpress/functions/network_home_url/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.0.0.

## Сигнатура

```php
network_home_url( string $path = '', string|null $scheme = null ): string
```

## Описание

Возвращает домашний URL с подходящим протоколом: «https» is_ssl() и «http» в остальных случаях. Если $scheme равен «http» или «https», значение is_ssl() переопределяется.

## Параметры

- `$path` `string` — необязательный, по умолчанию `''`. Путь относительно домашнего URL.
- `$scheme` `string|null` — необязательный, по умолчанию `null`. Схема, задающая контекст домашнего URL. Принимает 'http', 'https' или 'relative'.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/link-template.php:3784`

```php
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 );
}
```

## История изменений

- 3.0.0 — Introduced.

## Связанные

Использует: [`get_network`](https://chugunov.pro/api-wordpress/functions/get_network/), [`is_ssl`](https://chugunov.pro/api-wordpress/functions/is_ssl/), [`set_url_scheme`](https://chugunov.pro/api-wordpress/functions/set_url_scheme/), [`is_multisite`](https://chugunov.pro/api-wordpress/functions/is_multisite/), [`home_url`](https://chugunov.pro/api-wordpress/functions/home_url/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`update_network_option_new_admin_email`](https://chugunov.pro/api-wordpress/functions/update_network_option_new_admin_email/), `WP_Automatic_Updater::send_debug_email`, [`wxr_site_url`](https://chugunov.pro/api-wordpress/functions/wxr_site_url/), [`wp_install_defaults`](https://chugunov.pro/api-wordpress/functions/wp_install_defaults/), [`wp_notify_postauthor`](https://chugunov.pro/api-wordpress/functions/wp_notify_postauthor/), [`wp_mail`](https://chugunov.pro/api-wordpress/functions/wp_mail/), [`wpmu_welcome_user_notification`](https://chugunov.pro/api-wordpress/functions/wpmu_welcome_user_notification/), [`maybe_redirect_404`](https://chugunov.pro/api-wordpress/functions/maybe_redirect_404/), [`wpmu_welcome_notification`](https://chugunov.pro/api-wordpress/functions/wpmu_welcome_notification/), [`wpmu_signup_blog_notification`](https://chugunov.pro/api-wordpress/functions/wpmu_signup_blog_notification/), [`wpmu_signup_user_notification`](https://chugunov.pro/api-wordpress/functions/wpmu_signup_user_notification/), [`get_blogaddress_by_name`](https://chugunov.pro/api-wordpress/functions/get_blogaddress_by_name/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/network_home_url/
