Ad Injection - Version 0.9.7.2

Version Description

Release with more debugging to try to track down top/bottom ads which have gone missing on some blogs.

Download this release

Release Info

Developer reviewmylife
Plugin Icon wp plugin Ad Injection
Version 0.9.7.2
Comparing to
See all releases

Code changes from version 0.9.7.1 to 0.9.7.2

Files changed (3) hide show
  1. ad-injection-admin.php +1 -1
  2. ad-injection.php +36 -8
  3. readme.txt +6 -3
ad-injection-admin.php CHANGED
@@ -331,7 +331,7 @@ function adinj_top_message_box(){
331
 
332
  } else {
333
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
334
- echo "28th February 2011: Fix for disappearing top/bottom ad - I'm sorry if you were affected by that! Archives and home ads now fully supported - you can add top/random/bottom ads to them. Big UI updates to support this. And fixes for when/where widget ads appear. I'd recommend you re-check that your ads appear where you expect them to. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>.';
335
  echo '</strong></p></div>';
336
  }
337
  }
331
 
332
  } else {
333
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
334
+ echo "1st March 2011: <font color='red'>If you are one of the people whose top/bottom ads have dissapeared with the 0.9.7.x release I'm very sorry - I'm working on it right now. This release has extra debugging in it to try to track the problem. If you are affected please turn on debug mode and then email me a link via the <a href='".adinj_feedback_url()."' target='_new'>quick feedback form</a> to one of your affected pages. I can then *hopefully* work out what is going on from the (hidden) debug messages. Thanks! If you want to downgrade to the previous 0.9.6.6 version you can get it from http://wordpress.org/extend/plugins/ad-injection/download/</font><br />Archives and home ads now fully supported - you can add top/random/bottom ads to them. Big UI updates to support this. And fixes for when/where widget ads appear. I'd recommend you re-check that your ads appear where you expect them to. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>.';
335
  echo '</strong></p></div>';
336
  }
337
  }
ad-injection.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ad Injection
4
  Plugin URI: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
5
  Description: Injects any advert (e.g. AdSense) into your WordPress posts or widget area. Restrict who sees the ads by post length, age, referrer or IP. Cache compatible.
6
- Version: 0.9.7.1
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -132,6 +132,7 @@ function adinj_addsevjs_hook(){
132
  }
133
 
134
  function adinj_get_ad_code($adtype, $ads_db){
 
135
  $ops = adinj_options();
136
  $ads_live = NULL;
137
  $ads_split = NULL;
@@ -139,12 +140,14 @@ function adinj_get_ad_code($adtype, $ads_db){
139
  $alt_split = NULL;
140
  $formatting = NULL;
141
  if ($ops['ad_insertion_mode'] == 'mfunc'){
 
142
  adinj_live_ads_array($adtype, $ads_db, $ads_live, $ads_split, 'string');
143
  if (adinj_db_version($ads_db) >= 2){
144
  adinj_live_ads_array($adtype.'_alt', $ads_db, $alt_live, $alt_split, 'string');
145
  }
146
  $formatting = adinj_formatting_options($adtype, $ads_db, 'string');
147
  } else {
 
148
  $ads_live = array();
149
  $ads_split = array();
150
  $alt_live = array();
@@ -155,11 +158,14 @@ function adinj_get_ad_code($adtype, $ads_db){
155
  }
156
  $formatting = adinj_formatting_options($adtype, $ads_db, 'array');
157
  }
 
158
  if (empty($ads_live) && empty($alt_live)){
 
159
  return "";
160
  }
161
-
162
  if ($ops['ad_insertion_mode'] == 'mfunc'){
 
163
  return adinj_ad_code_eval("\n
164
  <!--mfunc adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)) -->
165
  <?php adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)); ?>
@@ -170,16 +176,22 @@ function adinj_get_ad_code($adtype, $ads_db){
170
  // else dynamic ad
171
  if ($ops['ad_insertion_mode'] == 'direct_dynamic' && adshow_show_adverts() !== true){
172
  $adname = adshow_pick_value($alt_live, $alt_split);
 
173
  } else {
174
  $adname = adshow_pick_value($ads_live, $ads_split);
 
175
  }
176
  $ad = $ads_db[$adname];
 
177
 
178
  if (empty($ad)){
 
179
  return "";
180
  }
181
 
 
182
  $ad = adshow_add_formatting($ad, $formatting);
 
183
  return adinj_ad_code_eval($ad);
184
  }
