Returns whether an element is in a specific scope.
Description
See also
Parameters
$tag_namestringrequired- Name of tag check.
$termination_liststring[]required- List of elements that terminate the search.
Source
public function has_element_in_specific_scope( string $tag_name, $termination_list ): bool {
foreach ( $this->walk_up() as $node ) {
$namespaced_name = 'html' === $node->namespace
? $node->node_name
: "{$node->namespace} {$node->node_name}";
if ( $namespaced_name === $tag_name ) {
return true;
}
if (
'(internal: H1 through H6 - do not use)' === $tag_name &&
in_array( $namespaced_name, array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ), true )
) {
return true;
}
if ( in_array( $namespaced_name, $termination_list, true ) ) {
return false;
}
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.