Ad Injection - Version 0.9.6.2

Version Description

  • Support for W3 Total Cache and WP Cache (as well as the already supported WP Super Cache).
Download this release

Release Info

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

Code changes from version 0.9.6.1 to 0.9.6.2

Files changed (4) hide show
  1. ad-injection-admin.php +52 -14
  2. ad-injection.php +1 -1
  3. readme.txt +41 -33
  4. ui-tab-main.php +64 -24
ad-injection-admin.php CHANGED
@@ -254,8 +254,12 @@ function adinj_top_message_box(){
254
  if (isset($_POST['adinj_action'])) {
255
  echo '<div id="message" class="updated below-h2"><p><strong>';
256
  echo 'All settings saved: ';
257
- if (is_plugin_active('wp-super-cache/wp-cache.php')) {
258
  echo "You might need to <a href='options-general.php?page=wpsupercache&amp;tab=tester'>clear your WP Super Cache cache</a> for the settings to take effect.";
 
 
 
 
259
  } else {
260
  echo "If you are using a caching plugin you might need to delete its cache for any changes to take effect.";
261
  }
@@ -278,7 +282,7 @@ function adinj_top_message_box(){
278
 
279
  } else {
280
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
281
- echo "21st January 2011: This is a big update introducing support for split testing / ad rotation. And also 'alternate content' as well as other fixes and updates. I've done my best to test this update but as the update is big there is a risk of problems. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">feedback form</a>.';
282
  echo '</strong></p></div>';
283
  }
284
  }
@@ -293,9 +297,9 @@ function adinj_side_info_box(){
293
  <div class="inside" style="margin:5px;">
294
  <h4>More Ad Injection information</h4>
295
  <ul>
 
296
  <li><a href="http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/" target="_new">Ad Injection at reviewmylife</a></li>
297
- <li><a href="http://wordpress.org/extend/plugins/ad-injection/" target="_new">Ad Injection at WordPress</a></li>
298
- <li><b><a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">Report a bug / give feedback</a></b></li>
299
  </ul>
300
  <h4>Coming in 2011</h4>
301
  <ul>
@@ -322,6 +326,11 @@ function adinj_side_info_box(){
322
  <?php
323
  }
324
 
 
 
 
 
 
325
  function adinj_add_checkbox($name){
326
  echo '<input type="hidden" name="'.$name.'" value="off" />';
327
  echo '<input type="checkbox" name="'.$name.'" '.adinj_ticked($name).' />';
@@ -359,17 +368,36 @@ function adinj_postbox_start($title, $anchor, $width='650px'){
359
  <div class="metabox-holder">
360
  <div class="postbox">
361
  <input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
362
- <div class="<?php echo $anchor; ?>-button"></div>
 
 
 
 
 
363
  <script type="text/javascript">
 
364
  jQuery(document).ready(function(){
365
- jQuery('.<?php echo $anchor; ?>-button').show().before('<a href="#" style="float:right" id="toggle-<?php echo $anchor; ?>" class="button">Show/Hide</a>');
366
- jQuery('a#toggle-<?php echo $anchor; ?>').click(function() {
367
- jQuery('#ui_<?php echo $anchor; ?>_hide').val(!jQuery('.<?php echo $anchor; ?>-box').is(":hidden"));
368
- jQuery('.<?php echo $anchor; ?>-box').slideToggle(1000);
369
- return false;
370
- });
371
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  </script>
 
 
373
  <input type='hidden' id='ui_<?php echo $anchor; ?>_hide' name='ui_<?php echo $anchor; ?>_hide' value='<?php echo $ops['ui_'.$anchor.'_hide']; ?>' />
374
  <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>
375
  <?php if($ops['ui_'.$anchor.'_hide'] == 'true'){ ?>
@@ -716,14 +744,15 @@ function adinj_get_version(){
716
 
717
  function adinj_problem_with_wpminify_check(){
718
  $wpm_options = get_option('wp_minify');
719
- if ($wpm_options['enable_html'] == true && is_plugin_active('wp-super-cache/wp-cache.php')){
 
720
  return true;
721
  }
722
  return false;
723
  }
724
 
725
  function adinj_get_problem_with_wpminify_message(){
726
- return '<font color="red">Problem: Ad Injection will not work if WP Minify is set to minify HTML whilst WP Super Cache is enabled.</font><br />
727
  Solution: Go to <a href="options-general.php?page=wp-minify">the WP Minify settings page</a> and untick "Enable HTML Minification".';
728
  }
729
 
@@ -749,6 +778,15 @@ function adinj_compatibility_checks() {
749
  }
750
  }
751
 
 
 
 
 
 
 
 
 
 
752
  //////////////////////////////////////////////////////////////////////////////
753
 
754
  function adinj_percentage_split($name_stem, $num, $ops, $total=NULL){
@@ -822,7 +860,7 @@ function adinj_activate_hook(){
822
  function adinj_install_db(){
823
  $new_options = adinj_default_options();
824
  // Dynamic defaults.
825
- if (!is_plugin_active('wp-super-cache/wp-cache.php')){
826
  $new_options['ad_insertion_mode'] = 'direct_dynamic';
827
  }
828
  adinj_update_options($new_options);
254
  if (isset($_POST['adinj_action'])) {
255
  echo '<div id="message" class="updated below-h2"><p><strong>';
256
  echo 'All settings saved: ';
257
+ if (is_plugin_active('wp-super-cache/wp-cache.php')){
258
  echo "You might need to <a href='options-general.php?page=wpsupercache&amp;tab=tester'>clear your WP Super Cache cache</a> for the settings to take effect.";
259
+ } else if (is_plugin_active('w3-total-cache/w3-total-cache.php')){
260
+ echo "You might need to <a href='options-general.php?page=w3tc_general'>clear your cache</a> for the settings to take effect.";
261
+ } else if (is_plugin_active('wp-cache/wp-cache.php')){
262
+ echo "You might need to <a href='options-general.php?page=wp-cache/wp-cache'>clear your cache</a> for the settings to take effect.";
263
  } else {
264
  echo "If you are using a caching plugin you might need to delete its cache for any changes to take effect.";
265
  }
282
 
283
  } else {
284
  echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
285
+ echo "22nd January 2011: Yesterday saw a big update introducing support for split testing / ad rotation. And also 'alternate content' as well as other fixes and updates. Today is support for W3 Total Cache and WP Cache (although for dynamic features I recommend WP Super Cache). Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">feedback form</a>.';
286
  echo '</strong></p></div>';
287
  }
288
  }
297
  <div class="inside" style="margin:5px;">
298
  <h4>More Ad Injection information</h4>
299
  <ul>
300
+ <li><a href="http://wordpress.org/extend/plugins/ad-injection/" target="_new">Ad Injection at WordPress (docs, FAQ)</a></li>
301
  <li><a href="http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/" target="_new">Ad Injection at reviewmylife</a></li>
302
+ <li><b><a href="<?php echo adinj_feedback_url(); ?>" target="_new">Report a bug / give feedback</a></b></li>
 
303
  </ul>
304
  <h4>Coming in 2011</h4>
305
  <ul>
326
  <?php
327
  }
328
 
329
+ function adinj_feedback_url(){
330
+ return "https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ";
331
+ //return "https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ&amp;entry_1=test";
332
+ }
333
+
334
  function adinj_add_checkbox($name){
335
  echo '<input type="hidden" name="'.$name.'" value="off" />';
336
  echo '<input type="checkbox" name="'.$name.'" '.adinj_ticked($name).' />';
368
  <div class="metabox-holder">
369
  <div class="postbox">
370
  <input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
371
+ <?php
372
+ $anchorclick = $anchor.'_click';
373
+ $anchorupdate = $anchor.'_update';
374
+ $anchorhide = 'ui_'.$anchor.'_hide';
375
+ echo <<<HTML
376
+ <a href="#" onclick='javascript:$anchorclick();return false;' style="float:right;display:none" id="toggle-$anchor" class="button">Show/Hide</a>
377
  <script type="text/javascript">
378
+
379
  jQuery(document).ready(function(){
380
+ $anchorupdate();
381
+ jQuery('#toggle-$anchor').show();
 
 
 
 
382
  });
383
+
384
+ function $anchorclick(){
385
+ jQuery('#$anchorhide').val(!jQuery('.$anchor-box').is(":hidden"));
386
+ $anchorupdate();
387
+ jQuery('.$anchor-box').slideToggle(1000);
388
+ return false;
389
+ }
390
+
391
+ function $anchorupdate(){
392
+ if (jQuery('#$anchorhide').val() == 'false'){
393
+ jQuery('#toggle-$anchor').text('Hide');
394
+ } else {
395
+ jQuery('#toggle-$anchor').text('Show');
396
+ }
397
+ }
398
  </script>
399
+ HTML;
400
+ ?>
401
  <input type='hidden' id='ui_<?php echo $anchor; ?>_hide' name='ui_<?php echo $anchor; ?>_hide' value='<?php echo $ops['ui_'.$anchor.'_hide']; ?>' />
402
  <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>
403
  <?php if($ops['ui_'.$anchor.'_hide'] == 'true'){ ?>
744
 
745
  function adinj_problem_with_wpminify_check(){
746
  $wpm_options = get_option('wp_minify');
747
+ $ops = adinj_options();
748
+ if ($wpm_options['enable_html'] == true && $ops['ad_insertion_mode'] == 'mfunc'){
749
  return true;
750
  }
751
  return false;
752
  }
753
 
754
  function adinj_get_problem_with_wpminify_message(){
755
+ return '<font color="red">Problem: Ad Injection will not work if WP Minify is set to minify HTML whilst mfunc mode is enabled.</font><br />
756
  Solution: Go to <a href="options-general.php?page=wp-minify">the WP Minify settings page</a> and untick "Enable HTML Minification".';
757
  }
758
 
778
  }
779
  }
780
 
781
+ function is_supported_caching_plugin_active(){
782
+ if (!is_plugin_active('wp-super-cache/wp-cache.php') &&
783
+ !is_plugin_active('w3-total-cache/w3-total-cache.php') &&
784
+ !is_plugin_active('wp-cache/wp-cache.php')){
785
+ return false;
786
+ }
787
+ return true;
788
+ }
789
+
790
  //////////////////////////////////////////////////////////////////////////////
791
 
792
  function adinj_percentage_split($name_stem, $num, $ops, $total=NULL){
860
  function adinj_install_db(){
861
  $new_options = adinj_default_options();
862
  // Dynamic defaults.
863
+ if (!is_supported_caching_plugin_active()){
864
  $new_options['ad_insertion_mode'] = 'direct_dynamic';
865
  }
866
  adinj_update_options($new_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.6.1
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.6.2
7
  Author: reviewmylife
8
  Author URI: http://www.reviewmylife.co.uk/
9
  License: GPLv2
readme.txt CHANGED
@@ -1,26 +1,27 @@
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, ad rotation, A:B testing, split testing
5
  Requires at least: 2.8.6
6
  Tested up to: 3.1
7
- Stable tag: 0.9.6.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
 
11
  == Description ==
12
 
13
- Ad Injection injects any kind of advert (e.g. Google AdSense, Amazon Associates, ClickBank, TradeDoubler, etc) into the existing content of your WordPress posts and pages. You can control the number of adverts based on the post length, and it can restrict who sees adverts by post age, visitor referrer and IP address. Adverts can be configured in the post (random, top, and bottom positions) or in any widget/sidebar area. There's support for A:B split testing / ad rotation. And the dynamic restrictions (by IP and referrer) work with WP Super Cache!
14
 
15
  **New Features 0.9.6.x**
16
 
17
  * Ad rotation / A:B split testing support for random, top, bottom and widget/sidebar adverts.
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
 
21
  = Automatic advert injection =
22
 
23
- 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 at a specified paragraph (e.g. the first or second). 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.
24
 
25
  = Widget support =
26
 
@@ -42,6 +43,10 @@ You can specify that ads should only be shown to search engine visitors (or from
42
 
43
  Adverts can be restricted to posts that are more than a defined numbers of days old. This prevents your regular visitors from having to see your ads.
44
 
 
 
 
 
45
  = Block ads from IP addresses =
46
 
47
  IP addresses of people who shouldn't see your ads can be defined. These could be the IP addresses of your friends, family, or even yourself.
@@ -58,11 +63,13 @@ The advert code can be copied and pasted directly from your ad provider (Google
58
 
59
  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. And you can select which paragraph random ads should start from.
60
 
61
- = Works with WP Super Cache =
62
 
63
- 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.
64
 
65
- 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).
 
 
66
 
67
  = Inject PHP and JavaScript =
68
 
@@ -82,18 +89,26 @@ As of January 2011 this plugin is being actively developed and maintained. Some
82
 
83
  This section describes how to install the plugin and get it working.
84
 
85
- 1. Upload the ad-injection folder to the '/wp-content/plugins/' directory. The plugin must be in a folder called 'ad-injection'. So the main plugin file will be at /wp-content/plugins/ad-injection/ad-injection.php
86
  2. Activate the plugin through the 'Plugins' menu in WordPress.
87
  3. Configure your ads. Carefully go through all the sections to setup your ad placements.
88
- 4. Make sure you select the option to say which ad injection mode to use. You need to say whether you are using WP Super Cache (or compatible) or not. Dynamic features (referrer and IP ad filtering) will only work with either 1) WP Super Cache (or compatible) or 2) no caching plugin.
89
  5. Tick the box right at the top to enable your ads.
90
  6. If you are using a caching plugin you may need to clear the cache to see your ads immediately.
91
 
 
 
 
 
 
 
 
 
92
  = How to uninstall =
93
 
94
  You can uninstall by deactivating the plugin and deleting from the WordPress plugins control panel.
95
 
96
- If you have been using mfunc mode with WP Super Cache then you *must* also clear the cache afterwards, otherwise you'll get errors saying the Ad Injection includes can't be found.
97
 
98
  == Frequently Asked Questions ==
99
 
@@ -110,10 +125,12 @@ One a basic level it can do the same job as Dax's excellent Adsense Injection. I
110
  * Can prevent specific IP addresses from seeing adverts.
111
  * Can define randomly positioned adverts, and adverts at the top and bottom of the posts.
112
  * Add adverts to the widget area.
 
113
  * Restrict adverts by category and tag.
114
  * Vary number of adverts based on post length.
115
  * You can inject raw JavaScript and PHP.
116
- * The dynamic features (restricting ads by referrer and IP) work with WP Super Cache.
 
117
  * Compatible with the <!--noadsense--> <!--adsensestart--> in-page tags from Adsense Injection to make migration easy.
118
  * Compatible with in-page tags from Whydowork Adsense and Quick Adsense.
119
  * Extra positioning options - for example you can force the first advert to be right after the first paragraph so that it will be 'above the fold'.
@@ -148,13 +165,13 @@ If you are testing the search engine referrer settings be aware that Ad Injectio
148
 
149
  Using a second browser in 'privacy mode' is also a good way of testing your site with a clean slate. A browser like Google Chrome will allow you to test your site with no cookies definied if you start a new private browsing session.
150
 
151
- = Do I need to have WP Super Cache installed? =
152
 
153
- 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
154
 
155
  = Will the dynamic features work with other caching plugins? =
156
 
157
- Potentially - if they are compatible with WP Super Cache's mfunc tags. I'm guessing they will work with the original WP Cache as I think the mfunc tags in WP Super Cache were inherited from here. However I haven't yet tested this. W3 Total Cache does have support for some kind of mfunc tags, but I haven't tested to see if they are compatible with the WP Super Cache ones. Do let me know!
158
 
159
  = Can I just have adverts on the home page? =
160
 
@@ -198,7 +215,7 @@ If you aren't interested in these features then it doesn't matter! Just make sur
198
 
199
  Problem: No ads appear when using mfunc mode.
200
 
201
- If you use WP Minify and WP Super Cache in combination with this plugin, you'll need to turn off the HTML minification in WP Minify. This is because HTML minification strips out the mfunc tags that Ad Injection uses. You can leave the CSS and JavaScript minification on if you already use them.
202
 
203
  **FeedWordPress**
204
 
@@ -208,20 +225,12 @@ By default FeedWordPress prevents the syndicated post contents from being passed
208
 
209
  From the FeedWordPress settings page go to 'Posts & Links' and then in the 'Formatting' section set 'Formatting filters' to 'Expose syndicated posts to formatting filters'.
210
 
211
- **W3 Total Cache (and other caching programs)**
212
-
213
- Problem: Dynamic features don't work.
214
-
215
- I don't think the dynamic features (restricting ads by IP and referrer) will work with any caching programs other than WP Super Cache and WP Cache. With other caching programs you should use the 'direct_static' mode.
216
-
217
- It is on my TODO list to try to make Ad Injection work with W3 Total Cache.
218
-
219
  = Some technical details =
220
 
221
  * Plugin stores all its settings in a single option (adinj_options).
222
  * Uninstall support is provided to delete this option if you uninstall the plugin.
223
  * Admin code is separated into a separate file so it is not loaded when your visitors view your pages.
224
- * When used with WP Super Cache the plugin loads its dynamic settings from a static PHP file so no MySQL database queries are required.
225
  * When mfunc mode is used the ads are saved as text files into the plugin folder. The plugin will therefore need write access to the plugins folder.
226
  * The JavaScript for setting the referrer cookie is inserted using wp_enqueue_scripts.
227
  * If there is anything I can do better please let me know - this is my first plugin so I still have a lot to learn!
@@ -237,15 +246,15 @@ Here are some things to check if the ads are not appearing, or are appearing whe
237
  5. Have you selected the correct insertion mode in the 'Ad insertion mode' section?
238
  6. The plugin inserts adverts after the closing HTML paragraph tag </p>. If the ads aren't appearing where you expect, check where your </p> tags are.
239
 
240
- = If you are using WP Super Cache. =
241
 
242
- 1. Have you enabled the WP Super Cache 'mfunc' mode? (in the Ad insertion mode and dynamic ad display restrictions pane)
243
  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).
244
  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.
245
 
246
  = If you are using WP Minify =
247
 
248
- 1. Turn off the HTML minification mode if you are also using WP Super Cache. HTML minification strips out the mfunc tags that Ad Injection needs to inject its ads.
249
  2. If you use the 'Place Minified JavaScript in footer' then try turning it off.
250
 
251
  = If you are getting errors when using mfunc mode check the following =
@@ -280,7 +289,10 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
280
 
281
  == Changelog ==
282
 
283
- = 0.9.6 =
 
 
 
284
  * Ad rotation / A:B split testing support for random, top, bottom and widget adverts.
285
  * Alternate content which can be defined for users who are dynamically blocked (by IP or referrer) from seeing adverts.
286
  * Choose which paragraph to start the random ads via the UI.
@@ -381,13 +393,9 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
381
 
382
  == Upgrade Notice ==
383
 
384
- = 0.9.6 =
385
  New split testing, ad rotation and alternate content features. If you have any problems with disappearing ads re-save them to make them appear again.
386
 
387
- = 0.9.5.2 =
388
- New CSS padding options for widgets. Fixes for CSS margin options.
389
- If you are using WP Super Cache 0.9.9.8 you can now switch to its faster mod_rewrite or PHP modes.
390
-
391
  = 0.8.3 =
392
  First public release.
393
 
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, 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.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
 
11
  == Description ==
12
 
13
+ Ad Injection injects any kind of advert (e.g. Google AdSense, Amazon Associates, ClickBank, TradeDoubler, etc) into the existing content of your WordPress posts and pages. You can control the number of adverts based on the post length, and it can restrict who sees adverts by post age, visitor referrer and IP address. Adverts can be configured in the post (random, top, and bottom positions) or in any widget/sidebar area. There's support for A:B split testing / ad rotation. And the dynamic restrictions (by IP and referrer) work with WP Super Cache, W3 Total Cache and WP Cache.
14
 
15
  **New Features 0.9.6.x**
16
 
17
  * Ad rotation / A:B split testing support for random, top, bottom and widget/sidebar adverts.
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
 
24
+ 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 at a specified paragraph (e.g. the first or second). Randomly positioning the adverts helps to reduce 'ad blindness'. Two additional adverts can be defined for the top and bottom of the content. Widget adverts can be defined as well.
25
 
26
  = Widget support =
27
 
43
 
44
  Adverts can be restricted to posts that are more than a defined numbers of days old. This prevents your regular visitors from having to see your ads.
45
 
46
+ = Category, tag and post type filters =
47
+
48
+ You can configure the adverts to only appear on specific categories, tags, or post types, or block the adverts from specific categories, tags or post types.
49
+
50
  = Block ads from IP addresses =
51
 
52
  IP addresses of people who shouldn't see your ads can be defined. These could be the IP addresses of your friends, family, or even yourself.
63
 
64
  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. And you can select which paragraph random ads should start from.
65
 
66
+ = Works with WP Super Cache, W3 Total Cache and WP Cache =
67
 
68
+ The dynamic features that require code to be executed for each page view (i.e. ad rotation, search engine visitors only, and ad blocking based on IP address) work with WP Super Cache, W3 Total Cache and WP Cache.
69
 
70
+ This plugin will automatically use the dynamic mfunc tag to ensure that the dynamic ad features still work when caching is on.
71
+
72
+ If you use WP Super Cache in mod_rewrite mode displaying the adverts (even with the dynamic restrictions) whilst caching requires no MySQL database access. For W3 Total Cache and WP Cache Ad Injection will not require any extra MySQL database access for cached pages other than what these plugin already use.
73
 
74
  = Inject PHP and JavaScript =
75
 
89
 
90
  This section describes how to install the plugin and get it working.
91
 
92
+ 1. Upload the ad-injection folder to the '/wp-content/plugins/' directory (or just use the WordPress plugin installer to do it for you). The plugin must be in a folder called 'ad-injection'. So the main plugin file will be at /wp-content/plugins/ad-injection/ad-injection.php
93
  2. Activate the plugin through the 'Plugins' menu in WordPress.
94
  3. Configure your ads. Carefully go through all the sections to setup your ad placements.
95
+ 4. Make sure you select the option to say which ad injection mode to use. Dynamic features (ad rotation, and referrer/IP ad filtering) will only work with either 1) WP Super Cache/W3 Total Cache/WP Cache or 2) no caching plugin.
96
  5. Tick the box right at the top to enable your ads.
97
  6. If you are using a caching plugin you may need to clear the cache to see your ads immediately.
98
 
99
+ **Recommended cache plugin settings**
100
+
101
+ * WP Super Cache - 0.9.9.8+ using mod_rewrite mode.
102
+ * W3 Total Cache - Page Cache: 'Disk (basic)' mode.
103
+ * WP Cache - Just turn the caching on.
104
+
105
+ 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).
106
+
107
  = How to uninstall =
108
 
109
  You can uninstall by deactivating the plugin and deleting from the WordPress plugins control panel.
110
 
111
+ If you have been using mfunc mode with a caching plugin then you *must* also clear the cache afterwards, otherwise you'll get errors saying the Ad Injection includes can't be found.
112
 
113
  == Frequently Asked Questions ==
114
 
125
  * Can prevent specific IP addresses from seeing adverts.
126
  * Can define randomly positioned adverts, and adverts at the top and bottom of the posts.
127
  * Add adverts to the widget area.
128
+ * Ad rotation / split testing.
129
  * Restrict adverts by category and tag.
130
  * Vary number of adverts based on post length.
131
  * You can inject raw JavaScript and PHP.
132
+ * The dynamic features (ad rotation, restricting ads by referrer and IP) work with WP Super Cache, W3 Total Cache and WP Cache.
133
+ * Define alternate content for users who are dynamically restricted from seeing ads.
134
  * Compatible with the <!--noadsense--> <!--adsensestart--> in-page tags from Adsense Injection to make migration easy.
135
  * Compatible with in-page tags from Whydowork Adsense and Quick Adsense.
136
  * Extra positioning options - for example you can force the first advert to be right after the first paragraph so that it will be 'above the fold'.
165
 
166
  Using a second browser in 'privacy mode' is also a good way of testing your site with a clean slate. A browser like Google Chrome will allow you to test your site with no cookies definied if you start a new private browsing session.
167
 
168
+ = Do I need to have WP Super Cache (or anther caching plugin) installed? =
169
 
170
+ 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 (ad rotation and 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 mfunc dynamic insertion mode in the Ad Injection settings screen.
171
 
172
  = Will the dynamic features work with other caching plugins? =
173
 
174
+ The dynamic features will work with any caching program that supports the mfunc tag. At the moment that is WP Super Cache, W3 Total Cache, and WP Cache.
175
 
176
  = Can I just have adverts on the home page? =
177
 
215
 
216
  Problem: No ads appear when using mfunc mode.
217
 
218
+ If you use WP Minify and a caching plugin in combination with Ad Injection, you'll need to turn off the HTML minification in WP Minify. This is because HTML minification strips out the mfunc tags that Ad Injection uses. You can leave the CSS and JavaScript minification on if you already use them.
219
 
220
  **FeedWordPress**
221
 
225
 
226
  From the FeedWordPress settings page go to 'Posts & Links' and then in the 'Formatting' section set 'Formatting filters' to 'Expose syndicated posts to formatting filters'.
227
 
 
 
 
 
 
 
 
 
228
  = Some technical details =
229
 
230
  * Plugin stores all its settings in a single option (adinj_options).
231
  * Uninstall support is provided to delete this option if you uninstall the plugin.
232
  * Admin code is separated into a separate file so it is not loaded when your visitors view your pages.
233
+ * When used with a compatible caching plugin Ad Injection loads its dynamic settings from a static PHP file, and the ads from disk so no extra MySQL database queries are required.
234
  * When mfunc mode is used the ads are saved as text files into the plugin folder. The plugin will therefore need write access to the plugins folder.
235
  * The JavaScript for setting the referrer cookie is inserted using wp_enqueue_scripts.
236
  * If there is anything I can do better please let me know - this is my first plugin so I still have a lot to learn!
246
  5. Have you selected the correct insertion mode in the 'Ad insertion mode' section?
247
  6. The plugin inserts adverts after the closing HTML paragraph tag </p>. If the ads aren't appearing where you expect, check where your </p> tags are.
248
 
249
+ = If you are using a caching plugin =
250
 
251
+ 1. Have you enabled Ad Injection's 'mfunc' mode? (in the Ad insertion mode and dynamic ad display restrictions pane)
252
  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).
253
  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.
254
 
255
  = If you are using WP Minify =
256
 
257
+ 1. Turn off the HTML minification mode if you are also using a caching plugin. HTML minification strips out the mfunc tags that Ad Injection needs to inject its ads.
258
  2. If you use the 'Place Minified JavaScript in footer' then try turning it off.
259
 
260
  = If you are getting errors when using mfunc mode check the following =
289
 
290
  == Changelog ==
291
 
292
+ = 0.9.6.2 =
293
+ * Support for W3 Total Cache and WP Cache (as well as the already supported WP Super Cache).
294
+
295
+ = 0.9.6.1 =
296
  * Ad rotation / A:B split testing support for random, top, bottom and widget adverts.
297
  * Alternate content which can be defined for users who are dynamically blocked (by IP or referrer) from seeing adverts.
298
  * Choose which paragraph to start the random ads via the UI.
393
 
394
  == Upgrade Notice ==
395
 
396
+ = 0.9.6.2 =
397
  New split testing, ad rotation and alternate content features. If you have any problems with disappearing ads re-save them to make them appear again.
398
 
 
 
 
 
399
  = 0.8.3 =
400
  First public release.
401
 
ui-tab-main.php CHANGED
@@ -87,7 +87,7 @@ function adinj_tab_main(){
87
  </td></tr>
88
  <tr><td>
89
  <?php
90
- _e("Always put the first ad after paragraph: ", 'adinj');
91
  adinj_selection_box("start_from_paragraph",
92
  array(ADINJ_DISABLED, 1, 2, 3, 4, 5), " ");
93
  ?>
@@ -281,35 +281,34 @@ function adinj_tab_main(){
281
  <h4>Ad insertion mode</h4>
282
 
283
  <blockquote>
284
- <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>
285
 
286
- <?php if (!is_plugin_active('wp-super-cache/wp-cache.php')) {
287
- 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>';
288
  } ?>
289
 
290
  <?php if ($ops['ad_insertion_mode'] != 'mfunc') { ?>
291
  <script type="text/javascript">
292
- document.write('<style type="text/css" media="screen">#wp_supercache_msg { display: none; }</style>');
293
  </script>
294
  <?php } ?>
295
 
296
- <div id="wp_supercache_msg" class="wp_supercache_msg">
297
- <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>
298
-
299
- <p>Go to the
300
-
301
- <?php if (is_plugin_active('wp-super-cache/wp-cache.php')) { ?>
302
- <a href='options-general.php?page=wpsupercache&amp;tab=settings'>WP Super Cache advanced options page</a>
303
- <?php } else { ?>
304
- WP Super Cache advanced options page
305
- <?php } ?>
306
- to configure the caching mode.</p>
307
 
308
- <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>
309
  </div>
310
 
311
- <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>
312
- <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>
313
  </blockquote>
314
  </div>
315
  <p></p>
@@ -320,15 +319,15 @@ function adinj_tab_main(){
320
  if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
321
  jQuery('.dynamic_features').slideUp(1000);
322
  jQuery('.dynamic_features_msg').slideDown(1000);
323
- jQuery('.wp_supercache_msg').slideUp(1000);
324
  } else if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_dynamic"){
325
  jQuery('.dynamic_features_msg').slideUp(1000);
326
  jQuery('.dynamic_features').slideDown(1000);
327
- jQuery('.wp_supercache_msg').slideUp(1000);
328
  } else { // mfunc
329
  jQuery('.dynamic_features_msg').slideUp(1000);
330
  jQuery('.dynamic_features').slideDown(1000);
331
- jQuery('.wp_supercache_msg').slideDown(1000);
332
  }
333
  return true;
334
  });
@@ -341,7 +340,8 @@ function adinj_tab_main(){
341
  <div class="dynamic_features_msg" style="display:none">
342
  <?php } ?>
343
  <div class="inside" style="margin:10px">
344
- <b><span style="font-size:10px;color:red;">Note: Dynamic features (restricting ad views by referrer and IP address) are only available in the mfunc, or direct dynamic modes.</span></b>
 
345
  </div>
346
  </div>
347
 
@@ -419,6 +419,46 @@ function adinj_tab_main(){
419
  adinj_docs();
420
  }
421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  function adinj_side_status_box(){
423
  ?>
424
  <div class="postbox-container" style="width:258px;">
@@ -724,7 +764,7 @@ function adinj_docs(){
724
 
725
  <h4>468x60 banner with dynamic PHP</h4>
726
 
727
- <p>The PHP will execute if either 1) WP Super Cache is turned on, or 2) if WP Super Cache is not installed/disabled. If you use another caching plugin the dynamic code will probably not work.</p>
728
 
729
  <p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="5">&lt;div style=&quot;background-color:#ffff99; width:468px; height:60px;&quot;&gt;
730
  &lt;b&gt;TEST ADVERT 468x60 with date() and rand()&lt;/b&gt;&lt;br /&gt;
87
  </td></tr>
88
  <tr><td>
89
  <?php
90
+ _e("Always put the first ad immediately after paragraph: ", 'adinj');
91
  adinj_selection_box("start_from_paragraph",
92
  array(ADINJ_DISABLED, 1, 2, 3, 4, 5), " ");
93
  ?>
281
  <h4>Ad insertion mode</h4>
282
 
283
  <blockquote>
284
+ <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>
285
 
286
+ <?php if (!is_supported_caching_plugin_active()) {
287
+ 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.</span></b></p>';
288
  } ?>
289
 
290
  <?php if ($ops['ad_insertion_mode'] != 'mfunc') { ?>
291
  <script type="text/javascript">
292
+ document.write('<style type="text/css" media="screen">#caching_plugin_msg { display: none; }</style>');
293
  </script>
294
  <?php } ?>
295
 
296
+ <div id="caching_plugin_msg" class="caching_plugin_msg">
297
+ <?php
298
+ if (is_plugin_active('wp-super-cache/wp-cache.php')){
299
+ adinj_wp_super_cache_msg();
300
+ } else if (is_plugin_active('w3-total-cache/w3-total-cache.php')){
301
+ adinj_w3_total_cache_msg();
302
+ } else if (is_plugin_active('wp-cache/wp-cache.php')){
303
+ adinj_wp_cache_msg();
304
+ }
305
+ adinj_unknown_cache_msg();
306
+ ?>
307
 
 
308
  </div>
309
 
310
+ <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>
311
+ <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: Direct static ad insertion</b> - No dynamic feature support. Select this if you are are not using dynamic features or are using an incompatible caching plugin.</p>
312
  </blockquote>
313
  </div>
314
  <p></p>
319
  if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
320
  jQuery('.dynamic_features').slideUp(1000);
321
  jQuery('.dynamic_features_msg').slideDown(1000);
322
+ jQuery('.caching_plugin_msg').slideUp(1000);
323
  } else if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_dynamic"){
324
  jQuery('.dynamic_features_msg').slideUp(1000);
325
  jQuery('.dynamic_features').slideDown(1000);
326
+ jQuery('.caching_plugin_msg').slideUp(1000);
327
  } else { // mfunc
328
  jQuery('.dynamic_features_msg').slideUp(1000);
329
  jQuery('.dynamic_features').slideDown(1000);
330
+ jQuery('.caching_plugin_msg').slideDown(1000);
331
  }
332
  return true;
333
  });
340
  <div class="dynamic_features_msg" style="display:none">
341
  <?php } ?>
