Ad Injection - Version 0.9.3.3

Version Description

Add a status box to make it easy to see what the main settings are.

Download this release

Release Info

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

Code changes from version 0.9.3.2 to 0.9.3.3

Files changed (3) hide show
  1. ad-injection-admin.php +207 -9
  2. ad-injection.php +1 -1
  3. readme.txt +7 -1
ad-injection-admin.php CHANGED
@@ -210,7 +210,6 @@ function adinj_options_page(){
210
  if (!empty($adinj_warning_msg_chmod)){
211
  echo '<br />Info: Some warnings were generated by chmod. See the <a href="#debugging">debugging</a> section for more info.';
212
  }
213
- echo '<br />Info: <a href="#restrictions">injection mode</a>='.$ops['ad_insertion_mode'];
214
  if ($ops['ads_enabled'] != 'on'){
215
  echo '<br /><font color="red">Warning: Ads are not enabled. You need to turn the ads on for everyone to see them.</font>';
216
  }
@@ -219,8 +218,80 @@ function adinj_options_page(){
219
  }
220
 
221
  ?>
222
-
223
- <div class="postbox-container" style="float:right; width:258px;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  <div class="metabox-holder">
225
  <div class="meta-box-sortables">
226
  <div id="toc" class="postbox">
@@ -228,7 +299,7 @@ function adinj_options_page(){
228
  <div class="inside" style="margin:5px;">
229
  <h4>More Ad Injection information</h4>
230
  <ul>
231
- <li><a href="http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/" target="_new">Ad Injection Home</a></li>
232
  <li><a href="http://wordpress.org/extend/plugins/ad-injection/" target="_new">Ad Injection at WordPress</a></li>
233
  <li><b><a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">Report a bug / give feedback</a></b></li>
234
  </ul>
@@ -253,13 +324,15 @@ function adinj_options_page(){
253
  </div>
254
  </div>
255
  </div>
256
- </div>
 
257
 
258
  <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>
259
 
260
  <form name="adinjform" method="post" action="">
261
  <?php wp_nonce_field('_adinj_form', '_adinj_nonce'); ?>
262
 
 
263
  <?php adinj_postbox_start(__("Global settings", 'adinj'), 'global'); ?>
264
 
265
  <p>These settings apply to all ads (random, top, bottom, and widget). They will override all other settings.</p>
@@ -396,7 +469,7 @@ function adinj_options_page(){
396
  </div>
397
 
398
  <input type="submit" style="float:right" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
399
- <h3><?php _e("Home page: Randomly Injected ad settings", 'adinj') ?> (<?php echo get_bloginfo('url'); ?>)</h3>
400
  <div class="inside" style="margin:10px">
401
  <p>These random ad injection settings are specific to your home page.</p>
402
 
@@ -501,7 +574,7 @@ function adinj_options_page(){
501
 
502
 
503
  <div class="inside" style="margin:10px">
504
- <h4>Show ads only to search engine visitors (dynamic feature)</h4>
505
 
506
  <blockquote>
507
  <input type="checkbox" name="sevisitors_only" <?php echo adinj_ticked('sevisitors_only'); ?> /><?php _e("Only show ads to search engine visitors (customise search engine referrers below if necessary).", 'adinj') ?><br />
@@ -586,7 +659,7 @@ function adinj_options_page(){
586
  function adinj_postbox_start($title, $anchor, $width='650px'){
587
  $ops = adinj_options();
588
  ?>
589
- <div class='postbox-container' style='width:<?php echo $width; ?>;clear:left'>
590
  <div class="metabox-holder">
591
  <div class="postbox">
592
  <input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
@@ -605,7 +678,7 @@ function adinj_postbox_start($title, $anchor, $width='650px'){
605
  });
606
  </script>
607
  <input type='hidden' id='ui_<?php echo $anchor; ?>_hide' name='ui_<?php echo $anchor; ?>_hide' value='<?php echo $ops['ui_'.$anchor.'_hide']; ?>' />
608
- <h3><a name="<?php echo $anchor ?>"></a><?php echo adinj_get_logo() . ' ' . $title; ?></h3>
609
  <div class="<?php echo $anchor; ?>-box">
610
  <div class="inside" style="margin:10px">
611
  <?php
@@ -620,6 +693,131 @@ function adinj_postbox_end(){
620
  </div> <!--postbox-container-->';
621
  }
622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  function adinj_selection_box($name, $values, $type=NULL){
624
  echo "<select name='$name'>";
625
  $ops = adinj_options();
210
  if (!empty($adinj_warning_msg_chmod)){
211
  echo '<br />Info: Some warnings were generated by chmod. See the <a href="#debugging">debugging</a> section for more info.';
212
  }
 
213
  if ($ops['ads_enabled'] != 'on'){
214
  echo '<br /><font color="red">Warning: Ads are not enabled. You need to turn the ads on for everyone to see them.</font>';
215
  }
218
  }
219
 
220
  ?>
221
+
222
+
223
+ <div style="width:258px; float:right;">
224
+ <div class="postbox-container" style="width:258px;">
225
+ <div class="metabox-holder">
226
+ <div class="meta-box-sortables" style="min-height:50px;">
227
+ <div id="toc" class="postbox">
228
+ <h3 class="hndle"><span><?php echo adinj_get_logo(); ?> Status</span></h3>
229
+ <div class="inside" style="margin:5px;">
230
+ <table border="0" cellpadding="2">
231
+ <tr><td style="text-align:right; vertical-align:top">
232
+ <b><a href="#global">Ads enabled</a></b>
233
+ </td><td>
234
+ <?php
235
+ $info = adinj_get_status('global'); echo adinj_dot($info[0]).' '.$info[1];
236
+ if ($info[0] != 'red') { ?>
237
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('exclude_home'); ?> home
238
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('exclude_page'); ?> page
239
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('exclude_single'); ?> single
240
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('exclude_archive'); ?> archive
241
+ </td></tr>
242
+ <tr><td style="text-align:right; vertical-align:top">
243
+ <b><a href="#random">Random ads</a></b>
244
+ </td><td>
245
+ <?php
246
+ $info = adinj_get_status('random'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
247
+ $info = adinj_get_status('random_home'); echo adinj_dot($info[0]).' '.$info[1];
248
+ ?>
249
+ </td></tr>
250
+ <tr><td style="text-align:right">
251
+ <b><a href="#topad">Top ad</a></b>
252
+ </td><td>
253
+ <?php $info = adinj_get_status('topad'); echo adinj_dot($info[0]).' '.$info[1]; ?>
254
+ </td></tr>
255
+ <tr><td style="text-align:right">
256
+ <b><a href="#bottomad">Bottom ad</a></b>
257
+ </td><td>
258
+ <?php $info = adinj_get_status('bottomad'); echo adinj_dot($info[0]).' '.$info[1]; ?>
259
+ </td></tr>
260
+ <tr><td style="text-align:right; vertical-align:top">
261
+ <b><a href="#widgets">Widgets</a></b>
262
+ </td><td>
263
+ <?php $info = adinj_get_status('widgets'); echo adinj_dot($info[0]).' '.$info[1];
264
+ if ($info[0] != 'red') { ?>
265
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('widget_exclude_home'); ?> home
266
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('widget_exclude_page'); ?> page
267
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('widget_exclude_single'); ?> single
268
+ <br />&nbsp;&nbsp;<?php echo adinj_green_or_red_dot('widget_exclude_archive'); ?> archive
269
+ <?php } ?>
270
+ </td></tr>
271
+ <tr><td style="text-align:right">
272
+ <b><a href="#restrictions">Mode</a></b>
273
+ </td><td>
274
+ <?php $info = adinj_get_status('mode'); echo adinj_dot($info[0]).' '.$info[1]; ?>
275
+ </td></tr>
276
+ <tr><td style="text-align:right">
277
+ <b><a href="#dynamic">Restrictions</a></b>
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 } ?>
284
+ </td></tr>
285
+ </table>
286
+ </div>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ </div>
291
+
292
+ <br />
293
+
294
+ <div class="postbox-container" style="width:258px;">
295
  <div class="metabox-holder">
296
  <div class="meta-box-sortables">
297
  <div id="toc" class="postbox">
299
  <div class="inside" style="margin:5px;">
300
  <h4>More Ad Injection information</h4>
301
  <ul>
302
+ <li><a href="http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/" target="_new">Ad Injection at reviewmylife</a></li>
303
  <li><a href="http://wordpress.org/extend/plugins/ad-injection/" target="_new">Ad Injection at WordPress</a></li>
304
  <li><b><a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">Report a bug / give feedback</a></b></li>
305
  </ul>
324
  </div>
325
  </div>
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
 
332
  <form name="adinjform" method="post" action="">
333
  <?php wp_nonce_field('_adinj_form', '_adinj_nonce'); ?>
334
 
335
+
336
  <?php adinj_postbox_start(__("Global settings", 'adinj'), 'global'); ?>
337
 
338
  <p>These settings apply to all ads (random, top, bottom, and widget). They will override all other settings.</p>
469
  </div>
470
 
471
  <input type="submit" style="float:right" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
472
+ <h3><a name="random_home"></a><?php _e("Home page: Randomly Injected ad settings", 'adinj') ?> (<?php echo get_bloginfo('url'); ?>)</h3>
473
  <div class="inside" style="margin:10px">
474
  <p>These random ad injection settings are specific to your home page.</p>
475
 
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>
580
  <input type="checkbox" name="sevisitors_only" <?php echo adinj_ticked('sevisitors_only'); ?> /><?php _e("Only show ads to search engine visitors (customise search engine referrers below if necessary).", 'adinj') ?><br />
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') ?>" />
678
  });
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
693
  </div> <!--postbox-container-->';
694
  }
695
 
696
+ function adinj_get_status($name){
697
+ $ops = adinj_options();
698
+ $status[] = 'black';
699
+ $status[] = 'Error...';
700
+ if ($name == 'global'){
701
+ if ($ops['exclude_home'] == 'on' &&
702
+ $ops['exclude_page'] == 'on' &&
703
+ $ops['exclude_single'] == 'on' &&
704
+ $ops['exclude_archive'] == 'on'){
705
+ $status[0] = 'red';
706
+ $status[1] = 'excluded from all';
707
+ return $status;
708
+ }
709
+ $val = $ops['ads_enabled'];
710
+ if ($val == 'on'){
711
+ $status[0] = 'green';
712
+ $status[1] = $val;
713
+ } else if ($val == 'off'){
714
+ $status[0] = 'red';
715
+ $status[1] = $val;
716
+ } else if ($val == 'test'){
717
+ $status[0] = 'orange';
718
+ $status[1] = 'test mode';
719
+ }
720
+ } else if ($name == 'random'){
721
+ $ad = $ops['ad_code_random_1'];
722
+ if (empty($ad)){
723
+ $status[0] = 'red';
724
+ $status[1] = 'no ad defined';
725
+ return $status;
726
+ }
727
+ $val = $ops['max_num_of_ads'];
728
+ if ($val == '0'){
729
+ $status[0] = 'red';
730
+ $status[1] = 'off';
731
+ } else {
732
+ $status[0] = 'green';
733
+ $status[1] = 'max ads: ' . $val;
734
+ }
735
+ } else if ($name == 'random_home'){
736
+ $val = $ops['max_num_of_ads_home_page'];
737
+ $msg = '<a href="#';
738
+ if ($val == 0){
739
+ $status[0] = 'red';
740
+ $msg .= 'random_home">0 on home';
741
+ } else if ($ops['exclude_home'] == 'on'){
742
+ $status[0] = 'red';
743
+ $msg .= 'global">exclude from home';
744
+ } else {
745
+ $status[0] = 'green';
746
+ $msg .= 'random_home">max ads: ' . $val .' (home)';
747
+ }
748
+ $status[1] = $msg.'</a>';
749
+ } else if ($name == 'topad'){
750
+ $ad = $ops['ad_code_top_1'];
751
+ if (empty($ad)){
752
+ $status[0] = 'red';
753
+ $status[1] = 'no ad defined';
754
+ return $status;
755
+ }
756
+ $val = $ops['top_ad_if_longer_than'];
757
+ if ($val == ADINJ_RULE_DISABLED){
758
+ $status[0] = 'red';
759
+ $status[1] = 'off';
760
+ } else {
761
+ $status[0] = 'green';
762
+ $status[1] = 'on';
763
+ }
764
+ } else if ($name == 'bottomad'){
765
+ $ad = $ops['ad_code_bottom_1'];
766
+ if (empty($ad)){
767
+ $status[0] = 'red';
768
+ $status[1] = 'no ad defined';
769
+ return $status;
770
+ }
771
+ $val = $ops['bottom_ad_if_longer_than'];
772
+ if ($val == ADINJ_RULE_DISABLED){
773
+ $status[0] = 'red';
774
+ $status[1] = 'off';
775
+ } else {
776
+ $status[0] = 'green';
777
+ $status[1] = 'on';
778
+ }
779
+ } else if ($name == 'widgets'){
780
+ if ($ops['widget_exclude_home'] == 'on' &&
781
+ $ops['widget_exclude_page'] == 'on' &&
782
+ $ops['widget_exclude_single'] == 'on' &&
783
+ $ops['widget_exclude_archive'] == 'on'){
784
+ $status[0] = 'red';
785
+ $status[1] = 'exclude from all';
786
+ } else {
787
+ $status[1] = 'see <a href="widgets.php">widgets</a> screen';
788
+ }
789
+ } else if ($name == 'mode'){
790
+ $status[1] = $ops['ad_insertion_mode'];
791
+ } else if ($name == 'restrictions'){
792
+ if ($ops['ad_insertion_mode'] == 'direct_static'){
793
+ $status[1] = 'n/a for direct static';
794
+ return $status;
795
+ }
796
+ $status[1] = "";
797
+ if ($ops['sevisitors_only'] == 'on'){
798
+ $status[1] .= 'referrer';
799
+ }
800
+ if (!empty($ops['blocked_ips'])){
801
+ $status[1] .= ' ip';
802
+ }
803
+ }
804
+ return $status;
805
+ }
806
+
807
+ // This is for 'exclude' options so 'on' is red.
808
+ function adinj_green_or_red_dot($option){
809
+ $ops = adinj_options();
810
+ if ($ops[$option] == 'on'){
811
+ return adinj_dot('red');
812
+ } else {
813
+ return adinj_dot('green');
814
+ }
815
+ }
816
+
817
+ function adinj_dot($colour){
818
+ return '<span style="color:'.$colour.'">&#x25cf;</span>';
819
+ }
820
+
821
  function adinj_selection_box($name, $values, $type=NULL){
822
  echo "<select name='$name'>";
823
  $ops = adinj_options();
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.2
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
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.3
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
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.2
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
 
@@ -193,6 +193,9 @@ 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.2 =
197
  Add test mode, and further reduce unnecessary file access.
198
 
@@ -244,6 +247,9 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
244
 
245
  == Upgrade Notice ==
246
 
 
 
 
247
  = 0.9.3.2 =
248
  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).
249
 
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.3
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
 
193
 
194
  == Changelog ==
195
 
196
+ = 0.9.3.3 =
197
+ Add a status box to make it easy to see what the main settings are.
198
+
199
  = 0.9.3.2 =
200
  Add test mode, and further reduce unnecessary file access.
201
 
247
 
248
  == Upgrade Notice ==
249
 
250
+ = 0.9.3.3 =
251
+ 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).
252
+
253
  = 0.9.3.2 =
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