wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



block_core_navigation_link_maybe_urldecode › WordPress Function

Odn/a
Przestarzałyn/a
block_core_navigation_link_maybe_urldecode ( $url )
Parametry:
  • (string) $url The url to decode.
    Wymagane: Tak
Powrót:
  • (string) $url Returns the decoded url.
Zdefiniowane na:
Codex:

Decodes a url if it's encoded, returning the same url if not.



Źródło

function block_core_navigation_link_maybe_urldecode( $url ) {
	$is_url_encoded = false;
	$query          = parse_url( $url, PHP_URL_QUERY );
	$query_params   = wp_parse_args( $query );

	foreach ( $query_params as $query_param ) {
		$can_query_param_be_encoded = is_string( $query_param ) && ! empty( $query_param );
		if ( ! $can_query_param_be_encoded ) {
			continue;
		}
		if ( rawurldecode( $query_param ) !== $query_param ) {
			$is_url_encoded = true;
			break;
		}
	}

	if ( $is_url_encoded ) {
		return rawurldecode( $url );
	}

	return $url;
}