Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #1296731

    Hi,

    After upgrading to 4.8.2, the language flags (WPML) are back in the menu. We’re using this function, to hide the flags:

    
    //--------------------------------------------------------------
    // Remove Enfold Language Switcher
    //--------------------------------------------------------------
    function avia_remove_main_menu_flags(){
            remove_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 9998, 2 );
            remove_filter( 'avf_fallback_menu_items', 'avia_append_lang_flags', 9998, 2 );
            remove_action( 'avia_meta_header', 'avia_wpml_language_switch', 10);
    }
    add_action('after_setup_theme','avia_remove_main_menu_flags');
    

    This function worked for a long time. Now since 4.8.2 it doesn’t work anymore. Why?

    Regards,
    Bernd

    #1297113

    Hey Bernd,

    Thank you for the inquiry.

    The previous handlers for the language switcher have been transferred to a different config file. Try to use this filter instead.

    
    //--------------------------------------------------------------
    // Remove Enfold Language Switcher
    //--------------------------------------------------------------
    function avia_remove_main_menu_flags(){
            remove_filter( 'wp_nav_menu_items', array( 'avia_WPML', 'handler_append_lang_flags' ), 9998, 2 );
    	remove_filter( 'avf_fallback_menu_items', array( 'avia_WPML', 'handler_append_lang_flags' ), 9998, 2 );
            remove_action( 'avia_meta_header', 'avia_wpml_language_switch', 10 );
            remove_action( 'ava_main_header_sidebar', 'avia_wpml_language_switch', 10 );
    }
    add_action('after_setup_theme','avia_remove_main_menu_flags');
    
    

    Or use this..

    function avia_append_lang_flags( $items, $args )
    	{
    		return $items;
    	}
    

    Best regards,
    Ismael

    #1297124

    Neither of these 2 code snippet solved the flags issue. They are still visible. The first code actually added a second list of flags.

    Why are you not adding this as an option in the theme setting? It doesn’t make sense that after a minor theme upgrade we need to deal with this kind of issues.

    #1297143

    Hi Ismael,

    I have the same problems as edanpr with your snippets :-(

    Regards,
    Bernd

    • This reply was modified 3 years, 6 months ago by Bernd.
    #1297308

    Hi,

    Sorry about that. We forgot to replace the add_filter with the remove_filter function. This is why another set of flags occur in the page. We edited the snippet above. Please try it again.

    Why are you not adding this as an option in the theme setting?

    We carefully choose which settings are actually needed in the theme options and try not to include everything in it. This is to keep the theme lean and clean as possible. And besides, having a language switcher on a multi-language site is a must, so it doesn’t really make sense to disable it, unless you want to configure or add your own set of language switcher, which is probably what you are after.

    Best regards,
    Ismael

    #1297329

    Thanks for the fix and the explanation about the setting (I don’t fully agree, but understand the reasoning). Unfortunately it still doesn’t work for me, waiting to hear if it worked for Bernd.

    I included my website privately, if you want to see it.

    I know it’s possible to solve this with CSS as well, but I prefer a PHP solution to prevent it from being on the page in the first place.

    Hope there is another solution.

    #1297396

    Hi,

    It works, but only in the main menu :-/ I am using a second small menu above the main menu. And there the flag still appears. I would also prefer the PHP solution :-)

    Regards,
    Bernd

    • This reply was modified 3 years, 6 months ago by Bernd.
    #1297533

    Hi,

    Thank you for following up.

    It works, but only in the main menu

    Glad to know that it is partially working. To remove the language switcher from the top bar or from the secondary menu, we added this bit in the snippet above.

           remove_action( 'avia_meta_header', 'avia_wpml_language_switch', 10 );
            remove_action( 'ava_main_header_sidebar', 'avia_wpml_language_switch', 10 );
    

    Please try it again.

    Best regards,
    Ismael

    #1297548

    Still didn’t solve the issue for me.

    BTW: I think there is a typo with the new code, did you mean “avia_main_header_sidebar” (and not “ava”) I checked with both spellings.

    Is there any other suggestion?

    Thank you

    #1297611

    The same here :-( Not solved the issue. The flag went off from the top bar, back in to the main menu…
    No matter if I use avia_main_header_sidebar or ava_main_header_sidebar.

    Regards,
    Bernd

    #1297865

    Hi,

    Did you actually use the whole snippet above?

    //--------------------------------------------------------------
    // Remove Enfold Language Switcher
    //--------------------------------------------------------------
    function avia_remove_main_menu_flags(){
            remove_filter( 'wp_nav_menu_items', array( 'avia_WPML', 'handler_append_lang_flags' ), 9998, 2 );
    	remove_filter( 'avf_fallback_menu_items', array( 'avia_WPML', 'handler_append_lang_flags' ), 9998, 2 );
            remove_action( 'avia_meta_header', 'avia_wpml_language_switch', 10 );
            remove_action( 'ava_main_header_sidebar', 'avia_wpml_language_switch', 10 );
    }
    add_action('after_setup_theme','avia_remove_main_menu_flags');
    

    Best regards,
    Ismael

    #1297943

    Yes, used the full snippet with and without the “ava” typo.

    #1298070

    Me too…

    Regards,
    Bernd

    #1298173

    Hi,

    Odd. This same snippet works properly on our end. @Bernd Please post the FTP and WP details in the private field so that we could check it further.

    Best regards,
    Ismael

    #1298506

    Ok.

    #1298879

    Hi,

    We just noticed that there is a new settings in the Enfold > Header > Extra Elements panel. The Enfold WPML Language Flags ( global setting – used for all languages ) settings should allow you to disable the default flags from the theme without removing the extra filters that the avia_WPML class added.


    @Bernd
    : We set the settings to the second option to disable the flags.

    Best regards,
    Ismael

    #1298919

    I confirm that using the setting – Enfold > Header > Extra Elements -> Enfold WPML Language Flags ( global setting – used for all languages ) , solved my issue (don’t need the snippet code).

    Thanks

    #1298926

    Hi,

    Thanks a lot. It works also on our other client sites with the old snippet code :-)

    Best regards,
    Bernd

    #1299245

    Hi,

    Glad to know that the option is working. Please feel free to open another thread if you need anything else. We will close this one for now.

    Have a nice day.

    Best regards,
    Ismael

Viewing 19 posts - 1 through 19 (of 19 total)
  • The topic ‘Language flags back in the menu after upgrading to 4.8.2’ is closed to new replies.