WP_HTML_Processor::step( string $node_to_process = self::PROCESS_NEXT_NODE ): bool

Steps through the HTML document and stop at the next tag, if any.

Description

See also

Parameters

$node_to_processstringoptional
Whether to parse the next node or reprocess the current node.

Default:self::PROCESS_NEXT_NODE

Return

bool Whether a tag was matched.

Source

				continue;
			}

			if ( isset( $needs_class ) && ! $this->has_class( $needs_class ) ) {
				continue;
			}

			if ( ! $this->is_tag_closer() || $visit_closers ) {
				return true;
			}
		}

		return false;
	}

	$breadcrumbs  = $query['breadcrumbs'];
	$match_offset = isset( $query['match_offset'] ) ? (int) $query['match_offset'] : 1;

	while ( $match_offset > 0 && $this->next_token() ) {
		if ( '#tag' !== $this->get_token_type() || $this->is_tag_closer() ) {
			continue;
		}

		if ( isset( $needs_class ) && ! $this->has_class( $needs_class ) ) {
			continue;
		}

		if ( $this->matches_breadcrumbs( $breadcrumbs ) && 0 === --$match_offset ) {
			return true;
		}
	}

	return false;
}

/**
 * Finds the next token in the HTML document.
 *
 * 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.
 *
 * @since 6.5.0 Added for internal support; do not use.
 * @since 6.7.2 Refactored so subclasses may extend.
 *
 * @return bool Whether a token was parsed.
 */
public function next_token(): bool {
	return $this->next_visitable_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.
 *
 * Note that this method may call itself recursively. This is why it is not
 * implemented as WP_HTML_Processor::next_token(), which instead calls
 * this method similarly to how WP_HTML_Tag_Processor::next_token()
 * calls the WP_HTML_Tag_Processor::base_class_next_token() method.

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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