network_home_url
函数
network_home_url ( $path = '', $scheme = null )
- 参数
-
-
(string)
$path
Optional. Path relative to the home URL. Default empty.- Required: 否
- Default: (empty)
-
(string|null)
$scheme
Optional. Scheme to give the home URL context. Accepts ‘http’, ‘https’, or ‘relative’. Default null.- Required: 否
- Default: null
-
(string)
- 返回值
-
- (string) Home URL link with optional path appended.
- 定义位置
-
-
wp-includes/link-template.php
, line 3662
-
wp-includes/link-template.php
- 引入
- 3.0.0
- 弃用
- –
检索当前网络的主页URL。
返回带有适当协议的主页URL,’https’是_ssl(),否则是’http’。如果`$scheme`是’http’或’https’,`is_ssl()’将被重写。
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 ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。