Ad Injection - Version 0.9.5.1

Version Description

New CSS padding options for widgets. Fixes for CSS margin options. Update docs for due to new mfunc support in WP Super Cache. If you are using mfunc mode and upgrade to the latest version of WP Super Cache (0.9.9.8) you can now use the faster mod_rewrite mode or PHP mode instead of legacy mode.

Download this release

Release Info

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

Code changes from version 0.9.5 to 0.9.5.1

Files changed (5) hide show
  1. ad-injection-admin.php +124 -28
  2. ad-injection-widget.php +8 -2
  3. ad-injection.php +14 -3
  4. adshow.php +12 -6
  5. readme.txt +21 -7
ad-injection-admin.php CHANGED
@@ -225,9 +225,9 @@ function adinj_options_page(){
225
  }
226
  echo '</p></div>';
227
 
228
- } else {
229
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
230
- echo "6th January 2011: Added top/bottom spacing options for widgets and new random align option. Plus bug fixes. This release contains some 'under the hood' changes to prepare for the new features that will be released later in January. If you spot any bugs, or odd behaviour please let me know via the ".'<a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">feedback form</a>.';
231
  echo '</strong></p></div>';
232
  }
233
  ?>
@@ -609,7 +609,33 @@ function adinj_options_page(){
609
  <h4>Ad insertion mode</h4>
610
 
611
  <blockquote>
612
- <p><input type="radio" name="ad_insertion_mode" value="mfunc" <?php if ($ops['ad_insertion_mode']=='mfunc') echo 'checked="checked"'; ?> /> <b>Use mfunc tags for dynamic features</b> - Dynamic features will work with WP Super Cache in legacy mode (or with a caching program that is compatible with WP Super Cache's mfunc tags). Dynamic features will also work if you don't use a caching program, although if you don't use a caching program 'direct' insertion will be more efficient.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613
  <p><input type="radio" name="ad_insertion_mode" value="direct_dynamic" <?php if ($ops['ad_insertion_mode']=='direct_dynamic') echo 'checked="checked"'; ?> /> <b>Direct ad insertion with dynamic features</b> - Dynamic features will work if no caching is used. Only select this if you are not using any caching plugin.</p>
614
  <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>
615
  </blockquote>
@@ -622,9 +648,15 @@ function adinj_options_page(){
622
  if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
623
  jQuery('.dynamic_features').slideUp(1000);
624
  jQuery('.dynamic_features_msg').slideDown(1000);
625
- } else {
 
 
 
 
 
626
  jQuery('.dynamic_features_msg').slideUp(1000);
627
  jQuery('.dynamic_features').slideDown(1000);
 
628
  }
629
  return true;
630
  });
