Uma área de pesquisa sobre o WordPress para devs e autores do tema



strip_fragment_from_url ›

Desde4.4.0
Obsoleton/a
strip_fragment_from_url ( $url )
Parâmetros:
  • (string) $url The URL to strip.
    Required: Yes
Retorna:
  • (string) The altered URL.
Definido em:
Codex:

Strips the #fragment from a URL, if one is present.



Fonte

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;
}