Ad Injection - Version 1.2.0.10

Version Description

  • Fix to allow categories/tags/author names which contain spaces.
  • Add category/tag/id/author filters for template ads.
  • Hopefully fixes the 'headers already sent message that some people got with 1.2.0.8
Download this release

Release Info

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

Code changes from version 1.2.0.9 to 1.2.0.10

Files changed (4) hide show
  1. ad-injection-admin.php +1 -1
  2. ad-injection.php +21 -12
  3. adshow.php +6 -2
  4. readme.txt +5 -5
ad-injection-admin.php CHANGED
@@ -342,7 +342,7 @@ function adinj_top_message_box(){
342
 
343
  } else if (!isset($_GET['tab'])){
344
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
345
- echo "1st February 2012: <font color=red>Update 10:00 UK Time: Have had to temporarily disable the cookie setting due to a bug... looking into it now!</font> Cookie management for search engine only mode now done in PHP instead of JavaScript which should be more robust. The JavaScript file is no longer needed saving a HTTP request. If you are already using this feature you may need to clear your cache to get it to work immediately (if not it will start working again when the cached pages expire). Full filter support for template ads. Fix for category/tag filters with spaces them. With support for my new <a href='http://wordpress.org/extend/plugins/ad-logger/' target='_new'>Ad Logger</a> plugin's AdSense click blocking feature. 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>.';
346
  echo '</strong></p></div>';
347
  }
348
  }
342
 
343
  } else if (!isset($_GET['tab'])){
344
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
345
+ echo "1st February 2012: Hopefully fix the unreliable cookie management code and fix any 'headers already sent' errors. Full filter support for template ads. Fix for category/tag filters with spaces them. With support for my new <a href='http://wordpress.org/extend/plugins/ad-logger/' target='_new'>Ad Logger</a> plugin's AdSense click blocking feature. 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>.';
346
  echo '</strong></p></div>';
347
  }
