function google_admanager_add_js in DFP Small Business (Google Ad Manager) 6.3
Same name and namespace in other branches
- 5 google_admanager.module \google_admanager_add_js()
- 6 google_admanager.module \google_admanager_add_js()
- 6.2 google_admanager.module \google_admanager_add_js()
- 7.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
6 calls to google_admanager_add_js()
- google_admanager_footer in ./
google_admanager.module - Implementation of hook_footer().
- google_admanager_gam_display_ad in plugins/
ad_providers/ gam.inc - google_admanager_gam_init in plugins/
ad_providers/ gam.inc - google_admanager_get_js in ./
google_admanager.module - Output the Google Admanager scripts by way of drupal_add_js().
- google_admanager_gpt_async_display_ad in plugins/
ad_providers/ gpt_async.inc
File
- ./
google_admanager.module, line 158
Code
function google_admanager_add_js($js = NULL, $type = 'slot', $offset = NULL) {
static $ga_js = array();
//add the init and service scripts the first time this is run
if (!isset($ga_js['init'])) {
$ga_js['init'] = array();
ctools_include('plugins');
$name = variable_get('google_admanager_delivery_method', 'gam');
$plugin = ctools_get_plugins('google_admanager', 'ad_providers', $name);
$conf = variable_get('google_admanager_' . $name, $plugin['defaults']);
if (isset($plugin['init']) && function_exists($plugin['init'])) {
$plugin['init']($conf);
}
}
// add the js to a type
if (isset($js) && isset($type)) {
if (!isset($ga_js[$type])) {
$ga_js[$type] = array();
}
if ($offset === NULL) {
$offset = count($ga_js[$type]);
}
array_splice($ga_js[$type], $offset, 0, $js);
}
//check that there is something to return
if (!isset($ga_js['init'])) {
return;
}
// $ga_js['init'] must have been set since we didn't return, so if js isn't
// set then return the whole array, just like drupal_add_js().
if (!isset($js)) {
return $ga_js;
}
}