You are here

function _adsense_managed_get_ad in Google AdSense integration 6

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

Generates the AdSense ad.

Parameters

string $format: Format of the ad.

string $slot: Slot Id for the AdSense ad.

Return value

string 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 169
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 = theme('adsense_placeholder', "client = {$client}<br />slot = {$slot}<br />width = {$ad['width']}<br />height = {$ad['height']}", $ad['width'], $ad['height']);
  }
  else {
    $secret = '';
    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 = "ca-{<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="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
MANAGED_TXT;
  }
  return $output;
}