Returns the nesting depth of the current location in the document.
Description
Example:
$processor = WP_HTML_Processor::create_fragment( '<div><p></p></div>' );
// The processor starts in the BODY context, meaning it has depth from the start: HTML > BODY.
2 === $processor->get_current_depth();
// Opening the DIV element increases the depth.
$processor->next_token();
3 === $processor->get_current_depth();
// Opening the P element increases the depth.
$processor->next_token();
4 === $processor->get_current_depth();
// The P element is closed during `next_token()` so the depth is decreased to reflect that.
$processor->next_token();
3 === $processor->get_current_depth();
Source
$adjusted_current_node = $this->get_adjusted_current_node();
$is_closer = $this->is_tag_closer();
$is_start_tag = WP_HTML_Tag_Processor::STATE_MATCHED_TAG === $this->parser_state && ! $is_closer;
$token_name = $this->get_token_name();
Changelog
Version | Description |
---|---|
6.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.