function linkedin_insights_tag_page_build in LinkedIn Insights Tag 7
Implements hook_page_build().
File
- ./
linkedin_insights_tag.module, line 35
Code
function linkedin_insights_tag_page_build(&$page) {
global $user;
$partner_id = check_plain(variable_get('linkedin_insights_tag__partner_id', ''));
$noscript = (bool) check_plain(variable_get('linkedin_insights_tag__image_only', 0));
// Validate Partner ID and whether or not the current user should be tracked.
if (preg_match('/^\\d+$/', $partner_id) && linkedin_insights_tag_role_tracking($user)) {
if (!$noscript) {
$path = drupal_get_path('module', 'linkedin_insights_tag');
$attached =& $page['page_bottom']['linkedin_insights_tag']['#attached'];
$attached['js'][] = array(
'type' => 'setting',
'data' => array(
'linkedinInsightsTag' => array(
'partnerId' => $partner_id,
),
),
);
$attached['js'][$path . '/js/linkedin_insights_tag.js'] = array(
'type' => 'file',
'scope' => 'footer',
);
$attached['js'][] = array(
'type' => 'external',
'data' => 'https://snap.licdn.com/li.lms-analytics/insight.min.js',
'scope' => 'footer',
'weight' => 1,
);
}
$noscript = [
'#theme' => 'html_tag',
'#tag' => 'noscript',
'#value' => '<img height="1" width="1" style="display:none;" alt="" src="https://dc.ads.linkedin.com/collect/?pid=' . $partner_id . '&fmt=gif" />',
];
$page['page_bottom']['noscript'] = [
'#weight' => 3,
'#markup' => render($noscript),
];
}
}