@@ -661,6 +693,7 @@ function adinj_options_page(){
661
  <h4>Blocked IP addresses (dynamic feature)</h4>
662
 
663
  <blockquote>
 
664
  <textarea name="blocked_ips" rows="4" cols="70"><?php echo $ops['blocked_ips']; ?></textarea>
665
  <p>Comma separated list e.g.: <br /><code>0.0.0.1, 0.0.0.2</code></p>
666
  <p>Or you can list one IP per line with optional comments e.g.</p>
@@ -670,28 +703,6 @@ function adinj_options_page(){
670
  </blockquote>
671
  </div>
672
 
673
-
674
- <h3>Recommended WP Super Cache settings:</h3>
675
- <div class="inside" style="margin:10px">
676
-
677
- <blockquote>
678
- <ul>
679
- <li>Cache hits to this website for quick access.</li>
680
- <li>Legacy page caching.</li>
681
- <li>Compress pages so they&#x2019;re served more quickly to visitors.</li>
682
- <li>Expire time: 36000 (10 hours). Or 3600 (1 hour) for very busy site.</li>
683
- </ul>
684
- </blockquote>
685
-
686
- <p>
687
- <?php if (is_plugin_active('wp-super-cache/wp-cache.php')) {
688
- echo "Go to the WP Super Cache <a href='options-general.php?page=wpsupercache&amp;tab=settings'>advanced settings page</a> (where you can set the caching mode to Legacy).";
689
- } else {
690
- echo "Note: WP Super Cache does not appear to be active.";
691
- } ?>
692
- </p>
693
- </div>
694
-
695
  </div>
696
 
697
  <?php adinj_postbox_end(); ?>
@@ -718,10 +729,14 @@ function adinj_options_page(){
718
 
719
  <input type="submit" name="adinj_action" value="<?php _e('Reset to Default', 'adinj') ?>" />
720
 
721
- <p>You can delete the database settings if you are going to uninstall Ad Injection.</p>
722
 
723
  <input type="submit" name="adinj_action" value="<?php _e('Delete settings from DB', 'adinj') ?>" />
724
 
 
 
 
 
725
  <?php adinj_postbox_end(); ?>
726
 
727
 
@@ -735,6 +750,31 @@ function adinj_options_page(){
735
  echo '</div> <!--wrap-->';
736
  }
737
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
738
  function adinj_postbox_start($title, $anchor, $width='650px'){
739
  $ops = adinj_options();
740
  ?>
@@ -881,7 +921,7 @@ function adinj_get_status($name){
881
  if ($ops['sevisitors_only'] == 'on'){
882
  $status[1] .= 'referrer';
883
  }
884
- if (!empty($ops['blocked_ips'])){
885
  $status[1] .= ' ip';
886
  }
887
  } else if ($name == 'debugging'){
@@ -1051,6 +1091,33 @@ function adinj_add_margin_top_bottom_options($prefix, $options=NULL, $topname=NU
1051
  array(ADINJ_DISABLED, 0, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30), "(px)", $options, $bdefault);
1052
  }
1053
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1054
  function adinj_debug_information(){
1055
  $stored_options = adinj_options();
1056
  $default_options = adinj_default_options();
@@ -1081,6 +1148,34 @@ function adinj_debug_information(){
1081
  }
1082
  echo '</table>';
1083
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1084
  echo '<h4>Other settings</h4><blockquote>';
1085
 
1086
  echo 'ADINJ_PATH='.ADINJ_PATH.'<br />';
@@ -1251,6 +1346,7 @@ function adinj_default_options(){
1251
  // dynamic features
1252
  'sevisitors_only' => '',
1253
  'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/',
 
1254
  'blocked_ips' => '',
1255
  'ad_insertion_mode' => 'mfunc',
1256
  // ui
225
  }
226
  echo '</p></div>';
227
 
228
+ } else {
229
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
230
+ echo "10th January 2011: Added new top/bottom padding options for widgets (slightly different behaviour to the existing top/bottom margin option). Plus added some fixes for the widget margins. If you spot any bugs, or odd behaviour please let me know via the ".'<a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">feedback form</a>.';
231
  echo '</strong></p></div>';
232
  }
233
  ?>
609
  <h4>Ad insertion mode</h4>
610
 
611
  <blockquote>
612
+ <p><input type="radio" name="ad_insertion_mode" value="mfunc" <?php if ($ops['ad_insertion_mode']=='mfunc') echo 'checked="checked"'; ?> /> <b>Use mfunc tags for dynamic features (WP Super Cache mode)</b> - Dynamic features will work with WP Super Cache. </p>
613
+
614
+ <?php if (!is_plugin_active('wp-super-cache/wp-cache.php')) {
615
+ echo '<p><b><span style="font-size:10px;color:red;">Note: WP Super Cache does not appear to be active. If you are not using WP Super Cache /WP Cache (or compatible) you should use one of the direct insertion modes.</span></b></p>';
616
+ } ?>
617
+
618
+ <?php if ($ops['ad_insertion_mode'] != 'mfunc') { ?>
619
+ <script type="text/javascript">
620
+ document.write('<style type="text/css" media="screen">#wp_supercache_msg { display: none; }</style>');
621
+ </script>
622
+ <?php } ?>
623
+
624
+ <div id="wp_supercache_msg" class="wp_supercache_msg">
625
+ <p>With WP Super Cache version 0.9.9.8+ you can use the fastest 'mod rewrite rules' caching mode. With older versions of WP Super Cache you'll have to use the slower 'legacy mode'.</p>
626
+
627
+ <p>Go to the
628
+
629
+ <?php if (is_plugin_active('wp-super-cache/wp-cache.php')) { ?>
630
+ <a href='options-general.php?page=wpsupercache&amp;tab=settings'>WP Super Cache advanced options page</a>
631
+ <?php } else { ?>
632
+ WP Super Cache advanced options page
633
+ <?php } ?>
634
+ to configure the caching mode.</p>
635
+
636
+ <p>Dynamic features will also work if you don't use a caching program with mfunc mode. Although if you don't use a caching program one of the 'direct' insertion modes will be more efficient.</p>
637
+ </div>
638
+
639
  <p><input type="radio" name="ad_insertion_mode" value="direct_dynamic" <?php if ($ops['ad_insertion_mode']=='direct_dynamic') echo 'checked="checked"'; ?> /> <b>Direct ad insertion with dynamic features</b> - Dynamic features will work if no caching is used. Only select this if you are not using any caching plugin.</p>
640
  <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>
641
  </blockquote>
648
  if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
649
  jQuery('.dynamic_features').slideUp(1000);
650
  jQuery('.dynamic_features_msg').slideDown(1000);
651
+ jQuery('.wp_supercache_msg').slideUp(1000);
652
+ } else if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_dynamic"){
653
+ jQuery('.dynamic_features_msg').slideUp(1000);
654
+ jQuery('.dynamic_features').slideDown(1000);
655
+ jQuery('.wp_supercache_msg').slideUp(1000);
656
+ } else { // mfunc
657
  jQuery('.dynamic_features_msg').slideUp(1000);
658
  jQuery('.dynamic_features').slideDown(1000);
659
+ jQuery('.wp_supercache_msg').slideDown(1000);
660
  }
661
  return true;
662
  });
