function official_facebook_pixel_page_attachments in Official Facebook Pixel 8
Implements hook_page_attachments().
File
- ./
official_facebook_pixel.module, line 28 - Contains official_facebook_pixel.module.
Code
function official_facebook_pixel_page_attachments(array &$page) {
// Return if user is admin
$roles = \Drupal::currentUser()
->getRoles();
if (is_array($roles) && in_array("administrator", $roles)) {
return;
}
$options = OfficialFacebookPixelOptions::getInstance();
// Return if pixel_id is not positive integer
if (!OfficialFacebookPixelUtils::isPositiveInteger($options
->getPixelId())) {
return;
}
OfficialFacebookPixelInjection::injectPixelCode($page);
}