WP_HTML_Open_Elements::remove_node()
Removes a specific node from the stack of open elements.
Method of the class: WP_HTML_Open_Elements{}
No Hooks.
Return
true|false
. Whether the node was found and removed from the stack of open elements.
Usage
$WP_HTML_Open_Elements = new WP_HTML_Open_Elements(); $WP_HTML_Open_Elements->remove_node( $token );
- $token(WP_HTML_Token) (required)
- The node to remove from the stack of open elements.
Changelog
Since 6.4.0 | Introduced. |
WP_HTML_Open_Elements::remove_node() WP HTML Open Elements::remove node code WP 6.6.2
public function remove_node( $token ) { if ( 'context-node' === $token->bookmark_name ) { return false; } foreach ( $this->walk_up() as $position_from_end => $item ) { if ( $token->bookmark_name !== $item->bookmark_name ) { continue; } $position_from_start = $this->count() - $position_from_end - 1; array_splice( $this->stack, $position_from_start, 1 ); $this->after_element_pop( $item ); return true; } return false; }