function amp_page_bottom in Accelerated Mobile Pages (AMP) 8
Same name and namespace in other branches
- 8.3 amp.module \amp_page_bottom()
- 8.2 amp.module \amp_page_bottom()
Implements hook_page_bottom for page bottom.
File
- ./
amp.module, line 252
Code
function amp_page_bottom(array &$page_bottom) {
$amp_context = \Drupal::service('router.amp_context');
if ($amp_context
->isAmpRoute()) {
$google_analytics_id = \Drupal::config('amp.settings')
->get('google_analytics_id');
if (!empty($google_analytics_id)) {
$amp_analytics = [
'#type' => 'amp_analytics',
'#attributes' => [
'type' => 'googleanalytics',
],
'#account' => $google_analytics_id,
];
$page_bottom['amp_analytics'] = $amp_analytics;
}
if (\Drupal::config('amp.settings')
->get('amp_pixel')) {
$domain = \Drupal::config('amp.settings')
->get('amp_pixel_domain_name');
$query_string = \Drupal::config('amp.settings')
->get('amp_pixel_query_string');
if (!empty($domain) && !empty($query_string)) {
$subs_random = \Drupal::config('amp.settings')
->get('amp_pixel_random_number');
$subs = [
'RANDOM' => [
'active' => $subs_random ? TRUE : FALSE,
],
];
$amp_pixel = [
'#theme' => 'amp_pixel',
'#domain' => $domain,
'#query_string' => $query_string,
'#subs' => $subs,
];
$page_bottom['amp_pixel'] = $amp_pixel;
}
}
}
}