esc_url ( $url, $protocols = null, $_context = 'display' )

  • (string) url The URL to be cleaned.
  • (string[]) protocols Optional. An array of acceptable protocols. Defaults to return value of wp_allowed_protocols().
  • (string) _context Private. Use esc_url_raw() for database usage.
  • (string) The cleaned URL after the {@see 'clean_url'} filter is applied. An empty string is returned if `$url` specifies a protocol other than those in `$protocols`, or if `$url` contains an empty string.
Defined at:


Checks and cleans a URL.A number of characters are removed from the URL. If the URL is for displaying (the default behaviour) ampersands are also replaced. The Array filter is applied to the returned cleaned URL.

Related Functions

rest_url, esc_url_raw, esc_xml, esc_sql, esc_html

Top Google Results

User discussions

wpseek mobile