WP_HTML_Processor::get_token_type
Indicates the kind of matched token, if any.
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:
#tagwhen matched on a tag.#textwhen matched on a text node.#cdata-sectionwhen matched on a CDATA node.#commentwhen matched on a comment.#doctypewhen matched on a DOCTYPE declaration.#presumptuous-tagwhen matched on an empty tag closer.#funky-commentwhen matched on a funky comment.
Метод класса: WP_HTML_Processor{}
Хуков нет.
Возвращает
Строку|null. What kind of token is matched, or null.
Использование
$WP_HTML_Processor = new WP_HTML_Processor(); $WP_HTML_Processor->get_token_type(): ?string;
Список изменений
| С версии 6.6.0 | Введена. |
| С версии 6.6.0 | Subclassed for the HTML Processor. |
Код WP_HTML_Processor::get_token_type() WP HTML Processor::get token type WP 6.9.4
public function get_token_type(): ?string {
if ( $this->is_virtual() ) {
/*
* This logic comes from the Tag Processor.
*
* @todo It would be ideal not to repeat this here, but it's not clearly
* better to allow passing a token name to `get_token_type()`.
*/
$node_name = $this->current_element->token->node_name;
$starting_char = $node_name[0];
if ( 'A' <= $starting_char && 'Z' >= $starting_char ) {
return '#tag';
}
if ( 'html' === $node_name ) {
return '#doctype';
}
return $node_name;
}
return parent::get_token_type();
}