You are here

function node_noindex_html_head_alter in Node Noindex 7

Implements hook_html_head_alter().

Remove rel canonical if noindex is set.

File

./node_noindex.module, line 79

Code

function node_noindex_html_head_alter(&$head_elements) {
  $noindex = _node_noindex_preg_grep_keys('/node_noindex/', $head_elements);
  if (empty($noindex)) {

    // Noindex is not set.
    return;
  }
  $keys = _node_noindex_preg_grep_keys('/drupal_add_html_head_link:canonical:/', $head_elements);
  foreach ($keys as $key => $value) {

    // Remove rel canonical.
    unset($head_elements[$key]);
  }
}