esc_url

Checks and cleans a URL.

Description

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

A number of characters are removed from the URL. If the URL is for displaying (the default behaviour) amperstands are also replaced. The esc_url filter is applied to the returned cleaned URL.

Returns (string)

The cleaned $url after the 'cleaned_url' filter is applied.

Parameters (2)

0. $url (string)
The URL to be cleaned.
1. $protocols — Optional. (null) => null
An array of acceptable protocols. Defaults to http,, https , ftp, ftps, mailto, news, irc, gopher, nntp, feed, telnet if not set.

Usage

  1. if ( !function_exists( 'esc_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.formatting.php'; 
  3.  
  4. // The URL to be cleaned. 
  5. $url = ''; 
  6.  
  7. // Optional. An array of acceptable protocols. 
  8. // Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set. 
  9. $protocols = null; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = esc_url($url, $protocols); 
  13.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/backpress/functions.formatting.php  
  1. function esc_url( $url, $protocols = null ) { 
  2. return clean_url( $url, $protocols, 'display' );