693
  <h4>Blocked IP addresses (dynamic feature)</h4>
694
 
695
  <blockquote>
696
+ <!--<input type="checkbox" name="block_ips" <?php echo adinj_ticked('block_ips'); ?> /><?php _e("Exclude ads from these IP addresses.", 'adinj') ?><br />-->
697
  <textarea name="blocked_ips" rows="4" cols="70"><?php echo $ops['blocked_ips']; ?></textarea>
698
  <p>Comma separated list e.g.: <br /><code>0.0.0.1, 0.0.0.2</code></p>
699
  <p>Or you can list one IP per line with optional comments e.g.</p>
703
  </blockquote>
704
  </div>
705
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
706
  </div>
707
 
708
  <?php adinj_postbox_end(); ?>
729
 
730
  <input type="submit" name="adinj_action" value="<?php _e('Reset to Default', 'adinj') ?>" />
731
 
732
+ <p>You can delete the database settings if you are going to uninstall Ad Injection (they will be automatically deleted if you uninstall via WordPress as well).</p>
733
 
734
  <input type="submit" name="adinj_action" value="<?php _e('Delete settings from DB', 'adinj') ?>" />
735
 
736
+ <p>This button will delete all your Ad Injection widgets.</p>
737
+
738
+ <input type="submit" name="adinj_action" value="<?php _e('Delete widget settings from DB', 'adinj') ?>" />
739
+
740
  <?php adinj_postbox_end(); ?>
741
 
742
 
750
  echo '</div> <!--wrap-->';
751
  }
752
 
