Codex

Attention Help us to improve the Codex by filling out our documentation survey!

Function Reference/esc url raw

Contents

Description

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.

Usage

<?php esc_url_raw$url$protocols ); ?>

Parameters

$url
(string) (required) The URL to be cleaned.
Default: None
$protocols
(array) (optional) An array of acceptable protocols. Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
Default: null

Return Values

(string) 
The cleaned $url after the 'clean_url' filter is applied.

Examples


<!-- Right -->
<?php
    $url 
'http://wordpress.org';
    
$response wp_remote_getesc_url_raw$url ) ); // no need to espace entities
    
if ( !is_wp_error$response ) ) {
        echo 
wp_remote_retrieve_body$response );
    }
?>

<!-- Wrong! Use esc_url instead! -->
<img src='<?php echo esc_url_raw$url ); ?>' />
<a href='<?php echo esc_url_raw$url ); ?>'>WordPress</a>

Notes

Changelog

  • Since: 2.8

Source File

esc_url_raw() is located in wp-includes/formatting.php.

Related

See the Data Validation article for an in-depth discussion of input and output sanitization.

See also index of Function Reference and index of Template Tags.