WP_HTML_Tag_Processor::next_token
Finds the next token in the HTML document.
An HTML document can be viewed as a stream of tokens, where tokens are things like HTML tags, HTML comments, text nodes, etc. This method finds the next token in the HTML document and returns whether it found one.
If it starts parsing a token and reaches the end of the document then it will seek to the start of the last token and pause, returning false to indicate that it failed to find a complete token.
Possible token types, based on the HTML specification:
- an HTML tag, whether opening, closing, or void.
- a text node - the plaintext inside tags.
- an HTML comment.
- a DOCTYPE declaration.
- a processing instruction, e.g.
<?xml version="1.0" ?>.
The Tag Processor currently only supports the tag token.
Method of the class: WP_HTML_Tag_Processor{}
No Hooks.
Returns
true|false. Whether a token was parsed.
Usage
$WP_HTML_Tag_Processor = new WP_HTML_Tag_Processor(); $WP_HTML_Tag_Processor->next_token(): bool;
Changelog
| Since 6.5.0 | Introduced. |
| Since 6.7.0 | Recognizes CDATA sections within foreign content. |
WP_HTML_Tag_Processor::next_token() WP HTML Tag Processor::next token code WP 7.0
public function next_token(): bool {
return $this->base_class_next_token();
}