esc_url_raw() WordPress Function

The esc_url_raw() function is a WordPress function that is used to escape URLs. It is useful for making sure that URLs are properly encoded and do not contain any invalid characters. This function can be used when validating user input or when displaying URLs in the browser.

esc_url_raw( string $url, string[] $protocols = null ) #

Performs esc_url() for database or redirect usage.


Description

Top ↑

See also


Top ↑

Parameters

$url

(string)(Required)The URL to be cleaned.

$protocols

(string[])(Optional) An array of acceptable protocols. Defaults to return value of wp_allowed_protocols().

Default value: null


Top ↑

Return

(string) The cleaned URL after esc_url() is run with the 'db' context.


Top ↑

More Information

The esc_url_raw() function is similar to esc_url() (and actually uses it), but unlike esc_url() it does not replace entities for display. The resulting URL is safe to use in database queries, redirects and HTTP requests.

This function is not safe to use for displaying the URL, use esc_url() instead.


Top ↑

Source

File: wp-includes/formatting.php

function esc_url_raw( $url, $protocols = null ) {
	return esc_url( $url, $protocols, 'db' );
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More