WP_HTML_Open_Elements::remove_node │ public │ WP 6.4.0

Removes a specific node from the stack of open elements.

Метод класса: WP_HTML_Open_Elements{}

Хуков нет.

Возвращает

bool. Whether the node was found and removed from the stack of open elements.

Использование

$WP_HTML_Open_Elements = new WP_HTML_Open_Elements();
$WP_HTML_Open_Elements->remove_node( $token ): bool;
$token(WP_HTML_Token) (обязательный)
The node to remove from the stack of open elements.

Список изменений

С версии 6.4.0 Введена.

Код WP_HTML_Open_Elements::remove_node() WP 7.1.3

public function remove_node( WP_HTML_Token $token ): bool {
	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;
}