WP_HTML_Open_Elements::contains_node()publicWP 6.4.0

Reports if a specific node is in the stack of open elements.

Method of the class: WP_HTML_Open_Elements{}

No Hooks.

Return

true|false. Whether the referenced node is in the stack of open elements.

Usage

$WP_HTML_Open_Elements = new WP_HTML_Open_Elements();
$WP_HTML_Open_Elements->contains_node( $token );
$token(WP_HTML_Token) (required)
Look for this node in the stack.

Changelog

Since 6.4.0 Introduced.

WP_HTML_Open_Elements::contains_node() code WP 6.6.2

public function contains_node( $token ) {
	foreach ( $this->walk_up() as $item ) {
		if ( $token->bookmark_name === $item->bookmark_name ) {
			return true;
		}
	}

	return false;
}