You are here

function amp_page_alter in Accelerated Mobile Pages (AMP) 7

Implements hook_page_alter().

File

./amp.module, line 594

Code

function amp_page_alter(array &$page) {
  if (amp_is_amp_request()) {
    if (variable_get('amp_pixel')) {
      $domain = variable_get('amp_pixel_domain_name');
      $query_string = variable_get('amp_pixel_query_string');
      $subs_random = FALSE;
      if (!empty($domain) && !empty($query_string)) {
        $subs_random = variable_get('amp_pixel_random_number');
      }
      $subs = array(
        'RANDOM' => array(
          'active' => $subs_random ? TRUE : FALSE,
        ),
      );
      $amp_pixel = array(
        '#theme' => 'amp_pixel',
        '#domain' => $domain,
        '#query_string' => $query_string,
        '#subs' => $subs,
      );
      $page['page_bottom']['amp_pixel'] = $amp_pixel;
    }
  }
}