sanitize_url

Performs esc_url() for database or redirect usage.

Description

(string) sanitize_url( (string) $url, (null) $protocols = null ); 

Returns (string)

The cleaned URL.

Parameters (2)

0. $url (string)
The URL to be cleaned.
1. $protocols — Optional. (null) => null
An array of acceptable protocols.

Usage

  1. if ( !function_exists( 'sanitize_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The URL to be cleaned. 
  5. $url = ''; 
  6.  
  7. // An array of acceptable protocols. 
  8. $protocols = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = sanitize_url($url, $protocols); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function sanitize_url( $url, $protocols = null ) { 
  2. _deprecated_function( __FUNCTION__, '2.8.0', 'esc_url_raw()' ); 
  3. return esc_url_raw( $url, $protocols );