WP_HTML_Tag_Processor::get_tag(): string|null

In this article

Returns the uppercase name of the matched tag.

Description

Example:

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

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

Return

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

Source

 * Example:
 *
 *     $p->set_attribute( 'data-TEST-id', 'update' );
 *     'update' === $p->get_enqueued_attribute_value( 'data-test-id' );
 *
 * Detect this difference based on the absence of the `=`, which _must_ exist in any
 * attribute containing a value, e.g. `<input type="text" enabled />`.
 *                                            ¹           ²
 *                                       1. Attribute with a string value.
 *                                       2. Boolean attribute whose value is `true`.
 */
$equals_at = strpos( $enqueued_text, '=' );
if ( false === $equals_at ) {
	return true;
}

/*
 * Finally, a normal update's value will appear after the `=` and
 * be double-quoted, as performed incidentally by `set_attribute`.
 *

Changelog

VersionDescription
6.2.0Introduced.

User Contributed Notes

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