Computes the HTML breadcrumbs for the currently-matched node, if matched.
Description
Breadcrumbs start at the outermost parent and descend toward the matched element.
They always include the entire path from the root HTML node to the matched element.
Source
public function get_breadcrumbs() {
$breadcrumbs = array();
foreach ( $this->state->stack_of_open_elements->walk_down() as $stack_item ) {
$breadcrumbs[] = $stack_item->node_name;
}
if ( ! $this->is_virtual() ) {
return $breadcrumbs;
}
foreach ( $this->element_queue as $queue_item ) {
if ( $this->current_element->token->bookmark_name === $queue_item->token->bookmark_name ) {
break;
}
if ( 'context-node' === $queue_item->token->bookmark_name ) {
break;
}
if ( 'real' === $queue_item->provenance ) {
break;
}
if ( WP_HTML_Stack_Event::PUSH === $queue_item->operation ) {
$breadcrumbs[] = $queue_item->token->node_name;
} else {
array_pop( $breadcrumbs );
}
}
if ( null !== parent::get_token_name() && ! parent::is_tag_closer() ) {
array_pop( $breadcrumbs );
}
// Add the virtual node we're at.
if ( WP_HTML_Stack_Event::PUSH === $this->current_element->operation ) {
$breadcrumbs[] = $this->current_element->token->node_name;
}
return $breadcrumbs;
}
Changelog
Version | Description |
---|---|
6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.