-
AuthorPosts
-
April 26, 2021 at 11:38 am #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,
BerndApril 28, 2021 at 8:02 am #1297113Hey 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,
IsmaelApril 28, 2021 at 8:56 am #1297124Neither 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.
April 28, 2021 at 11:49 am #1297143Hi Ismael,
I have the same problems as edanpr with your snippets :-(
Regards,
Bernd- This reply was modified 3 years, 7 months ago by Bernd.
April 29, 2021 at 11:32 am #1297308Hi,
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,
IsmaelApril 29, 2021 at 12:51 pm #1297329Thanks 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.
April 29, 2021 at 4:44 pm #1297396Hi,
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, 7 months ago by Bernd.
April 30, 2021 at 12:38 pm #1297533Hi,
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,
IsmaelApril 30, 2021 at 1:11 pm #1297548Still 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
April 30, 2021 at 5:29 pm #1297611The 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,
BerndMay 3, 2021 at 6:03 am #1297865Hi,
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,
IsmaelMay 3, 2021 at 9:12 am #1297943Yes, used the full snippet with and without the “ava” typo.
May 3, 2021 at 5:20 pm #1298070Me too…
Regards,
BerndMay 4, 2021 at 7:29 am #1298173Hi,
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,
IsmaelMay 5, 2021 at 12:01 pm #1298506Ok.
May 7, 2021 at 9:03 am #1298879Hi,
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,
IsmaelMay 7, 2021 at 11:27 am #1298919I 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
May 7, 2021 at 12:10 pm #1298926Hi,
Thanks a lot. It works also on our other client sites with the old snippet code :-)
Best regards,
BerndMay 10, 2021 at 5:59 am #1299245 -
AuthorPosts
- The topic ‘Language flags back in the menu after upgrading to 4.8.2’ is closed to new replies.