Automattic\WooCommerce\Admin
PageController::get_breadcrumbs
Get breadcrumbs for WooCommerce Admin Page navigation.
Method of the class: PageController{}
Hooks from the method
Returns
Array. Navigation pieces (breadcrumbs).
Usage
$PageController = new PageController(); $PageController->get_breadcrumbs();
PageController::get_breadcrumbs() PageController::get breadcrumbs code WC 10.4.3
public function get_breadcrumbs() {
$current_page = $this->get_current_page();
// Bail if this isn't a page registered with this controller.
if ( false === $current_page ) {
// Filter documentation below.
return apply_filters( 'woocommerce_navigation_get_breadcrumbs', array( '' ), $current_page );
}
$page_title = ! empty( $current_page['page_title'] ) ? $current_page['page_title'] : $current_page['title'];
$page_title = (array) $page_title;
if ( 1 === count( $page_title ) ) {
$breadcrumbs = $page_title;
} else {
// If this page has multiple title pieces, only link the first one.
$breadcrumbs = array_merge(
array(
array( $current_page['path'], reset( $page_title ) ),
),
array_slice( $page_title, 1 )
);
}
if ( isset( $current_page['parent'] ) ) {
$parent_id = $current_page['parent'];
while ( $parent_id ) {
if ( isset( $this->pages[ $parent_id ] ) ) {
$parent = $this->pages[ $parent_id ];
if ( 0 === strpos( $parent['path'], self::PAGE_ROOT ) ) {
$parent['path'] = 'admin.php?page=' . $parent['path'];
}
array_unshift( $breadcrumbs, array( $parent['path'], reset( $parent['title'] ) ) );
$parent_id = isset( $parent['parent'] ) ? $parent['parent'] : false;
} else {
$parent_id = false;
}
}
}
$woocommerce_breadcrumb = array( 'admin.php?page=' . self::PAGE_ROOT, __( 'WooCommerce', 'woocommerce' ) );
array_unshift( $breadcrumbs, $woocommerce_breadcrumb );
/**
* The navigation breadcrumbs for the current page.
*
* @param array $breadcrumbs Navigation pieces (breadcrumbs).
* @param array|boolean $current_page The connected page data or false if not identified.
*/
return apply_filters( 'woocommerce_navigation_get_breadcrumbs', $breadcrumbs, $current_page );
}