Skip to content

Instantly share code, notes, and snippets.

@andriyun
Forked from mrcgrtz/template.php
Last active August 29, 2015 14:06
Show Gist options
  • Save andriyun/ffaaccf1d6f1a577bee6 to your computer and use it in GitHub Desktop.
Save andriyun/ffaaccf1d6f1a577bee6 to your computer and use it in GitHub Desktop.
<?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