1 theme.inc theme_head_tag($variables)

Returns HTML for a generic HTML tag with attributes.

This function should only be used for adding HTML tags within the HEAD tag on the page.

@since 1.0.0

Parameters

$variables: An associative array containing:

  • element: An associative array describing the tag:

    • #tag: The HTML tag to output. Typical tags added within the HEAD tag of the page:

      • meta: To provide meta information, such as a page refresh.
      • link: To refer to stylesheets and other contextual information.
      • script: To load JavaScript.
    • #attributes: (optional) An array of HTML attributes to apply to the tag.
    • #value: (optional) A string containing tag content, such as inline CSS.
    • #value_prefix: (optional) A string to prepend to #value, e.g. a CDATA wrapper prefix.
    • #value_suffix: (optional) A string to append to #value, e.g. a CDATA wrapper suffix.

Related topics

File

core/includes/theme.inc, line 2562
The theme system, which controls the output of Backdrop.

Code

function theme_head_tag($variables) {
  $element = $variables['element'];
  $attributes = isset($element['#attributes']) ? backdrop_attributes($element['#attributes']) : '';
  if (!isset($element['#value'])) {
    return '<' . $element['#tag'] . $attributes . " />\n";
  }
  else {
    $output = '<' . $element['#tag'] . $attributes . '>';
    if (isset($element['#value_prefix'])) {
      $output .= $element['#value_prefix'];
    }
    $output .= $element['#value'];
    if (isset($element['#value_suffix'])) {
      $output .= $element['#value_suffix'];
    }
    $output .= '</' . $element['#tag'] . ">\n";
    return $output;
  }
}