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();
Return
int
Nesting-depth of current location in the document.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/html-api/class-wp-html-processor.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.