WP_HTML_Tag_Processor::has_class()publicWP 6.4.0

Returns if a matched tag contains the given ASCII case-insensitive class name.

Метод класса: WP_HTML_Tag_Processor{}

Хуков нет.

Возвращает

true|false|null. Whether the matched tag contains the given class name, or null if not matched.

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

$WP_HTML_Tag_Processor = new WP_HTML_Tag_Processor();
$WP_HTML_Tag_Processor->has_class( $wanted_class );
$wanted_class(строка) (обязательный)
Look for this CSS class name, ASCII case-insensitive.

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

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

Код WP_HTML_Tag_Processor::has_class() WP 6.6.1

public function has_class( $wanted_class ) {
	if ( self::STATE_MATCHED_TAG !== $this->parser_state ) {
		return null;
	}

	$wanted_class = strtolower( $wanted_class );

	foreach ( $this->class_list() as $class_name ) {
		if ( $class_name === $wanted_class ) {
			return true;
		}
	}

	return false;
}