Used By
| Used By | Description |
|---|---|
| wp-includes/canonical.php: redirect_canonical() | Redirects incoming links to the proper URL based on the site url. |
Strips the #fragment from a URL, if one is present.
(string) (Required) The URL to strip.
(string) The altered URL.
File: wp-includes/canonical.php
function strip_fragment_from_url( $url ) {
$parsed_url = parse_url( $url );
if ( ! empty( $parsed_url['host'] ) ) {
// This mirrors code in redirect_canonical(). It does not handle every case.
$url = $parsed_url['scheme'] . '://' . $parsed_url['host'];
if ( ! empty( $parsed_url['port'] ) ) {
$url .= ':' . $parsed_url['port'];
}
if ( ! empty( $parsed_url['path'] ) ) {
$url .= $parsed_url['path'];
}
if ( ! empty( $parsed_url['query'] ) ) {
$url .= '?' . $parsed_url['query'];
}
}
return $url;
} | Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/strip_fragment_from_url