Automattic\WooCommerce\Blocks

CoreBreadcrumbsCompatibility::get_shop_page_breadcrumb_item │ private │ WC 1.0

Get the shop page breadcrumb item.

Method of the class: CoreBreadcrumbsCompatibility{}

No Hooks.

Returns

array|null. Shop page breadcrumb item.

Usage

// private - for code of main (parent) class only
$result = $this->get_shop_page_breadcrumb_item( $shop_url );
$shop_url(string)
Shop archive URL.
Default: ''

CoreBreadcrumbsCompatibility::get_shop_page_breadcrumb_item() code WC 11.1.2

private function get_shop_page_breadcrumb_item( $shop_url = '' ) {
	$shop_page  = $this->get_woocommerce_page_post( 'shop' );
	$shop_url   = $shop_url ? $shop_url : (
		$shop_page ? get_permalink( $shop_page ) : get_post_type_archive_link( 'product' )
	);
	$shop_label = $shop_page ? get_the_title( $shop_page ) : '';

	if ( ! $shop_label ) {
		$product_post_type = get_post_type_object( 'product' );
		$shop_label        = $product_post_type ? $product_post_type->labels->name : '';
	}

	if ( ! $shop_url || ! $shop_label ) {
		return null;
	}

	return array(
		'label' => $shop_label,
		'url'   => $shop_url,
	);
}