Automattic\WooCommerce\Internal\ShopperLists

ShopperListsController::add_wishlist_menu_itempublicWC 1.0

Insert the Wishlist link just before the logout link.

Method of the class: ShopperListsController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ShopperListsController = new ShopperListsController();
$ShopperListsController->add_wishlist_menu_item( $items ): array;
$items(array) (required)
Existing menu items keyed by slug.

ShopperListsController::add_wishlist_menu_item() code WC 11.0.1

public function add_wishlist_menu_item( $items ): array {
	if ( ! is_array( $items ) ) {
		return array();
	}

	$wishlist_endpoint = $this->get_wishlist_endpoint();
	$wishlist_label    = __( 'Wishlist', 'woocommerce' );

	// Insert the wishlist item before the logout item, or at the end if not present.
	$logout_pos = array_search( 'customer-logout', array_keys( $items ), true );
	if ( false === $logout_pos ) {
		$items[ $wishlist_endpoint ] = $wishlist_label;
	} else {
		$items = array_slice( $items, 0, $logout_pos, true )
			+ array( $wishlist_endpoint => $wishlist_label )
			+ array_slice( $items, $logout_pos, null, true );
	}
	return $items;
}