function drupal_add_html_head_link

Adds a LINK tag with a distinct 'rel' attribute to the page's HEAD.

This function can be called as long the HTML header hasn't been sent, which on normal pages is up through the preprocess step of theme('html'). Adding a link will overwrite a prior link with the exact same 'rel' and 'href' attributes.

Parameters

$attributes: Associative array of element attributes including 'href' and 'rel'.

$header: Optional flag to determine if a HTTP 'Link:' header should be sent.

7 calls to drupal_add_html_head_link()
drupal_add_feed in drupal/core/includes/common.inc
Adds a feed URL for the current page.
node_page_view in drupal/core/modules/node/node.module
Page callback: Displays a single node.
Rss::attachTo in drupal/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php
taxonomy_term_page in drupal/core/modules/taxonomy/taxonomy.pages.inc
Menu callback; displays all nodes associated with a term.
template_preprocess_book_navigation in drupal/core/modules/book/book.module
Prepares variables for book navigation templates.

... See full list

File

drupal/core/includes/common.inc, line 1636
Common functions that many Drupal modules will need to reference.

Code

function drupal_add_html_head_link($attributes, $header = FALSE) {
  $element = array(
    '#tag' => 'link',
    '#attributes' => $attributes,
  );
  $href = $attributes['href'];
  if ($header) {

    // Also add a HTTP header "Link:".
    $href = '<' . check_plain($attributes['href']) . '>;';
    unset($attributes['href']);
    $element['#attached']['drupal_add_http_header'][] = array(
      'Link',
      $href . drupal_http_header_attributes($attributes),
      TRUE,
    );
  }
  drupal_add_html_head($element, 'drupal_add_html_head_link:' . $attributes['rel'] . ':' . $href);
}