esc_url_raw( string $url, array $protocols = null )

Performs esc_url() for database usage.


Description Description


Parameters Parameters

$url

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

$protocols

(array) (Optional) An array of acceptable protocols.

Default value: null


Top ↑

Return Return

(string) The cleaned URL.


Top ↑

Source Source

File: wp-includes/formatting.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
2.8.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Codex

    Right and Wrong usage

    <!-- Right -->
    $url = 'http://wordpress.org';
    $response = wp_remote_get( esc_url_raw( $url ) ); // no need to escape 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>
    

You must log in before being able to contribute a note or feedback.