WP_HTML_Processor::insert_virtual_node( string $token_name, string|null $bookmark_name = null ): WP_HTML_Token

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Inserts a virtual element on the stack of open elements.

Parameters

$token_namestringrequired
Name of token to create and insert into the stack of open elements.
$bookmark_namestring|nulloptional
Name to give bookmark for created virtual node.
Defaults to auto-creating a bookmark name.

Default:null

Return

WP_HTML_Token Newly-created virtual token.

Source

private function insert_virtual_node( $token_name, $bookmark_name = null ): WP_HTML_Token {
	$here = $this->bookmarks[ $this->state->current_token->bookmark_name ];
	$name = $bookmark_name ?? $this->bookmark_token();

	$this->bookmarks[ $name ] = new WP_HTML_Span( $here->start, 0 );

	$token = new WP_HTML_Token( $name, $token_name, false );
	$this->insert_html_element( $token );
	return $token;
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.