Version Description
- New: Setting to allow priority of Ad Injection's the_content filter to be changed. This may help with some themes that are overriding the WordPress default 'wpautop' behaviour.
- Fix: Start at paragraph setting may have been incorrectly upgraded if previously using an old version of this plugin.
Download this release
Release Info
Developer | reviewmylife |
Plugin | Ad Injection |
Version | 1.2.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.0.2 to 1.2.0.3
- ad-injection-admin.php +48 -27
- ad-injection.php +38 -40
- adinj-sev.js +43 -38
- adshow.php +77 -40
- readme.txt +17 -21
- ui-tab-adrotation.php +13 -2
- ui-tab-main.php +29 -11
ad-injection-admin.php
CHANGED
@@ -122,34 +122,41 @@ function extract_text_args($name, &$ops, $start=NULL, $end=NULL, $save_path_stem
|
|
122 |
// still be referenced by adshow.
|
123 |
function adinj_write_config_file(){
|
124 |
if (!adinj_mfunc_mode()) return;
|
|
|
125 |
|
126 |
-
$
|
127 |
-
$
|
128 |
|
129 |
$block_ips = adinj_ticked('block_ips')?'true':'false';
|
130 |
-
$
|
131 |
|
132 |
-
$
|
133 |
-
$
|
|
|
134 |
|
135 |
$debug_mode = adinj_ticked('debug_mode')?'true':'false';
|
136 |
|
|
|
|
|
137 |
$config = <<<CONFIG
|
138 |
<?php
|
139 |
/*
|
140 |
-
Ad Injection config file
|
141 |
DO NOT EDIT MANUALLY
|
142 |
This file is generated by Ad Injection
|
143 |
*/
|
144 |
|
145 |
-
function
|
146 |
-
function
|
147 |
|
148 |
function adinj_config_block_ips() { return $block_ips; }
|
149 |
-
function
|
|
|
|
|
|
|
|
|
150 |
|
151 |
-
function
|
152 |
-
function adinj_config_blocked_keywords() { return array($keyword_list); }
|
153 |
|
154 |
function adinj_config_debug_mode() { return $debug_mode; }
|
155 |
|
@@ -335,7 +342,7 @@ function adinj_top_message_box(){
|
|
335 |
|
336 |
} else if (!isset($_GET['tab'])){
|
337 |
echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
|
338 |
-
echo "
|
339 |
echo '</strong></p></div>';
|
340 |
}
|
341 |
}
|
@@ -448,7 +455,7 @@ function adinj_admin_tabs( $current = 0 ) {
|
|
448 |
$current = 'main';
|
449 |
}
|
450 |
}
|
451 |
-
$tabs = array( 'main' => __( 'Main', 'ad-injection' ), 'adrotation' => __( 'Ad codes / Ad rotation', 'ad-injection' ), 'debug' => __( 'Debug' ) );
|
452 |
$links = array();
|
453 |
foreach( $tabs as $tab => $name ) {
|
454 |
if ( $current == $tab ) {
|
@@ -458,9 +465,9 @@ function adinj_admin_tabs( $current = 0 ) {
|
|
458 |
}
|
459 |
}
|
460 |
|
461 |
-
echo '<div id="nav"><
|
462 |
echo implode( "", $links );
|
463 |
-
echo '</
|
464 |
}
|
465 |
|
466 |
// TODO replace with new Javascript
|
@@ -622,12 +629,15 @@ function adinj_max_num_ads($adtype, $pagetype){
|
|
622 |
$ops = adinj_options();
|
623 |
if (adinj_ticked('exclude_'.$pagetype)) return 0;
|
624 |
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom' ||
|
625 |
-
$adtype == 'footer' || $adtype == 'widget'){
|
626 |
if (adinj_ticked($adtype.'_exclude_'.$pagetype)) return 0;
|
627 |
}
|
628 |
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom' || $adtype == 'footer'){
|
629 |
if (adinj_count_live_ads($adtype, $ops) == 0) return 0;
|
630 |
}
|
|
|
|
|
|
|
631 |
if ($adtype == 'top' || $adtype == 'bottom'){
|
632 |
if ($pagetype == "single" || $pagetype == "page"){
|
633 |
return 1;
|
@@ -645,7 +655,7 @@ function adinj_max_num_ads($adtype, $pagetype){
|
|
645 |
//TODO
|
646 |
}
|
647 |
}
|
648 |
-
if ($adtype == 'widget' || $adtype == 'footer'){
|
649 |
return 1;
|
650 |
}
|
651 |
return 0;
|
@@ -1341,6 +1351,15 @@ function adinj_upgrade_db(){
|
|
1341 |
}
|
1342 |
}
|
1343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1344 |
// 3. Bump up db version number.
|
1345 |
$new_options['db_version'] = $new_dbversion;
|
1346 |
|
@@ -1381,9 +1400,9 @@ function adinj_default_options(){
|
|
1381 |
// single posts and pages
|
1382 |
'top_ad_if_longer_than' => 'd',
|
1383 |
'max_num_of_ads' => '2', // random ads
|
1384 |
-
'no_random_ads_if_shorter_than' => '
|
1385 |
-
'one_ad_if_shorter_than' => '
|
1386 |
-
'two_ads_if_shorter_than' => '
|
1387 |
'three_ads_if_shorter_than' => 'd',
|
1388 |
'bottom_ad_if_longer_than' => 'd',
|
1389 |
// Home page ads
|
@@ -1391,9 +1410,9 @@ function adinj_default_options(){
|
|
1391 |
'home_max_num_top_ads_per_page' => '1',
|
1392 |
'home_max_num_random_ads_per_post' => '1',
|
1393 |
'home_max_num_random_ads_per_page' => '3',
|
1394 |
-
'home_no_random_ads_if_shorter_than' => '
|
1395 |
-
'home_one_ad_if_shorter_than' => '
|
1396 |
-
'home_two_ads_if_shorter_than' => '
|
1397 |
'home_three_ads_if_shorter_than' => 'd',
|
1398 |
'home_bottom_ad_if_longer_than' => 'd',
|
1399 |
'home_max_num_bottom_ads_per_page' => '1',
|
@@ -1402,9 +1421,9 @@ function adinj_default_options(){
|
|
1402 |
'archive_max_num_top_ads_per_page' => '1',
|
1403 |
'archive_max_num_random_ads_per_post' => '1',
|
1404 |
'archive_max_num_random_ads_per_page' => '3',
|
1405 |
-
'archive_no_random_ads_if_shorter_than' => '
|
1406 |
-
'archive_one_ad_if_shorter_than' => '
|
1407 |
-
'archive_two_ads_if_shorter_than' => '
|
1408 |
'archive_three_ads_if_shorter_than' => 'd',
|
1409 |
'archive_bottom_ad_if_longer_than' => 'd',
|
1410 |
'archive_max_num_bottom_ads_per_page' => '1',
|
@@ -1633,6 +1652,8 @@ function adinj_default_options(){
|
|
1633 |
'template_exclude_archive' => '',
|
1634 |
'template_exclude_search' => '',
|
1635 |
'template_exclude_404' => '',
|
|
|
|
|
1636 |
// ui main tab
|
1637 |
'ui_global_hide' => 'false',
|
1638 |
'ui_adsettings_hide' => 'false',
|
@@ -1653,7 +1674,7 @@ function adinj_default_options(){
|
|
1653 |
'ui_multiple_random_hide' => 'false',
|
1654 |
'ui_multiple_bottom_hide' => 'false',
|
1655 |
'ui_multiple_footer_hide' => 'false',
|
1656 |
-
'
|
1657 |
'ui_docs_tags_hide' => 'true',
|
1658 |
// ui debug tab
|
1659 |
'ui_debugging_hide' => 'false',
|
122 |
// still be referenced by adshow.
|
123 |
function adinj_write_config_file(){
|
124 |
if (!adinj_mfunc_mode()) return;
|
125 |
+
$ops = adinj_options();
|
126 |
|
127 |
+
$allow_referrers = adinj_ticked('sevisitors_only')?'true':'false';
|
128 |
+
$allowed_referrers_list = adinj_quote_list('ad_referrers');
|
129 |
|
130 |
$block_ips = adinj_ticked('block_ips')?'true':'false';
|
131 |
+
$blocked_ip_list = adinj_quote_list('blocked_ips');
|
132 |
|
133 |
+
$block_referrers = adinj_ticked('block_keywords')?'true':'false';
|
134 |
+
$blocked_referrers_list = adinj_quote_list('blocked_keywords');
|
135 |
+
$block_hours = $ops['block_ads_for_hours'];
|
136 |
|
137 |
$debug_mode = adinj_ticked('debug_mode')?'true':'false';
|
138 |
|
139 |
+
$version = adinj_db_version($ops);
|
140 |
+
|
141 |
$config = <<<CONFIG
|
142 |
<?php
|
143 |
/*
|
144 |
+
Ad Injection config file dbversion=$version
|
145 |
DO NOT EDIT MANUALLY
|
146 |
This file is generated by Ad Injection
|
147 |
*/
|
148 |
|
149 |
+
function adinj_config_allow_referrers() { return $allow_referrers; }
|
150 |
+
function adinj_config_allowed_referrers_list() { return array($allowed_referrers_list); }
|
151 |
|
152 |
function adinj_config_block_ips() { return $block_ips; }
|
153 |
+
function adinj_config_blocked_ips_list() { return array($blocked_ip_list); }
|
154 |
+
|
155 |
+
function adinj_config_block_referrers() { return $block_referrers; }
|
156 |
+
function adinj_config_blocked_referrers_list() { return array($blocked_referrers_list); }
|
157 |
+
function adinj_config_block_hours() { return $block_hours; }
|
158 |
|
159 |
+
function adinj_config_block_after_ad_click() { return false; }
|
|
|
160 |
|
161 |
function adinj_config_debug_mode() { return $debug_mode; }
|
162 |
|
342 |
|
343 |
} else if (!isset($_GET['tab'])){
|
344 |
echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
|
345 |
+
echo "27th September 2011: New option to allow Ad Injection's priority to be changed in case your theme causes problems with it (in the Advanced tab). Plus other 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>.';
|
346 |
echo '</strong></p></div>';
|
347 |
}
|
348 |
}
|
455 |
$current = 'main';
|
456 |
}
|
457 |
}
|
458 |
+
$tabs = array( 'main' => __( 'Main', 'ad-injection' ), 'adrotation' => __( 'Ad codes / Ad rotation / Advanced', 'ad-injection' ), 'debug' => __( 'Debug' ) );
|
459 |
$links = array();
|
460 |
foreach( $tabs as $tab => $name ) {
|
461 |
if ( $current == $tab ) {
|
465 |
}
|
466 |
}
|
467 |
|
468 |
+
echo '<div id="nav"><h3 class="themes-php">';
|
469 |
echo implode( "", $links );
|
470 |
+
echo '</h3></div>';
|
471 |
}
|
472 |
|
473 |
// TODO replace with new Javascript
|
629 |
$ops = adinj_options();
|
630 |
if (adinj_ticked('exclude_'.$pagetype)) return 0;
|
631 |
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom' ||
|
632 |
+
$adtype == 'footer' || $adtype == 'widget' || $adtype == 'template'){
|
633 |
if (adinj_ticked($adtype.'_exclude_'.$pagetype)) return 0;
|
634 |
}
|
635 |
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom' || $adtype == 'footer'){
|
636 |
if (adinj_count_live_ads($adtype, $ops) == 0) return 0;
|
637 |
}
|
638 |
+
if ($pagetype == 'front'){ // front could be an archive or a page so we don't do an ad count
|
639 |
+
return 1;
|
640 |
+
}
|
641 |
if ($adtype == 'top' || $adtype == 'bottom'){
|
642 |
if ($pagetype == "single" || $pagetype == "page"){
|
643 |
return 1;
|
655 |
//TODO
|
656 |
}
|
657 |
}
|
658 |
+
if ($adtype == 'widget' || $adtype == 'footer' || $adtype == 'template'){
|
659 |
return 1;
|
660 |
}
|
661 |
return 0;
|
1351 |
}
|
1352 |
}
|
1353 |
|
1354 |
+
if ($stored_dbversion < 19){
|
1355 |
+
if ($new_options['random_ads_start_at'] == 'd' ||
|
1356 |
+
$new_options['random_ads_start_at'] == 'Rule Disabled' ||
|
1357 |
+
$new_options['random_ads_start_at'] == 'Disabled'){
|
1358 |
+
$new_options['random_ads_start_mode'] = 'anywhere';
|
1359 |
+
$new_options['random_ads_start_at'] = '1';
|
1360 |
+
}
|
1361 |
+
}
|
1362 |
+
|
1363 |
// 3. Bump up db version number.
|
1364 |
$new_options['db_version'] = $new_dbversion;
|
1365 |
|
1400 |
// single posts and pages
|
1401 |
'top_ad_if_longer_than' => 'd',
|
1402 |
'max_num_of_ads' => '2', // random ads
|
1403 |
+
'no_random_ads_if_shorter_than' => 'd',
|
1404 |
+
'one_ad_if_shorter_than' => 'd',
|
1405 |
+
'two_ads_if_shorter_than' => 'd',
|
1406 |
'three_ads_if_shorter_than' => 'd',
|
1407 |
'bottom_ad_if_longer_than' => 'd',
|
1408 |
// Home page ads
|
1410 |
'home_max_num_top_ads_per_page' => '1',
|
1411 |
'home_max_num_random_ads_per_post' => '1',
|
1412 |
'home_max_num_random_ads_per_page' => '3',
|
1413 |
+
'home_no_random_ads_if_shorter_than' => 'd',
|
1414 |
+
'home_one_ad_if_shorter_than' => 'd',
|
1415 |
+
'home_two_ads_if_shorter_than' => 'd',
|
1416 |
'home_three_ads_if_shorter_than' => 'd',
|
1417 |
'home_bottom_ad_if_longer_than' => 'd',
|
1418 |
'home_max_num_bottom_ads_per_page' => '1',
|
1421 |
'archive_max_num_top_ads_per_page' => '1',
|
1422 |
'archive_max_num_random_ads_per_post' => '1',
|
1423 |
'archive_max_num_random_ads_per_page' => '3',
|
1424 |
+
'archive_no_random_ads_if_shorter_than' => 'd',
|
1425 |
+
'archive_one_ad_if_shorter_than' => 'd',
|
1426 |
+
'archive_two_ads_if_shorter_than' => 'd',
|
1427 |
'archive_three_ads_if_shorter_than' => 'd',
|
1428 |
'archive_bottom_ad_if_longer_than' => 'd',
|
1429 |
'archive_max_num_bottom_ads_per_page' => '1',
|
1652 |
'template_exclude_archive' => '',
|
1653 |
'template_exclude_search' => '',
|
1654 |
'template_exclude_404' => '',
|
1655 |
+
// advanced settings
|
1656 |
+
'the_content_filter_priority' => '10', // 10 is the default for add_filter
|
1657 |
// ui main tab
|
1658 |
'ui_global_hide' => 'false',
|
1659 |
'ui_adsettings_hide' => 'false',
|
1674 |
'ui_multiple_random_hide' => 'false',
|
1675 |
'ui_multiple_bottom_hide' => 'false',
|
1676 |
'ui_multiple_footer_hide' => 'false',
|
1677 |
+
'ui_advanced_hide' => 'true',
|
1678 |
'ui_docs_tags_hide' => 'true',
|
1679 |
// ui debug tab
|
1680 |
'ui_debugging_hide' => 'false',
|
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: 1.2.0.
|
7 |
Author: reviewmylife
|
8 |
Author URI: http://www.reviewmylife.co.uk/
|
9 |
License: GPLv2
|
@@ -16,7 +16,7 @@ License: GPLv2
|
|
16 |
//
|
17 |
define('ADINJ_NO_CONFIG_FILE', 1);
|
18 |
|
19 |
-
// DB
|
20 |
// _ = before split testing
|
21 |
// 2 = split testing support
|
22 |
// 3 = added front options
|
@@ -34,7 +34,8 @@ define('ADINJ_NO_CONFIG_FILE', 1);
|
|
34 |
// 16 = after paragraph options, older option for widget
|
35 |
// 17 = block ads for days
|
36 |
// 18 = 1.2.0.0 New ad insertion engine and new top/random/bottom positioning options
|
37 |
-
|
|
|
38 |
|
39 |
// Files
|
40 |
// TODO will these paths work on windows?
|
@@ -93,6 +94,16 @@ function adinj_option($option){
|
|
93 |
return $ops[$option];
|
94 |
}
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
// TODO make the cookie domain from wp-config.php accessible to script
|
97 |
//$cookie_domain = COOKIE_DOMAIN; // TODO test
|
98 |
//var adinj_cookie_domain = "$cookie_domain"; //JS line. TODO test
|
@@ -117,7 +128,7 @@ SCRIPT;
|
|
117 |
if ($sevisitors) echo "var adinj_referrers = new Array($referrer_list);\n";
|
118 |
if ($block) echo "var adinj_blocked_referrers = new Array($blocked_list);\n";
|
119 |
if ($block) echo "var adinj_blocked_hours = $blocked_hours;\n";
|
120 |
-
echo "
|
121 |
echo "</script>\n";
|
122 |
}
|
123 |
|
@@ -142,14 +153,6 @@ function adinj_quote_list($option){
|
|
142 |
return implode(", ", $newlist);
|
143 |
}
|
144 |
|
145 |
-
function adinj_addsevjs_hook(){
|
146 |
-
// TODO can re-enable this check once the widget ads are factored in.
|
147 |
-
//if (adinj_ads_completely_disabled_from_page()) return;
|
148 |
-
if (!adinj_ticked('sevisitors_only') && !adinj_ticked('block_keywords')) return;
|
149 |
-
// Put the search engine detection / cookie setting script in the footer
|
150 |
-
wp_enqueue_script('adinj_sev', WP_PLUGIN_URL.'/ad-injection/adinj-sev.js', NULL, NULL, true);
|
151 |
-
}
|
152 |
-
|
153 |
function adinj_get_ad_code($adtype, $ads_db){
|
154 |
$ops = adinj_options();
|
155 |
$ads_live = NULL;
|
@@ -238,24 +241,6 @@ function adinj_live_ads_array($type, $ads_option, &$ads, &$split, $output_type="
|
|
238 |
$file_stem = 'ad_'.$type.'_';
|
239 |
}
|
240 |
|
241 |
-
if (adinj_db_version($ads_option) == 1){
|
242 |
-
// old DB support (no ad rotation support) - TODO delete later
|
243 |
-
if ($type == 'random'|| $type == 'top' || $type == 'bottom'){
|
244 |
-
if ($output_type == "string"){
|
245 |
-
$ads = "'ad_".$type."_1.txt'";
|
246 |
-
} else {
|
247 |
-
$ads[] = 'ad_code_'.$type.'_1';
|
248 |
-
}
|
249 |
-
} else if (preg_match("/widget_[\d+]/i", $type)){
|
250 |
-
if ($output_type == "string"){
|
251 |
-
$ads = "'ad_".$type.".txt'";
|
252 |
-
} else {
|
253 |
-
$ads[] = 'advert';
|
254 |
-
}
|
255 |
-
}
|
256 |
-
return;
|
257 |
-
}
|
258 |
-
|
259 |
// DB with support for ad rotation
|
260 |
for ($i=1; $i<=10; ++$i){
|
261 |
$ad_name = $op_stem.$i;
|
@@ -707,7 +692,14 @@ function adinj_content_hook($content){
|
|
707 |
}
|
708 |
$paracount = count($original_paragraph_positions);
|
709 |
if ($debug_on) $debug .= "\nContent length=$length (".$ops['content_length_unit'].") Raw character length=$rawlength Paragraph count=$paracount";
|
710 |
-
if($paracount == 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
|
712 |
$topad = adinj_ad_code_top();
|
713 |
if (empty($topad)) { if ($debug_on) $debug .= "\nNo top ad defined in any of the ad code boxes"; }
|
@@ -755,8 +747,9 @@ function adinj_content_hook($content){
|
|
755 |
|
756 |
# Insert the adverts into the content. Scan through the paragraph list in reverse order.
|
757 |
$adpos = count($random_ad_paragraphs);
|
|
|
758 |
for ($i=$paracount; $i>0; --$i){
|
759 |
-
if ($i === $bottom_ad_paragraph && $
|
760 |
$content = substr_replace($content, $bottomad, $original_paragraph_positions[$i-1], 0);
|
761 |
++$adinj_total_bottom_ads_used;
|
762 |
}
|
@@ -782,7 +775,7 @@ function adinj_content_hook($content){
|
|
782 |
$content = $topad.$content;
|
783 |
++$adinj_total_top_ads_used;
|
784 |
}
|
785 |
-
if ($bottom_ad_paragraph !== -1 && $
|
786 |
$content = $content.$bottomad;
|
787 |
++$adinj_total_bottom_ads_used;
|
788 |
}
|
@@ -1268,12 +1261,17 @@ function adinj_widgets_init() {
|
|
1268 |
register_widget('Ad_Injection_Widget');
|
1269 |
}
|
1270 |
|
1271 |
-
|
1272 |
-
|
1273 |
-
//
|
1274 |
-
|
1275 |
-
|
1276 |
-
add_action('
|
1277 |
-
|
|
|
|
|
|
|
|
|
|
|
1278 |
|
1279 |
?>
|
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: 1.2.0.3
|
7 |
Author: reviewmylife
|
8 |
Author URI: http://www.reviewmylife.co.uk/
|
9 |
License: GPLv2
|
16 |
//
|
17 |
define('ADINJ_NO_CONFIG_FILE', 1);
|
18 |
|
19 |
+
// DB Versions
|
20 |
// _ = before split testing
|
21 |
// 2 = split testing support
|
22 |
// 3 = added front options
|
34 |
// 16 = after paragraph options, older option for widget
|
35 |
// 17 = block ads for days
|
36 |
// 18 = 1.2.0.0 New ad insertion engine and new top/random/bottom positioning options
|
37 |
+
// 20 = 1.2.0.3 the_content_filter_priority setting
|
38 |
+
define('ADINJ_DB_VERSION', 20);
|
39 |
|
40 |
// Files
|
41 |
// TODO will these paths work on windows?
|
94 |
return $ops[$option];
|
95 |
}
|
96 |
|
97 |
+
function adinj_addsevjs_hook(){
|
98 |
+
// TODO can re-enable this check once the widget ads are factored in.
|
99 |
+
//if (adinj_ads_completely_disabled_from_page()) return;
|
100 |
+
if (!adinj_ticked('sevisitors_only') && !adinj_ticked('block_keywords')) return;
|
101 |
+
// Put the search engine detection / cookie setting script in the footer
|
102 |
+
// TODO would be better to use plugin version, but that only seems accessible in admin
|
103 |
+
$version = adinj_db_version(adinj_options());
|
104 |
+
wp_enqueue_script('adinj_sev', WP_PLUGIN_URL.'/ad-injection/adinj-sev.js?v='.$version, NULL, NULL, true);
|
105 |
+
}
|
106 |
+
|
107 |
// TODO make the cookie domain from wp-config.php accessible to script
|
108 |
//$cookie_domain = COOKIE_DOMAIN; // TODO test
|
109 |
//var adinj_cookie_domain = "$cookie_domain"; //JS line. TODO test
|
128 |
if ($sevisitors) echo "var adinj_referrers = new Array($referrer_list);\n";
|
129 |
if ($block) echo "var adinj_blocked_referrers = new Array($blocked_list);\n";
|
130 |
if ($block) echo "var adinj_blocked_hours = $blocked_hours;\n";
|
131 |
+
echo "adinj_dynamic_checks();\n";
|
132 |
echo "</script>\n";
|
133 |
}
|
134 |
|
153 |
return implode(", ", $newlist);
|
154 |
}
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
function adinj_get_ad_code($adtype, $ads_db){
|
157 |
$ops = adinj_options();
|
158 |
$ads_live = NULL;
|
241 |
$file_stem = 'ad_'.$type.'_';
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
// DB with support for ad rotation
|
245 |
for ($i=1; $i<=10; ++$i){
|
246 |
$ad_name = $op_stem.$i;
|
692 |
}
|
693 |
$paracount = count($original_paragraph_positions);
|
694 |
if ($debug_on) $debug .= "\nContent length=$length (".$ops['content_length_unit'].") Raw character length=$rawlength Paragraph count=$paracount";
|
695 |
+
if($paracount == 0) {
|
696 |
+
if ($debug_on) $debug .= "\nWarning: No paragraph (</p>) tags found.\n
|
697 |
+
Your theme or one of your plugins may have changed the priority of the wpautop\n
|
698 |
+
filter so it is getting run later than expected (after Ad Injection has run).\n
|
699 |
+
You can try modifying the priority setting of Ad Injection's wp_content filter\n
|
700 |
+
from the settings screen.\n
|
701 |
+
Try 100, or if that fails 200!";
|
702 |
+
}
|
703 |
|
704 |
$topad = adinj_ad_code_top();
|
705 |
if (empty($topad)) { if ($debug_on) $debug .= "\nNo top ad defined in any of the ad code boxes"; }
|
747 |
|
748 |
# Insert the adverts into the content. Scan through the paragraph list in reverse order.
|
749 |
$adpos = count($random_ad_paragraphs);
|
750 |
+
$bottomadsetting = $ops['bottom_ad_position'];
|
751 |
for ($i=$paracount; $i>0; --$i){
|
752 |
+
if ($i === $bottom_ad_paragraph && $bottomadsetting != 0){
|
753 |
$content = substr_replace($content, $bottomad, $original_paragraph_positions[$i-1], 0);
|
754 |
++$adinj_total_bottom_ads_used;
|
755 |
}
|
775 |
$content = $topad.$content;
|
776 |
++$adinj_total_top_ads_used;
|
777 |
}
|
778 |
+
if ($bottom_ad_paragraph !== -1 && $bottomadsetting == 0){ // default is special case as themes can't be trusted to close the final paragraph
|
779 |
$content = $content.$bottomad;
|
780 |
++$adinj_total_bottom_ads_used;
|
781 |
}
|
1261 |
register_widget('Ad_Injection_Widget');
|
1262 |
}
|
1263 |
|
1264 |
+
adinj_setup_hooks_and_filters();
|
1265 |
+
function adinj_setup_hooks_and_filters(){
|
1266 |
+
// activate
|
1267 |
+
register_activation_hook(__FILE__, 'adinj_activate_hook');
|
1268 |
+
// Content injection
|
1269 |
+
add_action('wp_enqueue_scripts', 'adinj_addsevjs_hook');
|
1270 |
+
$setting = adinj_option('the_content_filter_priority');
|
1271 |
+
$priority = isset($setting) ? $setting : 10; // 10 is the WordPress default filter priority
|
1272 |
+
add_filter('the_content', 'adinj_content_hook', $priority);
|
1273 |
+
add_action('wp_footer', 'adinj_footer_hook');
|
1274 |
+
add_action('wp_footer', 'adinj_print_referrers_hook');
|
1275 |
+
}
|
1276 |
|
1277 |
?>
|
adinj-sev.js
CHANGED
@@ -1,25 +1,40 @@
|
|
1 |
/*
|
2 |
Part of the Ad Injection plugin for WordPress
|
3 |
-
http://www.reviewmylife.co.uk/
|
4 |
*/
|
5 |
|
|
|
6 |
function adinj_check_referrer(){
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
return;
|
9 |
}
|
10 |
-
adinj_searchenginevisitor();
|
11 |
}
|
12 |
|
13 |
// Based on code from
|
14 |
// http://www.scratch99.com/2008/09/avoid-smart-pricing-show-adsense-only-to-search-engine-visitors/
|
15 |
-
function
|
16 |
-
|
17 |
-
|
18 |
-
}
|
19 |
-
var referrers = adinj_allowed_referrers_setting();
|
20 |
-
var length = referrers.length;
|
21 |
for (var i=0; i<length; ++i) {
|
22 |
-
if (document.referrer.indexOf(
|
23 |
var expiry = new Date();
|
24 |
expiry.setTime(expiry.getTime() + 1000*60*60); // 1 hour
|
25 |
document.cookie = "adinj=1; expires=" + expiry.toGMTString() + "; path=/; ";
|
@@ -29,22 +44,7 @@ function adinj_searchenginevisitor(){
|
|
29 |
return false;
|
30 |
}
|
31 |
|
32 |
-
function
|
33 |
-
if (typeof adinj_referrers != 'undefined'){
|
34 |
-
return adinj_referrers;
|
35 |
-
} else {
|
36 |
-
document.write("<!--ADINJ DEBUG: couldn't find adinj_referrers value. Using defaults.-->");
|
37 |
-
return new Array('.google.', '.bing.', '.yahoo.', '.ask.', 'search?', 'search.');
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
function adinj_blocked(){
|
42 |
-
if (adinj_searchEngineCookieSet()){
|
43 |
-
return false;
|
44 |
-
}
|
45 |
-
if (adinj_blockedCookieSet()){
|
46 |
-
return true;
|
47 |
-
}
|
48 |
var blocked = adinj_blocked_referrers_setting();
|
49 |
var length = blocked.length;
|
50 |
for (var i=0; i<length; ++i) {
|
@@ -58,6 +58,15 @@ function adinj_blocked(){
|
|
58 |
return false;
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
function adinj_blocked_referrers_setting(){
|
62 |
if (typeof adinj_blocked_referrers != 'undefined'){
|
63 |
return adinj_blocked_referrers;
|
@@ -76,18 +85,14 @@ function adinj_blocked_hours_setting(){
|
|
76 |
}
|
77 |
}
|
78 |
|
79 |
-
function
|
80 |
-
|
81 |
-
if(results){
|
82 |
-
return true;
|
83 |
-
}
|
84 |
-
return false;
|
85 |
}
|
86 |
|
87 |
-
function
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
return
|
93 |
}
|
1 |
/*
|
2 |
Part of the Ad Injection plugin for WordPress
|
3 |
+
http://www.reviewmylife.co.uk/
|
4 |
*/
|
5 |
|
6 |
+
// old entry method - deprecated - TODO delete later
|
7 |
function adinj_check_referrer(){
|
8 |
+
adinj_dynamic_checks();
|
9 |
+
}
|
10 |
+
|
11 |
+
// new entry method
|
12 |
+
function adinj_dynamic_checks(){
|
13 |
+
if (adinj_adlogblockedCookieSet()){
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
if (adinj_allowedCookieSet()){
|
17 |
+
// if 'allowed' cookie is already set we ignore blocked checks
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
if (adinj_adinjblockedCookieSet()){
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
if (adinj_blocked_referrer()){
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
if (adinj_allowed_referrer()){
|
27 |
return;
|
28 |
}
|
|
|
29 |
}
|
30 |
|
31 |
// Based on code from
|
32 |
// http://www.scratch99.com/2008/09/avoid-smart-pricing-show-adsense-only-to-search-engine-visitors/
|
33 |
+
function adinj_allowed_referrer(){
|
34 |
+
var allowed = adinj_allowed_referrers_setting();
|
35 |
+
var length = allowed.length;
|
|
|
|
|
|
|
36 |
for (var i=0; i<length; ++i) {
|
37 |
+
if (document.referrer.indexOf(allowed[i])!==-1) {
|
38 |
var expiry = new Date();
|
39 |
expiry.setTime(expiry.getTime() + 1000*60*60); // 1 hour
|
40 |
document.cookie = "adinj=1; expires=" + expiry.toGMTString() + "; path=/; ";
|
44 |
return false;
|
45 |
}
|
46 |
|
47 |
+
function adinj_blocked_referrer(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
var blocked = adinj_blocked_referrers_setting();
|
49 |
var length = blocked.length;
|
50 |
for (var i=0; i<length; ++i) {
|
58 |
return false;
|
59 |
}
|
60 |
|
61 |
+
function adinj_allowed_referrers_setting(){
|
62 |
+
if (typeof adinj_referrers != 'undefined'){
|
63 |
+
return adinj_referrers;
|
64 |
+
} else {
|
65 |
+
document.write("<!--ADINJ DEBUG: couldn't find adinj_referrers value. Using defaults.-->");
|
66 |
+
return new Array('.google.', '.bing.', '.yahoo.', '.ask.', 'search?', 'search.');
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
function adinj_blocked_referrers_setting(){
|
71 |
if (typeof adinj_blocked_referrers != 'undefined'){
|
72 |
return adinj_blocked_referrers;
|
85 |
}
|
86 |
}
|
87 |
|
88 |
+
function adinj_allowedCookieSet() {
|
89 |
+
return document.cookie.match('(^|;) ?adinj=([^;]*)(;|$)');
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
|
92 |
+
function adinj_adinjblockedCookieSet() {
|
93 |
+
return document.cookie.match('(^|;) ?adinjblocked=([^;]*)(;|$)');
|
94 |
+
}
|
95 |
+
|
96 |
+
function adinj_adlogblockedCookieSet() {
|
97 |
+
return document.cookie.match('(^|;) ?adlogblocked=([^;]*)(;|$)');
|
98 |
}
|
adshow.php
CHANGED
@@ -4,6 +4,8 @@ Part of the Ad Injection plugin for WordPress
|
|
4 |
http://www.reviewmylife.co.uk/
|
5 |
*/
|
6 |
|
|
|
|
|
7 |
if (!defined('ADINJ_NO_CONFIG_FILE')){
|
8 |
$adinj_dir = dirname(__FILE__);
|
9 |
if (file_exists($adinj_dir.'/ad-injection-config.php')){
|
@@ -24,13 +26,14 @@ if (!function_exists('adshow_functions_exist')){
|
|
24 |
// file is regenerated - e.g. if cached versions of pages are served
|
25 |
function adshow_functions_exist(){
|
26 |
if (!defined('ADINJ_NO_CONFIG_FILE')){
|
27 |
-
if (!adshow_functions_exist_impl('
|
28 |
-
if (!adshow_functions_exist_impl('
|
29 |
if (!adshow_functions_exist_impl('adinj_config_block_ips')){ return false; }
|
30 |
-
if (!adshow_functions_exist_impl('
|
31 |
-
if (!adshow_functions_exist_impl('
|
32 |
-
if (!adshow_functions_exist_impl('
|
33 |
//if (!adshow_functions_exist_impl('adinj_config_block_hours')){ return false; }
|
|
|
34 |
if (!adshow_functions_exist_impl('adinj_config_debug_mode')){ return false; }
|
35 |
}
|
36 |
return true;
|
@@ -45,11 +48,11 @@ function adshow_functions_exist_impl($function){
|
|
45 |
}
|
46 |
|
47 |
if (defined('ADINJ_NO_CONFIG_FILE')){
|
48 |
-
function
|
49 |
return adinj_ticked('sevisitors_only');
|
50 |
}
|
51 |
|
52 |
-
function
|
53 |
$list = adinj_quote_list('ad_referrers');
|
54 |
return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
55 |
}
|
@@ -58,25 +61,30 @@ function adinj_config_block_ips() {
|
|
58 |
return adinj_ticked('block_ips');
|
59 |
}
|
60 |
|
61 |
-
function
|
62 |
$list = adinj_quote_list('blocked_ips');
|
63 |
return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
64 |
}
|
65 |
|
66 |
-
function
|
67 |
return adinj_ticked('block_keywords');
|
68 |
}
|
69 |
|
70 |
-
function
|
71 |
$list = adinj_quote_list('blocked_keywords');
|
72 |
return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
73 |
}
|
74 |
|
75 |
-
function adinj_config_block_hours() {
|
76 |
$ops = adinj_options();
|
77 |
return $ops['block_ads_for_hours'];
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
80 |
function adinj_config_debug_mode() {
|
81 |
return adinj_ticked('debug_mode');
|
82 |
}
|
@@ -227,15 +235,56 @@ function adshow_add_formatting($ad, $ops = array()){
|
|
227 |
|
228 |
//////////////////////////////////////////////////////////////////////////////
|
229 |
|
230 |
-
if (!function_exists('
|
231 |
-
function
|
232 |
if (!adshow_functions_exist()){ return false; }
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
if ($_COOKIE["adinjblocked"]==1) {
|
235 |
-
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG:
|
236 |
-
return
|
237 |
}
|
238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
// return true if the visitor has recently come from a search engine
|
240 |
// and has the adinj cookie set.
|
241 |
if ($_COOKIE["adinj"]==1) {
|
@@ -244,9 +293,9 @@ function adshow_fromasearchengine(){ //todo rename to allowed_referrer
|
|
244 |
}
|
245 |
|
246 |
$referrer = $_SERVER['HTTP_REFERER'];
|
247 |
-
$
|
248 |
-
foreach ($
|
249 |
-
if (stripos($referrer, $
|
250 |
return true;
|
251 |
}
|
252 |
}
|
@@ -258,21 +307,10 @@ if (!function_exists('adshow_blocked_referrer')){
|
|
258 |
function adshow_blocked_referrer(){
|
259 |
if (!adshow_functions_exist()){ return false; }
|
260 |
|
261 |
-
if ($_COOKIE["adinj"]==1) {
|
262 |
-
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: blocked check ignored because adinj cookie set-->\n"; }
|
263 |
-
return false;
|
264 |
-
}
|
265 |
-
|
266 |
-
// true if blocked cookie is set
|
267 |
-
if ($_COOKIE["adinjblocked"]==1) {
|
268 |
-
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: adinjblocked cookie set-->\n"; }
|
269 |
-
return true;
|
270 |
-
}
|
271 |
-
|
272 |
$referrer = $_SERVER['HTTP_REFERER'];
|
273 |
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: referrer=$referrer-->\n"; }
|
274 |
|
275 |
-
$blocked =
|
276 |
foreach ($blocked as $bl) {
|
277 |
if (stripos($referrer, $bl) !== false) {
|
278 |
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: ads blocked - referrer contains $bl -->\n"; }
|
@@ -288,20 +326,19 @@ function adshow_blocked_ip(){
|
|
288 |
if (!adshow_functions_exist()){ return false; }
|
289 |
|
290 |
$visitorIP = $_SERVER['REMOTE_ADDR'];
|
291 |
-
return in_array($visitorIP,
|
292 |
}
|
293 |
}
|
294 |
|
295 |
-
if (!function_exists('
|
296 |
-
function
|
297 |
if (!adshow_functions_exist()){ return false; }
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
return true;
|
305 |
}
|
306 |
}
|
307 |
|
4 |
http://www.reviewmylife.co.uk/
|
5 |
*/
|
6 |
|
7 |
+
// TODO set cookies here as well so blocking / showing works without JS
|
8 |
+
|
9 |
if (!defined('ADINJ_NO_CONFIG_FILE')){
|
10 |
$adinj_dir = dirname(__FILE__);
|
11 |
if (file_exists($adinj_dir.'/ad-injection-config.php')){
|
26 |
// file is regenerated - e.g. if cached versions of pages are served
|
27 |
function adshow_functions_exist(){
|
28 |
if (!defined('ADINJ_NO_CONFIG_FILE')){
|
29 |
+
if (!adshow_functions_exist_impl('adinj_config_allow_referrers')){ return false; }
|
30 |
+
if (!adshow_functions_exist_impl('adinj_config_allowed_referrers_list')){ return false; }
|
31 |
if (!adshow_functions_exist_impl('adinj_config_block_ips')){ return false; }
|
32 |
+
if (!adshow_functions_exist_impl('adinj_config_blocked_ips_list')){ return false; }
|
33 |
+
if (!adshow_functions_exist_impl('adinj_config_block_referrers')){ return false; }
|
34 |
+
if (!adshow_functions_exist_impl('adinj_config_blocked_referrers_list')){ return false; }
|
35 |
//if (!adshow_functions_exist_impl('adinj_config_block_hours')){ return false; }
|
36 |
+
//if (!adshow_functions_exist_impl('adinj_config_block_after_ad_click')){ return false; }
|
37 |
if (!adshow_functions_exist_impl('adinj_config_debug_mode')){ return false; }
|
38 |
}
|
39 |
return true;
|
48 |
}
|
49 |
|
50 |
if (defined('ADINJ_NO_CONFIG_FILE')){
|
51 |
+
function adinj_config_allow_referrers() {
|
52 |
return adinj_ticked('sevisitors_only');
|
53 |
}
|
54 |
|
55 |
+
function adinj_config_allowed_referrers_list() {
|
56 |
$list = adinj_quote_list('ad_referrers');
|
57 |
return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
58 |
}
|
61 |
return adinj_ticked('block_ips');
|
62 |
}
|
63 |
|
64 |
+
function adinj_config_blocked_ips_list() {
|
65 |
$list = adinj_quote_list('blocked_ips');
|
66 |
return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
67 |
}
|
68 |
|
69 |
+
function adinj_config_block_referrers() {
|
70 |
return adinj_ticked('block_keywords');
|
71 |
}
|
72 |
|
73 |
+
function adinj_config_blocked_referrers_list() {
|
74 |
$list = adinj_quote_list('blocked_keywords');
|
75 |
return preg_split("/[,'\s]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
76 |
}
|
77 |
|
78 |
+
function adinj_config_block_hours() { // if blocked by referrer
|
79 |
$ops = adinj_options();
|
80 |
return $ops['block_ads_for_hours'];
|
81 |
}
|
82 |
|
83 |
+
function adinj_config_block_after_ad_click() {
|
84 |
+
return false;
|
85 |
+
//return adinj_ticked('block_after_ad_click'); //TODO maybe this should be checking something else
|
86 |
+
}
|
87 |
+
|
88 |
function adinj_config_debug_mode() {
|
89 |
return adinj_ticked('debug_mode');
|
90 |
}
|
235 |
|
236 |
//////////////////////////////////////////////////////////////////////////////
|
237 |
|
238 |
+
if (!function_exists('adshow_show_adverts')){
|
239 |
+
function adshow_show_adverts(){
|
240 |
if (!adshow_functions_exist()){ return false; }
|
241 |
+
//echo 'ref:'.$_SERVER['HTTP_REFERER'];
|
242 |
+
//if (adinj_config_block_after_ad_click() && adshow_clicked_ad()) return "click_blocked"; //TODO
|
243 |
+
|
244 |
+
if (adinj_config_block_ips() && adshow_blocked_ip()) return "blocked_ip";
|
245 |
+
|
246 |
+
if ($_COOKIE["adinj"]==1) {
|
247 |
+
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: blocked check ignored because adinj cookie set-->\n"; }
|
248 |
+
return true;
|
249 |
+
}
|
250 |
+
|
251 |
if ($_COOKIE["adinjblocked"]==1) {
|
252 |
+
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: no ads because adinjblocked cookie set-->\n"; }
|
253 |
+
return true;
|
254 |
}
|
255 |
|
256 |
+
if (adinj_config_block_referrers() && adshow_blocked_referrer()) return "blocked_referrer";
|
257 |
+
|
258 |
+
if (adinj_config_allow_referrers() && !adshow_allowed_referrer()) return "not_an_allowed_referrer";
|
259 |
+
|
260 |
+
return true;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
// Redirect new config method to old config methods until the config file gets re-generated.
|
265 |
+
// TODO test!
|
266 |
+
if (!function_exists('adinj_config_allow_referrers') && function_exists('adinj_config_sevisitors_only')){
|
267 |
+
function adinj_config_allow_referrers() { return adinj_config_sevisitors_only(); }
|
268 |
+
}
|
269 |
+
if (!function_exists('adinj_config_allowed_referrers_list') && function_exists('adinj_config_search_engine_referrers')){
|
270 |
+
function adinj_config_allowed_referrers_list() { return adinj_config_search_engine_referrers(); }
|
271 |
+
}
|
272 |
+
//
|
273 |
+
if (!function_exists('adinj_config_block_referrers') && function_exists('adinj_config_block_keywords')){
|
274 |
+
function adinj_config_block_referrers() { return adinj_config_block_keywords(); }
|
275 |
+
}
|
276 |
+
if (!function_exists('adinj_config_blocked_referrers_list') && function_exists('adinj_config_blocked_keywords')){
|
277 |
+
function adinj_config_blocked_referrers_list() { return adinj_config_blocked_keywords(); }
|
278 |
+
}
|
279 |
+
//
|
280 |
+
if (!function_exists('adinj_config_blocked_ips_list') && function_exists('adinj_config_blocked_ips')){
|
281 |
+
function adinj_config_blocked_ips_list() { return adinj_config_blocked_ips(); }
|
282 |
+
}
|
283 |
+
|
284 |
+
if (!function_exists('adshow_allowed_referrer')){
|
285 |
+
function adshow_allowed_referrer(){
|
286 |
+
if (!adshow_functions_exist()){ return false; }
|
287 |
+
|
288 |
// return true if the visitor has recently come from a search engine
|
289 |
// and has the adinj cookie set.
|
290 |
if ($_COOKIE["adinj"]==1) {
|
293 |
}
|
294 |
|
295 |
$referrer = $_SERVER['HTTP_REFERER'];
|
296 |
+
$allowedreferrers = adinj_config_allowed_referrers_list();
|
297 |
+
foreach ($allowedreferrers as $allowed) {
|
298 |
+
if (stripos($referrer, $allowed) !== false) {
|
299 |
return true;
|
300 |
}
|
301 |
}
|
307 |
function adshow_blocked_referrer(){
|
308 |
if (!adshow_functions_exist()){ return false; }
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
$referrer = $_SERVER['HTTP_REFERER'];
|
311 |
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: referrer=$referrer-->\n"; }
|
312 |
|
313 |
+
$blocked = adinj_config_blocked_referrers_list();
|
314 |
foreach ($blocked as $bl) {
|
315 |
if (stripos($referrer, $bl) !== false) {
|
316 |
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: ads blocked - referrer contains $bl -->\n"; }
|
326 |
if (!adshow_functions_exist()){ return false; }
|
327 |
|
328 |
$visitorIP = $_SERVER['REMOTE_ADDR'];
|
329 |
+
return in_array($visitorIP, adinj_config_blocked_ips_list());
|
330 |
}
|
331 |
}
|
332 |
|
333 |
+
if (!function_exists('adshow_clicked_ad')){
|
334 |
+
function adshow_clicked_ad(){
|
335 |
if (!adshow_functions_exist()){ return false; }
|
336 |
|
337 |
+
if ($_COOKIE["adlogblocked"]==1) {
|
338 |
+
if (adinj_config_debug_mode()){ echo "<!--ADINJ DEBUG: blocked because adlogblocked cookie set-->\n"; }
|
339 |
+
return true;
|
340 |
+
}
|
341 |
+
return false;
|
|
|
342 |
}
|
343 |
}
|
344 |
|
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.2.1
|
7 |
-
Stable tag: 1.2.0.
|
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 |
|
@@ -479,7 +479,13 @@ Problem: Random ads don't show.
|
|
479 |
|
480 |
Reason: Shortcodes Ultimate disables the wpautop filter which adds the <p></p> tags to the page. It re-applies this filter at a priority of 99 which is after Ad Injection has run. Therefore when Ad Injection runs it can't find any </p> tags which it needs to position the random adverts.
|
481 |
|
482 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
|
484 |
= Will Ad Injection work with the multi-blog version of WordPress? =
|
485 |
|
@@ -579,11 +585,15 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
|
|
579 |
|
580 |
== Changelog ==
|
581 |
|
|
|
|
|
|
|
|
|
582 |
= 1.2.0.2 =
|
583 |
* Fix: Problem with repeating bottom ads and ID filters not being properly applied to archives.
|
584 |
|
585 |
= 1.2.0.1 =
|
586 |
-
* Fix: Bottom ad
|
587 |
|
588 |
= 1.2.0.0 =
|
589 |
* Set the position of the top and bottom advert by paragraph or character.
|
@@ -789,27 +799,13 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
|
|
789 |
|
790 |
== Upgrade Notice ==
|
791 |
|
|
|
|
|
|
|
|
|
792 |
= 1.2.0.2 =
|
793 |
* Fix: Problem with repeating bottom ads and ID filters not being properly applied to archives.
|
794 |
|
795 |
-
= 1.2.0.1 =
|
796 |
-
* Fix: Bottom ad moved can potentially move up a paragraph if theme doesn't put closing paragraph at end of post.
|
797 |
-
|
798 |
-
= 1.2.0.0 =
|
799 |
-
* New top, random and bottom positioning options. UI updates. Debug message improvements.
|
800 |
-
|
801 |
-
= 1.1.0.6 =
|
802 |
-
* New block ads by referrer feature. Reduce UI memory usage for people with lots of tags. Fix randomad override tag.
|
803 |
-
|
804 |
-
= 1.1.0.4 =
|
805 |
-
* First ad can now be started at or after a paragraph or character position. Position override tags. Separate old post restriction for widget ads. Template ad examples in the 'Test ads' section. Warning message improvements. Other fixes.
|
806 |
-
|
807 |
-
= 1.1.0.2 =
|
808 |
-
* Remove confusing Disabled/Enabled drop down options as all ads can be enabled/disabled from the tick boxes. Please check your ads after this update and report any problems!
|
809 |
-
|
810 |
-
= 1.1.0.1 =
|
811 |
-
* Template ads - you can now include ads anywhere in your theme template with some simple tags. UI usability improvements.
|
812 |
-
|
813 |
= 0.8.3 =
|
814 |
First public release.
|
815 |
|
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.2.1
|
7 |
+
Stable tag: 1.2.0.3
|
8 |
|
9 |
Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
|
10 |
|
479 |
|
480 |
Reason: Shortcodes Ultimate disables the wpautop filter which adds the <p></p> tags to the page. It re-applies this filter at a priority of 99 which is after Ad Injection has run. Therefore when Ad Injection runs it can't find any </p> tags which it needs to position the random adverts.
|
481 |
|
482 |
+
Solution: Follow the below advice for the 'theme conflicts'.
|
483 |
+
|
484 |
+
= Are there any known theme conflicts? =
|
485 |
+
|
486 |
+
Ad Injection (when injection random ads) works by looking for the end paragraph tags (<p></p>). Some themes override the wpautop filter and set it to run after the plugins. This means that Ad Injection can't find the end paragraph tags, and so can't inject any random ads. If this happens try changing the the_content filter priority from the Advanced tab in the Ad Injection UI. Try values of 100, and if that doesn't work 200.
|
487 |
+
|
488 |
+
Themes which I know have this issue include 'Avenue', 'TheTravelTheme' and 'Vectors'.
|
489 |
|
490 |
= Will Ad Injection work with the multi-blog version of WordPress? =
|
491 |
|
585 |
|
586 |
== Changelog ==
|
587 |
|
588 |
+
= 1.2.0.3 =
|
589 |
+
* New: Setting to allow priority of Ad Injection's the_content filter to be changed. This may help with some themes that are overriding the WordPress default 'wpautop' behaviour.
|
590 |
+
* Fix: Start at paragraph setting may have been incorrectly upgraded if previously using an old version of this plugin.
|
591 |
+
|
592 |
= 1.2.0.2 =
|
593 |
* Fix: Problem with repeating bottom ads and ID filters not being properly applied to archives.
|
594 |
|
595 |
= 1.2.0.1 =
|
596 |
+
* Fix: Bottom ad can potentially move up a paragraph if theme doesn't put closing paragraph at end of post.
|
597 |
|
598 |
= 1.2.0.0 =
|
599 |
* Set the position of the top and bottom advert by paragraph or character.
|
799 |
|
800 |
== Upgrade Notice ==
|
801 |
|
802 |
+
= 1.2.0.3 =
|
803 |
+
* New: Setting to allow priority of Ad Injection's the_content filter to be changed to help with problem themes.
|
804 |
+
* Fix: Start at paragraph setting may have been incorrectly upgraded if previously using an old version of this plugin.
|
805 |
+
|
806 |
= 1.2.0.2 =
|
807 |
* Fix: Problem with repeating bottom ads and ID filters not being properly applied to archives.
|
808 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
809 |
= 0.8.3 =
|
810 |
First public release.
|
811 |
|
ui-tab-adrotation.php
CHANGED
@@ -10,7 +10,7 @@ function adinj_tab_adrotation(){
|
|
10 |
$ops = adinj_options();
|
11 |
|
12 |
echo <<<DOCS
|
13 |
-
<p><a href="#multiple_top">Top adverts</a> | <a href="#multiple_random">Random adverts</a> | <a href="#multiple_bottom">Bottom adverts</a> | <a href="#multiple_footer">Footer adverts</a> | <a href="#docs_tags">Tag docs</a> | <a href="#testads">Test ads</a></p>
|
14 |
DOCS;
|
15 |
|
16 |
$total_rand_split = adinj_total_split('ad_code_random_', $ops);
|
@@ -85,8 +85,9 @@ DOCS;
|
|
85 |
adinj_postbox_end();
|
86 |
|
87 |
|
|
|
|
|
88 |
adinj_docs_tags();
|
89 |
-
|
90 |
|
91 |
adinj_testads();
|
92 |
|
@@ -115,6 +116,16 @@ echo <<<EOT
|
|
115 |
EOT;
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
function adinj_docs_tags(){
|
119 |
?>
|
120 |
|
10 |
$ops = adinj_options();
|
11 |
|
12 |
echo <<<DOCS
|
13 |
+
<p><a href="#multiple_top">Top adverts</a> | <a href="#multiple_random">Random adverts</a> | <a href="#multiple_bottom">Bottom adverts</a> | <a href="#multiple_footer">Footer adverts</a> | <a href="#advanced">Advanced</a> | <a href="#docs_tags">Tag docs</a> | <a href="#testads">Test ads</a></p>
|
14 |
DOCS;
|
15 |
|
16 |
$total_rand_split = adinj_total_split('ad_code_random_', $ops);
|
85 |
adinj_postbox_end();
|
86 |
|
87 |
|
88 |
+
adinj_advanced();
|
89 |
+
|
90 |
adinj_docs_tags();
|
|
|
91 |
|
92 |
adinj_testads();
|
93 |
|
116 |
EOT;
|
117 |
}
|
118 |
|
119 |
+
|
120 |
+
function adinj_advanced(){
|
121 |
+
adinj_postbox_start(__("Advanced settings", 'adinj'), "advanced");
|
122 |
+
echo "<p>If your theme or another plugin is causing problems with Ad Injection (e.g. by changing the priority of the 'wpautop' filter which may prevent the random ads from being added) you can try modifying Ad Injection's the_content filter priority here. Try '100', if that doesn't work try something higher. ";
|
123 |
+
adinj_selection_box("the_content_filter_priority", array(0,1,10,11,100,200,1000));
|
124 |
+
echo ' Default: 10</p>';
|
125 |
+
adinj_postbox_end();
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
function adinj_docs_tags(){
|
130 |
?>
|
131 |
|
ui-tab-main.php
CHANGED
@@ -579,17 +579,31 @@ function adinj_add_exclude_row($name, $prefix=''){
|
|
579 |
?>
|
580 |
<tr>
|
581 |
<td><b><?php echo $name; ?></b></td>
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
|
|
|
|
589 |
</tr>
|
590 |
<?php
|
591 |
}
|
592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
function adinj_random_ad_limit_table(){
|
594 |
?>
|
595 |
<tr><td> |_ No ads if post shorter than:</td>
|
@@ -755,6 +769,7 @@ function adinj_side_status_box(){
|
|
755 |
<td><b>S</b></td>
|
756 |
<td><b>P</b></td>
|
757 |
<td><b>H</b></td>
|
|
|
758 |
<td><b>A</b></td>
|
759 |
</tr>
|
760 |
<tr>
|
@@ -764,6 +779,7 @@ function adinj_side_status_box(){
|
|
764 |
<td><?php adinj_print_ad_dot('top', 'single') ?></td>
|
765 |
<td><?php adinj_print_ad_dot('top', 'page') ?></td>
|
766 |
<td><?php adinj_print_ad_dot('top', 'home') ?></td>
|
|
|
767 |
<td><?php adinj_print_ad_dot('top', 'archive') ?></td>
|
768 |
</tr>
|
769 |
<tr>
|
@@ -773,6 +789,7 @@ function adinj_side_status_box(){
|
|
773 |
<td><?php adinj_print_ad_dot('random', 'single') ?></td>
|
774 |
<td><?php adinj_print_ad_dot('random', 'page') ?></td>
|
775 |
<td><?php adinj_print_ad_dot('random', 'home') ?></td>
|
|
|
776 |
<td><?php adinj_print_ad_dot('random', 'archive') ?></td>
|
777 |
</tr>
|
778 |
<tr>
|
@@ -782,6 +799,7 @@ function adinj_side_status_box(){
|
|
782 |
<td><?php adinj_print_ad_dot('bottom', 'single') ?></td>
|
783 |
<td><?php adinj_print_ad_dot('bottom', 'page') ?></td>
|
784 |
<td><?php adinj_print_ad_dot('bottom', 'home') ?></td>
|
|
|
785 |
<td><?php adinj_print_ad_dot('bottom', 'archive') ?></td>
|
786 |
</tr>
|
787 |
<tr>
|
@@ -791,6 +809,7 @@ function adinj_side_status_box(){
|
|
791 |
<td><?php adinj_print_ad_dot('footer', 'single') ?></td>
|
792 |
<td><?php adinj_print_ad_dot('footer', 'page') ?></td>
|
793 |
<td><?php adinj_print_ad_dot('footer', 'home') ?></td>
|
|
|
794 |
<td><?php adinj_print_ad_dot('footer', 'archive') ?></td>
|
795 |
</tr>
|
796 |
<tr>
|
@@ -800,6 +819,7 @@ function adinj_side_status_box(){
|
|
800 |
<td><?php adinj_print_ad_dot('widget', 'single') ?></td>
|
801 |
<td><?php adinj_print_ad_dot('widget', 'page') ?></td>
|
802 |
<td><?php adinj_print_ad_dot('widget', 'home') ?></td>
|
|
|
803 |
<td><?php adinj_print_ad_dot('widget', 'archive') ?></td>
|
804 |
</tr>
|
805 |
<tr>
|
@@ -809,13 +829,11 @@ function adinj_side_status_box(){
|
|
809 |
<td><?php adinj_print_ad_dot('template', 'single') ?></td>
|
810 |
<td><?php adinj_print_ad_dot('template', 'page') ?></td>
|
811 |
<td><?php adinj_print_ad_dot('template', 'home') ?></td>
|
|
|
812 |
<td><?php adinj_print_ad_dot('template', 'archive') ?></td>
|
813 |
</tr>
|
814 |
</table>
|
815 |
-
<p>S=single post
|
816 |
-
P=single page<br />
|
817 |
-
H=home<br />
|
818 |
-
A=archive<br />
|
819 |
<!--E=excerpt--></p>
|
820 |
</td></tr>
|
821 |
|
579 |
?>
|
580 |
<tr>
|
581 |
<td><b><?php echo $name; ?></b></td>
|
582 |
+
<?php
|
583 |
+
adinj_add_exclude_row_td($prefix, 'exclude_single', 'adinj_single', $all);
|
584 |
+
adinj_add_exclude_row_td($prefix, 'exclude_page', 'adinj_page', $all);
|
585 |
+
adinj_add_exclude_row_td($prefix, 'exclude_home', 'adinj_home', $all);
|
586 |
+
adinj_add_exclude_row_td($prefix, 'exclude_front', 'adinj_front', $all);
|
587 |
+
adinj_add_exclude_row_td($prefix, 'exclude_archive', 'adinj_archive', $all);
|
588 |
+
adinj_add_exclude_row_td($prefix, 'exclude_404', 'adinj_404', $all);
|
589 |
+
adinj_add_exclude_row_td($prefix, 'exclude_search', 'adinj_search', $all);
|
590 |
+
?>
|
591 |
</tr>
|
592 |
<?php
|
593 |
}
|
594 |
|
595 |
+
function adinj_add_exclude_row_td($prefix, $setting, $class, $all){
|
596 |
+
if (adinj_ticked($setting) || adinj_ticked($prefix.$setting)){
|
597 |
+
?>
|
598 |
+
<td style="background-color:#ff9999"><?php adinj_add_checkbox($prefix.$setting, $class, $all) ?></td>
|
599 |
+
<?php
|
600 |
+
} else {
|
601 |
+
?>
|
602 |
+
<td style="background-color:#ccff99"><?php adinj_add_checkbox($prefix.$setting, $class, $all) ?></td>
|
603 |
+
<?php
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
function adinj_random_ad_limit_table(){
|
608 |
?>
|
609 |
<tr><td> |_ No ads if post shorter than:</td>
|
769 |
<td><b>S</b></td>
|
770 |
<td><b>P</b></td>
|
771 |
<td><b>H</b></td>
|
772 |
+
<td><b>F</b></td>
|
773 |
<td><b>A</b></td>
|
774 |
</tr>
|
775 |
<tr>
|
779 |
<td><?php adinj_print_ad_dot('top', 'single') ?></td>
|
780 |
<td><?php adinj_print_ad_dot('top', 'page') ?></td>
|
781 |
<td><?php adinj_print_ad_dot('top', 'home') ?></td>
|
782 |
+
<td><?php adinj_print_ad_dot('top', 'front') ?></td>
|
783 |
<td><?php adinj_print_ad_dot('top', 'archive') ?></td>
|
784 |
</tr>
|
785 |
<tr>
|
789 |
<td><?php adinj_print_ad_dot('random', 'single') ?></td>
|
790 |
<td><?php adinj_print_ad_dot('random', 'page') ?></td>
|
791 |
<td><?php adinj_print_ad_dot('random', 'home') ?></td>
|
792 |
+
<td><?php adinj_print_ad_dot('random', 'front') ?></td>
|
793 |
<td><?php adinj_print_ad_dot('random', 'archive') ?></td>
|
794 |
</tr>
|
795 |
<tr>
|
799 |
<td><?php adinj_print_ad_dot('bottom', 'single') ?></td>
|
800 |
<td><?php adinj_print_ad_dot('bottom', 'page') ?></td>
|
801 |
<td><?php adinj_print_ad_dot('bottom', 'home') ?></td>
|
802 |
+
<td><?php adinj_print_ad_dot('bottom', 'front') ?></td>
|
803 |
<td><?php adinj_print_ad_dot('bottom', 'archive') ?></td>
|
804 |
</tr>
|
805 |
<tr>
|
809 |
<td><?php adinj_print_ad_dot('footer', 'single') ?></td>
|
810 |
<td><?php adinj_print_ad_dot('footer', 'page') ?></td>
|
811 |
<td><?php adinj_print_ad_dot('footer', 'home') ?></td>
|
812 |
+
<td><?php adinj_print_ad_dot('footer', 'front') ?></td>
|
813 |
<td><?php adinj_print_ad_dot('footer', 'archive') ?></td>
|
814 |
</tr>
|
815 |
<tr>
|
819 |
<td><?php adinj_print_ad_dot('widget', 'single') ?></td>
|
820 |
<td><?php adinj_print_ad_dot('widget', 'page') ?></td>
|
821 |
<td><?php adinj_print_ad_dot('widget', 'home') ?></td>
|
822 |
+
<td><?php adinj_print_ad_dot('widget', 'front') ?></td>
|
823 |
<td><?php adinj_print_ad_dot('widget', 'archive') ?></td>
|
824 |
</tr>
|
825 |
<tr>
|
829 |
<td><?php adinj_print_ad_dot('template', 'single') ?></td>
|
830 |
<td><?php adinj_print_ad_dot('template', 'page') ?></td>
|
831 |
<td><?php adinj_print_ad_dot('template', 'home') ?></td>
|
832 |
+
<td><?php adinj_print_ad_dot('template', 'front') ?></td>
|
833 |
<td><?php adinj_print_ad_dot('template', 'archive') ?></td>
|
834 |
</tr>
|
835 |
</table>
|
836 |
+
<p>S=single post | P=single page | H=home | F=front | A=archive
|
|
|
|
|
|
|
837 |
<!--E=excerpt--></p>
|
838 |
</td></tr>
|
839 |
|