- Timestamp:
- 05/23/2024 11:35:52 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r58190 r58191 622 622 623 623 return $breadcrumbs; 624 } 625 626 /** 627 * Returns the nesting depth of the current location in the document. 628 * 629 * Example: 630 * 631 * $processor = WP_HTML_Processor::create_fragment( '<div><p></p></div>' ); 632 * // The processor starts in the BODY context, meaning it has depth from the start: HTML > BODY. 633 * 2 === $processor->get_current_depth(); 634 * 635 * // Opening the DIV element increases the depth. 636 * $processor->next_token(); 637 * 3 === $processor->get_current_depth(); 638 * 639 * // Opening the P element increases the depth. 640 * $processor->next_token(); 641 * 4 === $processor->get_current_depth(); 642 * 643 * // The P element is closed during `next_token()` so the depth is decreased to reflect that. 644 * $processor->next_token(); 645 * 3 === $processor->get_current_depth(); 646 * 647 * @since 6.6.0 648 * 649 * @return int Nesting-depth of current location in the document. 650 */ 651 public function get_current_depth() { 652 return $this->state->stack_of_open_elements->count(); 624 653 } 625 654
Note: See TracChangeset
for help on using the changeset viewer.