You are here

function _amp_dfp_headers in Accelerated Mobile Pages (AMP) 7

A callback to render amp_ad with js library added to head.

@params $variables The theme variables.

Return value

The passed-in element with the js library necessary for the amp-ad element added to head.

1 call to _amp_dfp_headers()
amp_dfp_preprocess_amp_dfp_tag in modules/amp_dfp/amp_dfp.module
Implements hook_preprocess_amp_dfp_tag().

File

modules/amp_dfp/amp_dfp.module, line 48
AMP integration for the DFP module.

Code

function _amp_dfp_headers($variables) {
  if (!empty($variables['sticky'])) {
    $head_js = array(
      '#tag' => 'script',
      '#type' => 'html_tag',
      '#attributes' => array(
        'src' => 'https://cdn.ampproject.org/v0/amp-sticky-ad-1.0.js',
        'async' => NULL,
        'custom-element' => 'amp-sticky-ad',
      ),
    );
    drupal_add_html_head($head_js, 'amp-sticky-ad');
  }
  else {
    $head_js = array(
      '#tag' => 'script',
      '#type' => 'html_tag',
      '#attributes' => array(
        'src' => 'https://cdn.ampproject.org/v0/amp-ad-0.1.js',
        'async' => NULL,
        'custom-element' => 'amp-ad',
      ),
    );
    drupal_add_html_head($head_js, 'amp-ad');
  }
}