WP_HTML_Tag_Processor::has_class( string $wanted_class ): bool|null

In this article

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

Parameters

$wanted_classstringrequired
Look for this CSS class name, ASCII case-insensitive.

Return

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

Source

public function has_class( $wanted_class ) {
	if ( ! $this->tag_name_starts_at ) {
		return null;
	}

	$wanted_class = strtolower( $wanted_class );

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

	return false;
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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