Ad Injection - Version 1.2.0.8

Version Description

  • Manage cookies in PHP instead of JavaScript to improve reliability.
  • Fix to allow categories/tags/author names which contain spaces.
  • Add category/tag/id/author filters for template ads.
Download this release

Release Info

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

Code changes from version 1.2.0.7 to 1.2.0.8

Files changed (5) hide show
  1. ad-injection-admin.php +10 -1
  2. ad-injection.php +25 -24
  3. adshow.php +6 -0
  4. readme.txt +13 -3
  5. ui-tab-main.php +2 -0
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 "4th December 2011: Tested on WordPress 3.3. 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
  }
@@ -1615,6 +1615,14 @@ function adinj_default_options(){
1615
  'footer_author_condition_entries' => '',
1616
  'footer_id_condition_mode' => 'o',
1617
  'footer_id_condition_entries' => '',
 
 
 
 
 
 
 
 
1618
  // exclusion tick boxes
1619
  'exclude_front' => 'off',
1620
  'exclude_home' => 'off',
@@ -1680,6 +1688,7 @@ function adinj_default_options(){
1680
  'ui_random_conditions_show' => 'false',
1681
  'ui_bottom_conditions_show' => 'false',
1682
  'ui_footer_conditions_show' => 'false',
 
1683
  'ui_footer_docs_show' => 'false',
1684
  // ui ad rotation tab
1685
  'ui_docs_adrotation_hide' => 'false',
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: 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
  }
1615
  'footer_author_condition_entries' => '',
1616
  'footer_id_condition_mode' => 'o',
1617
  'footer_id_condition_entries' => '',
1618
+ 'template_category_condition_mode' => 'o',
1619
+ 'template_category_condition_entries' => '',
1620
+ 'template_tag_condition_mode' => 'o',
1621
+ 'template_tag_condition_entries' => '',
1622
+ 'template_author_condition_mode' => 'o',
1623
+ 'template_author_condition_entries' => '',
1624
+ 'template_id_condition_mode' => 'o',
1625
+ 'template_id_condition_entries' => '',
1626
  // exclusion tick boxes
1627
  'exclude_front' => 'off',
1628
  'exclude_home' => 'off',
1688
  'ui_random_conditions_show' => 'false',
1689
  'ui_bottom_conditions_show' => 'false',
1690
  'ui_footer_conditions_show' => 'false',
1691
+ 'ui_template_conditions_show' => 'false',
1692
  'ui_footer_docs_show' => 'false',
1693
  // ui ad rotation tab
1694
  'ui_docs_adrotation_hide' => 'false',
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.7
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -35,7 +35,8 @@ define('ADINJ_NO_CONFIG_FILE', 1);
35
  // 17 = block ads for days
36
  // 18 = 1.2.0.0 New ad insertion engine and new top/random/bottom positioning options
37
  // 20 = 1.2.0.3 the_content_filter_priority setting
38
- define('ADINJ_DB_VERSION', 20);
 
39
 
40
  // Files
41
  // TODO will these paths work on windows?
@@ -98,11 +99,11 @@ function adinj_option($option){
98
  function adinj_addsevjs_hook(){
99
  // TODO can re-enable this check once the widget ads are factored in.
100
  //if (adinj_ads_completely_disabled_from_page()) return;
101
- if (!adinj_ticked('sevisitors_only') && !adinj_ticked('block_keywords')) return;
102
  // Put the search engine detection / cookie setting script in the footer
103
  // TODO would be better to use plugin version, but that only seems accessible in admin
104
- $version = adinj_db_version(adinj_options());
105
- wp_enqueue_script('adinj_sev', WP_PLUGIN_URL.'/ad-injection/adinj-sev.js?v='.$version, NULL, NULL, true);
106
  }
107
 
108
  // TODO make the cookie domain from wp-config.php accessible to script
@@ -114,23 +115,14 @@ function adinj_print_referrers_hook(){
114
  $sevisitors = adinj_ticked('sevisitors_only');
115
  $block = adinj_ticked('block_keywords');
116
  if (!$sevisitors && !$block) return;
117
-
118
- echo <<<SCRIPT
119
-
120
- <script type="text/javascript">
121
- // Ad Injection plugin
122
-
123
- SCRIPT;
124
-
125
- $ops = adinj_options();
126
- $referrer_list = adinj_quote_list('ad_referrers');
127
- $blocked_list = adinj_quote_list('blocked_keywords');
128
- $blocked_hours = $ops['block_ads_for_hours'];
129
- if ($sevisitors) echo "var adinj_referrers = new Array($referrer_list);\n";
130
- if ($block) echo "var adinj_blocked_referrers = new Array($blocked_list);\n";
131
- if ($block) echo "var adinj_blocked_hours = $blocked_hours;\n";
132
- echo "adinj_dynamic_checks();\n";
133
- echo "</script>\n";
134
  }
135
 
136
  function adinj_quote_list($option){
@@ -179,7 +171,7 @@ function adinj_get_ad_code($adtype, $ads_db){
179
  }
180
  if (adinj_mfunc_mode()){
181
  return adinj_ad_code_eval("\n
182
- <!--mfunc adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)) -->
183
  <?php adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)); ?>
184
  <!--/mfunc-->
185
  ");
@@ -611,9 +603,16 @@ function adinj_author_data($data){ return $data; }
611
  function adinj_post_id($data){ return $data; }
612
 
613
  function adinj_split_comma_list($list){
614
- return preg_split("/[\s,]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
 
 
615
  }
616
 
 
 
 
 
 
617
  function adinj_footer_hook(){
618
  if (is_feed()) return; // TODO feed specific ads
619
  if (adinj_num_footer_ads_to_insert() <= 0) return;
@@ -1242,6 +1241,8 @@ function adinj_print_ad($adname=''){
1242
  return;
1243
  }
1244
  if (adinj_excluded_by_tick_box('template_')) return;
 
 
1245
  if ($adname == 'random'){
1246
  echo adinj_ad_code_random();
1247
  } else if ($adname == 'top'){
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.8
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
35
  // 17 = block ads for days
36
  // 18 = 1.2.0.0 New ad insertion engine and new top/random/bottom positioning options
37
  // 20 = 1.2.0.3 the_content_filter_priority setting
38
+ // 21 = 1.2.0.8 Template conditions
39
+ define('ADINJ_DB_VERSION', 21);
40
 
41
  // Files
42
  // TODO will these paths work on windows?
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
  $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){
171
  }
172
  if (adinj_mfunc_mode()){
173
  return adinj_ad_code_eval("\n
174
+ <!--Ad Injection mfunc mode ad code--><!--mfunc adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)) -->
175
  <?php adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)); ?>
176
  <!--/mfunc-->
177
  ");
603
  function adinj_post_id($data){ return $data; }
604
 
605
  function adinj_split_comma_list($list){
606
+ $list = preg_split("/[,]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
607
+ array_walk($list, 'adinj_trim_value');
608
+ return $list;
609
  }
610
 
611
+ function adinj_trim_value(&$value){
612
+ $value = trim($value);
613
+ }
614
+
615
+
616
  function adinj_footer_hook(){
617
  if (is_feed()) return; // TODO feed specific ads
618
  if (adinj_num_footer_ads_to_insert() <= 0) return;
1241
  return;
1242
  }
1243
  if (adinj_excluded_by_tick_box('template_')) return;
1244
+ $dummydebug = '';
1245
+ if (adinj_ads_filtered_out('template', $dummydebug)) return;
1246
  if ($adname == 'random'){
1247
  echo adinj_ad_code_random();
1248
  } else if ($adname == 'top'){
adshow.php CHANGED
@@ -259,9 +259,15 @@ function adshow_show_adverts(){
259
  }
260
 
261
  if (adinj_config_block_referrers() && adshow_blocked_referrer()) return "blocked_referrer";
 
 
 
 
262
 
263
  if (adinj_config_allow_referrers() && !adshow_allowed_referrer()) return "not_an_allowed_referrer";
264
 
 
 
265
  return true;
266
  }
267
  }
259
  }
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
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: reviewmylife
3
  Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
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.0
7
- Stable tag: 1.2.0.7
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
 
