Conflict with Polylang when saving locations
-
Hello,
I am the author of Polylang and a conflict has been reported when saving locations.
How to reproduce?
Install Max Mega Menu and Polylang. Add 2 languages in Polylang, for exemple English and Fran?ais. Then go to Mega Menu > Menu Locations and click on “Add another menu location”. Two new locations are created: “Max Mega Menu Location 1 English” and “Max Mega Menu Location 1 Fran?ais” and everything looks good.
Then open one location and click on “Save changes”. The locations are renamed to
“Max Mega Menu Location 1 English English”, and “Max Mega Menu Location 1 Fran?ais Fran?ais”. Each time you save changes on more “English” and “Fran?ais” are appended to the description.If I rename only one location, it’s ok for this one, but the other gets an additional language name.
If I rename *both* locations for example to “Main Menu” and click to “Save changes”, then I get “Main Menu English” and “Main Menu Fran?ais” as one could expect. But after doing that I can’t add anymore location.
I debugged this latest issue and found the source in
Mega_Menu_Settings::get_next_menu_location_id()
In this function, you expect that the location identifier ends by an integer which is true with Max Mega Menu alone, but wrong when combined with Polylang. You would getmax_mega_menu_1
as you expect for the default language butmax_mega_menu_1___fr
for the French location.
I suggest to replace the line:
$menu_id = end( $parts );
by
$menu_id = (int) end( $parts );
which solves the issue for me.
- The topic ‘Conflict with Polylang when saving locations’ is closed to new replies.