Ad Injection - Version 0.9.4

Version Description

Global tag and category restrictions. Smoother JQuery show/hide blocks (especially on IE)

Download this release

Release Info

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

Code changes from version 0.9.3.4 to 0.9.4

Files changed (3) hide show
  1. ad-injection-admin.php +215 -62
  2. ad-injection.php +68 -7
  3. readme.txt +12 -1
ad-injection-admin.php CHANGED
@@ -278,6 +278,14 @@ function adinj_options_page(){
278
  </td><td>
279
  <?php $info = adinj_get_status('restrictions'); echo adinj_dot($info[0]).' '.$info[1]; ?>
280
  </td></tr>
 
 
 
 
 
 
 
 
281
  <tr><td>
282
  </td><td>
283
  <?php } ?>
@@ -307,13 +315,14 @@ function adinj_options_page(){
307
  <ul>
308
  <li>More precise control over which categories and tags the ads are shown in.</li>
309
  <li>Extra places where adverts can be inserted.</li>
 
310
  </ul>
311
 
312
  <h4><font color="red">Be careful!</font></h4>
313
  <p>Make sure that the ad settings and positioning you define are in compliance with your ad provider's terms of service!</p>
314
 
315
  <h4><font color="red">Beta version</font></h4>
316
- <p>This plugin has only only recently been released - please bare with me if there are any bugs. I'm actively listening to your feedback and fixing any problems, and adding new features that you request. Please let me know if you like the plugin too!</p>
317
 
318
  <h4>More by this author</h4>
319
  <ul>
@@ -326,6 +335,17 @@ function adinj_options_page(){
326
  </div>
327
  </div>
328
  </div>
 
 
 
 
 
 
 
 
 
 
 
329
 
330
  <p><a href="#random">Random ads</a> | <a href="#topad">Top</a> | <a href="#bottomad">Bottom</a> | <a href="#widgets">Widgets</a> | <a href="#restrictions">Ad insert mode/dynamic restrictions</a> | <a href="#debugging">Debug</a> | <a href="#docs">Quick Start</a> | <a href="#testads">Test ads</a></p>
331
 
@@ -356,18 +376,24 @@ function adinj_options_page(){
356
  echo ">$older_than_days[$value]</option>";
357
  }
358
  ?>
359
- </select><?php _e(" (days)", 'adinj') ?> (only for single posts and pages)</p>
360
  </td></tr>
361
- <tr><td>
362
  Don't show ads on these page types:
363
  </td><td>
364
- <input type="checkbox" name="exclude_home" <?php echo adinj_ticked('exclude_home'); ?> />home<br />
365
- <input type="checkbox" name="exclude_page" <?php echo adinj_ticked('exclude_page'); ?> />page (<?php echo wp_count_posts('page', 'readable')->publish; ?> page(s))<br />
366
- <input type="checkbox" name="exclude_single" <?php echo adinj_ticked('exclude_single'); ?> />single (<?php echo wp_count_posts('post', 'readable')->publish; ?> individual blog post(s))<br />
367
- <input type="checkbox" name="exclude_archive" <?php echo adinj_ticked('exclude_archive'); ?> />archive (only <a href="#widgets">widgets</a> currently appear on archives)<br />
368
  </td></tr>
369
  </table>
370
 
 
 
 
 
 
 
371
  <?php adinj_postbox_end(); ?>
372
 
373
 
@@ -410,7 +436,7 @@ function adinj_options_page(){
410
  <?php _e("Maximum number of randomly injected ads: ", 'adinj') ?></td><td>
411
  <select name='max_num_of_ads'>
412
  <?php
413
- for ($value=0; $value<=6; ++$value){
414
  echo "<option value=\"$value\" ";
415
  if($ops['max_num_of_ads'] == $value) echo 'selected="selected"';
416
  echo ">$value</option>";
@@ -571,9 +597,42 @@ function adinj_options_page(){
571
  <p><input type="radio" name="ad_insertion_mode" value="direct_static" <?php if ($ops['ad_insertion_mode']=='direct_static') echo 'checked="checked"'; ?> /> <b>Direct static ad insertion</b> - No dynamic feature support. Select this if you are using a caching plugin which is not compatible with WP Super Cache's mfunc tags.</p>
572
  </blockquote>
573
  </div>
574
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
 
576
  <div class="inside" style="margin:10px">
 
577
  <h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
578
 
579
  <blockquote>
@@ -592,9 +651,9 @@ function adinj_options_page(){
592
 
593
  <p>For reference your current IP address is <code><?php echo $_SERVER['REMOTE_ADDR'] ?></code></p>
594
  </blockquote>
595
-
596
  </div>
597
 
 
598
  <h3>Recommended WP Super Cache settings:</h3>
599
  <div class="inside" style="margin:10px">
600
 
@@ -614,6 +673,9 @@ function adinj_options_page(){
614
  echo "Note: WP Super Cache does not appear to be active.";
615
  } ?>
616
  </p>
 
 
 
617
 
618
  <?php adinj_postbox_end(); ?>
619
 
@@ -659,16 +721,13 @@ function adinj_options_page(){
659
  function adinj_postbox_start($title, $anchor, $width='650px'){
660
  $ops = adinj_options();
661
  ?>
662
- <div class='postbox-container' style='width:<?php echo $width; ?>;float:left;'>
663
  <div class="metabox-holder">
664
  <div class="postbox">
665
  <input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
666
  <div class="<?php echo $anchor; ?>-button"></div>
667
  <script type="text/javascript">
668
  jQuery(document).ready(function(){
669
- if (jQuery('#ui_<?php echo $anchor; ?>_hide').val() == 'true'){
670
- jQuery('.<?php echo $anchor; ?>-box').hide();
671
- }
672
  jQuery('.<?php echo $anchor; ?>-button').show().before('<a href="#" style="float:right" id="toggle-<?php echo $anchor; ?>" class="button">Show/Hide</a>');
673
  jQuery('a#toggle-<?php echo $anchor; ?>').click(function() {
674
  jQuery('#ui_<?php echo $anchor; ?>_hide').val(!jQuery('.<?php echo $anchor; ?>-box').is(":hidden"));
@@ -679,8 +738,16 @@ function adinj_postbox_start($title, $anchor, $width='650px'){
679
  </script>
680
  <input type='hidden' id='ui_<?php echo $anchor; ?>_hide' name='ui_<?php echo $anchor; ?>_hide' value='<?php echo $ops['ui_'.$anchor.'_hide']; ?>' />
681
  <h3><?php $info = adinj_get_status($anchor); echo adinj_dot($info[0]); ?> <a name="<?php echo $anchor; ?>"></a><?php echo adinj_get_logo() . ' ' . $title; ?></h3>
 
 
 
 
 
 
682
  <div class="<?php echo $anchor; ?>-box">
 
683
  <div class="inside" style="margin:10px">
 
684
  <?php
685
  }
686
 
@@ -800,6 +867,15 @@ function adinj_get_status($name){
800
  if (!empty($ops['blocked_ips'])){
801
  $status[1] .= ' ip';
802
  }
 
 
 
 
 
 
 
 
 
803
  }
804
  return $status;
805
  }
@@ -830,12 +906,76 @@ function adinj_selection_box($name, $values, $type=NULL){
830
  } else {
831
  $typetxt = $type;
832
  }
833
- if ($value === ADINJ_RULE_DISABLED) $typetxt = "";
834
  echo ">$value $typetxt</option>";
835
  }
836
  echo "</select>";
837
  }
838
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839
  function adinj_add_alignment_options($prefix){
840
  _e("Alignment", 'adinj');
841
  echo "<br />";
@@ -1015,53 +1155,66 @@ function adinj_options_need_upgrading($stored_options){
1015
 
1016
  function adinj_default_options(){
1017
  return array(
1018
- 'ads_enabled' => 'off',
1019
- 'max_num_of_ads' => '2', // single posts and pages
1020
- 'max_num_of_ads_home_page' => '3',
1021
- 'no_random_ads_if_shorter_than' => '100',
1022
- 'one_ad_if_shorter_than' => '500',
1023
- 'two_ads_if_shorter_than' => '1000',
1024
- 'three_ads_if_shorter_than' => ADINJ_RULE_DISABLED,
1025
- 'top_ad_if_longer_than' => ADINJ_RULE_DISABLED,
1026
- 'bottom_ad_if_longer_than' => ADINJ_RULE_DISABLED,
1027
- 'rnd_align' => ADINJ_RULE_DISABLED,
1028
- 'rnd_margin_top' => '3',
1029
- 'rnd_margin_bottom' => '3',
1030
- 'top_align' => ADINJ_RULE_DISABLED,
1031
- 'top_margin_top' => '3',
1032
- 'top_margin_bottom' => '3',
1033
- 'bottom_align' => ADINJ_RULE_DISABLED,
1034
- 'bottom_margin_top' => '3',
1035
- 'bottom_margin_bottom' => '3',
1036
- 'widget_exclude_home' => '',
1037
- 'widget_exclude_page' => '',
1038
- 'widget_exclude_single' => '',
1039
- 'widget_exclude_archive' => '',
1040
- 'ads_on_page_older_than' => '10',
1041
- 'exclude_home' => '',
1042
- 'exclude_page' => '',
1043
- 'exclude_single' => '',
1044
- 'exclude_archive' => '',
1045
- 'first_paragraph_ad' => '',
1046
- 'multiple_ads_at_same_position' => '',
1047
- 'sevisitors_only' => '',
1048
- 'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/',
1049
- 'blocked_ips' => '',
1050
- 'ad_insertion_mode' => 'mfunc',
1051
- 'ad_code_random_1' => '',
1052
- 'ad_code_top_1' => '',
1053
- 'ad_code_bottom_1' => '',
1054
- 'ui_global_hide' => 'false',
1055
- 'ui_random_hide' => 'false',
1056
- 'ui_topad_hide' => 'false',
1057
- 'ui_bottomad_hide' => 'false',
1058
- 'ui_widgets_hide' => 'false',
1059
- 'ui_restrictions_hide' => 'false',
1060
- 'ui_debugging_hide' => 'true',
1061
- 'ui_docs_hide' => 'false',
1062
- 'ui_testads_hide' => 'false',
1063
- 'debug_mode' => ''
1064
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
1065
  }
1066
 
1067
  function adinj_getdefault($option){
278
  </td><td>
279
  <?php $info = adinj_get_status('restrictions'); echo adinj_dot($info[0]).' '.$info[1]; ?>
280
  </td></tr>
281
+ <tr><td style="text-align:right">
282
+ <b><a href="#debugging">Debug mode</a></b>
283
+ </td><td>
284
+ <?php $info = adinj_get_status('debugging'); echo adinj_dot($info[0]).' '.$info[1]; ?>
285
+ </td></tr>
286
+ <tr><td>
287
+ </td><td>
288
+ </td></tr>
289
  <tr><td>
290
  </td><td>
291
  <?php } ?>
315
  <ul>
316
  <li>More precise control over which categories and tags the ads are shown in.</li>
317
  <li>Extra places where adverts can be inserted.</li>
318
+ <li>Merry Christmas by the way!</li>
319
  </ul>
320
 
321
  <h4><font color="red">Be careful!</font></h4>
322
  <p>Make sure that the ad settings and positioning you define are in compliance with your ad provider's terms of service!</p>
323
 
324
  <h4><font color="red">Beta version</font></h4>
325
+ <p>This plugin has only only recently been released. I'm actively listening to your feedback and fixing any problems, and adding new features that you request. Please let me know if you like the plugin too!</p>
326
 
327
  <h4>More by this author</h4>
328
  <ul>
335
  </div>
336
  </div>
337
  </div>
338
+
339
+ <script type="text/javascript">
340
+ function adinj_addtext(element, value) {
341
+ if (value.length == 0) return;
342
+ separator = ', ';
343
+ if (element.value.length == 0){
344
+ separator = '';
345
+ }
346
+ element.value += (separator + value);
347
+ }
348
+ </script>
349
 
350
  <p><a href="#random">Random ads</a> | <a href="#topad">Top</a> | <a href="#bottomad">Bottom</a> | <a href="#widgets">Widgets</a> | <a href="#restrictions">Ad insert mode/dynamic restrictions</a> | <a href="#debugging">Debug</a> | <a href="#docs">Quick Start</a> | <a href="#testads">Test ads</a></p>
351
 
376
  echo ">$older_than_days[$value]</option>";
377
  }
378
  ?>
379
+ </select><?php _e(" (days)", 'adinj') ?> - only for single posts and pages</p>
380
  </td></tr>
381
+ <tr><td style="vertical-align:top">
382
  Don't show ads on these page types:
383
  </td><td>
384
+ <input type="checkbox" name="exclude_home" <?php echo adinj_ticked('exclude_home'); ?> />home - <?php echo get_bloginfo('url'); ?><br />
385
+ <input type="checkbox" name="exclude_page" <?php echo adinj_ticked('exclude_page'); ?> />page - <?php echo wp_count_posts('page', 'readable')->publish; ?> page(s)<br />
386
+ <input type="checkbox" name="exclude_single" <?php echo adinj_ticked('exclude_single'); ?> />single -<?php echo wp_count_posts('post', 'readable')->publish; ?> individual blog post(s)<br />
387
+ <input type="checkbox" name="exclude_archive" <?php echo adinj_ticked('exclude_archive'); ?> />archive - only <a href="#widgets">widgets</a> currently appear on archives<br />
388
  </td></tr>
389
  </table>
390
 
391
+ <b>Category and tag conditions</b>
392
+
393
+ <?php adinj_condition_table('global_category', 'category slugs. e.g: cat1, cat2, cat3', 'category'); ?>
394
+
395
+ <?php adinj_condition_table('global_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag'); ?>
396
+
397
  <?php adinj_postbox_end(); ?>
398
 
399
 
436
  <?php _e("Maximum number of randomly injected ads: ", 'adinj') ?></td><td>
437
  <select name='max_num_of_ads'>
438
  <?php
439
+ for ($value=0; $value<=10; ++$value){
440
  echo "<option value=\"$value\" ";
441
  if($ops['max_num_of_ads'] == $value) echo 'selected="selected"';
442
  echo ">$value</option>";
597
  <p><input type="radio" name="ad_insertion_mode" value="direct_static" <?php if ($ops['ad_insertion_mode']=='direct_static') echo 'checked="checked"'; ?> /> <b>Direct static ad insertion</b> - No dynamic feature support. Select this if you are using a caching plugin which is not compatible with WP Super Cache's mfunc tags.</p>
598
  </blockquote>
599
  </div>
600
+ <p></p>
601
+
602
+ <script type="text/javascript">
603
+ jQuery(document).ready(function(){
604
+ jQuery('input[name=ad_insertion_mode]:radio').change(function() {
605
+ if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
606
+ jQuery('.dynamic_features').slideUp(1000);
607
+ jQuery('.dynamic_features_msg').slideDown(1000);
608
+ } else {
609
+ jQuery('.dynamic_features_msg').slideUp(1000);
610
+ jQuery('.dynamic_features').slideDown(1000);
611
+ }
612
+ return true;
613
+ });
614
+ });
615
+ </script>
616
+
617
+ <?php if ($ops['ad_insertion_mode'] == 'direct_static') { ?>
618
+ <div class="dynamic_features_msg">
619
+ <?php } else { ?>
620
+ <div class="dynamic_features_msg" style="display:none">
621
+ <?php } ?>
622
+ <div class="inside" style="margin:10px">
623
+ <b><span style="font-size:10px;color:red;">Note: Dynamic features (restricting ad views by referrer and IP address) are only available in the mfunc, or direct dynamic modes.</span></b>
624
+ </div>
625
+ </div>
626
+
627
+ <?php if ($ops['ad_insertion_mode'] == 'direct_static') { ?>
628
+ <script type="text/javascript">
629
+ document.write('<style type="text/css" media="screen">#dynamic_features { display: none; }</style>');
630
+ </script>
631
+ <?php } ?>
632
+ <div id="dynamic_features" class="dynamic_features">
633
 
634
  <div class="inside" style="margin:10px">
635
+
636
  <h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
637
 
638
  <blockquote>
651
 
652
  <p>For reference your current IP address is <code><?php echo $_SERVER['REMOTE_ADDR'] ?></code></p>
653
  </blockquote>
 
654
  </div>
655
 
656
+
657
  <h3>Recommended WP Super Cache settings:</h3>
658
  <div class="inside" style="margin:10px">
659
 
673
  echo "Note: WP Super Cache does not appear to be active.";
674
  } ?>
675
  </p>
676
+ </div>
677
+
678
+ </div>
679
 
680
  <?php adinj_postbox_end(); ?>
681
 
721
  function adinj_postbox_start($title, $anchor, $width='650px'){
722
  $ops = adinj_options();
723
  ?>
724
+ <div class='postbox-container' style='width:<?php echo $width; ?>;float:left; clear:left;'>
725
  <div class="metabox-holder">
726
  <div class="postbox">
727
  <input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
728
  <div class="<?php echo $anchor; ?>-button"></div>
729
  <script type="text/javascript">
730
  jQuery(document).ready(function(){
 
 
 
731
  jQuery('.<?php echo $anchor; ?>-button').show().before('<a href="#" style="float:right" id="toggle-<?php echo $anchor; ?>" class="button">Show/Hide</a>');
732
  jQuery('a#toggle-<?php echo $anchor; ?>').click(function() {
733
  jQuery('#ui_<?php echo $anchor; ?>_hide').val(!jQuery('.<?php echo $anchor; ?>-box').is(":hidden"));
738
  </script>
739
  <input type='hidden' id='ui_<?php echo $anchor; ?>_hide' name='ui_<?php echo $anchor; ?>_hide' value='<?php echo $ops['ui_'.$anchor.'_hide']; ?>' />
740
  <h3><?php $info = adinj_get_status($anchor); echo adinj_dot($info[0]); ?> <a name="<?php echo $anchor; ?>"></a><?php echo adinj_get_logo() . ' ' . $title; ?></h3>
741
+ <?php if($ops['ui_'.$anchor.'_hide'] == 'true'){ ?>
742
+ <script type="text/javascript">
743
+ document.write('<style type="text/css" media="screen">#<?php echo $anchor; ?>-box { display: none; }</style>');
744
+ </script>
745
+ <div id="<?php echo $anchor; ?>-box" class="<?php echo $anchor; ?>-box">
746
+ <?php } else { ?>
747
  <div class="<?php echo $anchor; ?>-box">
748
+ <?php } ?>
749
  <div class="inside" style="margin:10px">
750
+
751
  <?php
752
  }
753
 
867
  if (!empty($ops['blocked_ips'])){
868
  $status[1] .= ' ip';
869
  }
870
+ } else if ($name == 'debugging'){
871
+ $val = $ops['debug_mode'];
872
+ if ($val == 'on'){
873
+ $status[0] = 'green';
874
+ $status[1] = 'on';
875
+ } else {
876
+ $status[0] = 'red';
877
+ $status[1] = 'off';
878
+ }
879
  }
880
  return $status;
881
  }
906
  } else {
907
  $typetxt = $type;
908
  }
909
+ if ($value === ADINJ_RULE_DISABLED || $value === '') $typetxt = "";
910
  echo ">$value $typetxt</option>";
911
  }
912
  echo "</select>";
913
  }
914
 
915
+ function adinj_condition_table($name, $description, $type){
916
+ $options = adinj_options();
917
+ ?>
918
+ <table border="0">
919
+ <tr><td>
920
+
921
+ <textarea name="<?php echo $name; ?>_condition_entries" rows="2" cols="40"><?php echo $options[$name.'_condition_entries']; ?></textarea>
922
+
923
+
924
+ </td><td style="vertical-align:top">
925
+
926
+ <?php
927
+ adinj_selection_box($name."_condition_mode",
928
+ array('Only show in', 'Never show in'));
929
+ ?>
930
+
931
+ <br />
932
+
933
+ <?php if ($type == 'category') { ?>
934
+ <select name="<?php echo $name; ?>_dropdown" onchange='adinj_addtext(<?php echo $name; ?>_condition_entries, this.options[this.selectedIndex].value);'>
935
+ <option value=""><?php echo 'Add ' . $type; ?></option>
936
+ <?php
937
+ $categories = get_categories();
938
+ foreach ($categories as $category) {
939
+ $option = '<option value="'.$category->category_nicename.'">';
940
+ $option .= $category->category_nicename;
941
+ $option .= ' ('.$category->category_count.')';
942
+ $option .= '</option>';
943
+ echo $option;
944
+ }
945
+ ?>
946
+ </select>
947
+ <NOSCRIPT><br /><span style="font-size:10px">As JavaScript is disabled you will have to manually type in the values.</span></NOSCRIPT>
948
+
949
+ <?php } else if ($type == 'tag') { ?>
950
+
951
+ <select name="<?php echo $name; ?>_dropdown" onchange='adinj_addtext(document.adinjform.<?php echo $name; ?>_condition_entries, this.options[this.selectedIndex].value);'">
952
+
953
+ <option value=""><?php echo 'Add ' . $type; ?></option>
954
+ <?php
955
+ $tags = get_tags();
956
+ foreach ($tags as $tag) {
957
+ $option = '<option value="'.$tag->slug.'">';
958
+ $option .= $tag->slug;
959
+ $option .= ' ('.$tag->count.')';
960
+ $option .= '</option>';
961
+ echo $option;
962
+ }
963
+ ?>
964
+ </select>
965
+ <NOSCRIPT><br /><span style="font-size:10px">As JavaScript is disabled you will have to manually type in the values.</span></NOSCRIPT>
966
+
967
+ <?php } else {
968
+ echo 'Type not defined: ' . $type;
969
+ }?>
970
+
971
+ </td></tr>
972
+ <tr><td colspan="2">
973
+ <span style="font-size:10px;">Comma separated list of <?php echo $description; ?></span>
974
+ </td></tr>
975
+ </table>
976
+ <?php
977
+ }
978
+
979
  function adinj_add_alignment_options($prefix){
980
  _e("Alignment", 'adinj');
981
  echo "<br />";
1155
 
1156
  function adinj_default_options(){
1157
  return array(
1158
+ // Global settings
1159
+ 'ads_enabled' => '',
1160
+ 'ads_on_page_older_than' => '10',
1161
+ 'exclude_home' => '',
1162
+ 'exclude_page' => '',
1163
+ 'exclude_single' => '',
1164
+ 'exclude_archive' => '',
1165
+ 'global_category_condition_mode' => ADINJ_ONLY_SHOW_IN,
1166
+ 'global_category_condition_entries' => '',
1167
+ 'global_tag_condition_mode' => ADINJ_ONLY_SHOW_IN,
1168
+ 'global_tag_condition_entries' => '',
1169
+ // Random ad
1170
+ 'ad_code_random_1' => '',
1171
+ 'max_num_of_ads' => '2', // single posts and pages
1172
+ 'no_random_ads_if_shorter_than' => '100',
1173
+ 'one_ad_if_shorter_than' => '500',
1174
+ 'two_ads_if_shorter_than' => '1000',
1175
+ 'three_ads_if_shorter_than' => ADINJ_RULE_DISABLED,
1176
+ 'top_ad_if_longer_than' => ADINJ_RULE_DISABLED,
1177
+ 'bottom_ad_if_longer_than' => ADINJ_RULE_DISABLED,
1178
+ 'rnd_align' => ADINJ_RULE_DISABLED,
1179
+ 'rnd_margin_top' => '3',
1180
+ 'rnd_margin_bottom' => '3',
1181
+ 'first_paragraph_ad' => '',
1182
+ 'multiple_ads_at_same_position' => '',
1183
+ // Home page specific random ads
1184
+ 'max_num_of_ads_home_page' => '3',
1185
+ // top
1186
+ 'ad_code_top_1' => '',
1187
+ 'top_align' => ADINJ_RULE_DISABLED,
1188
+ 'top_margin_top' => '3',
1189
+ 'top_margin_bottom' => '3',
1190
+ // bottom
1191
+ 'ad_code_bottom_1' => '',
1192
+ 'bottom_align' => ADINJ_RULE_DISABLED,
1193
+ 'bottom_margin_top' => '3',
1194
+ 'bottom_margin_bottom' => '3',
1195
+ // widgets
1196
+ 'widget_exclude_home' => '',
1197
+ 'widget_exclude_page' => '',
1198
+ 'widget_exclude_single' => '',
1199
+ 'widget_exclude_archive' => '',
1200
+ // dynamic features
1201
+ 'sevisitors_only' => '',
1202
+ 'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/',
1203
+ 'blocked_ips' => '',
1204
+ 'ad_insertion_mode' => 'mfunc',
1205
+ // ui
1206
+ 'ui_global_hide' => 'false',
1207
+ 'ui_random_hide' => 'false',
1208
+ 'ui_topad_hide' => 'false',
1209
+ 'ui_bottomad_hide' => 'false',
1210
+ 'ui_widgets_hide' => 'false',
1211
+ 'ui_restrictions_hide' => 'false',
1212
+ 'ui_debugging_hide' => 'true',
1213
+ 'ui_docs_hide' => 'false',
1214
+ 'ui_testads_hide' => 'false',
1215
+ // debug
1216
+ 'debug_mode' => ''
1217
+ );
1218
  }
1219
 
1220
  function adinj_getdefault($option){
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.3.4
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -25,6 +25,9 @@ define('ADINJ_AD_BOTTOM_FILE', 'ad_bottom_1.txt');
25
  // Constants
26
  define('ADINJ_RULE_DISABLED', 'Rule Disabled');
27
  define('ADINJ_ALWAYS_SHOW', 'Always show');
 
 
 
28
 
29
  // Global variables
30
  $adinj_total_rand_ads_used = 0;
@@ -94,7 +97,8 @@ function adinj_quote_list($option){
94
  $list = implode(" ", $stripped_lines);
95
 
96
  $list = preg_replace("/'/", "", $list);
97
- $referrers = preg_split("/[\s,]+/", $list);
 
98
  foreach ($referrers as $referrer){
99
  $newlist[] = "'" . $referrer . "'";
100
  }
@@ -257,11 +261,11 @@ function adinj_adverts_disabled_flag(){
257
  //////////For runtime ads - i.e. when caching is off and config.php not loaded
258
  function adinj_search_engine_referrers(){
259
  $list = adinj_quote_list('ad_referrers');
260
- return preg_split("/[,'\s*]/", $list);
261
  }
262
  function adinj_blocked_ips(){
263
  $list = adinj_quote_list('blocked_ips');
264
- return preg_split("/[,'\s*]/", $list);
265
  }
266
  function adinj_fromasearchengine(){
267
  $referrer = $_SERVER['HTTP_REFERER'];
@@ -346,11 +350,14 @@ function adinj_ads_completely_disabled_from_page($content=NULL){
346
  // no ads on old posts/pages if rule is enabled
347
  if((is_page() || is_single()) && !adinj_is_old_post()) return "NOADS: !is_old_post";
348
 
349
- if ($content == NULL){
350
- return false;
351
- }
 
 
352
 
353
  // manual ad disabling tags
 
354
  if (strpos($content, "<!--noadsense-->") !== false) return "NOADS: noadsense tag"; // 'Adsense Injection' tag
355
  if (strpos($content, "<!-no-adsense-->") !== false) return "NOADS: no-adsense tag"; // 'Whydowork Adsense' tag
356
  if (stripos($content,'<!--NoAds-->') !== false) return "NOADS: NoAds tag"; // 'Quick Adsense' tag
@@ -359,6 +366,60 @@ function adinj_ads_completely_disabled_from_page($content=NULL){
359
  return false;
360
  }
361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  function adinj_inject_hook($content){
363
  if (is_feed()) return $content;
364
 
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.4
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
25
  // Constants
26
  define('ADINJ_RULE_DISABLED', 'Rule Disabled');
27
  define('ADINJ_ALWAYS_SHOW', 'Always show');
28
+ //
29
+ define('ADINJ_ONLY_SHOW_IN', 'Only show in');
30
+ define('ADINJ_NEVER_SHOW_IN', 'Never show in');
31
 
32
  // Global variables
33
  $adinj_total_rand_ads_used = 0;
97
  $list = implode(" ", $stripped_lines);
98
 
99
  $list = preg_replace("/'/", "", $list);
100
+ $referrers = preg_split("/[\s,]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
101
+ if (empty($referrers)) return '';
102
  foreach ($referrers as $referrer){
103
  $newlist[] = "'" . $referrer . "'";
104
  }
261
  //////////For runtime ads - i.e. when caching is off and config.php not loaded
262
  function adinj_search_engine_referrers(){
263
  $list = adinj_quote_list('ad_referrers');
264
+ return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
265
  }
266
  function adinj_blocked_ips(){
267
  $list = adinj_quote_list('blocked_ips');
268
+ return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
269
  }
270
  function adinj_fromasearchengine(){
271
  $referrer = $_SERVER['HTTP_REFERER'];
350
  // no ads on old posts/pages if rule is enabled
351
  if((is_page() || is_single()) && !adinj_is_old_post()) return "NOADS: !is_old_post";
352
 
353
+ $category_ok = adinj_allowed_in_category('global');
354
+ if (!$category_ok) return "NOADS: blocked from category";
355
+
356
+ $tag_ok = adinj_allowed_in_tag('global');
357
+ if (!$tag_ok) return "NOADS: blocked from tag";
358
 
359
  // manual ad disabling tags
360
+ if ($content == NULL) return false;
361
  if (strpos($content, "<!--noadsense-->") !== false) return "NOADS: noadsense tag"; // 'Adsense Injection' tag
362
  if (strpos($content, "<!-no-adsense-->") !== false) return "NOADS: no-adsense tag"; // 'Whydowork Adsense' tag
363
  if (stripos($content,'<!--NoAds-->') !== false) return "NOADS: NoAds tag"; // 'Quick Adsense' tag
366
  return false;
367
  }
368
 
369
+ function adinj_allowed_in_category($scope){
370
+ $ops = adinj_options();
371
+ $cat_list = $ops[$scope.'_category_condition_entries'];
372
+ $cat_array = preg_split("/[\s,]+/", $cat_list, -1, PREG_SPLIT_NO_EMPTY);
373
+ if (empty($cat_array)) return true;
374
+
375
+ $cat_mode = $ops[$scope.'_category_condition_mode'];
376
+ global $post;
377
+ foreach(get_the_category($post->ID) as $allcats) {
378
+ $postcat = $allcats->category_nicename;
379
+ if (in_array($postcat, $cat_array)){
380
+ if ($cat_mode == ADINJ_ONLY_SHOW_IN){
381
+ return true;
382
+ } else if ($cat_mode == ADINJ_NEVER_SHOW_IN){
383
+ return false;
384
+ }
385
+ }
386
+ }
387
+ if ($cat_mode == ADINJ_ONLY_SHOW_IN){
388
+ return false;
389
+ } else if ($cat_mode == ADINJ_NEVER_SHOW_IN){
390
+ return true;
391
+ }
392
+ echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_category-->");
393
+ return true;
394
+ }
395
+
396
+ function adinj_allowed_in_tag($scope){
397
+ $ops = adinj_options();
398
+ $tag_list = $ops[$scope.'_tag_condition_entries'];
399
+ $tag_array = preg_split("/[\s,]+/", $tag_list, -1, PREG_SPLIT_NO_EMPTY);
400
+ if (empty($tag_array)) return true;
401
+
402
+ $tag_mode = $ops[$scope.'_tag_condition_mode'];
403
+ global $post;
404
+ foreach(get_the_tags($post->ID) as $alltags) {
405
+ $posttag = $alltags->slug;
406
+ if (in_array($posttag, $tag_array)){
407
+ if ($tag_mode == ADINJ_ONLY_SHOW_IN){
408
+ return true;
409
+ } else if ($tag_mode == ADINJ_NEVER_SHOW_IN){
410
+ return false;
411
+ }
412
+ }
413
+ }
414
+ if ($tag_mode == ADINJ_ONLY_SHOW_IN){
415
+ return false;
416
+ } else if ($tag_mode == ADINJ_NEVER_SHOW_IN){
417
+ return true;
418
+ }
419
+ echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_tag-->");
420
+ return true;
421
+ }
422
+
423
  function adinj_inject_hook($content){
424
  if (is_feed()) return $content;
425
 
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, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free
5
  Requires at least: 3.0.0
6
  Tested up to: 3.0.3
7
- Stable tag: 0.9.3.4
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
 
@@ -99,6 +99,10 @@ One a basic level it can do the same job as Dax's excellent Adsense Injection. I
99
 
100
  Thanks to Dax by the way for providing the inspiration for this plugin!
101
 
 
 
 
 
102
  = Do I need to have WP Super Cache installed? =
103
 
104
  No! All the features of this plugin will work with no caching plugin installed. But if you do have WP Super Cache the dynamic features (enabling ads based on IP address and referrer) will still work. And your blog will run a lot faster than with no caching plugin. Usually a caching plugin would prevent dynamic plugin features from working. Just make sure you have WP Super Cache configured in 'Legacy' mode and that you choose the option on Ad Injection to say that you are using WP Super Cache.
@@ -193,6 +197,10 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
193
 
194
  == Changelog ==
195
 
 
 
 
 
196
  = 0.9.3.4 =
197
  Clean up old settings restore block.
198
 
@@ -250,6 +258,9 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
250
 
251
  == Upgrade Notice ==
252
 
 
 
 
253
  = 0.9.3.4 =
254
  If you are using mfunc mode and have added ad widgets with a version prior to 0.9.2 please re-save them to regenerate the ad files (fixed for upgrades from 0.9.2).
255
 
4
  Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free
5
  Requires at least: 3.0.0
6
  Tested up to: 3.0.3
7
+ Stable tag: 0.9.4
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
 
99
 
100
  Thanks to Dax by the way for providing the inspiration for this plugin!
101
 
102
+ = Does this plugin 'take' a percentage of my ad earnings? =
103
+
104
+ No! Absolutely not. Some ad plugins replace your publisher ID with their own for a certain percentage of adverts. Ad Injection does NOT do this. All your earnings are your own. Ad Injection makes no modifications to your ad code. What you paste into the ad boxes is what is injected into your pages.
105
+
106
  = Do I need to have WP Super Cache installed? =
107
 
108
  No! All the features of this plugin will work with no caching plugin installed. But if you do have WP Super Cache the dynamic features (enabling ads based on IP address and referrer) will still work. And your blog will run a lot faster than with no caching plugin. Usually a caching plugin would prevent dynamic plugin features from working. Just make sure you have WP Super Cache configured in 'Legacy' mode and that you choose the option on Ad Injection to say that you are using WP Super Cache.
197
 
198
  == Changelog ==
199
 
200
+ = 0.9.4 =
201
+ Global tag and category restrictions.
202
+ Smoother JQuery show/hide blocks (especially on IE)
203
+
204
  = 0.9.3.4 =
205
  Clean up old settings restore block.
206
 
258
 
259
  == Upgrade Notice ==
260
 
261
+ = 0.9.4 =
262
+ If you are using mfunc mode and have added ad widgets with a version prior to 0.9.2 please re-save them to regenerate the ad files (fixed for upgrades from 0.9.2).
263
+
264
  = 0.9.3.4 =
265
  If you are using mfunc mode and have added ad widgets with a version prior to 0.9.2 please re-save them to regenerate the ad files (fixed for upgrades from 0.9.2).
266