753
+ // From WP Super cache
754
+ function adinj_admin_tabs( $current = 0 ) {
755
+ global $wp_db_version;
756
+ if ( $current == 0 ) {
757
+ if ( isset( $_GET[ 'tab' ] ) ) {
758
+ $current = $_GET[ 'tab' ];
759
+ } else {
760
+ $current = 'main';
761
+ }
762
+ }
763
+ $tabs = array( 'main' => __( 'Main', 'ad-injection' ), 'adrotation' => __( 'Ad Rotation / A:B Testing', 'ad-injection' ), 'alternate' => __( 'Alternate Content', 'ad-injection' ) );
764
+ $links = array();
765
+ foreach( $tabs as $tab => $name ) {
766
+ if ( $current == $tab ) {
767
+ $links[] = "<a class='nav-tab nav-tab-active' href='?page=ad-injection&tab=$tab'>$name</a>";
768
+ } else {
769
+ $links[] = "<a class='nav-tab' href='?page=ad-injection&tab=$tab'>$name</a>";
770
+ }
771
+ }
772
+
773
+ echo '<div id="nav"><h2 class="themes-php">';
774
+ echo implode( "", $links );
775
+ echo '</h2></div>';
776
+ }
777
+
778
  function adinj_postbox_start($title, $anchor, $width='650px'){
779
  $ops = adinj_options();
780
  ?>
921
  if ($ops['sevisitors_only'] == 'on'){
922
  $status[1] .= 'referrer';
923
  }
924
+ if ($ops['block_ips'] == 'on' && !empty($ops['blocked_ips'])){
925
  $status[1] .= ' ip';
926
  }
927
  } else if ($name == 'debugging'){
1091
  array(ADINJ_DISABLED, 0, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30), "(px)", $options, $bdefault);
1092
  }
1093
 
1094
+ function adinj_add_padding_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){
1095
+ $tname = $prefix.'padding_top';
1096
+ $bname = $prefix.'padding_bottom';
1097
+ $tdefault = NULL;
1098
+ $bdefault = NULL;
1099
+ if ($topname != NULL){
1100
+ $tname = $topname;
1101
+ $tdefault = "padding_top";
1102
+ }
1103
+ if ($bottomname != NULL){
1104
+ $bname = $bottomname;
1105
+ $bdefault = "padding_bottom";
1106
+ }
1107
+
1108
+ _e("Padding top", 'adinj');
1109
+ echo "<br />";
1110
+ adinj_selection_box($tname,
1111
+ array(ADINJ_DISABLED, 0, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30), "(px)", $options, $tdefault);
1112
+
1113
+ echo "<br />";
1114
+
1115
+ _e("Padding bottom", 'adinj');
1116
+ echo "<br />";
1117
+ adinj_selection_box($bname,
1118
+ array(ADINJ_DISABLED, 0, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30), "(px)", $options, $bdefault);
1119
+ }
1120
+
1121
  function adinj_debug_information(){
1122
  $stored_options = adinj_options();
1123
  $default_options = adinj_default_options();
1148
  }
1149
  echo '</table>';
1150
 
1151
+ ?><h4>Widget settings dump from database (all in 'widget_adinj' option)</h4>
1152
+ <table border="1" style="width:610px; word-wrap:break-word;">
1153
+ <tr><td><b>Widget</b></td><td><b>Setting:Value</b></td></tr>
1154
+ <?php
1155
+ //<td><b>Value</b></td>
1156
+ $widgetops = get_option('widget_adinj');
1157
+ $count = 0;
1158
+ foreach($widgetops as $key=>$val){
1159
+ if ($count % 2 == 0){
1160
+ echo '<tr style="background-color:#cccccc"><td style="vertical-align:top">';
1161
+ } else {
1162
+ echo '<tr><td style="vertical-align:top">';
1163
+ }
1164
+ echo $key;
1165
+ echo "</td>";
1166
+ echo '<td style="vertical-align:top">';
1167
+ if (is_array($val)){
1168
+ foreach($val as $subkey=>$subval){
1169
+ echo $subkey.':'.htmlentities($subval).'<br />';
1170
+ }
1171
+ } else {
1172
+ echo htmlentities($val);
1173
+ }
1174
+ echo '</td></tr>';
1175
+ ++$count;
1176
+ }
1177
+ echo '</table>';
1178
+
1179
  echo '<h4>Other settings</h4><blockquote>';
1180
 
1181
  echo 'ADINJ_PATH='.ADINJ_PATH.'<br />';
1346
  // dynamic features
1347
  'sevisitors_only' => '',
1348
  'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/',
1349
+ 'block_ips' => 'on',
1350
  'blocked_ips' => '',
1351
  'ad_insertion_mode' => 'mfunc',
1352
  // ui
