Version Description
Save options in admin_menu hook so that WordPress is correctly initialised when saving. Allows 'pluggable' include to be removed, which should fix 'Cannot redeclare get_userdatabylogin' conflict with vbbridge.
Download this release
Release Info
Developer | reviewmylife |
Plugin | Ad Injection |
Version | 0.9.4.6 |
Comparing to | |
See all releases |
Code changes from version 0.9.4.5 to 0.9.4.6
- ad-injection-admin.php +58 -59
- ad-injection.php +1 -1
- readme.txt +32 -1
ad-injection-admin.php
CHANGED
@@ -25,11 +25,6 @@ if (!is_admin()) return;
|
|
25 |
$adinj_warning_msg_chmod = "";
|
26 |
$adinj_warning_msg_filewrite = "";
|
27 |
|
28 |
-
if (is_admin() && !function_exists('check_admin_referer')){
|
29 |
-
//TODO check_admin_referer doesn't exist on post. Why?
|
30 |
-
require_once( ABSPATH . WPINC . '/pluggable.php' );
|
31 |
-
}
|
32 |
-
|
33 |
function adinj_checkNonce(){
|
34 |
if (empty($_POST) || !check_admin_referer('_adinj_form', '_adinj_nonce')){
|
35 |
echo 'form error';
|
@@ -44,63 +39,65 @@ function adinj_update_options($ops){
|
|
44 |
$adinj_data = get_option('adinj_options');
|
45 |
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
-
}
|
62 |
-
|
63 |
-
$raw_ad_code_random = stripslashes($_POST['ad_code_random_1']);
|
64 |
-
$ops['ad_code_random_1'] = $raw_ad_code_random;
|
65 |
-
|
66 |
-
$raw_ad_code_top = stripslashes($_POST['ad_code_top_1']);
|
67 |
-
$ops['ad_code_top_1'] = $raw_ad_code_top;
|
68 |
-
|
69 |
-
$raw_ad_code_bottom = stripslashes($_POST['ad_code_bottom_1']);
|
70 |
-
$ops['ad_code_bottom_1'] = $raw_ad_code_bottom;
|
71 |
-
|
72 |
-
$ad_referrers = stripslashes($_POST['ad_referrers']); // TODO do i need strip slashes?
|
73 |
-
$ops['ad_referrers'] = $ad_referrers;
|
74 |
-
|
75 |
-
$blocked_ips = stripslashes($_POST['blocked_ips']);
|
76 |
-
$ops['blocked_ips'] = $blocked_ips;
|
77 |
-
|
78 |
-
adinj_update_options($ops);
|
79 |
-
|
80 |
-
if ($ops['ad_insertion_mode'] == 'mfunc') {
|
81 |
-
write_ad_to_file($raw_ad_code_random, ADINJ_AD_PATH.'/'.ADINJ_AD_RANDOM_FILE);
|
82 |
-
write_ad_to_file($raw_ad_code_top, ADINJ_AD_PATH.'/'.ADINJ_AD_TOP_FILE);
|
83 |
-
write_ad_to_file($raw_ad_code_bottom, ADINJ_AD_PATH.'/'.ADINJ_AD_BOTTOM_FILE);
|
84 |
-
adinj_write_config_file();
|
85 |
-
}
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
}
|
|
|
104 |
}
|
105 |
|
106 |
// Test reminder: These generated functions won't exist until the first save
|
@@ -176,6 +173,8 @@ function adinj_get_logo(){
|
|
176 |
}
|
177 |
|
178 |
function adinj_options_page(){
|
|
|
|
|
179 |
$ops = adinj_options();
|
180 |
if ($ops === false || adinj_options_need_upgrading($ops)){
|
181 |
// Upgraded via FTP without being deactivated/reactivated
|
25 |
$adinj_warning_msg_chmod = "";
|
26 |
$adinj_warning_msg_filewrite = "";
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
function adinj_checkNonce(){
|
29 |
if (empty($_POST) || !check_admin_referer('_adinj_form', '_adinj_nonce')){
|
30 |
echo 'form error';
|
39 |
$adinj_data = get_option('adinj_options');
|
40 |
}
|
41 |
|
42 |
+
function adinj_save_options(){
|
43 |
+
// TODO investigate register_settings for a future release
|
44 |
+
if (isset($_POST['adinj_action'])){
|
45 |
+
switch($_POST['adinj_action']){
|
46 |
+
case 'Save all settings':
|
47 |
+
adinj_checkNonce();
|
48 |
+
|
49 |
+
// Extract all know options
|
50 |
+
$default_options = adinj_default_options();
|
51 |
+
foreach ($default_options as $key => $value){
|
52 |
+
if (isset($_POST[$key])){
|
53 |
+
$ops[$key] = $_POST[$key];
|
54 |
+
} else {
|
55 |
+
$ops[$key] = "";
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
$raw_ad_code_random = stripslashes($_POST['ad_code_random_1']);
|
60 |
+
$ops['ad_code_random_1'] = $raw_ad_code_random;
|
61 |
+
|
62 |
+
$raw_ad_code_top = stripslashes($_POST['ad_code_top_1']);
|
63 |
+
$ops['ad_code_top_1'] = $raw_ad_code_top;
|
64 |
+
|
65 |
+
$raw_ad_code_bottom = stripslashes($_POST['ad_code_bottom_1']);
|
66 |
+
$ops['ad_code_bottom_1'] = $raw_ad_code_bottom;
|
67 |
+
|
68 |
+
$ad_referrers = stripslashes($_POST['ad_referrers']); // TODO do i need strip slashes?
|
69 |
+
$ops['ad_referrers'] = $ad_referrers;
|
70 |
+
|
71 |
+
$blocked_ips = stripslashes($_POST['blocked_ips']);
|
72 |
+
$ops['blocked_ips'] = $blocked_ips;
|
73 |
+
|
74 |
+
adinj_update_options($ops);
|
75 |
+
|
76 |
+
if ($ops['ad_insertion_mode'] == 'mfunc') {
|
77 |
+
write_ad_to_file($raw_ad_code_random, ADINJ_AD_PATH.'/'.ADINJ_AD_RANDOM_FILE);
|
78 |
+
write_ad_to_file($raw_ad_code_top, ADINJ_AD_PATH.'/'.ADINJ_AD_TOP_FILE);
|
79 |
+
write_ad_to_file($raw_ad_code_bottom, ADINJ_AD_PATH.'/'.ADINJ_AD_BOTTOM_FILE);
|
80 |
+
adinj_write_config_file();
|
81 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
break;
|
84 |
|
85 |
+
case 'Reset to Default':
|
86 |
+
adinj_checkNonce();
|
87 |
+
adinj_update_options(adinj_default_options());
|
88 |
+
break;
|
89 |
+
|
90 |
+
case 'Delete settings from DB':
|
91 |
+
adinj_checkNonce();
|
92 |
+
delete_option('adinj_options');
|
93 |
+
|
94 |
+
case 'Delete widget settings from DB':
|
95 |
+
adinj_checkNonce();
|
96 |
+
delete_option('widget_adinj');
|
97 |
+
// TODO add option to delete ads files as well
|
98 |
+
break;
|
99 |
+
}
|
100 |
+
}
|
101 |
}
|
102 |
|
103 |
// Test reminder: These generated functions won't exist until the first save
|
173 |
}
|
174 |
|
175 |
function adinj_options_page(){
|
176 |
+
adinj_save_options();
|
177 |
+
|
178 |
$ops = adinj_options();
|
179 |
if ($ops === false || adinj_options_need_upgrading($ops)){
|
180 |
// Upgraded via FTP without being deactivated/reactivated
|
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.4.
|
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.4.6
|
7 |
Author: reviewmylife
|
8 |
Author URI: http://www.reviewmylife.co.uk/
|
9 |
License: GPLv2
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-w
|
|
4 |
Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free
|
5 |
Requires at least: 2.8.6
|
6 |
Tested up to: 3.0.3
|
7 |
-
Stable tag: 0.9.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 |
|
@@ -90,6 +90,7 @@ One a basic level it can do the same job as Dax's excellent Adsense Injection. I
|
|
90 |
* Can prevent specific IP addresses from seeing adverts.
|
91 |
* Can define randomly positioned adverts, and adverts at the top and bottom of the posts.
|
92 |
* Add adverts to the widget area.
|
|
|
93 |
* Vary number of adverts based on post length.
|
94 |
* You can inject raw JavaScript and PHP.
|
95 |
* The dynamic features (restricting ads by referrer and IP) work with WP Super Cache.
|
@@ -103,6 +104,30 @@ Thanks to Dax by the way for providing the inspiration for this plugin!
|
|
103 |
|
104 |
No! Absolutely not. Some ad plugins replace your publisher ID with their own for a certain percentage of adverts. Ad Injection does NOT do this. All your earnings are your own. Ad Injection makes no modifications to your ad code. What you paste into the ad boxes is what is injected into your pages.
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
= Do I need to have WP Super Cache installed? =
|
107 |
|
108 |
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.
|
@@ -201,6 +226,9 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
|
|
201 |
|
202 |
== Changelog ==
|
203 |
|
|
|
|
|
|
|
204 |
= 0.9.4.5 =
|
205 |
Fix problem with mfunc mode widgets on archive pages.
|
206 |
|
@@ -281,6 +309,9 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
|
|
281 |
|
282 |
== Upgrade Notice ==
|
283 |
|
|
|
|
|
|
|
284 |
= 0.9.4.5 =
|
285 |
If you are using mfunc mode or switch to mfunc and have added ad widgets you may need to re-save them to regenerate the ad files.
|
286 |
|
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.0.3
|
7 |
+
Stable tag: 0.9.4.6
|
8 |
|
9 |
Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
|
10 |
|
90 |
* Can prevent specific IP addresses from seeing adverts.
|
91 |
* Can define randomly positioned adverts, and adverts at the top and bottom of the posts.
|
92 |
* Add adverts to the widget area.
|
93 |
+
* Restrict adverts by category and tag.
|
94 |
* Vary number of adverts based on post length.
|
95 |
* You can inject raw JavaScript and PHP.
|
96 |
* The dynamic features (restricting ads by referrer and IP) work with WP Super Cache.
|
104 |
|
105 |
No! Absolutely not. Some ad plugins replace your publisher ID with their own for a certain percentage of adverts. Ad Injection does NOT do this. All your earnings are your own. Ad Injection makes no modifications to your ad code. What you paste into the ad boxes is what is injected into your pages.
|
106 |
|
107 |
+
= Is using this plugin allowed for Google AdSense? =
|
108 |
+
|
109 |
+
As far as I can tell using this plugin should be legal for AdSense **as long as you** make sure the ad quantities/placements comply with their TOS. However it is up to you to make sure that your website complies.
|
110 |
+
|
111 |
+
Ad Injection is designed as a generic plugin for injecting all types of adverts. It will not specifically check that the defined ad quantities or positions are in compliance of the AdSense TOS for you. For example Ad Injection will allow you to inject more ads than Google allows if you configure it to do so.
|
112 |
+
|
113 |
+
Be careful if you use the float left/right positioning options. These options could cause your AdSense adverts to appear under other elements of your page if you have also set a float value for them (e.g. floating images, and adverts together could be problematic). However the new 'clear' option should allow you to make sure this doesn't happen.
|
114 |
+
|
115 |
+
The best advice for any advert plugin is to manually check that you are happy with the advert quantities and positioning it produces, to ensure that you comply with the TOS for your ad program.
|
116 |
+
|
117 |
+
You use this plugin at your own risk.
|
118 |
+
|
119 |
+
= Do you have any testing recommendations? =
|
120 |
+
|
121 |
+
For testing your ad settings I'd recommend that you first disable any caching plugin, and then set Ad Injection to test mode.
|
122 |
+
|
123 |
+
If you are unsure as to why ads are appearing (or aren't) enable debug mode from the UI and look for the 'ADINJ DEBUG' tags in the HTML source of your webpage.
|
124 |
+
|
125 |
+
When you are happy with the ad quantities / positions you can disable debug mode, re-enable your caching plugin, and set the Ad Injection mode to 'On'.
|
126 |
+
|
127 |
+
If you are testing the search engine referrer settings be aware that Ad Injection sets a one hour cookie when you visit via a site with a matching referrer. This means that after you have visited the site via the matching referrer the adverts will keep showing for the next hour. Clear your cookies to reset the behaviour. The Firefox 'Cookie Monster' plugin is very useful if you want to check the status of the cookie. Look for the 'adinj' cookie. Instead of clearing all your cookies you can just delete this one.
|
128 |
+
|
129 |
+
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.
|
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.
|
226 |
|
227 |
== Changelog ==
|
228 |
|
229 |
+
= 0.9.4.6 =
|
230 |
+
Save options in admin_menu hook so that WordPress is correctly initialised when saving. Allows 'pluggable' include to be removed, which should fix 'Cannot redeclare get_userdatabylogin' conflict with vbbridge.
|
231 |
+
|
232 |
= 0.9.4.5 =
|
233 |
Fix problem with mfunc mode widgets on archive pages.
|
234 |
|
309 |
|
310 |
== Upgrade Notice ==
|
311 |
|
312 |
+
= 0.9.4.6 =
|
313 |
+
If you are using mfunc mode or switch to mfunc and have added ad widgets you may need to re-save them to regenerate the ad files.
|
314 |
+
|
315 |
= 0.9.4.5 =
|
316 |
If you are using mfunc mode or switch to mfunc and have added ad widgets you may need to re-save them to regenerate the ad files.
|
317 |
|