WP_HTML_Tag_Processor::matches(): bool

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Checks whether a given tag and its attributes match the search criteria.

Return

bool Whether the given tag and its attribute match the search criteria.

Source

 * This matches the DOM API value `nodeName`. Some values
 * are static, such as `#text` for a text node, while others
 * are dynamically generated from the token itself.
 *
 * Dynamic names:
 *  - Uppercase tag name for tag matches.
 *  - `html` for DOCTYPE declarations.
 *
 * Note that if the Tag Processor is not matched on a token
 * then this function will return `null`, either because it
 * hasn't yet found a token or because it reached the end
 * of the document without matching a token.
 *
 * @since 6.5.0
 *
 * @return string|null Name of the matched token.
 */
public function get_token_name(): ?string {
	switch ( $this->parser_state ) {
		case self::STATE_MATCHED_TAG:
			return $this->get_tag();

		case self::STATE_TEXT_NODE:
			return '#text';

		case self::STATE_CDATA_NODE:
			return '#cdata-section';

		case self::STATE_COMMENT:
			return '#comment';

		case self::STATE_DOCTYPE:
			return 'html';

		case self::STATE_PRESUMPTUOUS_TAG:
			return '#presumptuous-tag';

		case self::STATE_FUNKY_COMMENT:
			return '#funky-comment';
	}

	return null;
}

Changelog

VersionDescription
6.2.0Introduced.

User Contributed Notes

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