How to remove WPML Generator Meta Tag by theme’s functions.php (override plugin function)?

I’ve tried hard to find a way to not let plugin WPML output the following <meta name="generator" content="WPML ver:2.8.1 stt:3,1;0" /> tag in <head> via help of theme’s function.php:

It’s called in sitepress.class.php beginning with line 255

Read More
if ( !is_admin() ) {
    add_action( 'wp_head', array( $this, 'meta_generator_tag' ) );
}

This specific question has already been asked once in WPML forum.
I’ve tried:

/* ::: Disable WPML Meta Generator Tag ::: */
if ( ! is_admin() ) {
    remove_action( 'wp_head', 'meta_generator_tag', 20 );
}
add_filter( 'meta_generator_tag', 'theme_generator_tag' );

function theme_generator_tag() {
    return false;
}

— without success

Related posts

2 comments

  1. The instance of this class is made global by WPML, so this should work:

    if ( ! empty ( $GLOBALS['sitepress'] ) ) {
        add_action( 'wp_head', function()
        {
            remove_action(
                current_filter(),
                array ( $GLOBALS['sitepress'], 'meta_generator_tag' )
            );
        },
        0
        );
    }
    
  2. Try this (note different remove_action():

    if(!is_admin()){
        remove_action( 'wp_head', array($sitepress, 'meta_generator_tag') );
    }
    add_filter( 'meta_generator_tag', 'theme_generator_tag' );
    
    function theme_generator_tag() {
        return false;
    }
    

    It worked for versions 2.0.4.1 and before, but not tested for newer ones.

Comments are closed.