@@ -497,7 +497,7 @@ Solution: Follow the below advice for the 'theme conflicts'.
497
 
498
  Ad Injection (when injecting random ads) works by looking for the end paragraph tags (&lt;p&gt;&lt;/p&gt;). Some themes override the wpautop filter and set it to run after the plugins. This means that Ad Injection can't find the end paragraph tags, and so can't inject any random ads. If this happens try changing the the_content filter priority from the Advanced tab in the Ad Injection UI. Try values of 100, and if that doesn't work 200.
499
 
500
- Themes which I know have this issue include 'Avenue', 'TheTravelTheme' and 'Vectors'.
501
 
502
  = Will Ad Injection work with the multi-blog version of WordPress? =
503
 
@@ -607,6 +607,11 @@ 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.7 =
611
  * Tested on WordPress 3.3.
612
  * Put mfunc code block on one line.
@@ -838,6 +843,11 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
838
 
839
  == Upgrade Notice ==
840
 
 
 
 
 
 
841
  = 1.2.0.7 =
842
  * Tested on WordPress 3.3.
843
  * Put mfunc code block on one line.
3
  Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
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.8
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
 
497
 
498
  Ad Injection (when injecting random ads) works by looking for the end paragraph tags (&lt;p&gt;&lt;/p&gt;). Some themes override the wpautop filter and set it to run after the plugins. This means that Ad Injection can't find the end paragraph tags, and so can't inject any random ads. If this happens try changing the the_content filter priority from the Advanced tab in the Ad Injection UI. Try values of 100, and if that doesn't work 200.
499
 
500
+ Themes which I know have this issue include 'Avenue', 'TheTravelTheme', 'Exciter Magazine', and 'Vectors'.
501
 
502
  = Will Ad Injection work with the multi-blog version of WordPress? =
503
 
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.
617
  * Put mfunc code block on one line.
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.
853
  * Put mfunc code block on one line.
ui-tab-main.php CHANGED
@@ -569,6 +569,8 @@ function adinj_filters_box($ops){
569
  <?php adinj_condition_tables('bottom_', 'ui_bottom_conditions_show'); ?>
570
  <h4>Footer ad filters</h4>
571
  <?php adinj_condition_tables('footer_', 'ui_footer_conditions_show'); ?>
 
 
572
  <?php
573
  adinj_postbox_end();
574
  }
569
  <?php adinj_condition_tables('bottom_', 'ui_bottom_conditions_show'); ?>
570
  <h4>Footer ad filters</h4>
571
  <?php adinj_condition_tables('footer_', 'ui_footer_conditions_show'); ?>
572
+ <h4>Template ad filters</h4>
573
+ <?php adinj_condition_tables('template_', 'ui_template_conditions_show'); ?>
574
  <?php
575
  adinj_postbox_end();
576
  }