Ad Injection - Version 0.9.7.6

Version Description

  • Category, tag and author exclusions now apply to home page posts.
  • Fixes for widget category exclusions.
Download this release

Release Info

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

Code changes from version 0.9.7.5 to 0.9.7.6

Files changed (3) hide show
  1. ad-injection-admin.php +1 -1
  2. ad-injection.php +42 -17
  3. readme.txt +7 -3
ad-injection-admin.php CHANGED
@@ -331,7 +331,7 @@ function adinj_top_message_box(){
331
 
332
  } else if (!isset($_GET['tab'])){
333
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
334
- echo "3rd March 2011: This update simplifies the ad insertion modes. Instead of two direct modes there is now just one. There is the same functionality as before, but now with less options. If you were previously using direct_static mode then you should verify that everything still works as you expect. Plus other minor fixes. 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 if (!isset($_GET['tab'])){
333
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
334
+ echo "5th March 2011: Category, tag and author exclusions bugs have been fixed. If you don't use these rules there is no change for you. If you do use these rules and were relying on the bugs, then your ads positions may have changed. Do check them! 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.5
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -477,22 +477,32 @@ function adinj_mode_never_show_in($mode){
477
  }
478
 
479
  function adinj_allowed_in_category($scope, $ops){
480
- $cat_array = adinj_split_comma_list($ops[$scope.'_category_condition_entries']);
481
- if (empty($cat_array)) return true;
482
 
483
  $mode = $ops[$scope.'_category_condition_mode'];
484
- if (adinj_mode_only_show_in($mode) && !(is_single() || is_category())){
 
 
 
 
 
485
  return false;
486
  }
487
 
488
- $postcategories = array();
489
- if (is_single()){
490
- global $post;
491
- $postcategories = get_the_category($post->ID);
 
 
 
 
 
492
  } else if (is_category()){
493
- $postcategories[] = get_category(get_query_var('cat'));
494
  } // else cat array is empty
495
- return adinj_allowed_in_list($postcategories, $cat_array, $mode, 'adinj_category_nicename');
496
  }
497
 
498
  function adinj_allowed_in_tag($scope, $ops){
@@ -500,14 +510,24 @@ function adinj_allowed_in_tag($scope, $ops){
500
  if (empty($conditions)) return true;
501
 
502
  $mode = $ops[$scope.'_tag_condition_mode'];
503
- if (adinj_mode_only_show_in($mode) && !(is_single() || is_tag())){
 
 
 
 
 
504
  return false;
505
  }
506
 
507
  $tags = array();
508
- if (is_single()){
509
- global $post;
510
  $tags = get_the_tags($post->ID);
 
 
 
 
 
511
  } else if (is_tag()){
512
  $tags[] = get_tag(get_query_var('tag_id'));
513
  } // else tag array is empty
@@ -519,14 +539,19 @@ function adinj_allowed_in_author($scope, $ops){
519
  if (empty($conditions)) return true;
520
 
521
  $mode = $ops[$scope.'_author_condition_mode'];
522
- if (adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_author())){
 
 
 
 
 
523
  return false;
524
  }
525
 
526
  $user = array();
527
- if (is_single() || is_page()){
528
- $data = get_the_author_meta('user_login');
529
- $user[] = $data ; //need to make it into array
530
  } else if (is_author()){
531
  $curauth = get_userdata(get_query_var('author'));
532
  $user[] = $curauth->user_login;
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.6
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
477
  }
478
 
479
  function adinj_allowed_in_category($scope, $ops){
480
+ $conditions = adinj_split_comma_list($ops[$scope.'_category_condition_entries']);
481
+ if (empty($conditions)) return true;
482
 
483
  $mode = $ops[$scope.'_category_condition_mode'];
484
+
485
+ if ($scope == 'widget' && adinj_mode_only_show_in($mode) && !(is_single() || is_category())){
486
+ return false;
487
+ }
488
+
489
+ if (adinj_mode_only_show_in($mode) && !(is_single() || is_home() || is_category())){
490
  return false;
491
  }
492
 
493
+ $categories = array();
494
+ global $post;
495
+ if (in_the_loop() && (is_single() || is_home())){
496
+ $categories = get_the_category($post->ID);
497
+ } else if (!in_the_loop() && is_single()){
498
+ $cat_ids = wp_get_object_terms($post->ID, 'category', 'fields=all');
499
+ foreach($cat_ids as $id){
500
+ $categories[] = get_category($id);
501
+ }
502
  } else if (is_category()){
503
+ $categories[] = get_category(get_query_var('cat'));
504
  } // else cat array is empty
505
+ return adinj_allowed_in_list($categories, $conditions, $mode, 'adinj_category_nicename');
506
  }
507
 
508
  function adinj_allowed_in_tag($scope, $ops){
510
  if (empty($conditions)) return true;
511
 
512
  $mode = $ops[$scope.'_tag_condition_mode'];
513
+
514
+ if ("$scope" == "widget" && adinj_mode_only_show_in($mode) && !(is_single() || is_tag())){
515
+ return false;
516
+ }
517
+
518
+ if (adinj_mode_only_show_in($mode) && !(is_single() || is_home() || is_tag())){
519
  return false;
520
  }
521
 
522
  $tags = array();
523
+ global $post;
524
+ if (in_the_loop() && (is_single() || is_home())){
525
  $tags = get_the_tags($post->ID);
526
+ } else if (!in_the_loop() && is_single()){
527
+ $tag_ids = wp_get_object_terms($post->ID, 'post_tag', 'fields=all');
528
+ foreach($tag_ids as $id){
529
+ $tags[] = get_tag($id);
530
+ }
531
  } else if (is_tag()){
532
  $tags[] = get_tag(get_query_var('tag_id'));
533
  } // else tag array is empty
539
  if (empty($conditions)) return true;
540
 
541
  $mode = $ops[$scope.'_author_condition_mode'];
542
+
543
+ if ($scope == 'widget' && adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_author())){
544
+ return false;
545
+ }
546
+
547
+ if (adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_home() || is_author())){
548
  return false;
549
  }
550
 
551
  $user = array();
552
+ if (is_single() || is_page() || is_home()){
553
+ $data = get_the_author_meta('user_login'); // works in and out of the loop
554
+ $user[] = $data; //need to make it into array
555
  } else if (is_author()){
556
  $curauth = get_userdata(get_query_var('author'));
557
  $user[] = $curauth->user_login;
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.5
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,10 @@ 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.5 =
376
  * Simplify the ad insertion modes. Replace the two previous direct modes with one.
377
  * Other minor bug fixes.
@@ -517,8 +521,8 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
517
 
518
  == Upgrade Notice ==
519
 
520
- = 0.9.7.5 =
521
- * Simplify ad insertion modes. Replace the two direct modes with one.
522
 
523
  = 0.8.3 =
524
  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.6
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.6 =
376
+ * Category, tag and author exclusions now apply to home page posts.
377
+ * Fixes for widget category exclusions.
378
+
379
  = 0.9.7.5 =
380
  * Simplify the ad insertion modes. Replace the two previous direct modes with one.
381
  * Other minor bug fixes.
521
 
522
  == Upgrade Notice ==
523
 
524
+ = 0.9.7.6 =
525
+ * Category, tag and author exclusions now apply to home page posts.
526
 
527
  = 0.8.3 =
528
  First public release.