• Resolved pixelyzed

    (@pixelyzed)


    I’ve read about a few issues some are having with the latest updates here. My problem seems different.

    What happens is that, after I update to the l;atest version (from 1.1 or 1.2), the language link in the menu disappears. Also, if I look at the pages list in the admin, the pages look unlinked/untraslated and if I open a specific page, the MSLS drop down to select the corresponding page in another language is empty. All pages were actually linked correctly before.

    Any idea what may be going on? This is a serious issue for us as most of our sites are bilingual and use your plugin.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    This is kind of strange but let me understand what’s going on:

    – Is that in every site the case? Like A does not see B and B does not see A?
    – Do you use custom code for filters or action provided by MSLS?
    – Does return back to 1.0.8 (the latest stable here) or 1.2 (at Github https://github.com/lloc/Multisite-Language-Switcher/releases) resolve that problem?

    Thread Starter pixelyzed

    (@pixelyzed)

    Hi!

    So far I had updated 2 client sites (including dev copies of each). I didn’t notice it until I updated in the second site’s dev copy. The first site was already updated and missing the language link.

    And yes I use the following code I found in MSLS docs somewhere. Been using variants of this for years (sometimes the link’s html changes or I target menus by name vs location but I always use the same hook.

    add_filter( 'wp_nav_menu_items', 'zw3_lang_switcher_menu_item', 10, 2 );
    function zw3_lang_switcher_menu_item( $items, $args ) {
    	// Typical condition if menu is in normal menu location:
    	// && 'secondary' == $args->theme_location
    	// Typical condition if menu is not in normal menu location and needs to be targeted by name:
    	// && 'Secondary' == $args->menu->name
    	if ( class_exists( 'MslsOutput' ) && 'Primary' == $args->menu->name ) {
    		$obj = new MslsOutput;
    		$arr = $obj->get( 1 );
    		if ( !empty( $arr ) ) {
    			$items .= '<li class="menu-item lang-switcher menu-item-type-custom menu-item-object-custom">' . implode( '</li><li class="menu-item menu-item-type-custom menu-item-object-custom">', $arr ) . '</li>';
    		}
    	}
    	return $items;
    }

    Returning back to 1.1 (the latest version I had downloaded) fixes it instantly, including the seemingly broken links between pages in different sites.

    Thanks!

    • This reply was modified 5 years, 11 months ago by pixelyzed.
    Thread Starter pixelyzed

    (@pixelyzed)

    FWIW, one site is on the Genesis theme and the other on GeneratePress.

    Plugin Author Dennis Ploetner

    (@realloc)

    There are at least two options because the code is outdated:

    1. You could use the addon MslsMenu -> https://www.ads-software.com/plugins/mslsmenu/
    2. or rewrite the code a bit:

    add_filter( 'wp_nav_menu_items', 'zw3_lang_switcher_menu_item', 10, 2 );
    function zw3_lang_switcher_menu_item( $items, $args ) {
    	if ( class_exists( lloc\Msls\MslsOutput::class ) && 'Primary' == $args->menu->name ) {
    		$obj = lloc\Msls\MslsOutput::init();
    		$arr = $obj->get( 1 );
    		if ( ! empty( $arr ) ) {
    			$items .= '<li class="menu-item lang-switcher menu-item-type-custom menu-item-object-custom">' . implode( '</li><li class="menu-item menu-item-type-custom menu-item-object-custom">', $arr ) . '</li>';
    		}
    	}
    	return $items;
    }
    Thread Starter pixelyzed

    (@pixelyzed)

    Hi Dennis,

    I updated the code and it indeed fixed the missing language link in menus. Awesome!

    On the other hand, I’M still seeing issues in the admin and the linking between pages in different language sites.

    I updated the plugin then uploaded the changed code. In the pages’ list, the pages that were linked to their counterpart in the other language site show as linked (I mean the chain/pencil icon “Create a new translation/Modify the translation) but, in the front end, some language links point to the other site’s home page and not the actual translated page it should link to.

    I need to open the page to edit and, this time the selection drop down is populated. I then just save the page and the front en link works again.

    I will need to test this again when I update another site. I will upload the new code first, then update the plugin and then report back what I find out.

    Thank you VERY much for your quick help so far. It is much apreciated!

    Plugin Author Dennis Ploetner

    (@realloc)

    Did you have the chance to test the latest version (v2.0.3)?

    Thread Starter pixelyzed

    (@pixelyzed)

    Hi!

    Yes, I just updated two sites from 1.1 to 2.0.3 without issue. In one case I uploaded the new code you provided first and in the other I put it after the update. No issues with either updates.

    Thank you very much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Translation Link Disappear from Menu after Update’ is closed to new replies.