185
 
@@ -188,14 +200,18 @@ function adinj_ad_code_random(){
188
  }
189
 
190
  function adinj_ad_code_top(){
 
191
  $ad = adinj_get_ad_code('top', adinj_options());
 
192
  global $adinj_total_all_ads_used;
193
  ++$adinj_total_all_ads_used;
194
  return $ad;
195
  }
196
 
197
  function adinj_ad_code_bottom(){
 
198
  $ad = adinj_get_ad_code('bottom', adinj_options());
 
199
  global $adinj_total_all_ads_used;
200
  ++$adinj_total_all_ads_used;
201
  return $ad;
@@ -574,7 +590,10 @@ function adinj_inject_hook($content){
574
  }
575
  }
576
 
577
- $ad_include = adinj_ad_code_include();
 
 
 
578
 
579
  # Ad sandwich mode
580
  if(is_page() || is_single()){
@@ -594,19 +613,21 @@ function adinj_inject_hook($content){
594
  if ($debug_on) $debug .= "\nnum words: = $length";
595
  }
596
  # Insert top and bottom ads if necesary
 
597
  if (adinj_num_top_ads_to_insert($length) > 0){
 
598
  $content = $ad_include.adinj_ad_code_top().$content;
599
- $ad_include = false;
600
  ++$adinj_total_top_ads_used;
601
- ++$adinj_total_all_ads_used;
602
  }
 
603
  if (adinj_num_bottom_ads_to_insert($length) > 0){
 
604
  $content = $content.adinj_ad_code_bottom();
605
  ++$adinj_total_bottom_ads_used;
606
- ++$adinj_total_all_ads_used;
607
  }
608
 
609
- if ($ad_include !== false) $content = $ad_include.$content;
610
 
611
  $num_rand_ads_to_insert = adinj_num_rand_ads_to_insert($length);
612
  if ($num_rand_ads_to_insert <= 0) return adinj($content, "no random ads on this post");
@@ -766,22 +787,28 @@ function adinj_get_current_page_type_prefix(){
766
  }
767
 
768
  function adinj_num_top_ads_to_insert($content_length){
 
769
  global $adinj_total_top_ads_used;
770
  $ops = adinj_options();
771
  $prefix = adinj_get_current_page_type_prefix();
 
772
  if (is_single() || is_page()){
773
  $max_num_ads_to_insert = 1 - $adinj_total_top_ads_used;
774
  } else {
775
  $max_num_ads_to_insert = $ops[$prefix.'max_num_top_ads_per_page'] - $adinj_total_top_ads_used;
776
  }
 
777
  if ($max_num_ads_to_insert <= 0) return 0;
 
778
  if (!adinj_allowed_in_category('top', $ops)) return "NOADS: top ad blocked from category";
779
  if (!adinj_allowed_in_tag('top', $ops)) return "NOADS: top ad blocked from tag";
780
  if (!adinj_allowed_in_author('top', $ops)) return "NOADS: top ad blocked from author";
781
 
782
  if (adinj_do_rule_if($ops[$prefix.'top_ad_if_longer_than'], '<', $content_length)){
 
783
  return 1;
784
  }
 
785
  return 0;
786
  }
787
 
@@ -789,8 +816,9 @@ function adinj_num_bottom_ads_to_insert($content_length){
789
  global $adinj_total_bottom_ads_used;
790
  $ops = adinj_options();
791
  $prefix = adinj_get_current_page_type_prefix();
 
792
  if (is_single() || is_page()){
793
- $max_num_ads_to_insert = 1 - $adinj_total_bottom_ads_used;;
794
  } else {
795
  $max_num_ads_to_insert = $ops[$prefix.'max_num_bottom_ads_per_page'] - $adinj_total_bottom_ads_used;
796
  }
3
  Plugin Name: Ad Injection
4
  Plugin URI: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
5
  Description: Injects any advert (e.g. AdSense) into your WordPress posts or widget area. Restrict who sees the ads by post length, age, referrer or IP. Cache compatible.
6
+ Version: 0.9.7.2
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
132
  }
133
 
134
  function adinj_get_ad_code($adtype, $ads_db){
135
+ echo "\n<!--*adinj_get_ad_code:".$adtype."-->";
136
  $ops = adinj_options();
137
  $ads_live = NULL;
138
  $ads_split = NULL;
140
  $alt_split = NULL;
141
  $formatting = NULL;
142
  if ($ops['ad_insertion_mode'] == 'mfunc'){
143
+ echo "<!--ga1-->";
144
  adinj_live_ads_array($adtype, $ads_db, $ads_live, $ads_split, 'string');
145
  if (adinj_db_version($ads_db) >= 2){
146
  adinj_live_ads_array($adtype.'_alt', $ads_db, $alt_live, $alt_split, 'string');
147
  }
148
  $formatting = adinj_formatting_options($adtype, $ads_db, 'string');
149
  } else {
150
+ echo "<!--ga2-->";
151
  $ads_live = array();
152
  $ads_split = array();
153
  $alt_live = array();
158
  }
159
  $formatting = adinj_formatting_options($adtype, $ads_db, 'array');
160
  }
161
+ echo "<!--ga3-->";
162
  if (empty($ads_live) && empty($alt_live)){
163
+ echo "<!--ga4-->";
164
  return "";
165
  }
166
+ echo "<!--ga5-->";
167
  if ($ops['ad_insertion_mode'] == 'mfunc'){
168
+ echo "<!--ga6-->";
169
  return adinj_ad_code_eval("\n
170
  <!--mfunc adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)) -->
171
  <?php adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)); ?>
