wordpress / latest / functions / sanitize_url.html

sanitize_url( string $url, string[] $protocols = null ): string

Sanitizes a URL for database or redirect usage.

Description

See also

Parameters

$url string Required
The URL to be cleaned.
$protocols string[] Optional
An array of acceptable protocols.
Defaults to return value of wp_allowed_protocols() .

Default: null

Return

string The cleaned URL after esc_url() is run with the 'db' context.

Source

File: wp-includes/formatting.php. View all references

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

Uses

Uses Description

Used By

Used By Description

Changelog

Version Description
5.9.0 Restored (un-deprecated).
2.8.0 Deprecated in favor of esc_url_raw() .
2.3.1 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/sanitize_url