Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

share|improve this question
    
Should be closed. We can't look at the plugins source or test anything. –  kaiser Oct 11 '13 at 8:22
    
Possibly a DUPLICATE OF THIS QUESTION - read answer to see the problem you're facing. –  kaiser Oct 11 '13 at 8:23
add comment

2 Answers

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
    );
}
share|improve this answer
    
That doesn't work on my server, it works locally for me though. Facing WP 3.6.1 on PHP 5.2.6-1 on the server and on PHP 5.3 locally. Getting Parse error: syntax error, unexpected T_FUNCTION back`. –  Volker E. Oct 12 '13 at 9:27
1  
Is your server’s PHP version up to date? It should be at least version 5.4. –  toscho Oct 12 '13 at 9:28
    
You're amazingly fast ;) –  Volker E. Oct 12 '13 at 9:31
    
Is there a way to get this working in PHP 5.2.x? –  Volker E. Oct 12 '13 at 9:37
    
Yes, create a named function and use that as callback. But why would you stay with an insecure, slow and outdated PHP version? –  toscho Oct 12 '13 at 9:44
add comment

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.

share|improve this answer
    
Thanks for your input. First I thought it should be the array notation as well. But it doesn't work. :\ –  Volker E. Oct 11 '13 at 7:14
    
I've found an old theme of mine where just one line was used in functions.php: remove_action( 'wp_head', array($sitepress, 'meta_generator_tag' ) );. –  Max Yudin Oct 11 '13 at 7:46
    
Yeah, it shouldn't make to much difference. For me as administrator, I obviously should know which version of WPML I'm using. Still, it doesn't work. I also put in the add_filter to ensure meta_generator_tag isn't used. Could it be that it's not possible to override the function via theme's function.php (anymore, as of 2.8.1)? –  Volker E. Oct 11 '13 at 8:10
    
The last idea is to add global $sitepress; before the code above. –  Max Yudin Oct 11 '13 at 8:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.