sanitize_url()WP 2.3.1

Sanitizes a URL for database or redirect usage.

No Hooks.

Return

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

Usage

sanitize_url( $url, $protocols );
$url(string) (required)
The URL to be cleaned.
$protocols(string[])
An array of acceptable protocols.
Default: return value of wp_allowed_protocols()

Notes

Changelog

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

sanitize_url() code WP 6.1.1

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