Automattic\WooCommerce\Blocks
CoreBreadcrumbsCompatibility::prepend_shop_page_to_breadcrumbs
Prepend the shop page to breadcrumb items.
Method of the class: CoreBreadcrumbsCompatibility{}
No Hooks.
Returns
array. Modified breadcrumb items.
Usage
// private - for code of main (parent) class only $result = $this->prepend_shop_page_to_breadcrumbs( $items );
- $items(array) (required)
- Array of breadcrumb items from Core.
CoreBreadcrumbsCompatibility::prepend_shop_page_to_breadcrumbs() CoreBreadcrumbsCompatibility::prepend shop page to breadcrumbs code WC 11.1.2
private function prepend_shop_page_to_breadcrumbs( $items ) {
$shop_page_item = $this->get_shop_page_breadcrumb_item();
if ( empty( $shop_page_item ) ) {
return $items;
}
$shop_page_index = $this->get_breadcrumb_item_index_by_url( $items, $shop_page_item['url'] );
if ( null !== $shop_page_index ) {
return $this->replace_breadcrumb_label_at_index( $items, $shop_page_index, $shop_page_item['label'] );
}
return $this->insert_parent_breadcrumb_item_if_missing_url( $items, $shop_page_item );
}