функция
Устаревший since 2.3.1
sanitize_url()
Устаревшее.
Помечено устаревшим с версии 5.9.0.
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
sanitize_url( string $url, string[] $protocols = null ): string
Описание
См. alsoesc_url()
Параметры
$url
string
обязательный
URL, который нужно очистить.
$protocols
string[]
необязательный
= null
Массив допустимых протоколов.
По умолчанию — возвращаемое значение wp_allowed_protocols() .
Возвращаемое значение
string
esc_url() 'db'
Исходный код
wp-includes/formatting.php:4618
function sanitize_url( $url, $protocols = null ) {
return esc_url( $url, $protocols, 'db' );
}
История изменений
| Версия | Описание |
|---|---|
| 6.9.0 | Prepends https:// to the URL if it does not already contain a scheme and the first item in $protocols is 'https'. |
| 5.9.0 | Restored (un-deprecated). |
| 2.8.0 | Deprecated in favor of esc_url_raw() . |
| 2.3.1 | Introduced. |