176
  // else dynamic ad
177
  if ($ops['ad_insertion_mode'] == 'direct_dynamic' && adshow_show_adverts() !== true){
178
  $adname = adshow_pick_value($alt_live, $alt_split);
179
+ echo "<!--ga7".$adname."-->";
180
  } else {
181
  $adname = adshow_pick_value($ads_live, $ads_split);
182
+ echo "<!--ga8".$adname."-->";
183
  }
184
  $ad = $ads_db[$adname];
185
+ echo "<!--ga9:".strlen($ad)."-->";
186
 
187
  if (empty($ad)){
188
+ echo "<!--ga10-->";
189
  return "";
190
  }
191
 
192
+ echo "<!--ga11-->";
193
  $ad = adshow_add_formatting($ad, $formatting);
194
+ echo "<!--ga12:".strlen($ad)."-->";
195
  return adinj_ad_code_eval($ad);
196
  }
197
 
200
  }
201
 
202
  function adinj_ad_code_top(){
203
+ echo "\n<!--xxxadinj_ad_code_top2b-->";
204
  $ad = adinj_get_ad_code('top', adinj_options());
205
+ echo "<!--c: ".strlen($ad)."-->";
206
  global $adinj_total_all_ads_used;
207
  ++$adinj_total_all_ads_used;
208
  return $ad;
209
  }
210
 
211
  function adinj_ad_code_bottom(){
212
+ echo "\n<!--xxxadinj_ad_code_bottom2b-->";
213
  $ad = adinj_get_ad_code('bottom', adinj_options());
214
+ echo "<!--c: ".strlen($ad)."-->";
215
  global $adinj_total_all_ads_used;
216
  ++$adinj_total_all_ads_used;
217
  return $ad;
590
  }
591
  }
592
 
593
+ $ad_include = "";
594
+ if ($ops['ad_insertion_mode'] == 'mfunc'){
595
+ $ad_include = adinj_ad_code_include();
596
+ }
597
 
598
  # Ad sandwich mode
599
  if(is_page() || is_single()){
613
  if ($debug_on) $debug .= "\nnum words: = $length";
614
  }
615
  # Insert top and bottom ads if necesary
616
+ echo "<!--1-->";
617
  if (adinj_num_top_ads_to_insert($length) > 0){
618
+ echo "<!--2-->";
619
  $content = $ad_include.adinj_ad_code_top().$content;
620
+ $ad_include = "";
621
  ++$adinj_total_top_ads_used;
 
622
  }