342
  <div class="inside" style="margin:10px">
343
+ <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>
344
+ </blockquote>
345
  </div>
346
  </div>
347
 
419
  adinj_docs();
420
  }
421
 
422
+ function adinj_wp_super_cache_msg(){
423
+ ?>
424
+ <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>
425
+ <p>Go to the
426
+ <?php if (is_plugin_active('wp-super-cache/wp-cache.php')) { ?>
427
+ <a href='options-general.php?page=wpsupercache&amp;tab=settings'>WP Super Cache advanced options page</a>
428
+ <?php } else { ?>
429
+ WP Super Cache advanced options page
430
+ <?php } ?>
431
+ to configure the caching mode.</p>
432
+ <?php
433
+ }
434
+
435
+ function adinj_w3_total_cache_msg(){
436
+ ?>
437
+ <p>W3 Total Cache will cache the the page on-disk if you use its Page Cache: 'Disk (basic)' mode. However if you use its Page Cache: Disk (enhanced) mode it won't cache the page. You might find that WP Super Cache works faster when Ad Injection's dynamic features are enabled as it can return pre-built static PHP pages via mod rewrite rules, rather than having load up WordPress to return them via PHP. If you aren't using Ad Injection's dynamic features then you can use W3 Total Cache with Page Cache: Disk (enhanced) mode.</p>
438
+ <?php
439
+ }
440
+
441
+ function adinj_wp_cache_msg(){
442
+ ?>
443
+ <p>With WP Cache just turn the caching on and all pages will be cached. You may however want to consider upgrading to WP Super Cache as it has more efficient caching options such as serving static files via mod rewrite.</p>
444
+ <?php
445
+ }
446
+
447
+ function adinj_unknown_cache_msg(){
448
+ ?>
449
+ <blockquote>
450
+ <p><b>Recommended settings:</b></p>
451
+ <blockquote>
452
+ <ul>
453
+ <li><b>WP Super Cache</b> - 0.9.9.8+ using mod_rewrite mode.</li>
454
+ <li><b>W3 Total Cache</b> - Page Cache: 'Disk (basic)' mode.</li>
455
+ <li><b>WP Cache</b> - Just turn the caching on.</li>
456
+ </ul>
457
+ </blockquote>
458
+ </blockquote>
459
+ <?php
460
+ }
461
+
462
  function adinj_side_status_box(){
463
  ?>
464
  <div class="postbox-container" style="width:258px;">
764
 
765
  <h4>468x60 banner with dynamic PHP</h4>
766
 
767
+ <p>The PHP will execute if you use a mfunc compatible caching plugin which is correctly configured, or if you don't use any caching plugin at all.</p>
768
 
769
  <p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="5">&lt;div style=&quot;background-color:#ffff99; width:468px; height:60px;&quot;&gt;
770
  &lt;b&gt;TEST ADVERT 468x60 with date() and rand()&lt;/b&gt;&lt;br /&gt;