Crocoblock / suggestions

The suggestions for CrocoBlock project
196 stars 79 forks source link

JetMenu: mega menu mobile does not use wpml current lang menu when logged out #3435

Open lukechinworth opened 3 years ago

lukechinworth commented 3 years ago

Describe the bug When logged out and viewing a wpml translation, the mega menu widget uses the translation of the selected menu for the desktop view, but not for the mobile view.

To Reproduce Steps to reproduce the behavior:

  1. Install elementor, jet menu, and wpml.
  2. Create a wp menu for the base language, and create a wp menu for the secondary language, and for "translation of" select the first menu.
  3. add the mega menu widget to an elementor page, and select the base menu for the desktop and mobile view.
  4. View the page on the front end in desktop for the base language, and the base menu displays.
  5. change to the secondary language on desktop and the secondary menu displays.
  6. change to mobile view and refresh the secondary language. Open the menu, and the base menu is displayed.

Expected behavior The secondary language menu should display on mobile when viewing the secondary language page. NOTE: this does work when logged in because the "dev" param is true.

Desktop (please complete the following information):

Additional context I believe the jet menu plugin needs to filter the menu id to the secondary menu id either when generating the markup, or in the ajax request to load the menu items:

mbaierl commented 2 years ago

The bug is in jet-menu/includes/rest-api/endpoints/get-menu-items.php function callback($request)

The function stores the result in a transient, but does NOT include the language when doing that: $transient_key = md5( sprintf( 'jet_menu_remote_items_data_%s', $menu_id ) );

Thus on another request the cached menu in the wrong language is loaded.

Easy to fix by including the language in the above mentioned code that generates the $transient_key variable.

@Crocoblock - until when will you fix this, the issue exists since June 2021?

mbaierl commented 2 years ago

The same applies to JetTabs File: jet-tabs/includes/rest-api/endpoints/elementor-template.php Function: callback The caching happens independent from the language.

mbaierl commented 2 years ago

In the file jet-menu/includes/rest-api/endpoints/get-menu-items.php, function "callback" (line 50) the following has to be added as well: $menu_id = apply_filters('wpml_object_id', $menu_id, 'nav_menu', true);