You are here

function _adsense_managed_get_ad in Google AdSense integration 5.3

Same name and namespace in other branches
  1. 6 managed/adsense_managed.module \_adsense_managed_get_ad()
  2. 7 managed/adsense_managed.module \_adsense_managed_get_ad()

Generates the AdSense ad

Parameters

$format: format of the ad

$slot: Slot Id for the AdSense ad

Return value

JavaScript that embeds the Google AdSense ad

1 call to _adsense_managed_get_ad()
adsense_display in ./adsense.module
Generates the Google AdSense Ad

File

managed/adsense_managed.module, line 153
Displays Google AdSense ads on Drupal pages

Code

function _adsense_managed_get_ad($format, $client, $slot) {
  $ad = adsense_ad_formats($format);
  if ($ad === NULL || empty($slot)) {
    $output = "";
  }
  elseif (variable_get('adsense_test_mode', ADSENSE_TEST_MODE_DEFAULT)) {
    $output = _adsense_format_box("client = {$client}<br />slot = {$slot}<br />width = {$ad['width']}<br />height = {$ad['height']}", $ad['width'], $ad['height']);
  }
  else {
    $secret = '';
    if (variable_get('adsense_secret_adtest', ADSENSE_SECRET_ADTEST_DEFAULT)) {
      $secret .= "google_adtest = 'on';\n";
    }
    if ($lang = variable_get('adsense_secret_language', ADSENSE_SECRET_LANGUAGE_DEFAULT)) {
      $secret .= "google_language = '{$lang}';";
    }
    $output = <<<MANAGED_TXT
<script type="text/javascript"><!--
google_ad_client = "{<span class="php-variable">$client</span>}";
/* {<span class="php-variable">$format</span>} */
google_ad_slot = "{<span class="php-variable">$slot</span>}";
google_ad_width = {<span class="php-variable">$ad</span>[<span class="php-string">'width'</span>]};
google_ad_height = {<span class="php-variable">$ad</span>[<span class="php-string">'height'</span>]};
{<span class="php-variable">$secret</span>}
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
MANAGED_TXT;
  }
  return $output;
}