WP_HTML_Processor::get_token_type(): string|null

In this article

Indicates the kind of matched token, if any.

Description

This differs from get_token_name() in that it always returns a static string indicating the type, whereas get_token_name() may return values derived from the token itself, such as a tag name or processing instruction tag.

Possible values:

  • #tag when matched on a tag.
  • #text when matched on a text node.
  • #cdata-section when matched on a CDATA node.
  • #comment when matched on a comment.
  • #doctype when matched on a DOCTYPE declaration.
  • #presumptuous-tag when matched on an empty tag closer.
  • #funky-comment when matched on a funky comment.

Return

string|null What kind of token is matched, or null.

Source

if ( is_string( $charset ) && 'tentative' === $this->state->encoding_confidence ) {
	$this->bail( 'Cannot yet process META tags with charset to determine encoding.' );
}

/*
 * >   - Otherwise, if the element has an http-equiv attribute whose value is
 * >     an ASCII case-insensitive match for the string "Content-Type", and
 * >     the element has a content attribute, and applying the algorithm for
 * >     extracting a character encoding from a meta element to that attribute's
 * >     value returns an encoding, and the confidence is currently tentative,
 * >     then change the encoding to the extracted encoding.
 */
$http_equiv = $this->get_attribute( 'http-equiv' );
$content    = $this->get_attribute( 'content' );
if (
	is_string( $http_equiv ) &&
	is_string( $content ) &&
	0 === strcasecmp( $http_equiv, 'Content-Type' ) &&
	'tentative' === $this->state->encoding_confidence
) {
	$this->bail( 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' );
}

Changelog

VersionDescription
6.6.0Introduced.

User Contributed Notes

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