You are here

function _adsense_can_insert_another in Google AdSense integration 6

Same name and namespace in other branches
  1. 5.3 adsense.module \_adsense_can_insert_another()
  2. 5 adsense.module \_adsense_can_insert_another()
  3. 5.2 adsense.module \_adsense_can_insert_another()

Determine if AdSense has reached limit on this page.

As per Google's policies, a page can have up to 3 ad units and 3 link units.

Return value

bool TRUE if we can insert another ad, FALSE if not allowed.

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

File

./adsense.module, line 568
Displays Google AdSense ads on Drupal pages.

Code

function _adsense_can_insert_another($type = ADSENSE_TYPE_AD) {
  static $num_ads = array(
    ADSENSE_TYPE_AD => 0,
    ADSENSE_TYPE_LINK => 0,
    ADSENSE_TYPE_SEARCH => 0,
  );
  $max_ads = array(
    ADSENSE_TYPE_AD => 3,
    ADSENSE_TYPE_LINK => 3,
    ADSENSE_TYPE_SEARCH => 2,
  );
  if ($num_ads[$type] < $max_ads[$type]) {
    $num_ads[$type]++;
    return TRUE;
  }

  // Because of #1627846, it's better to always return TRUE.
  return TRUE;

  // return FALSE;
}