• Resolved fkoomek

    (@fkoomek)


    Hello. I am using an older version of your plugin (before rewriting the code) and through searching this forum I was able to make it work with Polylang. Based on the answer here in support I use code like this:

    if (get_locale() == 'cs_CZ') {
            //Display the Czech left menu
    	wp_nav_menu( array(
                        'menu'            => 'my-menu-l-cz',
                        'items_wrap'      => '<ul id="mobmenuleft" class="%2$s">%3$s</ul>',
                        'container_class' => 'menu rounded',
                        'container'       => '',
                        'fallback_cb'     => false,
                        'depth'           => 3,
                        'walker'          => new WP_Mobile_Menu_Walker_Nav_Menu( 'left' ),
                    ) );	
        } else {
           			
                    //Display the Default left menu
                    wp_nav_menu( array(
                        'menu'            => 'my-menu-l-en',
                        'items_wrap'      => '<ul id="mobmenuleft" class="%2$s">%3$s</ul>',
                        'container_class' => 'menu rounded',
                        'container'       => '',
                        'fallback_cb'     => false,
                        'depth'           => 3,
                        'walker'          => new WP_Mobile_Menu_Walker_Nav_Menu( 'left' ),
                    ) );

    The same was for the right menu.
    However, the new version of your plugin works differently. I found code (class-wp-mobile-menu-core.php – line 507:

         if ( '' !== $current_menu ) {
                // Display the menu.
                $output = wp_nav_menu( array(
                    $menu_param   => $current_menu,
                    'items_wrap'  => '<ul id="mobmenu' . $menu . '">%3$s</ul>',
                    'fallback_cb' => false,
                    'depth'       => $mobmenu_depth,
                    'walker'      => new WP_Mobile_Menu_Walker_Nav_Menu( $menu, '' ),
                    'echo'        => false,
                ) );
    

    It seems that this code handles displaying both, right and left menu together. So, if I replace $current_menu with for example ‘my-menu-l-cz’, both, the left and the right menu shows this menu. Could you help me with what condition to use or how to separate the left and right menu so that I could use the Polylang condition and make it work?
    Many thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter fkoomek

    (@fkoomek)

    So, from line 507 it’s:

            if ( '' !== $current_menu ) {
    			if (get_locale() == 'cs_CZ') {
    			if($menu =='right'){
                // Display the right CZ menu.
                $output = wp_nav_menu( array(
                    $menu_param   => 'menu-r-cz',
                    'items_wrap'  => '<ul id="mobmenu' . $menu . '">%3$s</ul>',
                    'fallback_cb' => false,
                    'depth'       => $mobmenu_depth,
                    'walker'      => new WP_Mobile_Menu_Walker_Nav_Menu( $menu, '' ),
                    'echo'        => false,
                ) );
    			}
    			
    			else if($menu =='left'){
                // Display the left CZ menu.
                $output = wp_nav_menu( array(
                    $menu_param   => 'my-menu-l-cz',
                    'items_wrap'  => '<ul id="mobmenu' . $menu . '">%3$s</ul>',
                    'fallback_cb' => false,
                    'depth'       => $mobmenu_depth,
                    'walker'      => new WP_Mobile_Menu_Walker_Nav_Menu( $menu, '' ),
                    'echo'        => false,
                ) );
    			}
    			}
    	else{
    			if($menu =='right'){
                // Display the right EN menu.
                $output = wp_nav_menu( array(
                    $menu_param   => 'menu-r-en',
                    'items_wrap'  => '<ul id="mobmenu' . $menu . '">%3$s</ul>',
                    'fallback_cb' => false,
                    'depth'       => $mobmenu_depth,
                    'walker'      => new WP_Mobile_Menu_Walker_Nav_Menu( $menu, '' ),
                    'echo'        => false,
                ) );
    			}
    			
    			else if($menu =='left'){
                // Display the left EN menu.
                $output = wp_nav_menu( array(
                    $menu_param   => 'my-menu-l-en',
                    'items_wrap'  => '<ul id="mobmenu' . $menu . '">%3$s</ul>',
                    'fallback_cb' => false,
                    'depth'       => $mobmenu_depth,
                    'walker'      => new WP_Mobile_Menu_Walker_Nav_Menu( $menu, '' ),
                    'echo'        => false,
                ) );
    			}
    	}
    • This reply was modified 5 years ago by fkoomek.
    Plugin Author Rui Guerreiro

    (@takanakui)

    Hi @fkoomek,

    I guess it shouldn’t be necessary to the modifications because if the menu is translated the wp_nav_menu should pick the correct menu.

    Doesn’t that happen with your main desktop menu?

    Can you provide me your site URL to have a look?

    Thanks

    Thread Starter fkoomek

    (@fkoomek)

    Hello.
    You’re right, I noticed in appearance – menus there is an option to assign left and right menu to all languages I have set in Polylang. However, when I did it this way, it broke the menus on frontend. Although I see that the correct menus are appended, also some strange elements are appended there too and the menus are broken and invisible. I haven’t had enough time to test it further yet. However, when I inserted menus directly in the code like I mentioned before it worked fine without problems.

    • This reply was modified 4 years, 12 months ago by fkoomek.
    Plugin Author Rui Guerreiro

    (@takanakui)

    It could have been a cache issue or something. In WP Mobile Menu we prepare all our strings for translation, besides that there isn’t any other integration with translation plugins.

    Thanks

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