function google_admanager_add_js in DFP Small Business (Google Ad Manager) 7.2
Same name and namespace in other branches
- 5 google_admanager.module \google_admanager_add_js()
- 6.3 google_admanager.module \google_admanager_add_js()
- 6 google_admanager.module \google_admanager_add_js()
- 6.2 google_admanager.module \google_admanager_add_js()
Store ad slots js and when called with no slot, return the whole ad manager javascript
Parameters
$js (optional) string with the slot script to add to the array.:
$type (optional) scripts have to be split up into 5 types and are output: in order ['init', 'service', 'slot', 'attr', 'close'].
Return value
if $js is empty, then an array of stored google_admanager javascript
4 calls to google_admanager_add_js()
- google_admanager_add_attribute in ./
google_admanager.module - Set page-level attributes to pass to GAM
- google_admanager_get_js in ./
google_admanager.module - Output the Google Admanager scripts by way of drupal_add_js().
- google_admanager_page_alter in ./
google_admanager.module - Implements hook_page_alter().
- theme_google_admanager_block in ./
google_admanager.module - Theme function the Ad Slot code
File
- ./
google_admanager.module, line 296
Code
function google_admanager_add_js($js = NULL, $type = 'slot') {
static $ga_js = array();
// add the js to a type
if (isset($js) && isset($type)) {
$ga_js[$type][] = $js;
//add the init and service scripts the first time this is run
if (!isset($ga_js['service'])) {
drupal_add_js('//partner.googleadservices.com/gampad/google_service.js', array(
'type' => 'external',
'inline' => TRUE,
));
$id = variable_get('google_admanager_account', '');
google_admanager_add_js('GS_googleAddAdSenseService("' . $id . '");', 'service');
google_admanager_add_js('GS_googleEnableAllServices();', 'service');
// set the close script to fetch the ads.
google_admanager_add_js('GA_googleFetchAds();', 'close');
}
return;
}
if (!isset($js)) {
return $ga_js;
}
}