WP_HTML_Processor::get_tag()
Returns the uppercase name of the matched tag.
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;
Method of the class: WP_HTML_Processor{}
No Hooks.
Return
String|null
. Name of currently matched tag in input HTML, or null if none found.
Usage
$WP_HTML_Processor = new WP_HTML_Processor(); $WP_HTML_Processor->get_tag();
Changelog
Since 6.4.0 | Introduced. |
WP_HTML_Processor::get_tag() WP HTML Processor::get tag code WP 6.6.2
public function get_tag() { if ( null !== $this->last_error ) { return null; } if ( $this->is_virtual() ) { return $this->current_element->token->node_name; } $tag_name = parent::get_tag(); switch ( $tag_name ) { case 'IMAGE': /* * > A start tag whose tag name is "image" * > Change the token's tag name to "img" and reprocess it. (Don't ask.) */ return 'IMG'; default: return $tag_name; } }