Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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.

    #1372534

    Hey,

    Thanks for contacting us!

    Our devs have fixed the issue and it will be included in upcoming version of Enfold :)

    Regards,
    Yigit

    #1372537

    Hey 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ünter

    #1372540

    this 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.

    #1372597

    Hi,

    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,
    Ismael

    #1372619

    Settings 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 1 year, 11 months ago by BlutVampir.
    #1372888

    Hi,


    @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,
    Ismael

    #1372952

    that code is running, thx alot !

    #1372977

    Hi,

    Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.