Indicates if the currently-matched tag matches the given breadcrumbs.
Description
A "*" represents a single tag wildcard, where any tag matches, but not no tags.
At some point this function may support a **
syntax for matching any number of unspecified tags in the breadcrumb stack. This has been intentionally left out, however, to keep this function simple and to avoid introducing backtracking, which could open up surprising performance breakdowns.
Example:
$processor = WP_HTML_Processor::create_fragment( '<div><span><figure><img></figure></span></div>' );
$processor->next_tag( 'img' );
true === $processor->matches_breadcrumbs( array( 'figure', 'img' ) );
true === $processor->matches_breadcrumbs( array( 'span', 'figure', 'img' ) );
false === $processor->matches_breadcrumbs( array( 'span', 'img' ) );
true === $processor->matches_breadcrumbs( array( 'span', '*', 'img' ) );
Parameters
$breadcrumbs
string[]required- DOM sub-path at which element is found, e.g.
array( 'FIGURE', 'IMG' )
.
May also contain the wildcard*
which matches a single element, e.g.array( 'SECTION', '*' )
.
Source
*
* @since 6.7.0
*
* @see self::$unsupported_exception
*
* @return WP_HTML_Unsupported_Exception|null
*/
public function get_unsupported_exception() {
return $this->unsupported_exception;
}
/**
* Finds the next tag matching the $query.
*
* @todo Support matching the class name and tag name.
*
* @since 6.4.0
* @since 6.6.0 Visits all tokens, including virtual ones.
*
* @throws Exception When unable to allocate a bookmark for the next token in the input HTML document.
*
* @param array|string|null $query {
* Optional. Which tag name to find, having which class, etc. Default is to find any tag.
*
* @type string|null $tag_name Which tag to find, or `null` for "any tag."
* @type string $tag_closers 'visit' to pause at tag closers, 'skip' or unset to only visit openers.
* @type int|null $match_offset Find the Nth tag matching all search criteria.
Changelog
Version | Description |
---|---|
6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.