ad-injection-widget.php CHANGED
@@ -44,7 +44,7 @@ class Ad_Injection_Widget extends WP_Widget {
44
  $include = adinj_ad_code_include();
45
  $adcode = adinj_get_mfunc_code($this->get_ad_file_name(), $instance);
46
  } else {
47
- $adcode = adshow_add_formatting($advert, adinj_formatting_options('widget_1', "array"));
48
  }
49
  $adcode = adinj_ad_code_eval($adcode);
50
 
@@ -64,6 +64,8 @@ class Ad_Injection_Widget extends WP_Widget {
64
  $instance['advert'] = $new_instance['advert'];
65
  $instance['margin_top'] = $new_instance['margin_top'];
66
  $instance['margin_bottom'] = $new_instance['margin_bottom'];
 
 
67
 
68
  write_ad_to_file($instance['advert'], $this->get_ad_file_path());
69
 
@@ -77,7 +79,9 @@ class Ad_Injection_Widget extends WP_Widget {
77
  'title' => '',
78
  'advert' => '',
79
  'margin_top' => ADINJ_DISABLED,
80
- 'margin_bottom' => ADINJ_DISABLED);
 
 
81
  $instance = wp_parse_args( (array) $instance, $defaults );
82
  ?>
83
 
@@ -94,6 +98,8 @@ class Ad_Injection_Widget extends WP_Widget {
94
  <textarea class="widefat" rows="12" cols="30" id="<?php echo $this->get_field_id('advert'); ?>" name="<?php echo $this->get_field_name('advert'); ?>"><?php echo $instance['advert']; ?></textarea>
95
  </td><td style="vertical-align: top">
96
  <?php adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom') ); ?>
 
 
97
  </td></tr>
98
  </table>
99
 
44
  $include = adinj_ad_code_include();
45
  $adcode = adinj_get_mfunc_code($this->get_ad_file_name(), $instance);
46
  } else {
47
+ $adcode = adshow_add_formatting($advert, $instance);
48
  }
49
  $adcode = adinj_ad_code_eval($adcode);
50
 
64
  $instance['advert'] = $new_instance['advert'];
65
  $instance['margin_top'] = $new_instance['margin_top'];
66
  $instance['margin_bottom'] = $new_instance['margin_bottom'];
67
+ $instance['padding_top'] = $new_instance['padding_top'];
68
+ $instance['padding_bottom'] = $new_instance['padding_bottom'];
69
 
70
  write_ad_to_file($instance['advert'], $this->get_ad_file_path());
71
 
79
  'title' => '',
80
  'advert' => '',
81
  'margin_top' => ADINJ_DISABLED,
82
+ 'margin_bottom' => ADINJ_DISABLED,
83
+ 'padding_top' => ADINJ_DISABLED,
84
+ 'padding_bottom' => ADINJ_DISABLED);
85
  $instance = wp_parse_args( (array) $instance, $defaults );
86
  ?>
87
 
98
  <textarea class="widefat" rows="12" cols="30" id="<?php echo $this->get_field_id('advert'); ?>" name="<?php echo $this->get_field_name('advert'); ?>"><?php echo $instance['advert']; ?></textarea>
99
  </td><td style="vertical-align: top">
100
  <?php adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom') ); ?>
101
+ <br />
102
+ <?php adinj_add_padding_top_bottom_options('widget_', $instance, $this->get_field_name('padding_top'), $this->get_field_name('padding_bottom') ); ?>
103
  </td></tr>
104
  </table>
