WP_HTML_Open_Elements::has_element_in_specific_scope
Returns whether an element is in a specific scope.
Метод класса: WP_HTML_Open_Elements{}
Хуков нет.
Возвращает
true|false. Whether the element was found in a specific scope.
Использование
$WP_HTML_Open_Elements = new WP_HTML_Open_Elements(); $WP_HTML_Open_Elements->has_element_in_specific_scope( $tag_name, $termination_list ): bool;
- $tag_name(строка) (обязательный)
- Name of tag check.
- $termination_list(string[]) (обязательный)
- List of elements that terminate the search.
Заметки
Список изменений
| С версии 6.4.0 | Введена. |
Код WP_HTML_Open_Elements::has_element_in_specific_scope() WP HTML Open Elements::has element in specific scope WP 6.9
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;
}