WPDev.one

esc_url()

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

Checks and cleans a URL.

Parameters 2 required

Name / Type Description
$url
string

The URL to be cleaned.

Required
string[]

$protocols Optional. An array of acceptable protocols. Defaults to return value of wp_allowed_protocols().

Required
$_context
string

Private. Use sanitize_url() for database usage.

Return Value

(string)
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.

Function Information

Since Version
2.8.0
Source File
wp-includes/formatting.php
Advertisement