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

Performs esc_url() for database or redirect usage.


Description

This function is an alias for esc_url_raw().

Top ↑

See also


Top ↑

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 value: null


Top ↑

Return

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


Top ↑

Source

File: wp-includes/formatting.php

function sanitize_url( $url, $protocols = null ) {
	return esc_url_raw( $url, $protocols );
}


Top ↑

Changelog

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

Top ↑

User Contributed Notes

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