-
AuthorPosts
-
November 14, 2022 at 4:33 pm #1372527
There is a new handler for Enfold Flags…
Like here:
https://kriesi.at/support/topic/remove-wpml-language-flags/ or https://kriesi.at/support/topic/remove-enfold-language-switcher-and-use-wpml-language-switcher/I can add following Code in the child theme:
function avia_remove_main_menu_flags(){ global $avia_WPML; remove_filter( 'wp_nav_menu_items', [ new avia_WPML, 'handler_append_lang_flags' ], 9999, 2 ); remove_filter( 'wp_nav_menu_items', [ 'avia_WPML', 'handler_append_lang_flags' ], 9998, 2 ); remove_filter( 'avf_fallback_menu_items', [ new avia_WPML, 'handler_append_lang_flags' ], 9999, 2 ); remove_filter( 'avf_fallback_menu_items', [ '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('init','avia_remove_main_menu_flags', 9999);
but still the language flags are shown.
I can decomment the 2 lines in config-wpml/class-avia-wpml.php:
//add_filter( 'wp_nav_menu_items', array( $this, 'handler_append_lang_flags' ), 9998, 2 ); //add_filter( 'avf_fallback_menu_items', array( $this, 'handler_append_lang_flags' ), 9998, 2 );
and the flags are gone, but not via code in the child theme. This will break at the next update… :/
How can I remove that over the child theme?
I do not want to use CSS or jQuery for those matters, as Google can find that code equalless what on the site. Please deliver a way for removing it via remove_filter. The other threads only including workaround for removal not a solution.Please deliver a new way with PHP which works to remove your unnessesary code in the child theme.
November 14, 2022 at 5:09 pm #1372534Hey,
Thanks for contacting us!
Our devs have fixed the issue and it will be included in upcoming version of Enfold :)
Regards,
YigitNovember 14, 2022 at 5:24 pm #1372537Hey BlutVampir,
Use
Avia_WPML()
to get the instance of the class for the handlers.
e.g.:
remove_filter( 'wp_nav_menu_items', [ Avia_WPML(), 'handler_append_lang_flags' ], 9998, 2 );
Best regards,
GünterNovember 14, 2022 at 5:37 pm #1372540this code:
add_action('init','avia_remove_main_menu_flags', 9999); function avia_remove_main_menu_flags() { remove_filter( 'wp_nav_menu_items', [ avia_WPML(), 'handler_append_lang_flags' ], 9999, 2 ); remove_filter( 'avf_fallback_menu_items', [ avia_WPML(), 'handler_append_lang_flags' ], 9999, 2 ); }
is not working.
November 15, 2022 at 6:10 am #1372597Hi,
Thank you for the update.
Have you tried disabling the flags from the Enfold > Header > Extra Elements panel? Please look for the Enfold WPML Language Flags (Global Setting) and adjust it accordingly.
this code: is not working.
You can try this instead.
add_action('after_setup_theme','avia_remove_main_menu_flags', 9999); function avia_remove_main_menu_flags() { remove_filter( 'wp_nav_menu_items', [ avia_WPML(), 'handler_append_lang_flags' ], 9999, 2 ); remove_filter( 'avf_fallback_menu_items', [ avia_WPML(), 'handler_append_lang_flags' ], 9999, 2 ); }
Or as we mentioned above, the flag settings can be adjusted from the Extra Elements panel.
Best regards,
IsmaelNovember 15, 2022 at 10:36 am #1372619Settings Option is working, but that means, I need to connect to around 20 sites and set manually the option.
I could update the php code and make a normal rollout, but unfortunatly, that code is also not working.
As said, there is a big issue with filters in an class within the theme to remove from child theme.You can as long as you want try to fix the code, but its not running properly. Why test that code within 5 mins and fail then to repeatly try to give wrong answers? Can you please give me a code which is working to remove over your filter which is working? Otherwise the hooks are useless (Yes, they are, as you cant remove them as it seams).
- This reply was modified 2 years, 1 month ago by BlutVampir.
November 17, 2022 at 5:52 am #1372888Hi,
@Guenter noticed that the priority number is incorrect. It should be 9998 instead of 9999, and we can revert the hook back to init instead of using the after_setup_theme hook. Please try this code again.add_action('init','avia_remove_main_menu_flags', 9999); function avia_remove_main_menu_flags() { remove_filter( 'wp_nav_menu_items', [ avia_WPML(), 'handler_append_lang_flags' ], 9998, 2 ); remove_filter( 'avf_fallback_menu_items', [ avia_WPML(), 'handler_append_lang_flags' ], 9998, 2 ); }
Thank you for your patience.
Best regards,
IsmaelNovember 17, 2022 at 2:48 pm #1372952that code is running, thx alot !
November 17, 2022 at 5:32 pm #1372977 -
AuthorPosts
- You must be logged in to reply to this topic.