Automattic\WooCommerce\Internal\ShopperLists

ShopperListsController::add_wishlist_menu_item │ public │ WC 1.0

Insert the Wishlist link just before the logout link.

Метод класса: ShopperListsController{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ShopperListsController = new ShopperListsController();
$ShopperListsController->add_wishlist_menu_item( $items ): array;
$items(массив) (обязательный)
Existing menu items keyed by slug.

Код ShopperListsController::add_wishlist_menu_item() WC 11.2.2

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;
}