WP_HTML_Processor::expects_closer()
Indicates if the currently-matched node expects a closing token, or if it will self-close on the next step.
Most HTML elements expect a closer, such as a P element or a DIV element. Others, like an IMG element are void and don't have a closing tag. Special elements, such as SCRIPT and STYLE, are treated just like void tags. Text nodes and self-closing foreign content will also act just like a void tag, immediately closing as soon as the processor advances to the next token.
Method of the class: WP_HTML_Processor{}
No Hooks.
Return
true|false
. Whether to expect a closer for the currently-matched node, or null if not matched on any token.
Usage
$WP_HTML_Processor = new WP_HTML_Processor(); $WP_HTML_Processor->expects_closer( $node );
- $node(?WP_HTML_Token)
- Node to examine instead of current node, if provided.
Default: null
Changelog
Since 6.6.0 | Introduced. |
WP_HTML_Processor::expects_closer() WP HTML Processor::expects closer code WP 6.6.2
public function expects_closer( $node = null ) { $token_name = $node->node_name ?? $this->get_token_name(); if ( ! isset( $token_name ) ) { return null; } return ! ( // Comments, text nodes, and other atomic tokens. '#' === $token_name[0] || // Doctype declarations. 'html' === $token_name || // Void elements. self::is_void( $token_name ) || // Special atomic elements. in_array( $token_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ); }