WP_HTML_Tag_Processor::next_tag( array|string|null $query = null ): bool

In this article

Finds the next tag matching the $query.

Parameters

$queryarray|string|nulloptional
Which tag name to find, having which class, etc. Default is 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.
    Defaults to 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>.

Default:null

Return

bool Whether a tag was matched.

Source

 * Example:
 *
 *     // Replace an attribute stored with a new value, indices
 *     // sourced from the lazily-parsed HTML recognizer.
 *     $start  = $attributes['src']->start;
 *     $length = $attributes['src']->length;
 *     $modifications[] = new WP_HTML_Text_Replacement( $start, $length, $new_value );
 *
 *     // Correspondingly, something like this will appear in this array.
 *     $lexical_updates = array(
 *         WP_HTML_Text_Replacement( 14, 28, 'https://my-site.my-domain/wp-content/uploads/2014/08/kittens.jpg' )
 *     );
 *
 * @since 6.2.0
 * @var WP_HTML_Text_Replacement[]
 */
protected $lexical_updates = array();

/**
 * Tracks and limits `seek()` calls to prevent accidental infinite loops.

Changelog

VersionDescription
6.5.0No longer processes incomplete tokens at end of document; pauses the processor at start of token.
6.2.0Introduced.

User Contributed Notes

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