Ad Injection - Version 0.9.6.6

Version Description

  • Widgets can be conditionally included on pages by category, tag, and author.
  • Widget ad pool size increased to 10.
  • Fix for using just bottom ad in mfunc mode.
  • Less JavaScript on admin pages.
  • Global author exclude option.
Download this release

Release Info

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

Code changes from version 0.9.6.5 to 0.9.6.6

ad-injection-admin.php CHANGED
@@ -204,7 +204,35 @@ function adinj_chmod($path, $permission){
204
  function adinj_get_logo(){
205
  return '<a href="http://www.reviewmylife.co.uk/" target="_new"><img src="'. WP_PLUGIN_URL . '/ad-injection/rml-micro-logo.png" width="16" height="16" border="0" alt="reviewmylife" /></a>';
206
  }
207
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  function adinj_options_page(){
209
  if (isset($_POST['adinj_action'])){
210
  adinj_save_options();
@@ -292,7 +320,7 @@ function adinj_top_message_box(){
292
 
293
  } else {
294
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
295
- echo "4th February 2011: There is a new content length counting method - you can now restrict ads by number of 'words'. The option is in the global settings. Also fixes for UTF-8 characters and search/404 restriction options. Plus ad pool size for top/random/bottom increased to 10. 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>.';
296
  echo '</strong></p></div>';
297
  }
298
  }
@@ -368,6 +396,7 @@ function adinj_admin_tabs( $current = 0 ) {
368
  echo '</h2></div>';
369
  }
370
 
 
371
  function adinj_postbox_start($title, $anchor, $width='650px'){
372
  $ops = adinj_options();
373
  ?>
@@ -391,7 +420,7 @@ echo <<<HTML
391
  function $anchorclick(){
392
  jQuery('#$anchorhide').val(!jQuery('.$anchor-box').is(":hidden"));
393
  $anchorupdate();
394
- jQuery('.$anchor-box').slideToggle(1000);
395
  return false;
396
  }
397
 
@@ -610,63 +639,94 @@ function adinj_selection_box($name, $values, $type="", $selected_value=NULL){
610
  echo "</select>";
611
  }
612
 
613
- function adinj_condition_table($name, $description, $type){
614
- $options = adinj_options();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
  ?>
616
  <table border="0">
617
  <tr><td>
618
 
619
- <textarea name="<?php echo $name; ?>_condition_entries" rows="2" cols="40"><?php echo $options[$name.'_condition_entries']; ?></textarea>
620
 
621
  </td><td style="vertical-align:top">
622
 
623
  <?php
624
- adinj_selection_box($name."_condition_mode",
625
- array('Only show in', 'Never show in'));
626
  ?>
627
 
628
  <br />
629
-
630
- <?php if ($type == 'category') { ?>
631
- <select name="<?php echo $name; ?>_dropdown" onchange='adinj_addtext(<?php echo $name; ?>_condition_entries, this.options[this.selectedIndex].value);'>
632
  <option value=""><?php echo 'Add ' . $type; ?></option>
633
- <?php
 
 
634
  $categories = get_categories();
635
- foreach ($categories as $category) {
636
- $cat = rawurldecode($category->category_nicename);
637
- $option = '<option value="'.$cat.'">';
638
- $option .= $cat;
639
- $option .= ' ('.$category->category_count.')';
640
- $option .= '</option>';
641
- echo $option;
642
  }
643
- ?>
644
- </select>
645
- <NOSCRIPT><br /><span style="font-size:10px">As JavaScript is disabled you will have to manually type in the values.</span></NOSCRIPT>
646
-
647
- <?php } else if ($type == 'tag') { ?>
648
-
649
- <select name="<?php echo $name; ?>_dropdown" onchange='adinj_addtext(document.adinjform.<?php echo $name; ?>_condition_entries, this.options[this.selectedIndex].value);'>
650
-
651
- <option value=""><?php echo 'Add ' . $type; ?></option>
652
- <?php
653
  $tags = get_tags();
654
  foreach ($tags as $tag) {
655
- $tagname = rawurldecode($tag->slug);
656
- $option = '<option value="'.$tagname.'">';
657
- $option .= $tagname;
658
- $option .= ' ('.$tag->count.')';
659
- $option .= '</option>';
660
- echo $option;
661
  }
662
- ?>
 
 
 
 
 
 
 
 
 
 
663
  </select>
664
  <NOSCRIPT><br /><span style="font-size:10px">As JavaScript is disabled you will have to manually type in the values.</span></NOSCRIPT>
665
 
666
- <?php } else {
667
- echo 'Type not defined: ' . $type;
668
- }?>
669
-
670
  </td></tr>
671
  <tr><td colspan="2">
672
  <span style="font-size:10px;">Comma separated list of <?php echo $description; ?></span>
@@ -675,6 +735,13 @@ function adinj_condition_table($name, $description, $type){
675
  <?php
676
  }
677
 
 
 
 
 
 
 
 
678
  function adinj_add_alignment_options($prefix){
679
  _e("Alignment", 'adinj');
680
  echo "<br />";
@@ -948,6 +1015,8 @@ function adinj_default_options(){
948
  'global_category_condition_entries' => '',
949
  'global_tag_condition_mode' => ADINJ_ONLY_SHOW_IN,
950
  'global_tag_condition_entries' => '',
 
 
951
  'content_length_unit' => 'words',
952
  // Random ads
953
  'ad_code_random_1' => '',
@@ -1092,6 +1161,8 @@ function adinj_default_options(){
1092
  'ui_debugging_hide' => 'true',
1093
  'ui_docs_hide' => 'false',
1094
  'ui_testads_hide' => 'false',
 
 
1095
  // ui ad rotation tab
1096
  'ui_multiple_random_hide' => 'false',
1097
  'ui_multiple_top_hide' => 'false',
204
  function adinj_get_logo(){
205
  return '<a href="http://www.reviewmylife.co.uk/" target="_new"><img src="'. WP_PLUGIN_URL . '/ad-injection/rml-micro-logo.png" width="16" height="16" border="0" alt="reviewmylife" /></a>';
206
  }
207
+
208
+ // only for Ad Injection admin pages
209
+ function adinj_admin_print_scripts_main(){
210
+ adinj_admin_print_scripts_widgets();
211
+ }
212
+
213
+ // only for widgets.php
214
+ function adinj_admin_print_scripts_widgets(){
215
+ echo "<!--start of Ad Injection scripts-->";
216
+ adinj_javascript_addtext();
217
+ echo <<<HTML
218
+ <script type="text/javascript">
219
+ function adinj_toggle_click(show_setting_id, toggle_button_id, toggle_box_id){
220
+ jQuery('#'+show_setting_id).val(jQuery('#'+toggle_box_id).is(":hidden"));
221
+ adinj_button_update(show_setting_id, toggle_button_id);
222
+ jQuery('#'+toggle_box_id).slideToggle(300);
223
+ }
224
+ function adinj_button_update(show_setting_id, toggle_button_id){
225
+ if (jQuery('#'+show_setting_id).val() == 'true'){
226
+ jQuery('#'+toggle_button_id).text('-');
227
+ } else {
228
+ jQuery('#'+toggle_button_id).text('+');
229
+ }
230
+ }
231
+ </script>
232
+ <!--end of Ad Injection scripts-->
233
+ HTML;
234
+ }
235
+
236
  function adinj_options_page(){
237
  if (isset($_POST['adinj_action'])){
238
  adinj_save_options();
320
 
321
  } else {
322
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
323
+ echo "11th February 2011: New category, tag and author restriction for widgets. This means you can configure different widgets for different page types. Widget ad pool increased to 10. New author restriction for global settings. Plus other bug fixes and UI tweaks. 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>.';
324
  echo '</strong></p></div>';
325
  }
326
  }
396
  echo '</h2></div>';
397
  }
398
 
399
+ // TODO replace with new Javascript
400
  function adinj_postbox_start($title, $anchor, $width='650px'){
401
  $ops = adinj_options();
402
  ?>
420
  function $anchorclick(){
421
  jQuery('#$anchorhide').val(!jQuery('.$anchor-box').is(":hidden"));
422
  $anchorupdate();
423
+ jQuery('.$anchor-box').slideToggle(300);
424
  return false;
425
  }
426
 
639
  echo "</select>";
640
  }
641
 
642
+ function adinj_javascript_addtext(){
643
+ ?>
644
+ <script type="text/javascript">
645
+ function adinj_addtext(element, value) {
646
+ if (value.length == 0) return;
647
+ separator = ', ';
648
+ if (element.value.length == 0){
649
+ separator = '';
650
+ }
651
+ element.value += (separator + value);
652
+ }
653
+ </script>
654
+ <?php
655
+ }
656
+
657
+ // TODO replace previous show/hide code with this
658
+ function adinj_add_show_hide_section($anchor, $show_op, $show_field_name, $ops){
659
+ $show_setting_id = $anchor.'_show';
660
+ $show_value = $ops[$show_op];
661
+
662
+ echo <<<HTML
663
+ <input type='hidden' id="$show_setting_id" name="$show_field_name" value='$show_value' />
664
+ <a href='#' onclick="javascript:adinj_toggle_click('$show_setting_id', '$anchor-button', '$anchor-box');return false;" style='float:left;display:none;width:10px;' id='$anchor-button' class='button'>+/-</a>
665
+ <br clear="all" />
666
+
667
+ <script type="text/javascript">
668
+ jQuery(document).ready(function(){
669
+ adinj_button_update('$show_setting_id', '$anchor-button');
670
+ jQuery('a#$anchor-button').show();
671
+ if ('$show_value' == 'false') jQuery('#$anchor-box').hide();
672
+ });
673
+ </script>
674
+
675
+ <div id="$anchor-box">
676
+ HTML;
677
+ }
678
+
679
+ function adinj_condition_table($name, $description, $type, $ops, $dropdown_fieldname=NULL, $textarea_fieldname=NULL){
680
+ if ($dropdown_fieldname == NULL){
681
+ $dropdown_fieldname = $name."_condition_mode";
682
+ }
683
+ if ($textarea_fieldname == NULL){
684
+ $textarea_fieldname = $name."_condition_entries";
685
+ }
686
  ?>
687
  <table border="0">
688
  <tr><td>
689
 
690
+ <textarea name="<?php echo $textarea_fieldname; ?>" rows="2" cols="40"><?php echo $ops[$name.'_condition_entries']; ?></textarea>
691
 
692
  </td><td style="vertical-align:top">
693
 
694
  <?php
695
+ adinj_selection_box($dropdown_fieldname,
696
+ array('Only show in', 'Never show in'), "", $ops[$name.'_condition_mode']);
697
  ?>
698
 
699
  <br />
700
+ <select name="<?php echo $name; ?>_dropdown" onchange='adinj_addtext(getElementsByName("<?php echo $textarea_fieldname; ?>")[0], this.options[this.selectedIndex].value);'>
 
 
701
  <option value=""><?php echo 'Add ' . $type; ?></option>
702
+
703
+ <?php
704
+ if ($type == 'category') {
705
  $categories = get_categories();
706
+ foreach ($categories as $cat) {
707
+ $nicename = rawurldecode($cat->category_nicename);
708
+ echo '<option value="'.$nicename.'">'.$nicename.' ('.$cat->category_count.')</option>';
 
 
 
 
709
  }
710
+ } else if ($type == 'tag') {
 
 
 
 
 
 
 
 
 
711
  $tags = get_tags();
712
  foreach ($tags as $tag) {
713
+ $slug = rawurldecode($tag->slug);
714
+ echo '<option value="'.$slug.'">'.$slug.' ('.$tag->count.')</option>';
 
 
 
 
715
  }
716
+ } else if ($type == 'author') {
717
+ $authors = adinj_get_authors();
718
+ foreach ($authors as $author) {
719
+ $login = $author->user_login;
720
+ $displayname = $author->display_name;
721
+ echo '<option value="'.$login.'">'.$login.' ('.$displayname.')</option>';
722
+ }
723
+ } else {
724
+ echo 'ADINJ DEBUG Type not defined: ' . $type;
725
+ }?>
726
+
727
  </select>
728
  <NOSCRIPT><br /><span style="font-size:10px">As JavaScript is disabled you will have to manually type in the values.</span></NOSCRIPT>
729
 
 
 
 
 
730
  </td></tr>
731
  <tr><td colspan="2">
732
  <span style="font-size:10px;">Comma separated list of <?php echo $description; ?></span>
735
  <?php
736
  }
737
 
738
+ // TODO Currently gets all users
739
+ function adinj_get_authors(){
740
+ global $wpdb;
741
+ $authors = $wpdb->get_results( "SELECT user_login, display_name from $wpdb->users" );
742
+ return $authors;
743
+ }
744
+
745
  function adinj_add_alignment_options($prefix){
746
  _e("Alignment", 'adinj');
747
  echo "<br />";
1015
  'global_category_condition_entries' => '',
1016
  'global_tag_condition_mode' => ADINJ_ONLY_SHOW_IN,
1017
  'global_tag_condition_entries' => '',
1018
+ 'global_author_condition_mode' => ADINJ_ONLY_SHOW_IN,
1019
+ 'global_author_condition_entries' => '',
1020
  'content_length_unit' => 'words',
1021
  // Random ads
1022
  'ad_code_random_1' => '',
1161
  'ui_debugging_hide' => 'true',
1162
  'ui_docs_hide' => 'false',
1163
  'ui_testads_hide' => 'false',
1164
+ //
1165
+ 'ui_conditions_show' => 'false',
1166
  // ui ad rotation tab
1167
  'ui_multiple_random_hide' => 'false',
1168
  'ui_multiple_top_hide' => 'false',
ad-injection-widget.php CHANGED
@@ -7,12 +7,14 @@ http://www.reviewmylife.co.uk/
7
  // 1 = original
8
  // 2 = split testing / alt content
9
  // 3 = increase db rotation slots to 10 - no UI support yet
10
- define('ADINJ_WIDGET_DB_VERSION', 3);
 
 
11
 
12
  class Ad_Injection_Widget extends WP_Widget {
13
  function Ad_Injection_Widget() {
14
  $widget_ops = array( 'classname' => 'adinjwidget', 'description' => 'Insert Ad Injection adverts into your sidebars/widget areas.' );
15
- $control_ops = array( 'width' => 450, 'height' => 300, 'id_base' => 'adinj' );
16
  $this->WP_Widget( 'adinj', 'Ad Injection', $widget_ops, $control_ops );
17
  }
18
 
@@ -29,6 +31,10 @@ class Ad_Injection_Widget extends WP_Widget {
29
  return;
30
  }
31
 
 
 
 
 
32
  extract( $args );
33
 
34
  $ops = adinj_options();
@@ -64,12 +70,16 @@ class Ad_Injection_Widget extends WP_Widget {
64
 
65
  // Only strip tags when potential for updated title
66
  $updated['title'] = strip_tags( $new_instance['title'] );
 
 
 
67
 
68
- write_ad_to_file($updated['advert_1'], $this->get_ad_file_path(1));
69
- write_ad_to_file($updated['advert_2'], $this->get_ad_file_path(2));
70
- write_ad_to_file($updated['advert_3'], $this->get_ad_file_path(3));
71
- write_ad_to_file($updated['advert_alt_1'], $this->get_alt_file_path(1));
72
- write_ad_to_file($updated['advert_alt_2'], $this->get_alt_file_path(2));
 
73
 
74
  return $updated;
75
  }
@@ -103,17 +113,38 @@ class Ad_Injection_Widget extends WP_Widget {
103
  'advert_alt_1_split' => '100',
104
  'advert_alt_2' => '',
105
  'advert_alt_2_split' => '100',
 
 
106
  //settings
107
  'margin_top' => ADINJ_DISABLED,
108
  'margin_bottom' => ADINJ_DISABLED,
109
  'padding_top' => ADINJ_DISABLED,
110
  'padding_bottom' => ADINJ_DISABLED,
 
 
 
 
 
 
111
  //ui
112
  'ui_ad_1_show' => 'true',
 
 
 
113
  'ui_ad_2_show' => 'false',
114
  'ui_ad_3_show' => 'false',
 
 
 
 
 
 
 
 
115
  'ui_alt_1_show' => 'false',
116
  'ui_alt_2_show' => 'false',
 
 
117
  //
118
  'db_version' => ADINJ_WIDGET_DB_VERSION
119
  );
@@ -141,47 +172,87 @@ class Ad_Injection_Widget extends WP_Widget {
141
 
142
  function form( $instance ) {
143
  $instance = $this->adinj_upgrade_widget_db($instance, $instance);
144
-
145
- $total_ad_split = adinj_total_split('advert_', $instance);
146
- $total_alt_split = adinj_total_split('advert_alt_', $instance);
147
-
148
  ?>
149
 
150
- <input type='hidden' <?php $this->add_id_and_name('db_version'); ?> value='<?php echo $defaults['db_version']; ?>' />
 
151
 
152
  <p>
153
- <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
154
- <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
155
  <br />
156
- <span style="font-size:10px;">Make sure any label complies with your ad provider's TOS. More info for <a href="http://adsense.blogspot.com/2007/04/encouraging-clicks.html" target="_new">AdSense</a> users.</span>
157
  </p>
158
 
159
  <style type="text/css">
160
  .adinjtable td { vertical-align: top; }
161
  </style>
162
 
163
- <table border="0" cellspacing="5" width="100% "class="adinjtable">
164
  <?php
 
165
  $this->add_row('advert_', 1, 'Ad code 1', 'ui_ad_1_show', $total_ad_split, $instance);
166
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  <tr><td>
168
  <?php adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom') ); ?>
169
  </td><td>
170
  <?php adinj_add_padding_top_bottom_options('widget_', $instance, $this->get_field_name('padding_top'), $this->get_field_name('padding_bottom') ); ?>
171
  </td></tr>
 
 
172
 
 
 
 
 
173
  <?php
174
- $this->add_row('advert_', 2, 'Ad code 2', 'ui_ad_2_show', $total_ad_split, $instance);
175
- $this->add_row('advert_', 3, 'Ad code 3', 'ui_ad_3_show', $total_ad_split, $instance);
176
- $this->add_row('advert_alt_', 1, 'Alt content 1', 'ui_alt_1_show', $total_alt_split, $instance);
177
- $this->add_row('advert_alt_', 2, 'Alt content 2', 'ui_alt_2_show', $total_alt_split, $instance);
178
  ?>
 
179
 
180
- </table>
 
 
 
 
 
 
 
 
 
 
181
 
182
- <p>Other options to define who sees these adverts (by page age, IP, referrer) are on the main <a href='options-general.php?page=ad-injection.php'>Ad Injection settings page</a>. The title will however always be displayed. If you want the title to be dynamic as well you should embed it in the ad code text box.</p>
183
 
184
- <p>You can also set which <a href='options-general.php?page=ad-injection.php#widgets'>page types</a> the widgets appear on.</p>
185
 
186
  <?php
187
  }
@@ -189,39 +260,20 @@ class Ad_Injection_Widget extends WP_Widget {
189
  function add_row($op_stem, $num, $label, $show_op, $total_split, $ops){
190
  $op = $op_stem.$num;
191
  $op_split = $op.'_split';
192
- $anchorid = $op_stem.uniqid().'_'.$num;
193
- $anchorclick = $anchorid.'_click';
194
- $show = $ops[$show_op];
195
- $hiddenfieldid = $this->get_field_id($show_op);
196
  $percentage_split = adinj_percentage_split($op_stem, $num, $ops, $total_split);
197
  ?>
198
  <tr><td colspan='2'>
199
- <textarea style="float:right" <?php $this->add_id_and_name($op_split); ?> rows="1" cols="4"><?php echo $ops[$op_split]; ?></textarea>
200
 
201
  <?php
202
  echo <<<HTML
203
- <a href='#' onclick='javascript:$anchorclick();return false;' style='float:left;display:none' id='toggle-$anchorid' class='button'>+/-</a>
204
-
205
- <label><b> $label</b></label> <label style='float:right'>(Rotation: $percentage_split)</label>
206
-
207
- <script type="text/javascript">
208
- jQuery(document).ready(function(){
209
- jQuery('a#toggle-$anchorid').show();
210
- if ('$show' == 'false') jQuery('.$anchorid-box').hide();
211
- });
212
- function $anchorclick(){
213
- jQuery('#$hiddenfieldid').val(jQuery('.$anchorid-box').is(":hidden"));
214
- jQuery('.$anchorid-box').slideToggle(1000);
215
- }
216
- </script>
217
-
218
- </td></tr>
219
- <tr><td colspan='2'>
220
-
221
- <div id="$anchorid-box" class="$anchorid-box">
222
 
223
  HTML;
224
-
 
225
  if ($op_stem == 'advert_' && $num == 2){
226
  echo '<span style="font-size:10px;">These boxes are for defining rotated adverts which replace the original advert according to the percentages defined. If you want multiple sidebar/widget ads you need to drag another widget into the sidebar.</span><br />';
227
  }
@@ -230,13 +282,22 @@ HTML;
230
  }
231
 
232
  ?>
233
- <input type='hidden' <?php $this->add_id_and_name($show_op); ?> value='<?php echo $ops[$show_op]; ?>' />
234
- <textarea class="widefat" rows="8" cols="50" width="100%" <?php $this->add_id_and_name($op); ?>><?php echo $ops[$op]; ?></textarea>
235
- </div>
236
  </td></tr>
237
  <?php
238
  }
239
 
 
 
 
 
 
 
 
 
 
240
  function add_id_and_name($op){
241
  echo 'id="'.$this->get_field_id($op).'" name="'.$this->get_field_name($op).'"';
242
  }
@@ -258,7 +319,6 @@ HTML;
258
  }
259
 
260
  function get_id(){
261
- //return $widget_id;
262
  $field = $this->get_field_id('advert_1');
263
  preg_match('/-(\d+)-/', $field, $matches);
264
  return $matches[1];
7
  // 1 = original
8
  // 2 = split testing / alt content
9
  // 3 = increase db rotation slots to 10 - no UI support yet
10
+ // 4 = added ui show fields for ads 4-10. Category/tag/author conditions.
11
+ // 5 = ad/alt pool show fields
12
+ define('ADINJ_WIDGET_DB_VERSION', 5);
13
 
14
  class Ad_Injection_Widget extends WP_Widget {
15
  function Ad_Injection_Widget() {
16
  $widget_ops = array( 'classname' => 'adinjwidget', 'description' => 'Insert Ad Injection adverts into your sidebars/widget areas.' );
17
+ $control_ops = array( 'width' => 500, 'height' => 300, 'id_base' => 'adinj' );
18
  $this->WP_Widget( 'adinj', 'Ad Injection', $widget_ops, $control_ops );
19
  }
20
 
31
  return;
32
  }
33
 
34
+ if (!adinj_allowed_in_category('widget', $instance)) return;
35
+ if (!adinj_allowed_in_tag('widget', $instance)) return;
36
+ if (!adinj_allowed_in_author('widget', $instance)) return;
37
+
38
  extract( $args );
39
 
40
  $ops = adinj_options();
70
 
71
  // Only strip tags when potential for updated title
72
  $updated['title'] = strip_tags( $new_instance['title'] );
73
+
74
+ // After first save mark it as saved
75
+ $updated['saved'] = 1;
76
 
77
+ for ($i=1; $i<=10; ++$i){
78
+ write_ad_to_file($updated['advert_'.$i], $this->get_ad_file_path($i));
79
+ }
80
+ for ($i=1; $i<=3; ++$i){
81
+ write_ad_to_file($updated['advert_alt_'.$i], $this->get_alt_file_path($i));
82
+ }
83
 
84
  return $updated;
85
  }
113
  'advert_alt_1_split' => '100',
114
  'advert_alt_2' => '',
115
  'advert_alt_2_split' => '100',
116
+ 'advert_alt_3' => '',
117
+ 'advert_alt_3_split' => '100',
118
  //settings
119
  'margin_top' => ADINJ_DISABLED,
120
  'margin_bottom' => ADINJ_DISABLED,
121
  'padding_top' => ADINJ_DISABLED,
122
  'padding_bottom' => ADINJ_DISABLED,
123
+ 'widget_category_condition_mode' => ADINJ_ONLY_SHOW_IN,
124
+ 'widget_category_condition_entries' => '',
125
+ 'widget_tag_condition_mode' => ADINJ_ONLY_SHOW_IN,
126
+ 'widget_tag_condition_entries' => '',
127
+ 'widget_author_condition_mode' => ADINJ_ONLY_SHOW_IN,
128
+ 'widget_author_condition_entries' => '',
129
  //ui
130
  'ui_ad_1_show' => 'true',
131
+ 'ui_conditions_show' => 'false',
132
+ 'ui_spacing_show' => 'false',
133
+ 'ui_ad_pool_show' => 'false',
134
  'ui_ad_2_show' => 'false',
135
  'ui_ad_3_show' => 'false',
136
+ 'ui_ad_4_show' => 'false',
137
+ 'ui_ad_5_show' => 'false',
138
+ 'ui_ad_6_show' => 'false',
139
+ 'ui_ad_7_show' => 'false',
140
+ 'ui_ad_8_show' => 'false',
141
+ 'ui_ad_9_show' => 'false',
142
+ 'ui_ad_10_show' => 'false',
143
+ 'ui_alt_pool_show' => 'false',
144
  'ui_alt_1_show' => 'false',
145
  'ui_alt_2_show' => 'false',
146
+ 'ui_alt_3_show' => 'false',
147
+ 'saved' => 0,
148
  //
149
  'db_version' => ADINJ_WIDGET_DB_VERSION
150
  );
172
 
173
  function form( $instance ) {
174
  $instance = $this->adinj_upgrade_widget_db($instance, $instance);
175
+
176
+ $savedfieldname = $this->get_field_name('saved');
177
+ $savedfieldvalue = $instance['saved'];
 
178
  ?>
179
 
180
+ <input type='hidden' <?php $this->add_name('db_version'); ?> value='<?php echo $defaults['db_version']; ?>' />
181
+ <input type='hidden' name="$savedfieldname" value='$savedfieldvalue' />
182
 
183
  <p>
184
+ <b>Title:</b><br />
185
+ <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:490px;" />
186
  <br />
187
+ <span style="font-size:10px;">Make sure any title complies with your ad provider's TOS. More info for <a href="http://adsense.blogspot.com/2007/04/encouraging-clicks.html" target="_new">AdSense</a> users.</span>
188
  </p>
189
 
190
  <style type="text/css">
191
  .adinjtable td { vertical-align: top; }
192
  </style>
193
 
194
+ <table border="0" width="490px" class="adinjtable">
195
  <?php
196
+ $total_ad_split = adinj_total_split('advert_', $instance);
197
  $this->add_row('advert_', 1, 'Ad code 1', 'ui_ad_1_show', $total_ad_split, $instance);
198
  ?>
199
+ </table>
200
+
201
+ <?php
202
+ if ($savedfieldvalue != 1){
203
+ echo '<b>The widget needs to be saved for first time to activate the other options.</b>';
204
+ return;
205
+ }
206
+ ?>
207
+
208
+ <br />
209
+ <b> Category, tag and author conditions</b>
210
+ <?php
211
+ $this->add_show_hide_section('ad_restrictions_'.uniqid(), 'ui_conditions_show', $instance);
212
+ adinj_condition_table('widget_category', 'category slugs. e.g: cat1, cat2, cat3', 'category', $instance, $this->get_field_name('widget_category_condition_mode'), $this->get_field_name('widget_category_condition_entries'));
213
+ adinj_condition_table('widget_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag', $instance, $this->get_field_name('widget_tag_condition_mode'), $this->get_field_name('widget_tag_condition_entries'));
214
+ adinj_condition_table('widget_author', 'author nicknames. e.g: john, paul', 'author', $instance, $this->get_field_name('widget_author_condition_mode'), $this->get_field_name('widget_author_condition_entries'));
215
+ echo '</div>'
216
+ ?>
217
+
218
+ <br />
219
+ <b> Spacing options</b>
220
+ <?php $this->add_show_hide_section('ad_spacing_'.uniqid(), 'ui_spacing_show', $instance); ?>
221
+ <table border="0" width="490px" class="adinjtable">
222
  <tr><td>
223
  <?php adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom') ); ?>
224
  </td><td>
225
  <?php adinj_add_padding_top_bottom_options('widget_', $instance, $this->get_field_name('padding_top'), $this->get_field_name('padding_bottom') ); ?>
226
  </td></tr>
227
+ </table>
228
+ </div>
229
 
230
+ <br />
231
+ <b> Ad rotation pool</b>
232
+ <?php $this->add_show_hide_section('ad_pool_'.uniqid(), 'ui_ad_pool_show', $instance); ?>
233
+ <table border="0" width="490px" class="adinjtable">
234
  <?php
235
+ for ($i=2; $i<=10; ++$i){
236
+ $this->add_row('advert_', $i, 'Ad code '.$i, 'ui_ad_'.$i.'_show', $total_ad_split, $instance);
237
+ }
 
238
  ?>
239
+ </table></div>
240
 
241
+ <br />
242
+ <b> Alt content pool</b>
243
+ <?php $this->add_show_hide_section('alt_pool_'.uniqid(), 'ui_alt_pool_show', $instance); ?>
244
+ <table border="0" cellspacing="5" width="490px" class="adinjtable">
245
+ <?php
246
+ $total_alt_split = adinj_total_split('advert_alt_', $instance);
247
+ for ($i=1; $i<=3; ++$i){
248
+ $this->add_row('advert_alt_', $i, 'Alt content '.$i, 'ui_alt_'.$i.'_show', $total_alt_split, $instance);
249
+ }
250
+ ?>
251
+ </table></div>
252
 
253
+ <br />
254
 
255
+ <p>Other options to define who sees these adverts (by page age, IP, referrer) are on the main <a href='options-general.php?page=ad-injection.php'>Ad Injection settings page</a>. You can also set which <a href='options-general.php?page=ad-injection.php#widgets'>page types</a> the widgets appear on.</p>
256
 
257
  <?php
258
  }
260
  function add_row($op_stem, $num, $label, $show_op, $total_split, $ops){
261
  $op = $op_stem.$num;
262
  $op_split = $op.'_split';
263
+ $anchorid = $op.'_'.uniqid();
264
+
 
 
265
  $percentage_split = adinj_percentage_split($op_stem, $num, $ops, $total_split);
266
  ?>
267
  <tr><td colspan='2'>
268
+ <input style="float:right; padding:0; margin:0;" <?php $this->add_name($op_split); ?> size="7" value="<?php echo $ops[$op_split]; ?>" />
269
 
270
  <?php
271
  echo <<<HTML
272
+ <b> $label</b> <label style='float:right'>(Rotation: $percentage_split)</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
  HTML;
275
+ $this->add_show_hide_section($anchorid, $show_op, $ops);
276
+
277
  if ($op_stem == 'advert_' && $num == 2){
278
  echo '<span style="font-size:10px;">These boxes are for defining rotated adverts which replace the original advert according to the percentages defined. If you want multiple sidebar/widget ads you need to drag another widget into the sidebar.</span><br />';
279
  }
282
  }
283
 
284
  ?>
285
+
286
+ <textarea class="widefat" rows="8" cols="50" width="100%" <?php $this->add_name($op); ?>><?php echo $ops[$op]; ?></textarea>
287
+ </div><!--add_show_hide_section-->
288
  </td></tr>
289
  <?php
290
  }
291
 
292
+ function add_show_hide_section($anchor, $show_op, $ops){
293
+ $show_field_name = $this->get_field_name($show_op);
294
+ adinj_add_show_hide_section($anchor, $show_op, $show_field_name, $ops);
295
+ }
296
+
297
+ function add_name($op){
298
+ echo 'id="'.$this->get_field_id($op).'" name="'.$this->get_field_name($op).'"';
299
+ }
300
+
301
  function add_id_and_name($op){
302
  echo 'id="'.$this->get_field_id($op).'" name="'.$this->get_field_name($op).'"';
303
  }
319
  }
320
 
321
  function get_id(){
 
322
  $field = $this->get_field_id('advert_1');
323
  preg_match('/-(\d+)-/', $field, $matches);
324
  return $matches[1];
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.6.5
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -49,7 +49,10 @@ if (is_admin()){
49
  }
50
 
51
  function adinj_admin_menu_hook(){
52
- add_options_page('Ad Injection', 'Ad Injection', 'manage_options', basename(__FILE__), 'adinj_options_page');
 
 
 
53
  }
54
 
55
  function adinj_options_link_hook($links, $file) {
@@ -439,9 +442,12 @@ function adinj_ads_completely_disabled_from_page($content=NULL){
439
  $category_ok = adinj_allowed_in_category('global', $ops);
440
  if (!$category_ok) return "NOADS: blocked from category";
441
 
442
- $tag_ok = adinj_allowed_in_tag('global', $ops);
443
  if (!$tag_ok) return "NOADS: blocked from tag";
444
 
 
 
 
445
  // manual ad disabling tags
446
  if ($content == NULL) return false;
447
  if (strpos($content, "<!--noadsense-->") !== false) return "NOADS: noadsense tag"; // 'Adsense Injection' tag
@@ -452,19 +458,12 @@ function adinj_ads_completely_disabled_from_page($content=NULL){
452
  return false;
453
  }
454
 
455
- function adinj_allowed_in_category($scope, $ops){
456
- $cat_list = $ops[$scope.'_category_condition_entries'];
457
- $cat_array = preg_split("/[\s,]+/", $cat_list, -1, PREG_SPLIT_NO_EMPTY);
458
- if (empty($cat_array)) return true;
459
-
460
- $cat_mode = $ops[$scope.'_category_condition_mode'];
461
- global $post;
462
- $postcategories = get_the_category($post->ID);
463
- if (is_array($postcategories)){
464
- foreach($postcategories as $cat) {
465
- $slug = $cat->category_nicename;
466
- $decodedslug = rawurldecode($slug); //allow UTF-8 encoded cats
467
- if (in_array($slug, $cat_array) || in_array($decodedslug, $cat_array)){
468
  if ($cat_mode == ADINJ_ONLY_SHOW_IN){
469
  return true;
470
  } else if ($cat_mode == ADINJ_NEVER_SHOW_IN){
@@ -478,38 +477,44 @@ function adinj_allowed_in_category($scope, $ops){
478
  } else if ($cat_mode == ADINJ_NEVER_SHOW_IN){
479
  return true;
480
  }
481
- echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_category-->");
482
  return true;
483
  }
484
 
 
 
 
 
 
 
 
 
 
485
  function adinj_allowed_in_tag($scope, $ops){
486
- $tag_list = $ops[$scope.'_tag_condition_entries'];
487
- $tag_array = preg_split("/[\s,]+/", $tag_list, -1, PREG_SPLIT_NO_EMPTY);
488
- if (empty($tag_array)) return true;
489
-
490
- $tag_mode = $ops[$scope.'_tag_condition_mode'];
491
  global $post;
492
- $posttags = get_the_tags($post->ID);
493
- if (is_array($posttags)){
494
- foreach($posttags as $tag) {
495
- $slug = $tag->slug;
496
- $decodedslug = rawurldecode($slug); //allow UTF-8 encoded tags
497
- if (in_array($slug, $tag_array) || in_array($decodedslug, $tag_array)){
498
- if ($tag_mode == ADINJ_ONLY_SHOW_IN){
499
- return true;
500
- } else if ($tag_mode == ADINJ_NEVER_SHOW_IN){
501
- return false;
502
- }
503
- }
504
- }
505
- }
506
- if ($tag_mode == ADINJ_ONLY_SHOW_IN){
507
- return false;
508
- } else if ($tag_mode == ADINJ_NEVER_SHOW_IN){
509
- return true;
510
- }
511
- echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_tag-->");
512
- return true;
513
  }
514
 
515
  function adinj_inject_hook($content){
@@ -551,13 +556,13 @@ function adinj_inject_hook($content){
551
  $length = 0;
552
  if ($ops['content_length_unit'] == 'all'){
553
  $length = strlen($content);
554
- if ($debug_on) $debug .= "\nlength = $length (including HTML chars)";
555
  } else if ($ops['content_length_unit'] == 'viewable'){
556
  $length = strlen(strip_tags($content));
557
- if ($debug_on) $debug .= "\nlength = $length (viewable chars only)";
558
  } else {
559
  $length = str_word_count(strip_tags($content));
560
- if ($debug_on) $debug .= "\nlength = $length (number of words)";
561
  }
562
  # Insert top and bottom ads if necesary
563
  if(is_page() || is_single()){
@@ -569,14 +574,13 @@ function adinj_inject_hook($content){
569
  $content = $content.adinj_ad_code_bottom();
570
  }
571
  }
 
572
 
573
  $num_rand_ads_to_insert = adinj_num_rand_ads_to_insert($length);
574
  if ($num_rand_ads_to_insert <= 0) return adinj($content, "all ads used up");
575
  $ad = adinj_ad_code_random();
576
  if (empty($ad)) return adinj($content, "no random ad defined");
577
 
578
- if ($ad_include !== false) $content = $ad_include.$content;
579
-
580
  if (!$debug_on) $debugtags=false;
581
 
582
  $content_adfree_header = "";
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.6.6
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
49
  }
50
 
51
  function adinj_admin_menu_hook(){
52
+ $options_page = add_options_page('Ad Injection', 'Ad Injection', 'manage_options', basename(__FILE__), 'adinj_options_page');
53
+ add_action("admin_print_scripts-".$options_page, "adinj_admin_print_scripts_main");
54
+ add_action("admin_print_scripts-widgets.php", "adinj_admin_print_scripts_widgets");
55
+
56
  }
57
 
58
  function adinj_options_link_hook($links, $file) {
442
  $category_ok = adinj_allowed_in_category('global', $ops);
443
  if (!$category_ok) return "NOADS: blocked from category";
444
 
445
+ $tag_ok = adinj_allowed_in_tag('global', $ops);
446
  if (!$tag_ok) return "NOADS: blocked from tag";
447
 
448
+ $author_ok = adinj_allowed_in_author('global', $ops);
449
+ if (!$author_ok) return "NOADS: blocked from author";
450
+
451
  // manual ad disabling tags
452
  if ($content == NULL) return false;
453
  if (strpos($content, "<!--noadsense-->") !== false) return "NOADS: noadsense tag"; // 'Adsense Injection' tag
458
  return false;
459
  }
460
 
461
+ function adinj_allowed_in_list($all_entries, $config_entries, $cat_mode, $func){
462
+ if (is_array($all_entries)){
463
+ foreach($all_entries as $entry) {
464
+ $string = $func($entry);
465
+ $decoded = rawurldecode($string); //allow UTF-8 encoded strings
466
+ if (in_array($string, $config_entries) || in_array($decoded, $config_entries)){
 
 
 
 
 
 
 
467
  if ($cat_mode == ADINJ_ONLY_SHOW_IN){
468
  return true;
469
  } else if ($cat_mode == ADINJ_NEVER_SHOW_IN){
477
  } else if ($cat_mode == ADINJ_NEVER_SHOW_IN){
478
  return true;
479
  }
480
+ echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_list-->");
481
  return true;
482
  }
483
 
484
+ function adinj_allowed_in_category($scope, $ops){
485
+ $cat_array = adinj_split_comma_list($ops[$scope.'_category_condition_entries']);
486
+ if (empty($cat_array)) return true;
487
+ global $post;
488
+ $postcategories = get_the_category($post->ID);
489
+ return adinj_allowed_in_list($postcategories, $cat_array,
490
+ $ops[$scope.'_category_condition_mode'], 'adinj_category_nicename');
491
+ }
492
+
493
  function adinj_allowed_in_tag($scope, $ops){
494
+ $conditions = adinj_split_comma_list($ops[$scope.'_tag_condition_entries']);
495
+ if (empty($conditions)) return true;
 
 
 
496
  global $post;
497
+ $tags = get_the_tags($post->ID);
498
+ return adinj_allowed_in_list($tags, $conditions,
499
+ $ops[$scope.'_tag_condition_mode'], 'adinj_tag_slug');
500
+ }
501
+
502
+ function adinj_allowed_in_author($scope, $ops){
503
+ $conditions = adinj_split_comma_list($ops[$scope.'_author_condition_entries']);
504
+ if (empty($conditions)) return true;
505
+ $data = get_the_author_meta('user_login');
506
+ $user[] = $data ; //need to make it into array
507
+ return adinj_allowed_in_list($user, $conditions,
508
+ $ops[$scope.'_author_condition_mode'], 'adinj_author_data');
509
+ }
510
+
511
+ //function parameters
512
+ function adinj_category_nicename($category){ return $category->category_nicename; }
513
+ function adinj_tag_slug($tag){ return $tag->slug; }
514
+ function adinj_author_data($data){ return $data; }
515
+
516
+ function adinj_split_comma_list($list){
517
+ return preg_split("/[\s,]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
518
  }
519
 
520
  function adinj_inject_hook($content){
556
  $length = 0;
557
  if ($ops['content_length_unit'] == 'all'){
558
  $length = strlen($content);
559
+ if ($debug_on) $debug .= "\nnum chars: = $length (including HTML chars)";
560
  } else if ($ops['content_length_unit'] == 'viewable'){
561
  $length = strlen(strip_tags($content));
562
+ if ($debug_on) $debug .= "\nnum chars: = $length (viewable chars only)";
563
  } else {
564
  $length = str_word_count(strip_tags($content));
565
+ if ($debug_on) $debug .= "\nnum words: = $length";
566
  }
567
  # Insert top and bottom ads if necesary
568
  if(is_page() || is_single()){
574
  $content = $content.adinj_ad_code_bottom();
575
  }
576
  }
577
+ if ($ad_include !== false) $content = $ad_include.$content;
578
 
579
  $num_rand_ads_to_insert = adinj_num_rand_ads_to_insert($length);
580
  if ($num_rand_ads_to_insert <= 0) return adinj($content, "all ads used up");
581
  $ad = adinj_ad_code_random();
582
  if (empty($ad)) return adinj($content, "no random ad defined");
583
 
 
 
584
  if (!$debug_on) $debugtags=false;
585
 
586
  $content_adfree_header = "";
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.6.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
 
@@ -18,6 +18,7 @@ Ad Injection injects any kind of advert (e.g. Google AdSense, Amazon Associates,
18
  * Alternate content which can be defined for users who are dynamically blocked (by IP or referrer) from seeing adverts.
19
  * Choose which paragraph to start the random ads via the UI.
20
  * Dynamic features will work with W3 Total Cache and WP Cache as well as the previously suppoted WP Super Cache.
 
21
 
22
  = Automatic advert injection =
23
 
@@ -225,6 +226,18 @@ Don't worry - everything will still work except for:
225
 
226
  If you aren't interested in these features then it doesn't matter! Just make sure you tick the box to say that you to use 'Direct static ad insertion' on the Ad Injection settings screen.
227
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  = Are there any known plugin conflicts? =
229
 
230
  **WP Minify**
@@ -305,6 +318,13 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
305
 
306
  == Changelog ==
307
 
 
 
 
 
 
 
 
308
  = 0.9.6.5 =
309
  * Add 'words' to content length counting options.
310
  * Fixes for categories/tags and ads with UTF-8 characters.
@@ -423,8 +443,8 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
423
 
424
  == Upgrade Notice ==
425
 
426
- = 0.9.6.5 =
427
- 'word' length restrictions, UTF-8 fixes, search/404 restriction options, and top/random/bottom ad pool size increased to 10.
428
 
429
  = 0.8.3 =
430
  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.6.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
 
18
  * Alternate content which can be defined for users who are dynamically blocked (by IP or referrer) from seeing adverts.
19
  * Choose which paragraph to start the random ads via the UI.
20
  * Dynamic features will work with W3 Total Cache and WP Cache as well as the previously suppoted WP Super Cache.
21
+ * Widgets can be conditionally included on pages by category, tag, and author.
22
 
23
  = Automatic advert injection =
24
 
226
 
227
  If you aren't interested in these features then it doesn't matter! Just make sure you tick the box to say that you to use 'Direct static ad insertion' on the Ad Injection settings screen.
228
 
229
+ = How can I show different ads for different post authors? =
230
+
231
+ This is something I hope to build into the UI at some point. But in the mean time you can use PHP in the ad code boxes to do this: e.g.
232
+
233
+ `<?php
234
+ $author = get_the_author();
235
+ if ($author == "john"){ ?>
236
+ This is John's Ad.
237
+ <?php } else if ($author == "paul") { ?>
238
+ This is Paul's Ad.
239
+ <?php } ?>`
240
+
241
  = Are there any known plugin conflicts? =
242
 
243
  **WP Minify**
318
 
319
  == Changelog ==
320
 
321
+ = 0.9.6.6 =
322
+ * Widgets can be conditionally included on pages by category, tag, and author.
323
+ * Widget ad pool size increased to 10.
324
+ * Fix for using just bottom ad in mfunc mode.
325
+ * Less JavaScript on admin pages.
326
+ * Global author exclude option.
327
+
328
  = 0.9.6.5 =
329
  * Add 'words' to content length counting options.
330
  * Fixes for categories/tags and ads with UTF-8 characters.
443
 
444
  == Upgrade Notice ==
445
 
446
+ = 0.9.6.6 =
447
+ Widget condition options - category, tag and author. Plus other fixes.
448
 
449
  = 0.8.3 =
450
  First public release.
ui-tab-adrotation.php CHANGED
@@ -81,7 +81,7 @@ echo <<<EOT
81
  <span style="font-size:10px;"><b>$title $num</b></span><br />
82
  <textarea name="$name" rows="8" cols="60">$ops[$name]</textarea>
83
  </td><td>
84
- <textarea name="$namesplit" rows="1" cols="7">$ops[$namesplit]</textarea>
85
  <br />
86
  $percent
87
  </td></tr>
81
  <span style="font-size:10px;"><b>$title $num</b></span><br />
82
  <textarea name="$name" rows="8" cols="60">$ops[$name]</textarea>
83
  </td><td>
84
+ <input name="$namesplit" size="7" value="$ops[$namesplit]" />
85
  <br />
86
  $percent
87
  </td></tr>
ui-tab-main.php CHANGED
@@ -9,16 +9,6 @@ if (!is_admin()) return;
9
  function adinj_tab_main(){
10
  $ops = adinj_options();
11
  ?>
12
- <script type="text/javascript">
13
- function adinj_addtext(element, value) {
14
- if (value.length == 0) return;
15
- separator = ', ';
16
- if (element.value.length == 0){
17
- separator = '';
18
- }
19
- element.value += (separator + value);
20
- }
21
- </script>
22
 
23
  <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>
24
 
@@ -103,13 +93,16 @@ function adinj_tab_main(){
103
  <tr><td colspan="2"><p><span style="font-size:10px;">When defining conditions that refer to the length of the content; do you want to count viewable characters, all characters (which includes HTML tags), or number of words?</span></p></td></tr>
104
  </table>
105
 
106
- <p><b>Category and tag conditions</b></p>
107
-
108
- <?php adinj_condition_table('global_category', 'category slugs. e.g: cat1, cat2, cat3', 'category'); ?>
109
-
110
- <?php adinj_condition_table('global_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag'); ?>
 
 
111
 
112
- <?php adinj_postbox_end(); ?>
 
113
 
114
 
115
  <?php adinj_postbox_start(__("Randomly Injected ad code", 'adinj'), 'random'); ?>
@@ -147,11 +140,7 @@ function adinj_tab_main(){
147
 
148
  <table border="0">
149
 
150
- <tr><td>
151
- <?php _e("Allow multiple ads to be injected at the same positions.", 'adinj') ?>
152
- </td><td>
153
- <?php adinj_add_checkbox('multiple_ads_at_same_position') ?> (default is to inject ads at unique positions)
154
- </td></tr>
155
 
156
 
157
  <tr><td>
@@ -167,6 +156,12 @@ function adinj_tab_main(){
167
  </select> <?php echo adinj_getdefault('max_num_of_ads'); ?><br />
168
  </td></tr>
169
 
 
 
 
 
 
 
170
  <tr><td colspan="2">
171
  <p></p>
172
  <table>
@@ -205,6 +200,8 @@ function adinj_tab_main(){
205
  ?>
206
  </td>
207
  </tr>
 
 
208
  </table>
209
 
210
  <br clear="all" />
@@ -315,7 +312,7 @@ function adinj_tab_main(){
315
  <?php adinj_add_checkbox('widget_exclude_home') ?>home - latest posts page (may be same as front)<br />
316
  <?php adinj_add_checkbox('widget_exclude_page') ?>page - <?php echo $count_pages->publish; ?> page(s)<br />
317
  <?php adinj_add_checkbox('widget_exclude_single') ?>single - <?php echo $count_posts->publish; ?> single blog post(s)<br />
318
- <?php adinj_add_checkbox('widget_exclude_archive') ?>archive - category, tag, author, and date pages types<br />
319
  <?php adinj_add_checkbox('widget_exclude_search') ?>search pages<br />
320
  <?php adinj_add_checkbox('widget_exclude_404') ?>404 error pages<br />
321
  </td></tr>
@@ -699,7 +696,6 @@ function adinj_debug_information(){
699
  echo 'ADINJ_PATH='.ADINJ_PATH.'<br />';
700
  echo 'ADINJ_CONFIG_FILE='.ADINJ_CONFIG_FILE.'<br />';
701
  echo 'ADINJ_AD_PATH='.ADINJ_AD_PATH.'<br />';
702
-
703
  echo 'Plugin version='.adinj_get_version();
704
  echo '</blockquote>';
705
 
@@ -818,7 +814,7 @@ function adinj_docs(){
818
  &lt;/div&gt;</textarea></p>
819
 
820
  <div style="background-color:#cccc99; width:468px; height:15px;">
821
- <font size="-2"><b>TEST ADVERT 160x90</b> <a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a></font>
822
  </div><p></p>
823
 
824
  <h4><a name="336x280"></a>336x280 large rectangle</h4>
9
  function adinj_tab_main(){
10
  $ops = adinj_options();
11
  ?>
 
 
 
 
 
 
 
 
 
 
12
 
13
  <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>
14
 
93
  <tr><td colspan="2"><p><span style="font-size:10px;">When defining conditions that refer to the length of the content; do you want to count viewable characters, all characters (which includes HTML tags), or number of words?</span></p></td></tr>
94
  </table>
95
 
96
+ <b>Category tag, and author conditions</b>
97
+ <?php
98
+ adinj_add_show_hide_section('ad_conditions_'.uniqid(), 'ui_conditions_show', 'ui_conditions_show', $ops);
99
+ adinj_condition_table('global_category', 'category slugs. e.g: cat1, cat2, cat3', 'category', $ops);
100
+ adinj_condition_table('global_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag', $ops);
101
+ adinj_condition_table('global_author', 'author nicknames. e.g: john, paul', 'author', $ops);
102
+ echo '</div>';
103
 
104
+ adinj_postbox_end();
105
+ ?>
106
 
107
 
108
  <?php adinj_postbox_start(__("Randomly Injected ad code", 'adinj'), 'random'); ?>
140
 
141
  <table border="0">
142
 
143
+
 
 
 
 
144
 
145
 
146
  <tr><td>
156
  </select> <?php echo adinj_getdefault('max_num_of_ads'); ?><br />
157
  </td></tr>
158
 
159
+ <tr><td>
160
+ <?php _e("Allow multiple ads to be injected at the same positions.", 'adinj') ?>
161
+ </td><td>
162
+ <?php adinj_add_checkbox('multiple_ads_at_same_position') ?> (default is to inject ads at unique positions)
163
+ </td></tr>
164
+
165
  <tr><td colspan="2">
166
  <p></p>
167
  <table>
200
  ?>
201
  </td>
202
  </tr>
203
+
204
+
205
  </table>
206
 
207
  <br clear="all" />
312
  <?php adinj_add_checkbox('widget_exclude_home') ?>home - latest posts page (may be same as front)<br />
313
  <?php adinj_add_checkbox('widget_exclude_page') ?>page - <?php echo $count_pages->publish; ?> page(s)<br />
314
  <?php adinj_add_checkbox('widget_exclude_single') ?>single - <?php echo $count_posts->publish; ?> single blog post(s)<br />
315
+ <?php adinj_add_checkbox('widget_exclude_archive') ?>archive - category, tag, author, and date types<br />
316
  <?php adinj_add_checkbox('widget_exclude_search') ?>search pages<br />
317
  <?php adinj_add_checkbox('widget_exclude_404') ?>404 error pages<br />
318
  </td></tr>
696
  echo 'ADINJ_PATH='.ADINJ_PATH.'<br />';
697
  echo 'ADINJ_CONFIG_FILE='.ADINJ_CONFIG_FILE.'<br />';
698
  echo 'ADINJ_AD_PATH='.ADINJ_AD_PATH.'<br />';
 
699
  echo 'Plugin version='.adinj_get_version();
700
  echo '</blockquote>';
701
 
814
  &lt;/div&gt;</textarea></p>
815
 
816
  <div style="background-color:#cccc99; width:468px; height:15px;">
817
+ <font size="-2"><b>TEST ADVERT 468x15</b> <a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a></font>
818
  </div><p></p>
819
 
820
  <h4><a name="336x280"></a>336x280 large rectangle</h4>