set_url_scheme
函数
set_url_scheme ( $url, $scheme = null )
- 参数
-
-
(string)
$url
Absolute URL that includes a scheme- Required: 是
-
(string|null)
$scheme
Optional. Scheme to give $url. Currently ‘http’, ‘https’, ‘login’, ‘login_post’, ‘admin’, ‘relative’, ‘rest’, ‘rpc’, or null. Default null.- Required: 否
- Default: null
-
(string)
- 返回值
-
- (string) URL with chosen scheme.
- 定义位置
-
-
wp-includes/link-template.php
, line 3808
-
wp-includes/link-template.php
- 引入
- 3.4.0
- 弃用
- –
设置一个URL的方案。
function set_url_scheme( $url, $scheme = null ) { $orig_scheme = $scheme; if ( ! $scheme ) { $scheme = is_ssl() ? 'https' : 'http'; } elseif ( 'admin' === $scheme || 'login' === $scheme || 'login_post' === $scheme || 'rpc' === $scheme ) { $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; } elseif ( 'http' !== $scheme && 'https' !== $scheme && 'relative' !== $scheme ) { $scheme = is_ssl() ? 'https' : 'http'; } $url = trim( $url ); if ( substr( $url, 0, 2 ) === '//' ) { $url = 'http:' . $url; } if ( 'relative' === $scheme ) { $url = ltrim( preg_replace( '#^w+://[^/]*#', '', $url ) ); if ( '' !== $url && '/' === $url[0] ) { $url = '/' . ltrim( $url, "/ tnrx0B" ); } } else { $url = preg_replace( '#^w+://#', $scheme . '://', $url ); } /** * Filters the resulting URL after setting the scheme. * * @since 3.4.0 * * @param string $url The complete URL including scheme and path. * @param string $scheme Scheme applied to the URL. One of 'http', 'https', or 'relative'. * @param string|null $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login', * 'login_post', 'admin', 'relative', 'rest', 'rpc', or null. */ return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。