Created
October 10, 2012 12:03
-
-
Save mrcgrtz/3865185 to your computer and use it in GitHub Desktop.
Remove unneeded meta tags and links from Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Override or insert variables into the HTML head. | |
* | |
* @param $head_elements | |
* An array of variables to pass to the HTML head. | |
*/ | |
function MYTHEME_html_head_alter(&$head_elements) { | |
// remove unneeded metatags | |
$remove = array( | |
//'system_meta_content_type', // Content Type | |
'system_meta_generator', // Generator | |
'metatag_canonical', // Canonical Link | |
'rdf_node_title', // DC:Title | |
); | |
foreach ($remove as $item) { | |
if (isset($head_elements[$item])) { | |
unset($head_elements[$item]); | |
} | |
} | |
// remove unneeded links | |
$remove = array( | |
'/^drupal_add_html_head_link:shortcut icon:/', // Favicon | |
'/^drupal_add_html_head_link:shortlink:/', // Shortlink | |
); | |
foreach ($remove as $item) { | |
foreach (preg_grep($item, array_keys($head_elements)) as $key) { | |
unset($head_elements[$key]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment