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

Sanitizes a URL for database or redirect usage.

Description

See also

Parameters

$urlstringrequired
The URL to be cleaned.
$protocolsstring[]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

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

Changelog

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

User Contributed Notes

You must log in before being able to contribute a note or feedback.