wp_kses_bad_protocol_once2()WP 1.0.0

This function processes URL protocols, checks to see if they're in the list of allowed protocols or not, and returns different data depending on the answer.

Хуков нет.

Возвращает

Строку. Sanitized content.

Использование

wp_kses_bad_protocol_once2( $string, $allowed_protocols );
$string(строка) (обязательный)
URI scheme to check against the list of allowed protocols.
$allowed_protocols(string[]) (обязательный)
Array of allowed URL protocols.

Список изменений

С версии 1.0.0 Введена.

Код wp_kses_bad_protocol_once2() WP 6.1.1

function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) {
	$string2 = wp_kses_decode_entities( $string );
	$string2 = preg_replace( '/\s/', '', $string2 );
	$string2 = wp_kses_no_null( $string2 );
	$string2 = strtolower( $string2 );

	$allowed = false;
	foreach ( (array) $allowed_protocols as $one_protocol ) {
		if ( strtolower( $one_protocol ) == $string2 ) {
			$allowed = true;
			break;
		}
	}

	if ( $allowed ) {
		return "$string2:";
	} else {
		return '';
	}
}