Index: adsense.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/adsense/adsense.module,v
retrieving revision 1.34.2.14
diff -u -p -r1.34.2.14 adsense.module
--- adsense.module	8 Dec 2006 17:06:36 -0000	1.34.2.14
+++ adsense.module	8 Dec 2006 18:41:38 -0000
@@ -452,7 +452,7 @@ function adsense_settings() {
   return $form;
 }  
 
-function adsense_display($format = '160x600', $group = 1, $channel = 1) {
+function adsense_display($format = '160x600', $group = 1, $channel = 1, $filter = FALSE) {
   static $num_adsense_on_this_page;
 
   if (!_adsense_validate_dimensions($format)) {
@@ -461,7 +461,7 @@ function adsense_display($format = '160x
   else {
     // This ad format is not cached, generate it
     // Check first if disabled or if we are at adsense limit or if this page doesn't allow adsense
-    if (_adsense_check_if_enabled()) {
+    if (_adsense_check_if_enabled() || $filter) {
       if (_adsense_can_insert_another()) {
         if (_adsense_page_match()) {
           // Ad should be displayed
@@ -484,7 +484,7 @@ function adsense_display($format = '160x
         $ad = '<!--adsense: placeholder-->' . _adsense_format_placeholder($format);
       }
       else {
-        $ad = '<!--adsense: ads disabled -->';
+        $ad = '<!--adsense: ads disabled-->';
       }
     }
   }
@@ -500,7 +500,7 @@ function _adsense_get_ad($format, $group
   
   $cache_key = "adsense-$group-$format-$channel";
   $cache = cache_get($cache_key);
-  if ($cache) {
+  if ($cache && !_adsense_check_placeholder()) {
     // This ad format is cached, use it
     $ad = '<!--adsense: cached-->' . $cache->data;
   }
@@ -509,6 +509,11 @@ function _adsense_get_ad($format, $group
     $ad = _adsense_format($format, $group, $channel);
     // Add it to cache
     cache_set($cache_key, $ad, CACHE_PERMANENT);
+
+    // Add it to cache if it's not a place holder
+    if(!_adsense_check_placeholder()) {
+      cache_set($cache_key, $ad, CACHE_PERMANENT);
+    }
   }
 
   return $ad;
@@ -536,7 +541,7 @@ function _adsense_check_if_enabled() {
 }
 
 function _adsense_check_placeholder() {
-  if (variable_get(ADSENSE_PLACEHOLDER, '1')) {
+  if (variable_get(ADSENSE_PLACEHOLDER, '1') && _adsense_check_if_enabled() == FALSE) {
     // Ads are globally disabled and a place holder is set
     return true;
   }
@@ -778,7 +783,7 @@ function _adsense_process_tags($text) {
             break;
           case 'tags':
             // Tag is in [adsense:468x60:1:1] format
-            $ad = adsense_display($match[1], $match[2], $match[3]);
+            $ad = adsense_display($match[1], $match[2], $match[3], TRUE);
         }
       $text = str_replace($match[0], $ad, $text);
       }
