WP_HTML_Open_Elements::current_node_is()
Indicates if the current node is of a given type or name.
It's possible to pass either a node type or a node name to this function. In the case there is no current element it will always return false.
Example:
// Is the current node a text node? $stack->current_node_is( '#text' );
// Is the current node a DIV element? $stack->current_node_is( 'DIV' );
// Is the current node any element/tag? $stack->current_node_is( '#tag' );
Method of the class: WP_HTML_Open_Elements{}
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
true|false
. Whether there is a current element that matches the given identity, whether a token name or type.
Usage
$WP_HTML_Open_Elements = new WP_HTML_Open_Elements(); $WP_HTML_Open_Elements->current_node_is( $identity ): bool;
- $identity(string) (required)
- Check if the current node has this name or type (depending on what is provided).
Notes
Changelog
Since 6.7.0 | Introduced. |
WP_HTML_Open_Elements::current_node_is() WP HTML Open Elements::current node is code WP 6.7.1
public function current_node_is( string $identity ): bool { $current_node = end( $this->stack ); if ( false === $current_node ) { return false; } $current_node_name = $current_node->node_name; return ( $current_node_name === $identity || ( '#doctype' === $identity && 'html' === $current_node_name ) || ( '#tag' === $identity && ctype_upper( $current_node_name ) ) ); }