WP_HTML_Open_Elements::has_element_in_specific_scope( string $tag_name, string[] $termination_list ): bool

Returns whether an element is in a specific scope.

Description

HTML Support

This function skips checking for the termination list because there are no supported elements which appear in the termination list.

See also

Parameters

$tag_namestringrequired
Name of tag check.
$termination_liststring[]required
List of elements that terminate the search.

Return

bool Whether the element was found in a specific scope.

Source

public function has_element_in_specific_scope( $tag_name, $termination_list ) {
	foreach ( $this->walk_up() as $node ) {
		if ( $node->node_name === $tag_name ) {
			return true;
		}

		if (
			'(internal: H1 through H6 - do not use)' === $tag_name &&
			in_array( $node->node_name, array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ), true )
		) {
			return true;
		}

		switch ( $node->node_name ) {
			case 'HTML':
				return false;
		}

		if ( in_array( $node->node_name, $termination_list, true ) ) {
			return false;
		}
	}

	return false;
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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