You are here

function google_admanager_add_js in DFP Small Business (Google Ad Manager) 5

Same name and namespace in other branches
  1. 6.3 google_admanager.module \google_admanager_add_js()
  2. 6 google_admanager.module \google_admanager_add_js()
  3. 6.2 google_admanager.module \google_admanager_add_js()
  4. 7.2 google_admanager.module \google_admanager_add_js()

Stored the ad slots and when called with no slot, return the whole ad manager javascript This function should be called from pianofiles_preprocess_page(&$vars) as followed if (module_exists('google_admanager')) { $vars['scripts'] .= google_admanager_add_js(); }

Parameters

$ad_slot string with the addSlot script:

Return value

google admanager code

1 call to google_admanager_add_js()
theme_google_admanager_block in ./google_admanager.module
Theme function the Ad Slot code

File

./google_admanager.module, line 118

Code

function google_admanager_add_js($ad_slot = NULL) {
  static $google_admanager_slots;
  if (isset($ad_slot)) {
    $google_admanager_slots .= $ad_slot;
  }
  else {
    if (isset($google_admanager_slots)) {
      $id = variable_get('google_admanager_account', '');

      // javascript which is supposed to come in the header
      $js = '<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"></script>' . "\n";
      $js .= '<script type="text/javascript">GS_googleAddAdSenseService("' . $id . '"); GS_googleEnableAllServices();</script>' . "\n";
      $js .= '<script type="text/javascript">' . $google_admanager_slots . '</script>' . "\n";
      $js .= '<script type="text/javascript">GA_googleFetchAds();</script>' . "\n";
      return $js;
    }
  }
}