105
 
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.5
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -133,6 +133,8 @@ function adinj_formatting_options($adname, $output_type="string", $options = arr
133
  $clear = "";
134
  $margin_top = "";
135
  $margin_bottom = "";
 
 
136
  if (preg_match("/random_[\d+]/i", $adname)){
137
  $align = $ops['rnd_align'];
138
  $clear = $ops['rnd_clear'];
@@ -153,17 +155,26 @@ function adinj_formatting_options($adname, $output_type="string", $options = arr
153
  $clear = $options['clear'];
154
  $margin_top = $options['margin_top'];
155
  $margin_bottom = $options['margin_bottom'];
 
 
156
  }
157
 
158
  if (adinj_disabled($align)) $align = "";
159
  if (adinj_disabled($clear)) $clear = "";
160
  if (adinj_disabled($margin_top)) $margin_top = "";
161
  if (adinj_disabled($margin_bottom)) $margin_bottom = "";
 
 
162
 
163
  if ($output_type == "string"){
164
- return "'align' => '$align', 'clear' => '$clear', 'margin_top' => '$margin_top', 'margin_bottom' => '$margin_bottom'";
165
  } else {
166
- return array('align' => $align, 'clear' => $clear, 'margin_top' => $margin_top, 'margin_bottom' => $margin_bottom);
 
 
 
 
 
167
  }
168
  }
169
 
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.5.1
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
133
  $clear = "";
134
  $margin_top = "";
135
  $margin_bottom = "";
136
+ $padding_top = "";
137
+ $padding_bottom = "";
138
  if (preg_match("/random_[\d+]/i", $adname)){
139
  $align = $ops['rnd_align'];
140
  $clear = $ops['rnd_clear'];
155
  $clear = $options['clear'];
156
  $margin_top = $options['margin_top'];
157
  $margin_bottom = $options['margin_bottom'];
158
+ $padding_top = $options['padding_top'];
159
+ $padding_bottom = $options['padding_bottom'];
160
  }
161
 
162
  if (adinj_disabled($align)) $align = "";
163
  if (adinj_disabled($clear)) $clear = "";
164
  if (adinj_disabled($margin_top)) $margin_top = "";
165
  if (adinj_disabled($margin_bottom)) $margin_bottom = "";
166
+ if (adinj_disabled($padding_top)) $padding_top = "";
167
+ if (adinj_disabled($padding_bottom)) $padding_bottom = "";
168
 
169
  if ($output_type == "string"){
170
+ return "'align' => '$align', 'clear' => '$clear', 'margin_top' => '$margin_top', 'margin_bottom' => '$margin_bottom', 'padding_top' => '$padding_top', 'padding_bottom' => '$padding_bottom'";
171
  } else {
172
+ return array('align' => $align,
173
+ 'clear' => $clear,
174
+ 'margin_top' => $margin_top,
175
+ 'margin_bottom' => $margin_bottom,
176
+ 'padding_top' => $padding_top,
177
+ 'padding_bottom' => $padding_bottom);
178
  }
179
  }
180
 
