WP_HTML_Processor::next_token()
Ensures internal accounting is maintained for HTML semantic rules while the underlying Tag Processor class is seeking to a bookmark.
This doesn't currently have a way to represent non-tags and doesn't process semantic rules for text nodes. For access to the raw tokens consider using WP_HTML_Tag_Processor instead.
Method of the class: WP_HTML_Processor{}
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
true|false
.
Usage
$WP_HTML_Processor = new WP_HTML_Processor(); $WP_HTML_Processor->next_token();
Changelog
Since 6.5.0 | Introduced. |
Since 6.5.0 | Added for internal support; do not use. |
WP_HTML_Processor::next_token() WP HTML Processor::next token code WP 6.6.2
public function next_token() { $this->current_element = null; if ( isset( $this->last_error ) ) { return false; } if ( 'done' !== $this->has_seen_context_node && 0 === count( $this->element_queue ) && ! $this->step() ) { while ( 'context-node' !== $this->state->stack_of_open_elements->current_node()->bookmark_name && $this->state->stack_of_open_elements->pop() ) { continue; } $this->has_seen_context_node = 'done'; return $this->next_token(); } $this->current_element = array_shift( $this->element_queue ); while ( isset( $this->context_node ) && ! $this->has_seen_context_node ) { if ( isset( $this->current_element ) ) { if ( $this->context_node === $this->current_element->token && WP_HTML_Stack_Event::PUSH === $this->current_element->operation ) { $this->has_seen_context_node = true; return $this->next_token(); } } $this->current_element = array_shift( $this->element_queue ); } if ( ! isset( $this->current_element ) ) { if ( 'done' === $this->has_seen_context_node ) { return false; } else { return $this->next_token(); } } if ( isset( $this->context_node ) && WP_HTML_Stack_Event::POP === $this->current_element->operation && $this->context_node === $this->current_element->token ) { $this->element_queue = array(); $this->current_element = null; return false; } // Avoid sending close events for elements which don't expect a closing. if ( WP_HTML_Stack_Event::POP === $this->current_element->operation && ! static::expects_closer( $this->current_element->token ) ) { return $this->next_token(); } return true; }