623
+ echo "<!--3-->";
624
  if (adinj_num_bottom_ads_to_insert($length) > 0){
625
+ echo "<!--4-->";
626
  $content = $content.adinj_ad_code_bottom();
627
  ++$adinj_total_bottom_ads_used;
 
628
  }
629
 
630
+ if ($ad_include !== "") $content = $ad_include.$content;
631
 
632
  $num_rand_ads_to_insert = adinj_num_rand_ads_to_insert($length);
633
  if ($num_rand_ads_to_insert <= 0) return adinj($content, "no random ads on this post");
787
  }
788
 
789
  function adinj_num_top_ads_to_insert($content_length){
790
+ echo "\n<!--adinj_num_top_ads_to_insert(".$content_length.")-->";
791
  global $adinj_total_top_ads_used;
792
  $ops = adinj_options();
793
  $prefix = adinj_get_current_page_type_prefix();
794
+ $max_num_ads_to_insert = 0;
795
  if (is_single() || is_page()){
796
  $max_num_ads_to_insert = 1 - $adinj_total_top_ads_used;
797
  } else {
798
  $max_num_ads_to_insert = $ops[$prefix.'max_num_top_ads_per_page'] - $adinj_total_top_ads_used;
799
  }
800
+ echo "<!--num1:".$max_num_ads_to_insert."-->";
801
  if ($max_num_ads_to_insert <= 0) return 0;
802
+ echo "<!--num2:-->";
803
  if (!adinj_allowed_in_category('top', $ops)) return "NOADS: top ad blocked from category";
804
  if (!adinj_allowed_in_tag('top', $ops)) return "NOADS: top ad blocked from tag";
805
  if (!adinj_allowed_in_author('top', $ops)) return "NOADS: top ad blocked from author";
806
 
807
  if (adinj_do_rule_if($ops[$prefix.'top_ad_if_longer_than'], '<', $content_length)){
808
+ echo "<!--num3:-->";
809
  return 1;
810
  }
811
+ echo "<!--num4:-->";
812
  return 0;
813
  }
814
 
816
  global $adinj_total_bottom_ads_used;
817
  $ops = adinj_options();
818
  $prefix = adinj_get_current_page_type_prefix();
819
+ $max_num_ads_to_insert = 0;
820
  if (is_single() || is_page()){
821
+ $max_num_ads_to_insert = 1 - $adinj_total_bottom_ads_used;
822
  } else {
823
  $max_num_ads_to_insert = $ops[$prefix.'max_num_bottom_ads_per_page'] - $adinj_total_bottom_ads_used;
824
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-w
4
  Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, widgets, sidebar, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free, blog, ad rotation, A:B testing, split testing, WP Super Cache, W3 Total Cache, WP Cache
5
  Requires at least: 2.8.6
6
  Tested up to: 3.1
7
- Stable tag: 0.9.7.1
8
 
9
  Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
10
 
@@ -372,6 +372,9 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
372
 
373
  == Changelog ==
374
 
 
 
 
375
  = 0.9.7.1 =
376
  Fix for disappearing top / bottom ad.
377
 
@@ -504,8 +507,8 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
504
 
505
  == Upgrade Notice ==
506
 
507
- = 0.9.7.1 =
508
- Fix for disappearing top/bottom ad.
509
 
510
  = 0.8.3 =
511
  First public release.
4
  Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, widgets, sidebar, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free, blog, ad rotation, A:B testing, split testing, WP Super Cache, W3 Total Cache, WP Cache
5
  Requires at least: 2.8.6
6
  Tested up to: 3.1
7
+ Stable tag: 0.9.7.2
8
 
9
  Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
10
 
372
 
373
  == Changelog ==
374
 
375
+ = 0.9.7.2 =
376
+ Release with more debugging to try to track down top/bottom ads which have gone missing on some blogs.
377
+
378
  = 0.9.7.1 =
379
  Fix for disappearing top / bottom ad.
380
 
507
 
508
  == Upgrade Notice ==
509
 
510
+ = 0.9.7.2 =
511
+ If you are using a release before 0.9.7 please don't upgrade yet as there is a problem with the 0.9.7.x releases which I am trying to fix.
512
 
513
  = 0.8.3 =
514
  First public release.