Summery Summery
Sets the scheme for a URL.
Syntax Syntax
Parameters Parameters
- $url
-
(Required) Absolute URL that includes a scheme
- $scheme
-
(Optional) Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', 'relative', 'rest', 'rpc', or null.
Default value: null
Return Return
(string) $url URL with chosen scheme.
Source Source
File: wp-includes/link-template.php
* * @param string $url The complete URL including scheme and path. * @param string $path Path relative to the URL. Blank string if no path is specified. * @param string $scheme The scheme to use. */ return apply_filters( 'self_admin_url', $url, $path, $scheme ); } /** * Sets the scheme for a URL. * * @since 3.4.0 * @since 4.4.0 The 'rest' scheme was added. * * @param string $url Absolute URL that includes a scheme * @param string|null $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', * 'login_post', 'admin', 'relative', 'rest', 'rpc', or null. Default null. * @return string URL with chosen scheme. */ 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 ) );
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.4.0 | The 'rest' scheme was added. |
3.4.0 | Introduced. |