WP_HTML_Tag_Processor::next_tag()
Finds the next tag matching the $query.
Method of the class: WP_HTML_Tag_Processor{}
No Hooks.
Return
true|false
. Whether a tag was matched.
Usage
$WP_HTML_Tag_Processor = new WP_HTML_Tag_Processor(); $WP_HTML_Tag_Processor->next_tag( $query );
- $query(array|string|null)
Which tag name to find, having which class, etc.
Default: to find any tag
-
tag_name(string|null)
Which tag to find, or null for "any tag." -
match_offset(int|null)
Find the Nth tag matching all search criteria.
1 for "first" tag, 3 for "third," etc.
Default: first tag -
class_name(string|null)
Tag must contain this whole class name to match. - tag_closers(string|null)
"visit" or "skip": whether to stop on tag closers, e.g. </div>.
-
Changelog
Since 6.2.0 | Introduced. |
Since 6.5.0 | No longer processes incomplete tokens at end of document; pauses the processor at start of token. |
WP_HTML_Tag_Processor::next_tag() WP HTML Tag Processor::next tag code WP 6.6.2
public function next_tag( $query = null ) { $this->parse_query( $query ); $already_found = 0; do { if ( false === $this->next_token() ) { return false; } if ( self::STATE_MATCHED_TAG !== $this->parser_state ) { continue; } if ( $this->matches() ) { ++$already_found; } } while ( $already_found < $this->sought_match_offset ); return true; }