WP_HTML_Processor::get_breadcrumbs(): string[]|null

In this article

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.

Return

string[]|null Array of tag names representing path to matched node, if matched, otherwise NULL.

Source

public function get_breadcrumbs() {
	if ( ! $this->get_tag() ) {
		return null;
	}

	$breadcrumbs = array();
	foreach ( $this->state->stack_of_open_elements->walk_down() as $stack_item ) {
		$breadcrumbs[] = $stack_item->node_name;
	}

	return $breadcrumbs;
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.