WP_HTML_Processor::get_tag(): string|null

In this article

Returns the uppercase name of the matched tag.

Description

The semantic rules for HTML specify that certain tags be reprocessed with a different tag name. Because of this, the tag name presented by the HTML Processor may differ from the one reported by the HTML Tag Processor, which doesn’t apply these semantic rules.

Example:

$processor = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
$processor->next_tag() === true;
$processor->get_tag() === 'DIV';

$processor->next_tag() === false;
$processor->get_tag() === null;

Return

string|null Name of currently matched tag in input HTML, or null if none found.

Source

	 * > Anything else
	 *
	 * > Insert an HTML element for a "head" start tag token with no attributes.
	 */
	before_head_anything_else:
	$this->state->head_element   = $this->insert_virtual_node( 'HEAD' );
	$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_HEAD;
	return $this->step( self::REPROCESS_CURRENT_NODE );
}

/**
 * Parses next element in the 'in head' insertion mode.
 *
 * This internal function performs the 'in head' insertion mode
 * logic for the generalized WP_HTML_Processor::step() function.
 *
 * @since 6.7.0
 *
 * @throws WP_HTML_Unsupported_Exception When encountering unsupported HTML input.
 *
 * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead
 * @see WP_HTML_Processor::step
 *

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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