Ad Injection - Version 1.2.0.13

Version Description

  • New option to exclude ads from blockquote and pre tags.
  • New tag to exclude ads from specific parts of posts.
Download this release

Release Info

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

Code changes from version 1.2.0.12 to 1.2.0.13

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 "14th April 2012: Fix for ads with UTF-8 characters. 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='http://wordpress.org/tags/ad-injection?forum_id=10'target='_new'>Ad Injection WordPress forum</a> or my ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>. If you like the plugin please consider making a donation using the PayPal box below :)';
346
  echo '</strong></p></div>';
347
  }
348
  }
@@ -412,10 +412,11 @@ function adinj_side_info_box(){
412
  <p>You are responsible for making sure the ad settings and positioning you define are in compliance with your ad provider's terms of service! Failure to do so could get you banned by them!</p>
413
 
414
  <h4><font color="red">Still in development</font></h4>
415
- <p>I'm actively listening to your feedback and fixing problems, and will be adding new features later in 2011. Please let me know if you like the plugin too!</p>
416
 
417
  <h4>More by this author</h4>
418
  <ul>
 
419
  <li><a href="http://wordpress.org/extend/plugins/ad-logger/" target="_new">Ad Logger plugin for WordPress</a></li>
420
  <li><a href="http://www.reviewmylife.co.uk/" target="_new">www.reviewmylife.co.uk</a></li>
421
  <li><a href="http://www.advancedhtml.co.uk/" target="_new">www.advancedhtml.co.uk</a></li>
@@ -1126,7 +1127,7 @@ function adinj_testads(){
1126
 
1127
  <h4>Template ad examples</h4>
1128
 
1129
- <p>Template ads allow any of the ads to be inserted anywhere in your theme. <b>*Don't*</b> try putting any of this code into one of the ad boxes - it is not an advert - it is code to load an advert directly your theme.</p>
1130
 
1131
  <b>Simple examples for loading top, random, bottom or footer ads</b><br />
1132
 
@@ -1398,6 +1399,7 @@ function adinj_default_options(){
1398
  'ads_on_page_older_than' => '0',
1399
  'widgets_on_page_older_than' => '0',
1400
  'content_length_unit' => 'words',
 
1401
  // random ad start/end position
1402
  'random_ads_start_mode' => 'anywhere',
1403
  'random_ads_start_unit' => 'paragraph',
342
 
343
  } else if (!isset($_GET['tab'])){
344
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
345
+ echo "8th May 2012: New option to exclude ads from &lt;blockquote&gt;&lt;/blockquote&gt; and &lt;pre&gt;&lt;/pre&gt; blocks (it is in the 'Other ad placement sections' area). And new &lt;!--adinj_exclude_start--&gt;&lt;!--adinj_exclude_end--&gt; which can be used to exlude ads from custom sections. Please contact me ASAP if you spot any bugs, or odd behaviour via the <a href='http://wordpress.org/tags/ad-injection?forum_id=10'target='_new'>Ad Injection WordPress forum</a> or my ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>. If you like the plugin please consider making a donation using the PayPal box below :)'."<br/>And finally I've just released my first iPhone game called <a href='http://itunes.apple.com/us/app/solar-balls/id521551813?ls=1&mt=8' target='_new'>Solar Balls</a> - please have a look and consider playing it :)";
346
  echo '</strong></p></div>';
347
  }
348
  }
412
  <p>You are responsible for making sure the ad settings and positioning you define are in compliance with your ad provider's terms of service! Failure to do so could get you banned by them!</p>
413
 
414
  <h4><font color="red">Still in development</font></h4>
415
+ <p>I'm actively listening to your feedback and fixing problems, and will be adding new features later in 2012. Please let me know if you like the plugin too!</p>
416
 
417
  <h4>More by this author</h4>
418
  <ul>
419
+ <li><a href="http://www.lorisware.com/solar-balls/" target="_new">Solar Balls for iOS</a> New!</li>
420
  <li><a href="http://wordpress.org/extend/plugins/ad-logger/" target="_new">Ad Logger plugin for WordPress</a></li>
421
  <li><a href="http://www.reviewmylife.co.uk/" target="_new">www.reviewmylife.co.uk</a></li>
422
  <li><a href="http://www.advancedhtml.co.uk/" target="_new">www.advancedhtml.co.uk</a></li>
1127
 
1128
  <h4>Template ad examples</h4>
1129
 
1130
+ <p>Template ads allow any of the ads to be inserted anywhere in your theme. <b>*Don't*</b> try putting any of this code into one of the ad boxes - it is not an advert - it is code to load an advert directly into your theme.</p>
1131
 
1132
  <b>Simple examples for loading top, random, bottom or footer ads</b><br />
1133
 
1399
  'ads_on_page_older_than' => '0',
1400
  'widgets_on_page_older_than' => '0',
1401
  'content_length_unit' => 'words',
1402
+ 'exclude_ads_from_block_tags' => 'off',
1403
  // random ad start/end position
1404
  'random_ads_start_mode' => 'anywhere',
1405
  'random_ads_start_unit' => 'paragraph',
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.12
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -36,7 +36,8 @@ define('ADINJ_NO_CONFIG_FILE', 1);
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?
@@ -704,7 +705,25 @@ function adinj_content_hook($content){
704
  $original_paragraph_positions = array();
705
  $prevpos = -1;
706
  while(($prevpos = stripos($content, ADINJ_PARA, $prevpos+1)) !== false){
707
- $original_paragraph_positions[] = $prevpos + strlen(ADINJ_PARA);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708
  }
709
  $paracount = count($original_paragraph_positions);
710
  if ($debug_on) $debug .= "\nContent length=$length (".$ops['content_length_unit'].") Raw character length=$rawlength Paragraph count=$paracount";
@@ -804,6 +823,12 @@ function adinj_content_hook($content){
804
  return adinj($content, "Ad Injection in-content injections complete!" . $debug);
805
  }
806
 
 
 
 
 
 
 
807
  function adinj_insert_fixed_ad(&$content, $ad, $adname, &$counter, &$debug){
808
  if (!adinj_excluded_by_tick_box($adname.'_')){
809
  $tagname = $adname.'ad';
@@ -946,7 +971,7 @@ function adinj_get_paragraph_from_position($content, $offset, $original_paragrap
946
  if ($position === false) return -1;
947
  $position += strlen(ADINJ_PARA);
948
  for ($i=0; $i<$paracount; ++$i){
949
- if ($position == $original_paragraph_positions[$i]) {
950
  $paragraph = $i+$adjust;
951
  return min($paragraph, $paracount);
952
  }
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.13
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
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
+ // 22 = 1.2.0.13 exclude_ads_from_block_tags option
40
+ define('ADINJ_DB_VERSION', 22);
41
 
42
  // Files
43
  // TODO will these paths work on windows?
705
  $original_paragraph_positions = array();
706
  $prevpos = -1;
707
  while(($prevpos = stripos($content, ADINJ_PARA, $prevpos+1)) !== false){
708
+ $next_blockquote_open = adinj_stripos($content, '<blockquote>', $prevpos);
709
+ $next_blockquote_close = adinj_stripos($content, '</blockquote>', $prevpos);
710
+ $next_pre_open = adinj_stripos($content, '<pre>', $prevpos);
711
+ $next_pre_close = adinj_stripos($content, '</pre>', $prevpos);
712
+ $valid = true;
713
+ if (adinj_ticked('exclude_ads_from_block_tags')){
714
+ $valid = (($next_blockquote_open == $next_blockquote_close) ||
715
+ ($next_blockquote_open > $prevpos && $next_blockquote_open <= $next_blockquote_close)) &&
716
+ (($next_pre_open == $next_pre_close) ||
717
+ ($next_pre_open > $prevpos && $next_pre_open <= $next_pre_close));
718
+ }
719
+ if($valid){
720
+ $next_exclude_open = adinj_stripos($content, '<!--adinj_exclude_start-->', $prevpos);
721
+ $next_exclude_close = adinj_stripos($content, '<!--adinj_exclude_end-->', $prevpos);
722
+ if (($next_exclude_open == $next_exclude_close) ||
723
+ ($next_exclude_open > $prevpos && $next_exclude_open <= $next_exclude_close)){
724
+ $original_paragraph_positions[] = $prevpos + strlen(ADINJ_PARA);
725
+ }
726
+ }
727
  }
728
  $paracount = count($original_paragraph_positions);
729
  if ($debug_on) $debug .= "\nContent length=$length (".$ops['content_length_unit'].") Raw character length=$rawlength Paragraph count=$paracount";
823
  return adinj($content, "Ad Injection in-content injections complete!" . $debug);
824
  }
825
 
826
+ function adinj_stripos($haystack, $needle, $offset=0){
827
+ $pos = stripos($haystack, $needle, $offset);
828
+ if ($pos === false) $pos = -1;
829
+ return $pos;
830
+ }
831
+
832
  function adinj_insert_fixed_ad(&$content, $ad, $adname, &$counter, &$debug){
833
  if (!adinj_excluded_by_tick_box($adname.'_')){
834
  $tagname = $adname.'ad';
971
  if ($position === false) return -1;
972
  $position += strlen(ADINJ_PARA);
973
  for ($i=0; $i<$paracount; ++$i){
974
+ if ($position <= $original_paragraph_positions[$i]) {
975
  $paragraph = $i+$adjust;
976
  return min($paragraph, $paracount);
977
  }
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.12
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
 
@@ -17,6 +17,7 @@ Ad Injection from [reviewmylife](http://www.reviewmylife.co.uk/ "reviewmylife")
17
  * Set the position of the top and bottom advert by paragraph or character.
18
  * Position the random ads to start or stop in the middle of the post.
19
  * Stop the random ads 2/3 of the way down a post, or at a paragraph/character position from the beginning/end of the post.
 
20
  * Fade unused Home/Archive options instead of making them dissapear.
21
  * Add page age settings to status.
22
  * Improve debug messages.
@@ -87,6 +88,12 @@ IP addresses of people who shouldn't see your ads can be defined. These could be
87
 
88
  If you need to override the top, random, or bottom ad positions on a specific post you can use these in-content tags to manually set the ad positions: &lt;!--topad--&gt; &lt;!--randomad--&gt; &lt;!--bottomad--&gt; &lt;!--adstart--&gt; &lt;!--adend--&gt; &lt;!--noads--&gt;
89
 
 
 
 
 
 
 
90
  = Alternate content =
91
 
92
  This is content that is displayed when ads are blocked for the user. You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.
@@ -418,6 +425,8 @@ Global advert
418
 
419
  You can download the Country Filter plugin from http://wordpress.org/extend/plugins/country-filter/
420
 
 
 
421
  = If I restrict a widget to both a category and a tag it doesn't appear in the relevant category/tag archives. Why? =
422
 
423
  If you set an ad with a tag restriction of 'tag1' and a category restriction of 'cat1', then it will only appear on pages that have BOTH the tag1 and cat1 property.
@@ -607,6 +616,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.12 =
611
  * Fix for ads with UTF-8 characters
612
 
@@ -850,6 +863,10 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
850
 
851
  == Upgrade Notice ==
852
 
 
 
 
 
853
  = 1.2.0.12 =
854
  * Fix for ads with UTF-8 characters
855
 
@@ -857,35 +874,6 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
857
  * Preserve HTML entities when saving - i.e. preserve special character sequences.
858
  * Add '400' as an option to the numbered drop downs.
859
 
860
- = 1.2.0.10 =
861
- * Fix to allow categories/tags/author names which contain spaces.
862
- * Add category/tag/id/author filters for template ads.
863
- * Hopefully fixes the 'headers already sent message that some people got with 1.2.0.8
864
-
865
- = 1.2.0.7 =
866
- * Tested on WordPress 3.3.
867
- * Put mfunc code block on one line.
868
-
869
- = 1.2.0.6 =
870
- * Fix problem with debug output.
871
- * Reduce memory on admin side for blogs with large numbers of tags.
872
- * More detailed debug for PHP exec errors.
873
- * Colour debug table changes.
874
-
875
- = 1.2.0.5 =
876
- * Fix: Problem with adinjblocked cookie reading.
877
-
878
- = 1.2.0.4 =
879
- * New: Support for Ad Logger's AdSense click blocking feature (that is my new plugin!).
880
- * New: Make more parts of the ad placement settings UI fade away if they can't be used.
881
-
882
- = 1.2.0.3 =
883
- * New: Setting to allow priority of Ad Injection's the_content filter to be changed to help with problem themes.
884
- * Fix: Start at paragraph setting may have been incorrectly upgraded if previously using an old version of this plugin.
885
-
886
- = 1.2.0.2 =
887
- * Fix: Problem with repeating bottom ads and ID filters not being properly applied to archives.
888
-
889
  = 0.8.3 =
890
  First public release.
891
 
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.13
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
 
17
  * Set the position of the top and bottom advert by paragraph or character.
18
  * Position the random ads to start or stop in the middle of the post.
19
  * Stop the random ads 2/3 of the way down a post, or at a paragraph/character position from the beginning/end of the post.
20
+ * New options to exlude ads from blockquote and pre sections. And custom ad exlude tags.
21
  * Fade unused Home/Archive options instead of making them dissapear.
22
  * Add page age settings to status.
23
  * Improve debug messages.
88
 
89
  If you need to override the top, random, or bottom ad positions on a specific post you can use these in-content tags to manually set the ad positions: &lt;!--topad--&gt; &lt;!--randomad--&gt; &lt;!--bottomad--&gt; &lt;!--adstart--&gt; &lt;!--adend--&gt; &lt;!--noads--&gt;
90
 
91
+ You can manually exclude ads from specific sections of the post using the &lt;!--adinj_exclude_start--&gt;&lt;!--adinj_exclude_end--&gt; tags.
92
+
93
+ = Exclude ads from block tags =
94
+
95
+ Ads can be excluded from &lt;blockquote&gt;&lt;/blockquote&gt; and &lt;pre&gt;&lt;/pre&gt; tags.
96
+
97
  = Alternate content =
98
 
99
  This is content that is displayed when ads are blocked for the user. You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.
425
 
426
  You can download the Country Filter plugin from http://wordpress.org/extend/plugins/country-filter/
427
 
428
+ You could also use the Geo IP functionality that CloudFlare offers (you can set it up for free if you are able to modify your DNS settings) http://support.cloudflare.com/kb/what-do-the-various-cloudflare-settings-do/how-does-cloudflare-ip-geolocation-work
429
+
430
  = If I restrict a widget to both a category and a tag it doesn't appear in the relevant category/tag archives. Why? =
431
 
432
  If you set an ad with a tag restriction of 'tag1' and a category restriction of 'cat1', then it will only appear on pages that have BOTH the tag1 and cat1 property.
616
 
617
  == Changelog ==
618
 
619
+ = 1.2.0.13 =
620
+ * New option to exclude ads from blockquote and pre tags.
621
+ * New tag to exclude ads from specific parts of posts.
622
+
623
  = 1.2.0.12 =
624
  * Fix for ads with UTF-8 characters
625
 
863
 
864
  == Upgrade Notice ==
865
 
866
+ = 1.2.0.13 =
867
+ * New option to exclude ads from blockquote and pre tags.
868
+ * New tag to exclude ads from specific parts of posts.
869
+
870
  = 1.2.0.12 =
871
  * Fix for ads with UTF-8 characters
872
 
874
  * Preserve HTML entities when saving - i.e. preserve special character sequences.
875
  * Add '400' as an option to the numbered drop downs.
876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
877
  = 0.8.3 =
878
  First public release.
879
 
ui-tab-adrotation.php CHANGED
@@ -139,6 +139,10 @@ function adinj_docs_tags(){
139
  <li><code>&lt;!--topad--&gt;</code> OR <code>&lt;!--randomad--&gt;</code> OR <code>&lt;!--bottomad--&gt;</code> - These tags allow precise positioning of the adverts instead of using the computer calculated positions.</li>
140
  </ul>
141
 
 
 
 
 
142
  <ul>
143
  <li><code>&lt;!--adstart--&gt;</code> - Random ads will start from this point.</li>
144
  <li><code>&lt;!--adend--&gt;</code> - Random ads will not be inserted after this point.</li>
139
  <li><code>&lt;!--topad--&gt;</code> OR <code>&lt;!--randomad--&gt;</code> OR <code>&lt;!--bottomad--&gt;</code> - These tags allow precise positioning of the adverts instead of using the computer calculated positions.</li>
140
  </ul>
141
 
142
+ <ul>
143
+ <li><code>&lt;!--adinj_exclude_start--&gt;&lt;!--adinj_exclude_end--&gt;</code> - Exclude ads from specific sections of the post.</li>
144
+ </ul>
145
+
146
  <ul>
147
  <li><code>&lt;!--adstart--&gt;</code> - Random ads will start from this point.</li>
148
  <li><code>&lt;!--adend--&gt;</code> - Random ads will not be inserted after this point.</li>
ui-tab-main.php CHANGED
@@ -378,6 +378,16 @@ JQUERYOPACITY;
378
  </td></tr>
379
  <tr><td colspan="4"><p><span style="font-size:10px;">When defining 'post longer than' / 'post shorter than' conditions; do you want to count viewable characters, all characters (which includes HTML tags), or number of words?<br />This setting does not apply to the settings for positioning the ads near a character position - these use the raw character count.</span></p></td></tr>
380
 
 
 
 
 
 
 
 
 
 
 
381
  </table>
382
 
383
 
378
  </td></tr>
379
  <tr><td colspan="4"><p><span style="font-size:10px;">When defining 'post longer than' / 'post shorter than' conditions; do you want to count viewable characters, all characters (which includes HTML tags), or number of words?<br />This setting does not apply to the settings for positioning the ads near a character position - these use the raw character count.</span></p></td></tr>
380
 
381
+ <tr>
382
+ <td>Exclude ads from &lt;blockquote&gt;&lt;/blockquote&gt; and &lt;pre&gt;&lt;/pre&gt; blocks:</td>
383
+ <td colspan="3">
384
+ <?php
385
+ adinj_add_checkbox('exclude_ads_from_block_tags');
386
+ ?>
387
+ </td></tr>
388
+ <tr><td colspan="4"><p><span style="font-size:10px;">Exclude ads from &lt;pre&gt;&lt;/pre&gt; and &lt;blockquote&gt;&lt;/blockquote&gt; tag blocks.<br/>
389
+ Ad Injection also supports &lt;!--adinj_exclude_start--&gt;&lt;!--adinj_exclude_end--&gt; tags. You don't need to tick the box for these to be enabled.</span></p></td></tr>
390
+
391
  </table>
392
 
393