348
  }
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: 1.2.0.9
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -99,11 +99,11 @@ function adinj_option($option){
99
  function adinj_addsevjs_hook(){
100
  // TODO can re-enable this check once the widget ads are factored in.
101
  //if (adinj_ads_completely_disabled_from_page()) return;
102
- //if (!adinj_ticked('sevisitors_only') && !adinj_ticked('block_keywords')) return;
103
  // Put the search engine detection / cookie setting script in the footer
104
  // TODO would be better to use plugin version, but that only seems accessible in admin
105
- //$version = adinj_db_version(adinj_options());
106
- //wp_enqueue_script('adinj_sev', WP_PLUGIN_URL.'/ad-injection/adinj-sev.js?v='.$version, NULL, NULL, true);
107
  }
108
 
109
  // TODO make the cookie domain from wp-config.php accessible to script
@@ -115,14 +115,23 @@ function adinj_print_referrers_hook(){
115
  $sevisitors = adinj_ticked('sevisitors_only');
116
  $block = adinj_ticked('block_keywords');
117
  if (!$sevisitors && !$block) return;
118
- //This will set any necessary cookies
119
- if (adinj_mfunc_mode()){
120
- echo adinj_ad_code_eval("\n
121
- <!--Ad Injection mfunc mode dynamic checks--><!--mfunc adshow_show_adverts() --><?php adshow_show_adverts(); ?><!--/mfunc-->
122
- ");
123
- } else {
124
- adshow_show_adverts();
125
- }
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
  function adinj_quote_list($option){
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: 1.2.0.10
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
99
  function adinj_addsevjs_hook(){
100
  // TODO can re-enable this check once the widget ads are factored in.
101
  //if (adinj_ads_completely_disabled_from_page()) return;
102
+ if (!adinj_ticked('sevisitors_only') && !adinj_ticked('block_keywords')) return;
103
  // Put the search engine detection / cookie setting script in the footer
104
  // TODO would be better to use plugin version, but that only seems accessible in admin
105
+ $version = adinj_db_version(adinj_options());
106
+ wp_enqueue_script('adinj_sev', WP_PLUGIN_URL.'/ad-injection/adinj-sev.js?v='.$version, NULL, NULL, false);
107
  }
108
 
109
  // TODO make the cookie domain from wp-config.php accessible to script
115
  $sevisitors = adinj_ticked('sevisitors_only');
116
  $block = adinj_ticked('block_keywords');
117
  if (!$sevisitors && !$block) return;
118
+
119
+ echo <<<SCRIPT
120
+
121
+ <script type="text/javascript">
122
+ // Ad Injection plugin
123
+
124
+ SCRIPT;
125
+
126
+ $ops = adinj_options();
127
+ $referrer_list = adinj_quote_list('ad_referrers');
128
+ $blocked_list = adinj_quote_list('blocked_keywords');
129
+ $blocked_hours = $ops['block_ads_for_hours'];
130
+ if ($sevisitors) echo "var adinj_referrers = new Array($referrer_list);\n";
131
+ if ($block) echo "var adinj_blocked_referrers = new Array($blocked_list);\n";
132
+ if ($block) echo "var adinj_blocked_hours = $blocked_hours;\n";
133
+ echo "adinj_dynamic_checks();\n";
134
+ echo "</script>\n";
135
  }
136
 
137
  function adinj_quote_list($option){
adshow.php CHANGED
@@ -260,14 +260,18 @@ function adshow_show_adverts(){
260
 
261
  if (adinj_config_block_referrers() && adshow_blocked_referrer()) return "blocked_referrer";
262
  if (adinj_config_block_referrers() && adshow_blocked_referrer()){
263
- //setcookie('adinjblocked', '1', time()+adinj_config_block_hours()*3600, '/');
 
 
264
  return "blocked_referrer";
265
  }
266
 
267
  if (adinj_config_allow_referrers() && !adshow_allowed_referrer()) return "not_an_allowed_referrer";
268
 
269
  //Set cookie
270
- //setcookie('adinj', '1', time()+3600, '/');
 
 
271
  return true;
272
  }
273
  }
260
 
261
  if (adinj_config_block_referrers() && adshow_blocked_referrer()) return "blocked_referrer";
262
  if (adinj_config_block_referrers() && adshow_blocked_referrer()){
263
+ if (!headers_sent()){
264
+ setcookie('adinjblocked', '1', time()+adinj_config_block_hours()*3600, '/');
265
+ }
266
  return "blocked_referrer";
267
  }
268
 
269
  if (adinj_config_allow_referrers() && !adshow_allowed_referrer()) return "not_an_allowed_referrer";
270
 
271
  //Set cookie
272
+ if (!headers_sent()){
273
+ setcookie('adinj', '1', time()+3600, '/');
274
+ }
275
  return true;
276
  }
277
  }
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.3.1
7
- Stable tag: 1.2.0.9
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
 
@@ -607,10 +607,10 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
607
 
608
  == Changelog ==
609
 
610
- = 1.2.0.8 =
611
- * Manage cookies in PHP instead of JavaScript to improve reliability.
612
  * Fix to allow categories/tags/author names which contain spaces.
613
  * Add category/tag/id/author filters for template ads.
 
614
 
615
  = 1.2.0.7 =
616
  * Tested on WordPress 3.3.
@@ -843,10 +843,10 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
843
 
844
  == Upgrade Notice ==
845
 
846
- = 1.2.0.8 =
847
- * Manage cookies in PHP instead of JavaScript to improve reliability.
848
  * Fix to allow categories/tags/author names which contain spaces.
849
  * Add category/tag/id/author filters for template ads.
 
850
 
851
  = 1.2.0.7 =
852
  * Tested on WordPress 3.3.
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.3.1
7
+ Stable tag: 1.2.0.10
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
 
607
 
608
  == Changelog ==
609
 
610
+ = 1.2.0.10 =
 
611
  * Fix to allow categories/tags/author names which contain spaces.
612
  * Add category/tag/id/author filters for template ads.
613
+ * Hopefully fixes the 'headers already sent message that some people got with 1.2.0.8
614
 
615
  = 1.2.0.7 =
616
  * Tested on WordPress 3.3.
843
 
844
  == Upgrade Notice ==
845
 
846
+ = 1.2.0.10 =
 
847
  * Fix to allow categories/tags/author names which contain spaces.
848
  * Add category/tag/id/author filters for template ads.
849
+ * Hopefully fixes the 'headers already sent message that some people got with 1.2.0.8
850
 
851
  = 1.2.0.7 =
852
  * Tested on WordPress 3.3.