Ad Injection - Version 0.9.7.5

Version Description

  • Simplify the ad insertion modes. Replace the two previous direct modes with one.
  • Other minor bug fixes.
Download this release

Release Info

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

Code changes from version 0.9.7.4 to 0.9.7.5

ad-injection-admin.php CHANGED
@@ -69,7 +69,7 @@ function adinj_save_options(){
69
 
70
  adinj_update_options($ops);
71
 
72
- if ($ops['ad_insertion_mode'] == 'mfunc') {
73
  adinj_write_config_file();
74
  }
75
 
@@ -120,7 +120,7 @@ function extract_text_args($name, &$ops, $start=NULL, $end=NULL, $save_path_stem
120
  // still be referenced by adshow.
121
  function adinj_write_config_file(){
122
  $ops = adinj_options();
123
- if ($ops['ad_insertion_mode'] != 'mfunc') return;
124
 
125
  $sevisitors_only = adinj_ticked('sevisitors_only')?'true':'false';
126
  $referrer_list = adinj_quote_list('ad_referrers');
@@ -308,9 +308,9 @@ function adinj_top_message_box(){
308
  }
309
  echo '</strong>';
310
  if ($ops['debug_mode']=='on' && $ops['ads_enabled'] == 'on'){
311
- echo "<br /><b>Recommendation:</b> Turn <a href='#debugging'>debug mode off</a> once you have got your ads working.";
312
  }
313
- if ($ops['ad_insertion_mode']=='mfunc'){
314
  if (!is_supported_caching_plugin_active()){
315
  echo "<br /><b>Recommendation:</b> It looks like you don't have a supported caching plugin (WP Super Cache, W3 Total Cache or WP Cache) active. Therefore one of the <a href='#restrictions'>direct insertion modes</a> might be better for you.";
316
  }
@@ -322,16 +322,16 @@ function adinj_top_message_box(){
322
  }
323
  global $adinj_warning_msg_chmod;
324
  if (!empty($adinj_warning_msg_chmod)){
325
- echo '<br />Info: Some warnings were generated by chmod. See the <a href="#debugging">debugging</a> section for more info.';
326
  }
327
  if ($ops['ads_enabled'] != 'on'){
328
  echo '<br /><font color="red">Warning: Ads are not enabled. You need to turn the ads on for everyone to see them.</font>';
329
  }
330
  echo '</p></div>';
331
 
332
- } else {
333
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
334
- echo "1st March 2011: <font color='red'>If you are one of the people whose top/bottom ads have dissapeared with the 0.9.7.x release I'm very sorry - I hope this release will fix it. If it doesn't please email me a link via the <a href='".adinj_feedback_url()."' target='_new'>quick feedback form</a> to one of your affected pages.</font> There are a some other bugs I've found whilst fixing this, I'll hopefully get them fixed this week/next week.<br />Archives and home ads now fully supported - you can add top/random/bottom ads to them. Big UI updates to support this. And fixes for when/where widget ads appear. I'd recommend you re-check that your ads appear where you expect them to. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>.';
335
  echo '</strong></p></div>';
336
  }
337
  }
@@ -809,7 +809,7 @@ function adinj_problem_with_wpminify_check(){
809
  if (!is_plugin_active('wp-minify/wp-minify.php')) return false;
810
  $wpm_options = get_option('wp_minify');
811
  $ops = adinj_options();
812
- if ($wpm_options['enable_html'] == true && $ops['ad_insertion_mode'] == 'mfunc'){
813
  return true;
814
  }
815
  return false;
@@ -1022,10 +1022,10 @@ function adinj_install_db(){
1022
  $new_options = adinj_default_options();
1023
  // Dynamic defaults.
1024
  if (!is_supported_caching_plugin_active()){
1025
- $new_options['ad_insertion_mode'] = 'direct_dynamic';
1026
  }
1027
  adinj_update_options($new_options);
1028
- if ($new_options['ad_insertion_mode'] == 'mfunc'){
1029
  // Create config file.
1030
  adinj_write_config_file();
1031
  }
@@ -1072,6 +1072,17 @@ function adinj_upgrade_db(){
1072
  if ($stored_dbversion < 6){
1073
  $new_options['home_max_num_random_ads_per_page'] = $stored_options['max_num_of_ads_home_page'];
1074
  }
 
 
 
 
 
 
 
 
 
 
 
1075
 
1076
  // 3. Bump up db version number.
1077
  $new_options['db_version'] = $new_dbversion;
69
 
70
  adinj_update_options($ops);
71
 
72
+ if (adinj_mfunc_mode()) {
73
  adinj_write_config_file();
74
  }
75
 
120
  // still be referenced by adshow.
121
  function adinj_write_config_file(){
122
  $ops = adinj_options();
123
+ if (!adinj_mfunc_mode()) return;
124
 
125
  $sevisitors_only = adinj_ticked('sevisitors_only')?'true':'false';
126
  $referrer_list = adinj_quote_list('ad_referrers');
308
  }
309
  echo '</strong>';
310
  if ($ops['debug_mode']=='on' && $ops['ads_enabled'] == 'on'){
311
+ echo "<br /><b>Recommendation:</b> Turn <a href='?page=ad-injection&amp;tab=debug#debugging'>debug mode off</a> once you have got your ads working.";
312
  }
313
+ if (adinj_mfunc_mode()){
314
  if (!is_supported_caching_plugin_active()){
315
  echo "<br /><b>Recommendation:</b> It looks like you don't have a supported caching plugin (WP Super Cache, W3 Total Cache or WP Cache) active. Therefore one of the <a href='#restrictions'>direct insertion modes</a> might be better for you.";
316
  }
322
  }
323
  global $adinj_warning_msg_chmod;
324
  if (!empty($adinj_warning_msg_chmod)){
325
+ echo '<br />Info: Some warnings were generated by chmod. See the <a href="?page=ad-injection&amp;tab=debug#debugging">debugging</a> section for more info.';
326
  }
327
  if ($ops['ads_enabled'] != 'on'){
328
  echo '<br /><font color="red">Warning: Ads are not enabled. You need to turn the ads on for everyone to see them.</font>';
329
  }
330
  echo '</p></div>';
331
 
332
+ } else if (!isset($_GET['tab'])){
333
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
334
+ echo "3rd March 2011: This update simplifies the ad insertion modes. Instead of two direct modes there is now just one. There is the same functionality as before, but now with less options. If you were previously using direct_static mode then you should verify that everything still works as you expect. Plus other minor fixes. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>.';
335
  echo '</strong></p></div>';
336
  }
337
  }
809
  if (!is_plugin_active('wp-minify/wp-minify.php')) return false;
810
  $wpm_options = get_option('wp_minify');
811
  $ops = adinj_options();
812
+ if ($wpm_options['enable_html'] == true && adinj_mfunc_mode()){
813
  return true;
814
  }
815
  return false;
1022
  $new_options = adinj_default_options();
1023
  // Dynamic defaults.
1024
  if (!is_supported_caching_plugin_active()){
1025
+ $new_options['ad_insertion_mode'] = 'direct';
1026
  }
1027
  adinj_update_options($new_options);
1028
+ if (adinj_mfunc_mode()){
1029
  // Create config file.
1030
  adinj_write_config_file();
1031
  }
1072
  if ($stored_dbversion < 6){
1073
  $new_options['home_max_num_random_ads_per_page'] = $stored_options['max_num_of_ads_home_page'];
1074
  }
1075
+
1076
+ if ($stored_dbversion < 9){
1077
+ if ($stored_options['ad_insertion_mode'] == 'direct_static'){
1078
+ $new_options['ad_insertion_mode'] = 'direct';
1079
+ $new_options['block_ips'] = 'off';
1080
+ $new_options['sevisitors_only'] = 'off';
1081
+ }
1082
+ if ($stored_options['ad_insertion_mode'] == 'direct_dynamic'){
1083
+ $new_options['ad_insertion_mode'] = 'direct';
1084
+ }
1085
+ }
1086
 
1087
  // 3. Bump up db version number.
1088
  $new_options['db_version'] = $new_dbversion;
ad-injection-widget.php CHANGED
@@ -40,7 +40,7 @@ class Ad_Injection_Widget extends WP_Widget {
40
  $ops = adinj_options();
41
 
42
  $include = "";
43
- if ($ops['ad_insertion_mode'] == 'mfunc'){
44
  $include = adinj_ad_code_include();
45
  }
46
 
40
  $ops = adinj_options();
41
 
42
  $include = "";
43
+ if (adinj_mfunc_mode()){
44
  $include = adinj_ad_code_include();
45
  }
46
 
ad-injection.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ad Injection
4
  Plugin URI: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
5
  Description: Injects any advert (e.g. AdSense) into your WordPress posts or widget area. Restrict who sees the ads by post length, age, referrer or IP. Cache compatible.
6
- Version: 0.9.7.4
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
@@ -25,7 +25,8 @@ define('ADINJ_NO_CONFIG_FILE', 1);
25
  // 6 = archive/home options
26
  // 7 = cat/tag/author restriction for top/random/bottom ads
27
  // 8 = ui options for new layout
28
- define('ADINJ_DB_VERSION', 8);
 
29
 
30
  // Files
31
  // TODO will these paths work on windows?
@@ -138,7 +139,7 @@ function adinj_get_ad_code($adtype, $ads_db){
138
  $alt_live = NULL;
139
  $alt_split = NULL;
140
  $formatting = NULL;
141
- if ($ops['ad_insertion_mode'] == 'mfunc'){
142
  adinj_live_ads_array($adtype, $ads_db, $ads_live, $ads_split, 'string');
143
  if (adinj_db_version($ads_db) >= 2){
144
  adinj_live_ads_array($adtype.'_alt', $ads_db, $alt_live, $alt_split, 'string');
@@ -158,7 +159,7 @@ function adinj_get_ad_code($adtype, $ads_db){
158
  if (empty($ads_live) && empty($alt_live)){
159
  return "";
160
  }
161
- if ($ops['ad_insertion_mode'] == 'mfunc'){
162
  return adinj_ad_code_eval("\n
163
  <!--mfunc adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)) -->
164
  <?php adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)); ?>
@@ -167,7 +168,7 @@ function adinj_get_ad_code($adtype, $ads_db){
167
  }
168
 
169
  // else dynamic ad
170
- if ($ops['ad_insertion_mode'] == 'direct_dynamic' && adshow_show_adverts() !== true){
171
  $adname = adshow_pick_value($alt_live, $alt_split);
172
  } else {
173
  $adname = adshow_pick_value($ads_live, $ads_split);
@@ -314,19 +315,17 @@ function adinj_ad_code_eval($ad){
314
 
315
  function adinj_ad_code_include(){
316
  $plugin_dir = ADINJ_PATH;
317
- $ops = adinj_options();
318
- $ad = "";
319
- if ($ops['ad_insertion_mode'] == 'mfunc'){
320
  // WP Super Cache's support for mclude assumes that we will be including
321
  // files from within ABSPATH. To remove this limitation we do the include
322
  // using mfunc instead.
323
- $ad = "\n
324
  <!--mfunc include_once('$plugin_dir/adshow.php') -->
325
  <?php include_once('$plugin_dir/adshow.php'); ?>
326
  <!--/mfunc-->
327
- ";
328
  }
329
- return adinj_ad_code_eval($ad);
330
  }
331
 
332
  function read_ad_from_file($ad_path){
@@ -547,11 +546,14 @@ function adinj_split_comma_list($list){
547
 
548
  function adinj_inject_hook($content){
549
  if (is_feed()) return $content; // TODO feed specific ads
550
-
551
  $ops = adinj_options();
552
  if(empty($ops)){
553
  return $content;
554
  }
 
 
 
555
  adinj_upgrade_db_if_necessary();
556
 
557
  global $adinj_total_all_ads_used, $adinj_total_random_ads_used, $adinj_total_top_ads_used, $adinj_total_bottom_ads_used;
@@ -572,7 +574,7 @@ function adinj_inject_hook($content){
572
  $debug_on = $ops['debug_mode'];
573
  $debug = "";
574
 
575
- if ($debug_on && $ops['ad_insertion_mode'] == 'direct_dynamic'){
576
  $showads = adshow_show_adverts();
577
  if ($showads !== true){
578
  $debug .= "\nNOADS: ad blocked at run time reason=$showads";
@@ -580,7 +582,7 @@ function adinj_inject_hook($content){
580
  }
581
 
582
  $ad_include = "";
583
- if ($ops['ad_insertion_mode'] == 'mfunc'){
584
  $ad_include = adinj_ad_code_include();
585
  }
586
 
@@ -868,6 +870,16 @@ function adinj_do_rule_if($rule_value, $condition, $content_length){
868
  }
869
  }
870
 
 
 
 
 
 
 
 
 
 
 
871
  function adinj_disabled($value){
872
  return "$value" == ADINJ_RULE_DISABLED || "$value" == ADINJ_DISABLED || "$value" == 'd' || "$value" == '';
873
  }
3
  Plugin Name: Ad Injection
4
  Plugin URI: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
5
  Description: Injects any advert (e.g. AdSense) into your WordPress posts or widget area. Restrict who sees the ads by post length, age, referrer or IP. Cache compatible.
6
+ Version: 0.9.7.5
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
25
  // 6 = archive/home options
26
  // 7 = cat/tag/author restriction for top/random/bottom ads
27
  // 8 = ui options for new layout
28
+ // 9 = replace the two direct modes with 'direct'
29
+ define('ADINJ_DB_VERSION', 9);
30
 
31
  // Files
32
  // TODO will these paths work on windows?
139
  $alt_live = NULL;
140
  $alt_split = NULL;
141
  $formatting = NULL;
142
+ if (adinj_mfunc_mode()){
143
  adinj_live_ads_array($adtype, $ads_db, $ads_live, $ads_split, 'string');
144
  if (adinj_db_version($ads_db) >= 2){
145
  adinj_live_ads_array($adtype.'_alt', $ads_db, $alt_live, $alt_split, 'string');
159
  if (empty($ads_live) && empty($alt_live)){
160
  return "";
161
  }
162
+ if (adinj_mfunc_mode()){
163
  return adinj_ad_code_eval("\n
164
  <!--mfunc adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)) -->
165
  <?php adshow_display_ad_file_v2(array($ads_live), array($ads_split), array($formatting), array($alt_live), array($alt_split)); ?>
168
  }
169
 
170
  // else dynamic ad
171
+ if (adshow_show_adverts() !== true){
172
  $adname = adshow_pick_value($alt_live, $alt_split);
173
  } else {
174
  $adname = adshow_pick_value($ads_live, $ads_split);
315
 
316
  function adinj_ad_code_include(){
317
  $plugin_dir = ADINJ_PATH;
318
+ if (adinj_mfunc_mode()){
 
 
319
  // WP Super Cache's support for mclude assumes that we will be including
320
  // files from within ABSPATH. To remove this limitation we do the include
321
  // using mfunc instead.
322
+ return adinj_ad_code_eval("\n
323
  <!--mfunc include_once('$plugin_dir/adshow.php') -->
324
  <?php include_once('$plugin_dir/adshow.php'); ?>
325
  <!--/mfunc-->
326
+ ");
327
  }
328
+ return "";
329
  }
330
 
331
  function read_ad_from_file($ad_path){
546
 
547
  function adinj_inject_hook($content){
548
  if (is_feed()) return $content; // TODO feed specific ads
549
+ if (!in_the_loop()) return $content; // Don't insert ads into meta description tags TODOTODO
550
  $ops = adinj_options();
551
  if(empty($ops)){
552
  return $content;
553
  }
554
+ $debug_on = $ops['debug_mode'];
555
+ if ($debug_on) echo "<!--adinj_inject_hook-->";
556
+
557
  adinj_upgrade_db_if_necessary();
558
 
559
  global $adinj_total_all_ads_used, $adinj_total_random_ads_used, $adinj_total_top_ads_used, $adinj_total_bottom_ads_used;
574
  $debug_on = $ops['debug_mode'];
575
  $debug = "";
576
 
577
+ if ($debug_on && adinj_direct_mode()){
578
  $showads = adshow_show_adverts();
579
  if ($showads !== true){
580
  $debug .= "\nNOADS: ad blocked at run time reason=$showads";
582
  }
583
 
584
  $ad_include = "";
585
+ if (adinj_mfunc_mode()){
586
  $ad_include = adinj_ad_code_include();
587
  }
588
 
870
  }
871
  }
872
 
873
+ function adinj_direct_mode(){
874
+ $ops = adinj_options();
875
+ return ($ops['ad_insertion_mode'] != 'mfunc');
876
+ }
877
+
878
+ function adinj_mfunc_mode(){
879
+ $ops = adinj_options();
880
+ return ($ops['ad_insertion_mode'] == 'mfunc');
881
+ }
882
+
883
  function adinj_disabled($value){
884
  return "$value" == ADINJ_RULE_DISABLED || "$value" == ADINJ_DISABLED || "$value" == 'd' || "$value" == '';
885
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-w
4
  Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, widgets, sidebar, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free, blog, ad rotation, A:B testing, split testing, WP Super Cache, W3 Total Cache, WP Cache
5
  Requires at least: 2.8.6
6
  Tested up to: 3.1
7
- Stable tag: 0.9.7.4
8
 
9
  Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
10
 
@@ -59,7 +59,7 @@ IP addresses of people who shouldn't see your ads can be defined. These could be
59
 
60
  = Alternate content =
61
 
62
- This is content that is displayed when ads are blocked for the user. Ads can only be blocked for specific users if you use one of the dynamic modes (mfunc or direct_dynamic). You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.
63
 
64
  = Not tied to any ad provider =
65
 
@@ -183,9 +183,9 @@ The dynamic features will work with any caching program that supports the mfunc
183
 
184
  Both WP Super Cache and W3 Total Cache are likely to be faster than WP Cache.
185
 
186
- If you aren't using the dynamic features (and you are using direct_static mode) then the only way to find out which is best between WP Super Cache and W3 Total Cache is to measure the performance yourself, as the speed depends on many factors that will be unique to your web server and web site.
187
 
188
- If you are using dynamic features (i.e. with mfunc mode) then WP Super Cache (in mod_rewrite mode) and W3 Total Cache (in Page Cache: Disk (basic) mode) are likely to offer similar performance as they both return the dynamic files via PHP.
189
 
190
  Note that W3 Total Cache will not cache pages with mfunc tags if you use the Page Cache: Disk (enhanced) mode.
191
 
@@ -273,7 +273,7 @@ This is John's Ad.
273
  This is Paul's Ad.
274
  <?php } ?>`
275
 
276
- Note this will only work in direct insertion mode. It won�t work in mfunc mode!
277
 
278
  = How can I show different ads to people in different countries? =
279
 
@@ -372,6 +372,10 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
372
 
373
  == Changelog ==
374
 
 
 
 
 
375
  = 0.9.7.4 =
376
  * UI fixes.
377
 
@@ -513,8 +517,8 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
513
 
514
  == Upgrade Notice ==
515
 
516
- = 0.9.7.4 =
517
- * Fix (hopefully) for the disappearing top/bottom adverts that affected some users of v0.9.7 - v0.9.7.2.
518
 
519
  = 0.8.3 =
520
  First public release.
4
  Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, widgets, sidebar, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free, blog, ad rotation, A:B testing, split testing, WP Super Cache, W3 Total Cache, WP Cache
5
  Requires at least: 2.8.6
6
  Tested up to: 3.1
7
+ Stable tag: 0.9.7.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
 
59
 
60
  = Alternate content =
61
 
62
+ This is content that is displayed when ads are blocked for the user. You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.
63
 
64
  = Not tied to any ad provider =
65
 
183
 
184
  Both WP Super Cache and W3 Total Cache are likely to be faster than WP Cache.
185
 
186
+ If you aren't using the dynamic features then the only way to find out which is best between WP Super Cache and W3 Total Cache is to measure the performance yourself, as the speed depends on many factors that will be unique to your web server and web site.
187
 
188
+ If you are using dynamic features with mfunc mode then WP Super Cache (in mod_rewrite mode) and W3 Total Cache (in Page Cache: Disk (basic) mode) are likely to offer similar performance as they both return the dynamic files via PHP.
189
 
190
  Note that W3 Total Cache will not cache pages with mfunc tags if you use the Page Cache: Disk (enhanced) mode.
191
 
273
  This is Paul's Ad.
274
  <?php } ?>`
275
 
276
+ Note this will only work in direct insertion mode. It won�t work in mfunc mode unless you also load in the WordPress database dependencies.
277
 
278
  = How can I show different ads to people in different countries? =
279
 
372
 
373
  == Changelog ==
374
 
375
+ = 0.9.7.5 =
376
+ * Simplify the ad insertion modes. Replace the two previous direct modes with one.
377
+ * Other minor bug fixes.
378
+
379
  = 0.9.7.4 =
380
  * UI fixes.
381
 
517
 
518
  == Upgrade Notice ==
519
 
520
+ = 0.9.7.5 =
521
+ * Simplify ad insertion modes. Replace the two direct modes with one.
522
 
523
  = 0.8.3 =
524
  First public release.
ui-tab-adrotation.php CHANGED
@@ -33,7 +33,7 @@ DOCS;
33
  <p>Ad rotation / split testing and alternate content are advanced features. If you don't understand these features you probably don't need them and can therefore ignore this tab. In summary:</p>
34
  <ul>
35
  <li><b>Ad rotation / split testing:</b> You can define multiple adverts for the same ad space which are rotated according to the ratios you define. The percentage of views that each ad will be shows is displated beneath the ratio text box. For example if you define two ads and set both to have a ratio of '50' they will each be shown (roughly) 50% of the time. The numbers don't have to add up to 100 as the ratio is calculated based on the total. e.g. if you have two advert - one is set with a ratio of '1' and the other '3' the ratios will be 25% and 75%. Please remember this isn't strict ad rotation, it is random selection based on ratios so the ratios will be correct over a large sample of ad views, not a small sample.</li>
36
- <li><b>Alternate content:</b> This is content that is displayed when ads are blocked for the user. Ads can only be blocked for specific users if you use one of the dynamic modes (mfunc or direct_dynamic). You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.</li>
37
  </ul>
38
  DOCS;
39
  adinj_postbox_end();
33
  <p>Ad rotation / split testing and alternate content are advanced features. If you don't understand these features you probably don't need them and can therefore ignore this tab. In summary:</p>
34
  <ul>
35
  <li><b>Ad rotation / split testing:</b> You can define multiple adverts for the same ad space which are rotated according to the ratios you define. The percentage of views that each ad will be shows is displated beneath the ratio text box. For example if you define two ads and set both to have a ratio of '50' they will each be shown (roughly) 50% of the time. The numbers don't have to add up to 100 as the ratio is calculated based on the total. e.g. if you have two advert - one is set with a ratio of '1' and the other '3' the ratios will be 25% and 75%. Please remember this isn't strict ad rotation, it is random selection based on ratios so the ratios will be correct over a large sample of ad views, not a small sample.</li>
36
+ <li><b>Alternate content:</b> This is content that is displayed when ads are blocked for the user. You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.</li>
37
  </ul>
38
  DOCS;
39
  adinj_postbox_end();
ui-tab-main.php CHANGED
@@ -141,7 +141,7 @@ function adinj_tab_main(){
141
  <tr><td colspan="4">
142
  <?php
143
  _e("Always put the first ad immediately after paragraph: ", 'adinj');
144
- adinj_selection_box("start_from_paragraph", array(ADINJ_RULE_DISABLED,1,2,3,4,5), " ");
145
  ?>
146
  </td></tr>
147
  <tr><td colspan="4">
@@ -233,17 +233,18 @@ function adinj_tab_main(){
233
  <?php adinj_postbox_start(__("Ad insertion mode and dynamic ad display restrictions", 'adinj'), 'restrictions'); ?>
234
  <h4>Ad insertion mode</h4>
235
  <blockquote>
236
- <p><input type="radio" name="ad_insertion_mode" value="mfunc" <?php if ($ops['ad_insertion_mode']=='mfunc') echo 'checked="checked"'; ?> /> <b>mfunc: Use mfunc tags for dynamic features</b> - Dynamic features will work with WP Super Cache, W3 Total Cache and WP Cache. Only select this mode if you are using one of those caching plugins.</p>
237
  <?php if (!is_supported_caching_plugin_active()) {
238
  echo '<p><b><span style="font-size:10px;color:red;">Note: A supported caching plugin does not appear to be active. If you are not using WP Super Cache / W3 Total Cache / WP Cache you should use one of the direct insertion modes below.</span></b></p>';
239
  } ?>
240
 
241
- <?php if ($ops['ad_insertion_mode'] != 'mfunc') { ?>
242
  <script type="text/javascript">
243
  document.write('<style type="text/css" media="screen">#caching_plugin_msg { display: none; }</style>');
244
  </script>
245
  <?php } ?>
246
-
 
247
  <div id="caching_plugin_msg" class="caching_plugin_msg">
248
  <?php
249
  if (is_plugin_active('wp-super-cache/wp-cache.php')){
@@ -255,11 +256,11 @@ function adinj_tab_main(){
255
  }
256
  adinj_unknown_cache_msg();
257
  ?>
258
-
259
  </div>
260
 
261
- <p><input type="radio" name="ad_insertion_mode" value="direct_dynamic" <?php if ($ops['ad_insertion_mode']=='direct_dynamic') echo 'checked="checked"'; ?> /> <b>direct_dynamic: 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>
262
- <p><input type="radio" name="ad_insertion_mode" value="direct_static" <?php if ($ops['ad_insertion_mode']=='direct_static') echo 'checked="checked"'; ?> /> <b><strike>direct_static: Direct static ad insertion</strike></b> - <font color="red">Warning: This mode will be removed very soon (March 2011). There will only be an 'mfunc' and a 'direct' mode to simplify things. I recommend you switch to 'direct_dynamic' if you are using this mode. If you aren't using dynamic features make sure the tick boxes below are unticked.</font> No dynamic feature support. Select this if you are are not using dynamic features or are using an incompatible caching plugin.</p>
 
263
  </blockquote>
264
  </div>
265
  <p></p>
@@ -267,42 +268,17 @@ function adinj_tab_main(){
267
  <script type="text/javascript">
268
  jQuery(document).ready(function(){
269
  jQuery('input[name=ad_insertion_mode]:radio').change(function() {
270
- if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
271
- jQuery('.dynamic_features').slideUp(1000);
272
- jQuery('.dynamic_features_msg').slideDown(1000);
273
- jQuery('.caching_plugin_msg').slideUp(1000);
274
- } else if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_dynamic"){
275
- jQuery('.dynamic_features_msg').slideUp(1000);
276
- jQuery('.dynamic_features').slideDown(1000);
277
- jQuery('.caching_plugin_msg').slideUp(1000);
278
  } else { // mfunc
279
- jQuery('.dynamic_features_msg').slideUp(1000);
280
- jQuery('.dynamic_features').slideDown(1000);
281
- jQuery('.caching_plugin_msg').slideDown(1000);
282
  }
283
  return true;
284
  });
285
  });
286
  </script>
287
 
288
- <?php if ($ops['ad_insertion_mode'] != 'direct_static') { ?>
289
- <script type="text/javascript">
290
- document.write('<style type="text/css" media="screen">#dynamic_features_msg { display: none; }</style>');
291
- </script>
292
- <?php } ?>
293
- <div id="dynamic_features_msg" class="dynamic_features_msg">
294
- <div class="inside" style="margin:10px">
295
- <blockquote><b><span style="font-size:10px;color:red;">Note: Dynamic ad blocking features (restricting ad views by referrer or IP address) are only available in the mfunc, or direct_dynamic modes.</span></b>
296
- </blockquote>
297
- </div>
298
- </div>
299
 
300
- <?php if ($ops['ad_insertion_mode'] == 'direct_static') { ?>
301
- <script type="text/javascript">
302
- document.write('<style type="text/css" media="screen">#dynamic_features { display: none; }</style>');
303
- </script>
304
- <?php } ?>
305
- <div id="dynamic_features" class="dynamic_features">
306
  <div class="inside" style="margin:10px">
307
  <h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
308
 
@@ -325,7 +301,6 @@ function adinj_tab_main(){
325
  </blockquote>
326
  </div>
327
 
328
- </div>
329
 
330
  <?php adinj_postbox_end(); ?>
331
 
141
  <tr><td colspan="4">
142
  <?php
143
  _e("Always put the first ad immediately after paragraph: ", 'adinj');
144
+ adinj_selection_box("start_from_paragraph", array(ADINJ_RULE_DISABLED,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20), " ");
145
  ?>
146
  </td></tr>
147
  <tr><td colspan="4">
233
  <?php adinj_postbox_start(__("Ad insertion mode and dynamic ad display restrictions", 'adinj'), 'restrictions'); ?>
234
  <h4>Ad insertion mode</h4>
235
  <blockquote>
236
+ <input type="radio" name="ad_insertion_mode" value="mfunc" <?php if (adinj_mfunc_mode()) echo 'checked="checked"'; ?> /> <b>mfunc: Insert ads using cache compatible mfunc tags</b> - Dynamic features will work with WP Super Cache, W3 Total Cache and WP Cache. Only select this mode if you are using one of those caching plugins and want to use dynamic features (IP / referrer restriction, alt content and ad roatation). If you aren't using dynamic features select direct mode.
237
  <?php if (!is_supported_caching_plugin_active()) {
238
  echo '<p><b><span style="font-size:10px;color:red;">Note: A supported caching plugin does not appear to be active. If you are not using WP Super Cache / W3 Total Cache / WP Cache you should use one of the direct insertion modes below.</span></b></p>';
239
  } ?>
240
 
241
+ <?php if (!adinj_mfunc_mode()) { ?>
242
  <script type="text/javascript">
243
  document.write('<style type="text/css" media="screen">#caching_plugin_msg { display: none; }</style>');
244
  </script>
245
  <?php } ?>
246
+ <br />
247
+
248
  <div id="caching_plugin_msg" class="caching_plugin_msg">
249
  <?php
250
  if (is_plugin_active('wp-super-cache/wp-cache.php')){
256
  }
257
  adinj_unknown_cache_msg();
258
  ?>
 
259
  </div>
260
 
261
+ <br />
262
+
263
+ <input type="radio" name="ad_insertion_mode" value="direct" <?php if (adinj_direct_mode()) echo 'checked="checked"'; ?> /> <b>direct: Direct ad code insertion</b> - Select this if you are not using an mfunc compatible caching plugin OR if you are not using the dynamic features.<br />
264
  </blockquote>
265
  </div>
266
  <p></p>
268
  <script type="text/javascript">
269
  jQuery(document).ready(function(){
270
  jQuery('input[name=ad_insertion_mode]:radio').change(function() {
271
+ if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct"){
272
+ jQuery('.caching_plugin_msg').slideUp(300);
 
 
 
 
 
 
273
  } else { // mfunc
274
+ jQuery('.caching_plugin_msg').slideDown(300);
 
 
275
  }
276
  return true;
277
  });
278
  });
279
  </script>
280
 
 
 
 
 
 
 
 
 
 
 
 
281
 
 
 
 
 
 
 
282
  <div class="inside" style="margin:10px">
283
  <h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
284
 
301
  </blockquote>
302
  </div>
303
 
 
304
 
305
  <?php adinj_postbox_end(); ?>
306