network_home_url()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
network_home_url( string $path = '', string|null $scheme = null ): string
Описание
Возвращает домашний URL с подходящим протоколом: «https» is_ssl() и «http» в остальных случаях. Если $scheme равен «http» или «https», значение is_ssl() переопределяется.
Оригинал (английский)
Returns the home URL with the appropriate protocol, ‘https’ is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.
Параметры
$path
string
необязательный
= ''
$scheme
string|null
необязательный
= null
Возвращаемое значение
string
Исходный код
wp-includes/link-template.php:3784
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. |

