• Resolved ludwigt

    (@ludwigt)


    The multi-lanuage manager plug-in PolyLang has a feature where you insert a language switcher into the menu.
    This little feature knocks CMW off the grid completely.
    Not a trace of it seems to show up in the generated HTML code as long as the switch exists within the menu.

    Great work with this plug-in though!

    kind regards
    Ludwig T

    https://www.ads-software.com/plugins/custom-menu-wizard/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wizzud

    (@wizzud)

    Thanks, I’ll investigate…

    Plugin Author wizzud

    (@wizzud)

    Findings so far (note that this is not a solution, more of an aide memoire for me)…

    Yep, CMW can not cope with the PolyLang switcher in the menu (especially when configured for Children Of anything involving current item).

    Why? …
    If a page in the menu has a second language alternative then when that page is the current menu item the language-switcher entry for the page’s language also gets “current” status. This means that there are 2 items in the menu with “current” status : the page item (correctly), and the language-switcher item for the language of the current page (incorrectly – my opinion, so probably debatable).
    CMW doesn’t expect more than one item to have a “current” status, so if the language-switcher item comes after the page item (in the menu order), then the language-switcher is determined as being the “current” item as far as CMW is concerned. If the page item happens to come after the language-switcher item, then the page item would be the “current” item (as far as CMW is concerned) and CMW would correctly show it as such.
    Basically, when determining the “current” item, CMW takes the last item marked as “current” from the elements passed to it by WordPress. So if the language-switcher is at the bottom of the menu then it will override the page’s “current” item status. If language-switcher were at the top of the menu, then the page’s “current” item status would be recognised by CMW.

    There’s a second problem with the language-switcher item in the menu, and that is that it does not consist of a single item! When the list of menu item elements reaches the widget the language-switcher menu item has become one item per language, and each of those items has the same ID!
    Now this is also something that CMW does not expect, and as a consequence CMW will only show the last of the languages put out by the switcher (if you set CMW to Show All, for example, instead of Children of Current Item).
    WordPress’s own Custom Menu widget copes with this non-unique ID situation slightly better than CMW, in that it does output all the language items … but it still doesn’t expect IDs to be duplicated as one can tell by adding, say, a page item as the child of the language-switcher item in the menu structure – the child page gets assigned to the first language (only) whereas one would ideally prefer it to be assigned as a child of the last language (to keep the languages together in a block).

    Where does this get me? Or you?
    Nowhere at the moment because, as noted at the top, this is not a solution … and I’m afraid I don’t currently have a solution, so I can only apologise for CMW’s inadequacy in this respect. I will keep looking at it, but please don’t hold your breath in expectation, because I’m not sure it’s feasibly solvable!

    If a page in the menu has a second language alternative then when that page is the current menu item the language-switcher entry for the page’s language also gets “current” status. This means that there are 2 items in the menu with “current” status : the page item (correctly), and the language-switcher item for the language of the current page (incorrectly – my opinion, so probably debatable)

    The current status on language item is added by WordPress but should be removed by Polylang (in the wp_nav_menu_objects filter). Normally the language item should end with the current status only on the home page (which may lead to 2 current items if there a home item).

    When the list of menu item elements reaches the widget the language-switcher menu item has become one item per language, and each of those items has the same ID!

    That’s clearly a Polylang bug. I will append the language code to the current ID in future versions (the modification is already done in 1.2 beta).

    Plugin Author wizzud

    (@wizzud)

    Having more than one item in the menu marked as “current” is actually easily achievable – merely by adding the same page to the menu twice – so it’s by no means a PolyLang-specific situation. I have changed CMW (v2.0.2) to only take the first one encountered (it used to allow subsequent “current” items to override any previous, and so ended up with the last one found). This should resolve the CMW visibility problem … at least for those people that have the language-switcher at the end of their menu (which I’m hoping might be the most likely scenario).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PolyLang incompatibility’ is closed to new replies.