adshow.php CHANGED
@@ -222,14 +222,20 @@ function adshow_add_formatting($ad, $ops = array()){
222
  if (strlen($ops['align']) > 0 ||
223
  strlen($ops['clear']) > 0 ||
224
  strlen($ops['margin_top']) > 0 ||
225
- strlen($ops['margin_bottom']) > 0) {
 
 
226
  $clear = "";
227
- $top = "";
228
- $bottom = "";
 
 
229
  if (strlen($ops['clear']) > 0) $clear="clear:" . $ops['clear'] . ";";
230
- if (strlen($ops['margin_top']) > 0) $top="margin-top:" . $ops['margin_top'] . "px;";
231
- if (strlen($ops['margin_bottom']) > 0) $bottom="margin-bottom:" . $ops['margin_bottom'] . "px;";
232
- $cssrules = $clear . $top . $bottom;
 
 
233
 
234
  if ($ops['align'] == 'rand lcr') $ops['align'] = array_rand(array_flip(array('left', 'center', 'right')));
235
  if ($ops['align'] == 'rand float lr') $ops['align'] = array_rand(array_flip(array('float left', 'float right')));
222
  if (strlen($ops['align']) > 0 ||
223
  strlen($ops['clear']) > 0 ||
224
  strlen($ops['margin_top']) > 0 ||
225
+ strlen($ops['margin_bottom']) > 0 ||
226
+ strlen($ops['padding_top']) > 0 ||
227
+ strlen($ops['padding_bottom']) > 0) {
228
  $clear = "";
229
+ $mtop = "";
230
+ $mbottom = "";
231
+ $ptop = "";
232
+ $pbottom = "";
233
  if (strlen($ops['clear']) > 0) $clear="clear:" . $ops['clear'] . ";";
234
+ if (strlen($ops['margin_top']) > 0) $mtop="margin-top:" . $ops['margin_top'] . "px;";
235
+ if (strlen($ops['margin_bottom']) > 0) $mbottom="margin-bottom:" . $ops['margin_bottom'] . "px;";
236
+ if (strlen($ops['padding_top']) > 0) $ptop="padding-top:" . $ops['padding_top'] . "px;";
237
+ if (strlen($ops['padding_bottom']) > 0) $pbottom="padding-bottom:" . $ops['padding_bottom'] . "px;";
238
+ $cssrules = $clear . $mtop . $mbottom . $ptop . $pbottom;
239
 
240
  if ($ops['align'] == 'rand lcr') $ops['align'] = array_rand(array_flip(array('left', 'center', 'right')));
241
  if ($ops['align'] == 'rand float lr') $ops['align'] = array_rand(array_flip(array('float left', 'float right')));
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Ad Injection ===
2
  Contributors: reviewmylife
3
  Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
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: 2.8.6
6
  Tested up to: 3.1
7
- Stable tag: 0.9.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
 
@@ -16,7 +16,7 @@ It injects any kind of advert (e.g. Google AdSense, Amazon Associates, ClickBank
16
 
17
  The ads can be injected into existing posts without requiring any modification of the post. The injection can be done randomly between paragraphs, and there is an option to always inject the first advert after the first paragraph. Randomly positioning the adverts helps to reduce 'ad blindness'. Two separate adverts can be defined for the top and bottom of the content. Widget adverts can be defined as well.
18
 
19
- = Widget support [new] =
20
 
21
  Widgets can be added to your sidebars, or other widget areas on any pages. The same ad display restrictions that you setup for your other ads will also apply to the widgets.
22
 
@@ -42,11 +42,13 @@ The advert code can be copied and pasted directly from your ad provider (Google
42
 
43
  = Flexible ad positioning =
44
 
45
- Easy positioning options are provided for left, right, center, float left, and float right. Extra spacing can be set above and below the ad. Or if that isn't flexible enough, you can write your own positioning code using HTML and CSS.
46
 
47
  = Works with WP Super Cache =
48
 
49
- The dynamic features that require code to be executed for each page view (i.e. search engine visitors only, and ad blocking based on IP address) work with WP Super Cache! This plugin will automatically use the dynamic mfunc tag to ensure that the dynamic ad features still work when caching is on. Displaying the adverts (even with the dynamic restrictions) whilst caching with WP Super Cache requires no MySQL database access. Note: WP Super Cache must be configured in 'Legacy' mode for the dynamic features to work.
 
 
50
 
51
  = Inject PHP and JavaScript =
52
 
@@ -58,6 +60,10 @@ If there are any panels on the admin screen that you don't need, you can click o
58
 
59
  For more information visit [reviewmylife](http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/ "reviewmylife blog").
60
 
 
 
 
 
61
  == Installation ==
62
 
63
  This section describes how to install the plugin and get it working.
@@ -130,7 +136,7 @@ Using a second browser in 'privacy mode' is also a good way of testing your site
130
 
131
  = Do I need to have WP Super Cache installed? =
132
 
133
- 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.
134
 
135
  = Will the dynamic features work with other caching plugins? =
136
 
@@ -186,7 +192,7 @@ Here are some things to check if the ads are not appearing, or are appearing whe
186
  = If you are using WP Super Cache. =
187
 
188
  1. Have you enabled the WP Super Cache 'mfunc' mode? (in the Ad insertion mode and dynamic ad display restrictions pane)
189
- 2. Are your WP Super Cache settings correct? It must be in 'Legacy' mode.
190
  3. If you are using WP Minify as well then turn off the HTML minification as this strips out the mfunc tags that Ad Injection uses to check if the adverts should be inserted.
191
 
192
  = If you are using WP Minify =
@@ -226,6 +232,10 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
226
 
227
  == Changelog ==
228
 
 
 
 
 
229
  = 0.9.5 =
230
  New option to add spacing above and below widgets.
231
  New options for randomly aligning random/top/bottom ads.
@@ -314,6 +324,10 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
314
 
315
  == Upgrade Notice ==
316
 
 
 
 
 
317
  = 0.9.5 =
318
  New spacing/alignment options, and misc fixes.
319
 
1
  === Ad Injection ===
2
  Contributors: reviewmylife
3
  Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
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, blog
5
  Requires at least: 2.8.6
6
  Tested up to: 3.1
7
+ Stable tag: 0.9.5.1
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
 
16
 
17
  The ads can be injected into existing posts without requiring any modification of the post. The injection can be done randomly between paragraphs, and there is an option to always inject the first advert after the first paragraph. Randomly positioning the adverts helps to reduce 'ad blindness'. Two separate adverts can be defined for the top and bottom of the content. Widget adverts can be defined as well.
18
 
19
+ = Widget support =
20
 
21
  Widgets can be added to your sidebars, or other widget areas on any pages. The same ad display restrictions that you setup for your other ads will also apply to the widgets.
22
 
42
 
43
  = Flexible ad positioning =
44
 
45
+ Easy positioning options are provided for left, right, center, float left, and float right (or a random variant of these). Extra spacing can be set above and below the ad using the CSS margin and padding boxes. Or if that isn't flexible enough, you can write your own positioning code using HTML and CSS.
46
 
47
  = Works with WP Super Cache =
48
 
49
+ The dynamic features that require code to be executed for each page view (i.e. search engine visitors only, and ad blocking based on IP address) work with WP Super Cache! This plugin will automatically use the dynamic mfunc tag to ensure that the dynamic ad features still work when caching is on. Displaying the adverts (even with the dynamic restrictions) whilst caching with WP Super Cache requires no MySQL database access.
50
+
51
+ Note: If you use a version of WP Super Cache prior to 0.9.9.8 it must be configured in 'Legacy' mode for the dynamic features to work. If you use WP Super Cache 0.9.9.8 or above you can use any of the caching modes (mod_rewrite and PHP are faster than legacy).
52
 
53
  = Inject PHP and JavaScript =
54
 
60
 
61
  For more information visit [reviewmylife](http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/ "reviewmylife blog").
62
 
63
+ = Actively being developed =
64
+
65
+ As of January 2011 this plugin is being actively developed and maintained. Some major new features are planned for January / February 2011. I'm very open to implementing your feature requests.
66
+
67
  == Installation ==
68
 
69
  This section describes how to install the plugin and get it working.
136
 
137
  = Do I need to have WP Super Cache installed? =
138
 
139
+ 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 choose the option on Ad Injection to say that you are using WP Super Cache. If using a version of WP
140
 
141
  = Will the dynamic features work with other caching plugins? =
142
 
192
  = If you are using WP Super Cache. =
193
 
194
  1. Have you enabled the WP Super Cache 'mfunc' mode? (in the Ad insertion mode and dynamic ad display restrictions pane)
195
+ 2. If you use a version of WP Super Cache prior to 0.9.9.8 it must be configured in 'Legacy' mode for the dynamic features to work. If you use WP Super Cache 0.9.9.8 or above you can use any of the caching modes (mod_rewrite and PHP are faster than legacy).
196
  3. If you are using WP Minify as well then turn off the HTML minification as this strips out the mfunc tags that Ad Injection uses to check if the adverts should be inserted.
197
 
198
  = If you are using WP Minify =
232
 
233
  == Changelog ==
234
 
235
+ = 0.9.5.1 =
236
+ New CSS padding options for widgets. Fixes for CSS margin options.
237
+ Update docs for due to new mfunc support in WP Super Cache. If you are using mfunc mode and upgrade to the latest version of WP Super Cache (0.9.9.8) you can now use the faster mod_rewrite mode or PHP mode instead of legacy mode.
238
+
239
  = 0.9.5 =
240
  New option to add spacing above and below widgets.
241
  New options for randomly aligning random/top/bottom ads.
324
 
325
  == Upgrade Notice ==
326
 
327
+ = 0.9.5.1 =
328
+ New CSS padding options for widgets. Fixes for CSS margin options.
329
+ If you are using WP Super Cache 0.9.9.8 you can now switch to its faster mod_rewrite or PHP modes.
330
+
331
  = 0.9.5 =
332
  New spacing/alignment options, and misc fixes.
333