This used to work fine for as long as I can remember:
function mytheme_html_head_alter(&$elements) {
unset($elements['system_meta_generator']);
}
I've tried the above code (minus the closing php tag and replaced the mytheme part with my theme's actual name) in my theme's template.php in latest D7 dev and it simply won't do magic any more :/
I have also tried various other flavors suggested around d.o and elsewhere over the internet like using &$head_elements
instead of &$elements
and meta_generator
instead of &$system_meta_generator
to no avail.
From what I've found, the code responsible for generating the "Generator" (no pun intended) meta tag is this part in /includes/common.inc:
// Show Drupal and the major version number in the META GENERATOR tag.
// Get the major version.
list($version, ) = explode('.', VERSION);
$elements['system_meta_generator'] = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array(
'name' => 'Generator',
'content' => 'Drupal ' . $version . ' (http://drupal.org)',
),
);
So &$elements
and system_meta_generator
should be the ones to work (in theory at least). Am I doing something wrong or did something perhaps change in core in the meantime?
Comments
Comment #1
floydm CreditAttribution: floydm commentedYour snippet removed the Generator tag for me in 7.19. Did you clear cache?
Comment #2
klonosI use latest 7.x-dev and yes I did try clearing all caches after each edit in my template.php.
Comment #3
klonos...stupid me! I had a typo (wrong letter case actually) in the "mytheme_" part of the function name.