block_core_navigation_link_maybe_urldecode

函数
block_core_navigation_link_maybe_urldecode ( $url )

如果URL已编码,则对其进行解码;如果未编码,则返回相同的URL。

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 ) {
		if ( rawurldecode( $query_param ) !== $query_param ) {
			$is_url_encoded = true;
			break;
		}
	}

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

	return $url;
}

常见问题

FAQs
查看更多 >