Version Description
- Footer ad support (only for themes that correctly use the wp_footer hook).
- Align and clear options for widgets.
- Word counting code now works for non-Latin languages.
Download this release
Release Info
Developer | reviewmylife |
Plugin | Ad Injection |
Version | 0.9.7.7 |
Comparing to | |
See all releases |
Code changes from version 0.9.7.6 to 0.9.7.7
- ad-injection-admin.php +101 -14
- ad-injection-widget.php +52 -7
- ad-injection.php +61 -15
- adshow.php +3 -64
- readme.txt +13 -3
- ui-tab-adrotation.php +15 -1
- ui-tab-main.php +84 -9
ad-injection-admin.php
CHANGED
@@ -59,10 +59,12 @@ function adinj_save_options(){
|
|
59 |
extract_text_args('ad_code_random_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_random_');
|
60 |
extract_text_args('ad_code_top_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_top_');
|
61 |
extract_text_args('ad_code_bottom_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_bottom_');
|
|
|
62 |
|
63 |
extract_text_args('ad_code_random_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_random_alt_');
|
64 |
extract_text_args('ad_code_top_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_top_alt_');
|
65 |
extract_text_args('ad_code_bottom_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_bottom_alt_');
|
|
|
66 |
|
67 |
extract_text_args('ad_referrers', $ops);
|
68 |
extract_text_args('blocked_ips', $ops);
|
@@ -331,7 +333,7 @@ function adinj_top_message_box(){
|
|
331 |
|
332 |
} else if (!isset($_GET['tab'])){
|
333 |
echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
|
334 |
-
echo "
|
335 |
echo '</strong></p></div>';
|
336 |
}
|
337 |
}
|
@@ -508,7 +510,7 @@ function adinj_get_status($name){
|
|
508 |
} else if ($name == 'adsettings'){
|
509 |
$status[0] = 'green';
|
510 |
} else if ($name == 'adverts'){
|
511 |
-
if (adinj_count_live_ads('top', $ops) > 0 || adinj_count_live_ads('random', $ops) || adinj_count_live_ads('bottom', $ops)){
|
512 |
$status[0] = 'green';
|
513 |
} else {
|
514 |
$status[0] = 'red';
|
@@ -551,10 +553,11 @@ function adinj_dot($colour){
|
|
551 |
function adinj_max_num_ads($adtype, $pagetype){
|
552 |
$ops = adinj_options();
|
553 |
if (adinj_ticked('exclude_'.$pagetype)) return 0;
|
554 |
-
if ($adtype == '
|
555 |
-
|
|
|
556 |
}
|
557 |
-
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom'){
|
558 |
if (adinj_count_live_ads($adtype, $ops) == 0) return 0;
|
559 |
}
|
560 |
if ($adtype == 'top' || $adtype == 'bottom'){
|
@@ -574,7 +577,7 @@ function adinj_max_num_ads($adtype, $pagetype){
|
|
574 |
//TODO
|
575 |
}
|
576 |
}
|
577 |
-
if ($adtype == 'widget'){
|
578 |
return 1;
|
579 |
}
|
580 |
return 0;
|
@@ -739,19 +742,33 @@ function adinj_get_authors(){
|
|
739 |
}
|
740 |
|
741 |
function adinj_add_alignment_options($prefix){
|
742 |
-
|
743 |
echo "<br />";
|
744 |
-
|
745 |
-
array('d', 'left', 'center', 'right', 'float left', 'float right', 'rand lcr', 'rand float lr', 'rand all'));
|
746 |
echo "<br />";
|
747 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
748 |
echo "<br />";
|
749 |
-
adinj_selection_box($
|
750 |
-
array('d', 'left', 'right', 'both'));
|
751 |
echo "<br />";
|
752 |
-
|
753 |
echo "<br />";
|
754 |
-
|
755 |
}
|
756 |
|
757 |
function adinj_add_margin_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){
|
@@ -997,9 +1014,11 @@ function adinj_ad_name_stem($adtype){
|
|
997 |
if ($adtype == 'top') return 'ad_code_top_';
|
998 |
if ($adtype == 'random') return 'ad_code_random_';
|
999 |
if ($adtype == 'bottom') return 'ad_code_bottom_';
|
|
|
1000 |
if ($adtype == 'top_alt') return 'ad_code_top_alt_';
|
1001 |
if ($adtype == 'random_alt') return 'ad_code_random_alt_';
|
1002 |
if ($adtype == 'bottom_alt') return 'ad_code_bottom_alt_';
|
|
|
1003 |
// TODO widget?
|
1004 |
return 'Error: adinj_ad_name_stem:'.$adtype;
|
1005 |
}
|
@@ -1156,6 +1175,13 @@ function adinj_default_options(){
|
|
1156 |
'random_tag_condition_entries' => '',
|
1157 |
'random_author_condition_mode' => 'o',
|
1158 |
'random_author_condition_entries' => '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1159 |
// single posts and pages
|
1160 |
'top_ad_if_longer_than' => 'd',
|
1161 |
'max_num_of_ads' => '2', // random ads
|
@@ -1223,6 +1249,13 @@ function adinj_default_options(){
|
|
1223 |
'top_tag_condition_entries' => '',
|
1224 |
'top_author_condition_mode' => 'o',
|
1225 |
'top_author_condition_entries' => '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1226 |
// Bottom ads
|
1227 |
'ad_code_bottom_1' => '',
|
1228 |
'ad_code_bottom_2' => '',
|
@@ -1260,6 +1293,57 @@ function adinj_default_options(){
|
|
1260 |
'bottom_tag_condition_entries' => '',
|
1261 |
'bottom_author_condition_mode' => 'o',
|
1262 |
'bottom_author_condition_entries' => '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1263 |
// widgets
|
1264 |
'widget_exclude_front' => '',
|
1265 |
'widget_exclude_home' => '',
|
@@ -1287,11 +1371,14 @@ function adinj_default_options(){
|
|
1287 |
'ui_top_conditions_show' => 'false',
|
1288 |
'ui_random_conditions_show' => 'false',
|
1289 |
'ui_bottom_conditions_show' => 'false',
|
|
|
|
|
1290 |
// ui ad rotation tab
|
1291 |
'ui_docs_adrotation_hide' => 'false',
|
1292 |
'ui_multiple_top_hide' => 'false',
|
1293 |
'ui_multiple_random_hide' => 'false',
|
1294 |
'ui_multiple_bottom_hide' => 'false',
|
|
|
1295 |
'ui_misc_hide' => 'true',
|
1296 |
'ui_docs_tags_hide' => 'true',
|
1297 |
// ui debug tab
|
59 |
extract_text_args('ad_code_random_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_random_');
|
60 |
extract_text_args('ad_code_top_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_top_');
|
61 |
extract_text_args('ad_code_bottom_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_bottom_');
|
62 |
+
extract_text_args('ad_code_footer_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_footer_');
|
63 |
|
64 |
extract_text_args('ad_code_random_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_random_alt_');
|
65 |
extract_text_args('ad_code_top_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_top_alt_');
|
66 |
extract_text_args('ad_code_bottom_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_bottom_alt_');
|
67 |
+
extract_text_args('ad_code_footer_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_footer_alt_');
|
68 |
|
69 |
extract_text_args('ad_referrers', $ops);
|
70 |
extract_text_args('blocked_ips', $ops);
|
333 |
|
334 |
} else if (!isset($_GET['tab'])){
|
335 |
echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
|
336 |
+
echo "18th March 2011: New footer ad support (will only work on themes that correctly use the wp_footer hook). New align and clear options for widgets. And the word counting code now works for non-Latin languages. Also I'll mention that during the rest of March and the first part of April I won't have full internet access due to travelling, so I will take longer to respond and fix any bugs. But please still contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>.';
|
337 |
echo '</strong></p></div>';
|
338 |
}
|
339 |
}
|
510 |
} else if ($name == 'adsettings'){
|
511 |
$status[0] = 'green';
|
512 |
} else if ($name == 'adverts'){
|
513 |
+
if (adinj_count_live_ads('top', $ops) > 0 || adinj_count_live_ads('random', $ops) > 0 || adinj_count_live_ads('bottom', $ops) > 0 || adinj_count_live_ads('footer', $ops) > 0){
|
514 |
$status[0] = 'green';
|
515 |
} else {
|
516 |
$status[0] = 'red';
|
553 |
function adinj_max_num_ads($adtype, $pagetype){
|
554 |
$ops = adinj_options();
|
555 |
if (adinj_ticked('exclude_'.$pagetype)) return 0;
|
556 |
+
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom' ||
|
557 |
+
$adtype == 'footer' || $adtype == 'widget'){
|
558 |
+
if (adinj_ticked($adtype.'_exclude_'.$pagetype)) return 0;
|
559 |
}
|
560 |
+
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom' || $adtype == 'footer'){
|
561 |
if (adinj_count_live_ads($adtype, $ops) == 0) return 0;
|
562 |
}
|
563 |
if ($adtype == 'top' || $adtype == 'bottom'){
|
577 |
//TODO
|
578 |
}
|
579 |
}
|
580 |
+
if ($adtype == 'widget' || $adtype == 'footer'){
|
581 |
return 1;
|
582 |
}
|
583 |
return 0;
|
742 |
}
|
743 |
|
744 |
function adinj_add_alignment_options($prefix){
|
745 |
+
adinj_add_alignment_clear_options($prefix);
|
746 |
echo "<br />";
|
747 |
+
adinj_add_padding_top_bottom_options($prefix);
|
|
|
748 |
echo "<br />";
|
749 |
+
adinj_add_margin_top_bottom_options($prefix);
|
750 |
+
}
|
751 |
+
|
752 |
+
function adinj_add_alignment_clear_options($prefix, $options=NULL, $alignname=NULL, $clearname=NULL){
|
753 |
+
$aname = $prefix.'align';
|
754 |
+
$cname = $prefix.'clear';
|
755 |
+
$adefault = NULL;
|
756 |
+
$cdefault = NULL;
|
757 |
+
if ($alignname != NULL){
|
758 |
+
$aname = $alignname;
|
759 |
+
$adefault = "align";
|
760 |
+
}
|
761 |
+
if ($clearname != NULL){
|
762 |
+
$cname = $clearname;
|
763 |
+
$cdefault = "clear";
|
764 |
+
}
|
765 |
+
_e("Alignment", 'adinj');
|
766 |
echo "<br />";
|
767 |
+
adinj_selection_box($aname,array('d','left','center','right','float left','float right','rand lcr','rand float lr','rand all'),"",$options[$adefault]);
|
|
|
768 |
echo "<br />";
|
769 |
+
_e("Clear (CSS)", 'adinj');
|
770 |
echo "<br />";
|
771 |
+
adinj_selection_box($cname,array('d','left','right','both'),"",$options[$cdefault]);
|
772 |
}
|
773 |
|
774 |
function adinj_add_margin_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){
|
1014 |
if ($adtype == 'top') return 'ad_code_top_';
|
1015 |
if ($adtype == 'random') return 'ad_code_random_';
|
1016 |
if ($adtype == 'bottom') return 'ad_code_bottom_';
|
1017 |
+
if ($adtype == 'footer') return 'ad_code_footer_';
|
1018 |
if ($adtype == 'top_alt') return 'ad_code_top_alt_';
|
1019 |
if ($adtype == 'random_alt') return 'ad_code_random_alt_';
|
1020 |
if ($adtype == 'bottom_alt') return 'ad_code_bottom_alt_';
|
1021 |
+
if ($adtype == 'footer_alt') return 'ad_code_footer_alt_';
|
1022 |
// TODO widget?
|
1023 |
return 'Error: adinj_ad_name_stem:'.$adtype;
|
1024 |
}
|
1175 |
'random_tag_condition_entries' => '',
|
1176 |
'random_author_condition_mode' => 'o',
|
1177 |
'random_author_condition_entries' => '',
|
1178 |
+
'random_exclude_front' => '',
|
1179 |
+
'random_exclude_home' => '',
|
1180 |
+
'random_exclude_page' => '',
|
1181 |
+
'random_exclude_single' => '',
|
1182 |
+
'random_exclude_archive' => '',
|
1183 |
+
'random_exclude_search' => '',
|
1184 |
+
'random_exclude_404' => '',
|
1185 |
// single posts and pages
|
1186 |
'top_ad_if_longer_than' => 'd',
|
1187 |
'max_num_of_ads' => '2', // random ads
|
1249 |
'top_tag_condition_entries' => '',
|
1250 |
'top_author_condition_mode' => 'o',
|
1251 |
'top_author_condition_entries' => '',
|
1252 |
+
'top_exclude_front' => '',
|
1253 |
+
'top_exclude_home' => '',
|
1254 |
+
'top_exclude_page' => '',
|
1255 |
+
'top_exclude_single' => '',
|
1256 |
+
'top_exclude_archive' => '',
|
1257 |
+
'top_exclude_search' => '',
|
1258 |
+
'top_exclude_404' => '',
|
1259 |
// Bottom ads
|
1260 |
'ad_code_bottom_1' => '',
|
1261 |
'ad_code_bottom_2' => '',
|
1293 |
'bottom_tag_condition_entries' => '',
|
1294 |
'bottom_author_condition_mode' => 'o',
|
1295 |
'bottom_author_condition_entries' => '',
|
1296 |
+
'bottom_exclude_front' => '',
|
1297 |
+
'bottom_exclude_home' => '',
|
1298 |
+
'bottom_exclude_page' => '',
|
1299 |
+
'bottom_exclude_single' => '',
|
1300 |
+
'bottom_exclude_archive' => '',
|
1301 |
+
'bottom_exclude_search' => '',
|
1302 |
+
'bottom_exclude_404' => '',
|
1303 |
+
// Footer ads
|
1304 |
+
'ad_code_footer_1' => '',
|
1305 |
+
'ad_code_footer_2' => '',
|
1306 |
+
'ad_code_footer_3' => '',
|
1307 |
+
'ad_code_footer_4' => '',
|
1308 |
+
'ad_code_footer_5' => '',
|
1309 |
+
'ad_code_footer_6' => '',
|
1310 |
+
'ad_code_footer_7' => '',
|
1311 |
+
'ad_code_footer_8' => '',
|
1312 |
+
'ad_code_footer_9' => '',
|
1313 |
+
'ad_code_footer_10' => '',
|
1314 |
+
'ad_code_footer_1_split' => '100',
|
1315 |
+
'ad_code_footer_2_split' => '100',
|
1316 |
+
'ad_code_footer_3_split' => '100',
|
1317 |
+
'ad_code_footer_4_split' => '100',
|
1318 |
+
'ad_code_footer_5_split' => '100',
|
1319 |
+
'ad_code_footer_6_split' => '100',
|
1320 |
+
'ad_code_footer_7_split' => '100',
|
1321 |
+
'ad_code_footer_8_split' => '100',
|
1322 |
+
'ad_code_footer_9_split' => '100',
|
1323 |
+
'ad_code_footer_10_split' => '100',
|
1324 |
+
'ad_code_footer_alt_1' => '',
|
1325 |
+
'ad_code_footer_alt_2' => '',
|
1326 |
+
'ad_code_footer_alt_1_split' => '100',
|
1327 |
+
'ad_code_footer_alt_2_split' => '100',
|
1328 |
+
'footer_align' => 'center',
|
1329 |
+
'footer_clear' => 'd',
|
1330 |
+
'footer_margin_top' => 'd',
|
1331 |
+
'footer_margin_bottom' => 'd',
|
1332 |
+
'footer_padding_top' => 'd',
|
1333 |
+
'footer_padding_bottom' => '3',
|
1334 |
+
'footer_category_condition_mode' => 'o',
|
1335 |
+
'footer_category_condition_entries' => '',
|
1336 |
+
'footer_tag_condition_mode' => 'o',
|
1337 |
+
'footer_tag_condition_entries' => '',
|
1338 |
+
'footer_author_condition_mode' => 'o',
|
1339 |
+
'footer_author_condition_entries' => '',
|
1340 |
+
'footer_exclude_front' => '',
|
1341 |
+
'footer_exclude_home' => '',
|
1342 |
+
'footer_exclude_page' => '',
|
1343 |
+
'footer_exclude_single' => '',
|
1344 |
+
'footer_exclude_archive' => '',
|
1345 |
+
'footer_exclude_search' => '',
|
1346 |
+
'footer_exclude_404' => '',
|
1347 |
// widgets
|
1348 |
'widget_exclude_front' => '',
|
1349 |
'widget_exclude_home' => '',
|
1371 |
'ui_top_conditions_show' => 'false',
|
1372 |
'ui_random_conditions_show' => 'false',
|
1373 |
'ui_bottom_conditions_show' => 'false',
|
1374 |
+
'ui_footer_conditions_show' => 'false',
|
1375 |
+
'ui_footer_docs_show' => 'false',
|
1376 |
// ui ad rotation tab
|
1377 |
'ui_docs_adrotation_hide' => 'false',
|
1378 |
'ui_multiple_top_hide' => 'false',
|
1379 |
'ui_multiple_random_hide' => 'false',
|
1380 |
'ui_multiple_bottom_hide' => 'false',
|
1381 |
+
'ui_multiple_footer_hide' => 'false',
|
1382 |
'ui_misc_hide' => 'true',
|
1383 |
'ui_docs_tags_hide' => 'true',
|
1384 |
// ui debug tab
|
ad-injection-widget.php
CHANGED
@@ -9,7 +9,9 @@ http://www.reviewmylife.co.uk/
|
|
9 |
// 3 = increase db rotation slots to 10 - no UI support yet
|
10 |
// 4 = added ui show fields for ads 4-10. Category/tag/author conditions.
|
11 |
// 5 = ad/alt pool show fields
|
12 |
-
|
|
|
|
|
13 |
|
14 |
class Ad_Injection_Widget extends WP_Widget {
|
15 |
function Ad_Injection_Widget() {
|
@@ -30,6 +32,16 @@ class Ad_Injection_Widget extends WP_Widget {
|
|
30 |
(is_404() && adinj_ticked('widget_exclude_404'))){
|
31 |
return;
|
32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
if (!adinj_allowed_in_category('widget', $instance)) return;
|
35 |
if (!adinj_allowed_in_tag('widget', $instance)) return;
|
@@ -120,14 +132,24 @@ class Ad_Injection_Widget extends WP_Widget {
|
|
120 |
'margin_bottom' => 'd',
|
121 |
'padding_top' => 'd',
|
122 |
'padding_bottom' => 'd',
|
|
|
|
|
123 |
'widget_category_condition_mode' => 'o',
|
124 |
'widget_category_condition_entries' => '',
|
125 |
'widget_tag_condition_mode' => 'o',
|
126 |
'widget_tag_condition_entries' => '',
|
127 |
'widget_author_condition_mode' => 'o',
|
128 |
'widget_author_condition_entries' => '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
//ui
|
130 |
'ui_ad_1_show' => 'true',
|
|
|
131 |
'ui_conditions_show' => 'false',
|
132 |
'ui_spacing_show' => 'false',
|
133 |
'ui_ad_pool_show' => 'false',
|
@@ -205,6 +227,24 @@ class Ad_Injection_Widget extends WP_Widget {
|
|
205 |
}
|
206 |
?>
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
<br />
|
209 |
<b> Category, tag and author conditions</b>
|
210 |
<?php
|
@@ -216,10 +256,12 @@ class Ad_Injection_Widget extends WP_Widget {
|
|
216 |
?>
|
217 |
|
218 |
<br />
|
219 |
-
<b> Spacing options</b>
|
220 |
<?php $this->add_show_hide_section('ad_spacing_'.uniqid(), 'ui_spacing_show', $instance); ?>
|
221 |
<table border="0" width="490px" class="adinjtable">
|
222 |
<tr><td>
|
|
|
|
|
223 |
<?php adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom') ); ?>
|
224 |
</td><td>
|
225 |
<?php adinj_add_padding_top_bottom_options('widget_', $instance, $this->get_field_name('padding_top'), $this->get_field_name('padding_bottom') ); ?>
|
@@ -252,11 +294,18 @@ class Ad_Injection_Widget extends WP_Widget {
|
|
252 |
|
253 |
<br />
|
254 |
|
255 |
-
<p>Other options to define who sees these adverts (by page age, IP, referrer) are on the main <a href='options-general.php?page=ad-injection.php'>Ad Injection settings page</a>. You can also set
|
256 |
|
257 |
<?php
|
258 |
}
|
259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
function add_row($op_stem, $num, $label, $show_op, $total_split, $ops){
|
261 |
$op = $op_stem.$num;
|
262 |
$op_split = $op.'_split';
|
@@ -298,10 +347,6 @@ HTML;
|
|
298 |
echo 'id="'.$this->get_field_id($op).'" name="'.$this->get_field_name($op).'"';
|
299 |
}
|
300 |
|
301 |
-
function add_id_and_name($op){
|
302 |
-
echo 'id="'.$this->get_field_id($op).'" name="'.$this->get_field_name($op).'"';
|
303 |
-
}
|
304 |
-
|
305 |
function get_ad_file_path($num){
|
306 |
return ADINJ_AD_PATH.'/'.$this->get_ad_file_name($num);
|
307 |
}
|
9 |
// 3 = increase db rotation slots to 10 - no UI support yet
|
10 |
// 4 = added ui show fields for ads 4-10. Category/tag/author conditions.
|
11 |
// 5 = ad/alt pool show fields
|
12 |
+
// 6 = page type restrictions
|
13 |
+
// 7 = align and clear
|
14 |
+
define('ADINJ_WIDGET_DB_VERSION', 7);
|
15 |
|
16 |
class Ad_Injection_Widget extends WP_Widget {
|
17 |
function Ad_Injection_Widget() {
|
32 |
(is_404() && adinj_ticked('widget_exclude_404'))){
|
33 |
return;
|
34 |
}
|
35 |
+
|
36 |
+
if ((is_front_page() && adinj_ticked('exclude_front', $instance)) ||
|
37 |
+
(is_home() && adinj_ticked('exclude_home', $instance)) ||
|
38 |
+
(is_page() && adinj_ticked('exclude_page', $instance)) ||
|
39 |
+
(is_single() && adinj_ticked('exclude_single', $instance)) ||
|
40 |
+
(is_archive() && adinj_ticked('exclude_archive', $instance)) ||
|
41 |
+
(is_search() && adinj_ticked('exclude_search', $instance)) ||
|
42 |
+
(is_404() && adinj_ticked('exclude_404', $instance))){
|
43 |
+
return;
|
44 |
+
}
|
45 |
|
46 |
if (!adinj_allowed_in_category('widget', $instance)) return;
|
47 |
if (!adinj_allowed_in_tag('widget', $instance)) return;
|
132 |
'margin_bottom' => 'd',
|
133 |
'padding_top' => 'd',
|
134 |
'padding_bottom' => 'd',
|
135 |
+
'align' => 'd',
|
136 |
+
'clear' => 'd',
|
137 |
'widget_category_condition_mode' => 'o',
|
138 |
'widget_category_condition_entries' => '',
|
139 |
'widget_tag_condition_mode' => 'o',
|
140 |
'widget_tag_condition_entries' => '',
|
141 |
'widget_author_condition_mode' => 'o',
|
142 |
'widget_author_condition_entries' => '',
|
143 |
+
'exclude_front' => '',
|
144 |
+
'exclude_home' => '',
|
145 |
+
'exclude_page' => '',
|
146 |
+
'exclude_single' => '',
|
147 |
+
'exclude_archive' => '',
|
148 |
+
'exclude_search' => '',
|
149 |
+
'exclude_404' => '',
|
150 |
//ui
|
151 |
'ui_ad_1_show' => 'true',
|
152 |
+
'ui_pagetypes_show' => 'false',
|
153 |
'ui_conditions_show' => 'false',
|
154 |
'ui_spacing_show' => 'false',
|
155 |
'ui_ad_pool_show' => 'false',
|
227 |
}
|
228 |
?>
|
229 |
|
230 |
+
<br />
|
231 |
+
<b> Exclude this widget from page types</b>
|
232 |
+
<?php $this->add_show_hide_section('ad_pagetypes_'.uniqid(), 'ui_pagetypes_show', $instance); ?>
|
233 |
+
<?php
|
234 |
+
$count_pages = wp_count_posts('page', 'readable');
|
235 |
+
$count_posts = wp_count_posts('post', 'readable');
|
236 |
+
?>
|
237 |
+
<?php $this->add_checkbox('exclude_front', $instance) ?>front - <?php echo get_bloginfo('url'); ?><br />
|
238 |
+
<?php $this->add_checkbox('exclude_home', $instance) ?>home page (latest posts page - may or may not be same as front)<br />
|
239 |
+
<?php $this->add_checkbox('exclude_page', $instance) ?>page - <?php echo $count_pages->publish; ?> single page(s)<br />
|
240 |
+
<?php $this->add_checkbox('exclude_single', $instance) ?>single - <?php echo $count_posts->publish; ?> single post(s)<br />
|
241 |
+
<?php $this->add_checkbox('exclude_archive', $instance) ?>archive - categories, tags, authors, dates<br />
|
242 |
+
<?php $this->add_checkbox('exclude_search', $instance) ?>search (widgets only for now)<br />
|
243 |
+
<?php $this->add_checkbox('exclude_404', $instance) ?>404 (widgets only for now)<br />
|
244 |
+
<span style="font-size:10px;"><b>Notes:</b> Your home page is the page displaying your latest posts. It may be different to your front page if you have configured your front page to be a static page.</span><br />
|
245 |
+
<span style="font-size:10px;">If you have <a href='options-reading.php'>set your front page</a> to be a static 'page' rather than your latest posts, the 'page' tick box will also apply to the front page.</span>
|
246 |
+
</div>
|
247 |
+
|
248 |
<br />
|
249 |
<b> Category, tag and author conditions</b>
|
250 |
<?php
|
256 |
?>
|
257 |
|
258 |
<br />
|
259 |
+
<b> Spacing and alignment options</b>
|
260 |
<?php $this->add_show_hide_section('ad_spacing_'.uniqid(), 'ui_spacing_show', $instance); ?>
|
261 |
<table border="0" width="490px" class="adinjtable">
|
262 |
<tr><td>
|
263 |
+
<?php adinj_add_alignment_clear_options('widget_', $instance, $this->get_field_name('align'), $this->get_field_name('clear') ); ?>
|
264 |
+
</td><td>
|
265 |
<?php adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom') ); ?>
|
266 |
</td><td>
|
267 |
<?php adinj_add_padding_top_bottom_options('widget_', $instance, $this->get_field_name('padding_top'), $this->get_field_name('padding_bottom') ); ?>
|
294 |
|
295 |
<br />
|
296 |
|
297 |
+
<p>Other options to define who sees these adverts (by page age, IP, referrer) are on the main <a href='options-general.php?page=ad-injection.php'>Ad Injection settings page</a>. You can also set a global <a href='options-general.php?page=ad-injection.php#adsettings'>page type</a> restrictions for the widgets.</p>
|
298 |
|
299 |
<?php
|
300 |
}
|
301 |
|
302 |
+
function add_checkbox($name, $instance){
|
303 |
+
?>
|
304 |
+
<input type="hidden" <?php $this->add_name($name); ?> value="off" />
|
305 |
+
<input type="checkbox" <?php $this->add_name($name); ?> <?php echo adinj_ticked($name, $instance); ?> />
|
306 |
+
<?php
|
307 |
+
}
|
308 |
+
|
309 |
function add_row($op_stem, $num, $label, $show_op, $total_split, $ops){
|
310 |
$op = $op_stem.$num;
|
311 |
$op_split = $op.'_split';
|
347 |
echo 'id="'.$this->get_field_id($op).'" name="'.$this->get_field_name($op).'"';
|
348 |
}
|
349 |
|
|
|
|
|
|
|
|
|
350 |
function get_ad_file_path($num){
|
351 |
return ADINJ_AD_PATH.'/'.$this->get_ad_file_name($num);
|
352 |
}
|
ad-injection.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Ad Injection
|
4 |
Plugin URI: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
|
5 |
Description: Injects any advert (e.g. AdSense) into your WordPress posts or widget area. Restrict who sees the ads by post length, age, referrer or IP. Cache compatible.
|
6 |
-
Version: 0.9.7.
|
7 |
Author: reviewmylife
|
8 |
Author URI: http://www.reviewmylife.co.uk/
|
9 |
License: GPLv2
|
@@ -26,7 +26,8 @@ define('ADINJ_NO_CONFIG_FILE', 1);
|
|
26 |
// 7 = cat/tag/author restriction for top/random/bottom ads
|
27 |
// 8 = ui options for new layout
|
28 |
// 9 = replace the two direct modes with 'direct'
|
29 |
-
|
|
|
30 |
|
31 |
// Files
|
32 |
// TODO will these paths work on windows?
|
@@ -201,6 +202,13 @@ function adinj_ad_code_bottom(){
|
|
201 |
return $ad;
|
202 |
}
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
/**
|
205 |
Old:
|
206 |
ad_code_random_1 <-> ad_random_1.txt
|
@@ -213,8 +221,8 @@ function adinj_live_ads_array($type, $ads_option, &$ads, &$split, $output_type="
|
|
213 |
$op_stem = "";
|
214 |
$file_stem = "";
|
215 |
|
216 |
-
if ($type == 'random' || $type == 'top' || $type == 'bottom' ||
|
217 |
-
$type == 'random_alt' || $type == 'top_alt' || $type == 'bottom_alt'){
|
218 |
$op_stem = 'ad_code_'.$type.'_';
|
219 |
$file_stem = 'ad_'.$type.'_';
|
220 |
} else if (preg_match("/widget_[\d+]/i", $type)){
|
@@ -277,6 +285,7 @@ function adinj_formatting_options($adtype, $ops, $output_type="string"){
|
|
277 |
if ($adtype == 'random') $prefix = 'rnd_';
|
278 |
if ($adtype == 'top') $prefix = 'top_';
|
279 |
if ($adtype == 'bottom') $prefix = 'bottom_';
|
|
|
280 |
//widgets have no prefix
|
281 |
|
282 |
$align = $ops[$prefix.'align'];
|
@@ -404,6 +413,19 @@ injection mode=$mode
|
|
404 |
//-->\n";
|
405 |
}
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
function adinj_ads_completely_disabled_from_page($content=NULL){
|
408 |
$ops = adinj_options();
|
409 |
if ($ops['ads_enabled'] == 'off' ||
|
@@ -482,11 +504,11 @@ function adinj_allowed_in_category($scope, $ops){
|
|
482 |
|
483 |
$mode = $ops[$scope.'_category_condition_mode'];
|
484 |
|
485 |
-
if (
|
486 |
return false;
|
487 |
}
|
488 |
|
489 |
-
if (adinj_mode_only_show_in($mode) && !(is_single() || is_home() || is_category())){
|
490 |
return false;
|
491 |
}
|
492 |
|
@@ -511,11 +533,11 @@ function adinj_allowed_in_tag($scope, $ops){
|
|
511 |
|
512 |
$mode = $ops[$scope.'_tag_condition_mode'];
|
513 |
|
514 |
-
if (
|
515 |
return false;
|
516 |
}
|
517 |
|
518 |
-
if (adinj_mode_only_show_in($mode) && !(is_single() || is_home() || is_tag())){
|
519 |
return false;
|
520 |
}
|
521 |
|
@@ -540,11 +562,11 @@ function adinj_allowed_in_author($scope, $ops){
|
|
540 |
|
541 |
$mode = $ops[$scope.'_author_condition_mode'];
|
542 |
|
543 |
-
if (
|
544 |
return false;
|
545 |
}
|
546 |
|
547 |
-
if (adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_home() || is_author())){
|
548 |
return false;
|
549 |
}
|
550 |
|
@@ -569,7 +591,12 @@ function adinj_split_comma_list($list){
|
|
569 |
return preg_split("/[\s,]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
570 |
}
|
571 |
|
572 |
-
function
|
|
|
|
|
|
|
|
|
|
|
573 |
if (is_feed()) return $content; // TODO feed specific ads
|
574 |
if (!in_the_loop()) return $content; // Don't insert ads into meta description tags TODOTODO
|
575 |
$ops = adinj_options();
|
@@ -625,7 +652,7 @@ function adinj_inject_hook($content){
|
|
625 |
$length = strlen(strip_tags($content));
|
626 |
if ($debug_on) $debug .= "\nnum chars: = $length (viewable chars only)";
|
627 |
} else {
|
628 |
-
$length =
|
629 |
if ($debug_on) $debug .= "\nnum words: = $length";
|
630 |
}
|
631 |
# Insert top and bottom ads if necesary
|
@@ -766,6 +793,12 @@ function adinj_inject_hook($content){
|
|
766 |
return adinj($content_adfree_header.$content.$content_adfree_footer, "Ads injected: " . $debug);
|
767 |
}
|
768 |
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
function adinj_paragraph_to_start_ads(){
|
770 |
$ops = adinj_options();
|
771 |
if (adinj_db_version($ops) == 1){
|
@@ -799,6 +832,7 @@ function adinj_get_current_page_type_prefix(){
|
|
799 |
}
|
800 |
|
801 |
function adinj_num_top_ads_to_insert($content_length){
|
|
|
802 |
$ops = adinj_options();
|
803 |
$prefix = adinj_get_current_page_type_prefix();
|
804 |
$max_num_ads_to_insert = 0;
|
@@ -821,6 +855,7 @@ function adinj_num_top_ads_to_insert($content_length){
|
|
821 |
}
|
822 |
|
823 |
function adinj_num_bottom_ads_to_insert($content_length){
|
|
|
824 |
$ops = adinj_options();
|
825 |
$prefix = adinj_get_current_page_type_prefix();
|
826 |
$max_num_ads_to_insert = 0;
|
@@ -843,6 +878,7 @@ function adinj_num_bottom_ads_to_insert($content_length){
|
|
843 |
}
|
844 |
|
845 |
function adinj_num_rand_ads_to_insert($content_length){
|
|
|
846 |
global $adinj_total_random_ads_used; // a page can be more than one post
|
847 |
$ops = adinj_options();
|
848 |
$max_ads_in_post = 0;
|
@@ -883,6 +919,15 @@ function adinj_num_rand_ads_to_insert($content_length){
|
|
883 |
return $max_num_rand_ads_to_insert;
|
884 |
}
|
885 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
function adinj_do_rule_if($rule_value, $condition, $content_length){
|
887 |
if (adinj_alwaysshow($rule_value)) return true;
|
888 |
if (adinj_disabled($rule_value)) return false;
|
@@ -913,8 +958,8 @@ function adinj_alwaysshow($value){
|
|
913 |
return "$value" == ADINJ_ALWAYS_SHOW || "$value" == 'a';
|
914 |
}
|
915 |
|
916 |
-
function adinj_ticked($option){
|
917 |
-
$ops = adinj_options();
|
918 |
if (!empty($ops[$option]) && $ops[$option] != 'off') return 'checked="checked"';
|
919 |
return false;
|
920 |
}
|
@@ -957,7 +1002,8 @@ function adinj_widgets_init() {
|
|
957 |
register_activation_hook(__FILE__, 'adinj_activate_hook');
|
958 |
// Content injection
|
959 |
add_action('wp_enqueue_scripts', 'adinj_addsevjs_hook');
|
960 |
-
add_filter('the_content', '
|
|
|
961 |
add_action('wp_footer', 'adinj_print_referrers_hook');
|
962 |
|
963 |
?>
|
3 |
Plugin Name: Ad Injection
|
4 |
Plugin URI: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/
|
5 |
Description: Injects any advert (e.g. AdSense) into your WordPress posts or widget area. Restrict who sees the ads by post length, age, referrer or IP. Cache compatible.
|
6 |
+
Version: 0.9.7.7
|
7 |
Author: reviewmylife
|
8 |
Author URI: http://www.reviewmylife.co.uk/
|
9 |
License: GPLv2
|
26 |
// 7 = cat/tag/author restriction for top/random/bottom ads
|
27 |
// 8 = ui options for new layout
|
28 |
// 9 = replace the two direct modes with 'direct'
|
29 |
+
// 10 = exclusion tick boxes for top, random, bottom, and new footer ad
|
30 |
+
define('ADINJ_DB_VERSION', 10);
|
31 |
|
32 |
// Files
|
33 |
// TODO will these paths work on windows?
|
202 |
return $ad;
|
203 |
}
|
204 |
|
205 |
+
function adinj_ad_code_footer(){
|
206 |
+
$ad = adinj_get_ad_code('footer', adinj_options());
|
207 |
+
global $adinj_total_all_ads_used;
|
208 |
+
++$adinj_total_all_ads_used;
|
209 |
+
return $ad;
|
210 |
+
}
|
211 |
+
|
212 |
/**
|
213 |
Old:
|
214 |
ad_code_random_1 <-> ad_random_1.txt
|
221 |
$op_stem = "";
|
222 |
$file_stem = "";
|
223 |
|
224 |
+
if ($type == 'random' || $type == 'top' || $type == 'bottom' || $type == 'footer' ||
|
225 |
+
$type == 'random_alt' || $type == 'top_alt' || $type == 'bottom_alt' || $type == 'footer_alt'){
|
226 |
$op_stem = 'ad_code_'.$type.'_';
|
227 |
$file_stem = 'ad_'.$type.'_';
|
228 |
} else if (preg_match("/widget_[\d+]/i", $type)){
|
285 |
if ($adtype == 'random') $prefix = 'rnd_';
|
286 |
if ($adtype == 'top') $prefix = 'top_';
|
287 |
if ($adtype == 'bottom') $prefix = 'bottom_';
|
288 |
+
if ($adtype == 'footer') $prefix = 'footer_';
|
289 |
//widgets have no prefix
|
290 |
|
291 |
$align = $ops[$prefix.'align'];
|
413 |
//-->\n";
|
414 |
}
|
415 |
|
416 |
+
function adinj_excluded_by_tick_box($prefix){
|
417 |
+
if (is_front_page() && adinj_ticked($prefix.'exclude_front') ||
|
418 |
+
is_home() && adinj_ticked($prefix.'exclude_home') ||
|
419 |
+
is_search() && adinj_ticked($prefix.'exclude_search') ||
|
420 |
+
is_404() && adinj_ticked($prefix.'exclude_404') ||
|
421 |
+
is_page() && adinj_ticked($prefix.'exclude_page') ||
|
422 |
+
is_single() && adinj_ticked($prefix.'exclude_single') ||
|
423 |
+
is_archive() && adinj_ticked($prefix.'exclude_archive')){
|
424 |
+
return true;
|
425 |
+
}
|
426 |
+
return false;
|
427 |
+
}
|
428 |
+
|
429 |
function adinj_ads_completely_disabled_from_page($content=NULL){
|
430 |
$ops = adinj_options();
|
431 |
if ($ops['ads_enabled'] == 'off' ||
|
504 |
|
505 |
$mode = $ops[$scope.'_category_condition_mode'];
|
506 |
|
507 |
+
if (!in_the_loop() && adinj_mode_only_show_in($mode) && !(is_single() || is_category())){
|
508 |
return false;
|
509 |
}
|
510 |
|
511 |
+
if (in_the_loop() && adinj_mode_only_show_in($mode) && !(is_single() || is_home() || is_category())){
|
512 |
return false;
|
513 |
}
|
514 |
|
533 |
|
534 |
$mode = $ops[$scope.'_tag_condition_mode'];
|
535 |
|
536 |
+
if (!in_the_loop() && adinj_mode_only_show_in($mode) && !(is_single() || is_tag())){
|
537 |
return false;
|
538 |
}
|
539 |
|
540 |
+
if (in_the_loop() && adinj_mode_only_show_in($mode) && !(is_single() || is_home() || is_tag())){
|
541 |
return false;
|
542 |
}
|
543 |
|
562 |
|
563 |
$mode = $ops[$scope.'_author_condition_mode'];
|
564 |
|
565 |
+
if (!in_the_loop() && adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_author())){
|
566 |
return false;
|
567 |
}
|
568 |
|
569 |
+
if (in_the_loop()&& adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_home() || is_author())){
|
570 |
return false;
|
571 |
}
|
572 |
|
591 |
return preg_split("/[\s,]+/", $list, -1, PREG_SPLIT_NO_EMPTY);
|
592 |
}
|
593 |
|
594 |
+
function adinj_footer_hook(){
|
595 |
+
if (adinj_num_footer_ads_to_insert() <= 0) return;
|
596 |
+
echo adinj_ad_code_footer();
|
597 |
+
}
|
598 |
+
|
599 |
+
function adinj_content_hook($content){
|
600 |
if (is_feed()) return $content; // TODO feed specific ads
|
601 |
if (!in_the_loop()) return $content; // Don't insert ads into meta description tags TODOTODO
|
602 |
$ops = adinj_options();
|
652 |
$length = strlen(strip_tags($content));
|
653 |
if ($debug_on) $debug .= "\nnum chars: = $length (viewable chars only)";
|
654 |
} else {
|
655 |
+
$length = str_word_count_utf8(strip_tags($content));
|
656 |
if ($debug_on) $debug .= "\nnum words: = $length";
|
657 |
}
|
658 |
# Insert top and bottom ads if necesary
|
793 |
return adinj($content_adfree_header.$content.$content_adfree_footer, "Ads injected: " . $debug);
|
794 |
}
|
795 |
|
796 |
+
//http://php.net/manual/en/function.str-word-count.php
|
797 |
+
define("WORD_COUNT_MASK", "/\p{L}[\p{L}\p{Mn}\p{Pd}'\x{2019}]*/u");
|
798 |
+
function str_word_count_utf8($str){
|
799 |
+
return preg_match_all(WORD_COUNT_MASK, $str, $matches);
|
800 |
+
}
|
801 |
+
|
802 |
function adinj_paragraph_to_start_ads(){
|
803 |
$ops = adinj_options();
|
804 |
if (adinj_db_version($ops) == 1){
|
832 |
}
|
833 |
|
834 |
function adinj_num_top_ads_to_insert($content_length){
|
835 |
+
if (adinj_excluded_by_tick_box('top_')) return 0;
|
836 |
$ops = adinj_options();
|
837 |
$prefix = adinj_get_current_page_type_prefix();
|
838 |
$max_num_ads_to_insert = 0;
|
855 |
}
|
856 |
|
857 |
function adinj_num_bottom_ads_to_insert($content_length){
|
858 |
+
if (adinj_excluded_by_tick_box('bottom_')) return 0;
|
859 |
$ops = adinj_options();
|
860 |
$prefix = adinj_get_current_page_type_prefix();
|
861 |
$max_num_ads_to_insert = 0;
|
878 |
}
|
879 |
|
880 |
function adinj_num_rand_ads_to_insert($content_length){
|
881 |
+
if (adinj_excluded_by_tick_box('random_')) return 0;
|
882 |
global $adinj_total_random_ads_used; // a page can be more than one post
|
883 |
$ops = adinj_options();
|
884 |
$max_ads_in_post = 0;
|
919 |
return $max_num_rand_ads_to_insert;
|
920 |
}
|
921 |
|
922 |
+
function adinj_num_footer_ads_to_insert(){
|
923 |
+
if (adinj_excluded_by_tick_box('footer_')) return 0;
|
924 |
+
$reason = adinj_ads_completely_disabled_from_page($content);
|
925 |
+
if ($reason !== false){
|
926 |
+
return 0;
|
927 |
+
}
|
928 |
+
return 1;
|
929 |
+
}
|
930 |
+
|
931 |
function adinj_do_rule_if($rule_value, $condition, $content_length){
|
932 |
if (adinj_alwaysshow($rule_value)) return true;
|
933 |
if (adinj_disabled($rule_value)) return false;
|
958 |
return "$value" == ADINJ_ALWAYS_SHOW || "$value" == 'a';
|
959 |
}
|
960 |
|
961 |
+
function adinj_ticked($option, $ops=array()){
|
962 |
+
if (empty($ops)) $ops = adinj_options();
|
963 |
if (!empty($ops[$option]) && $ops[$option] != 'off') return 'checked="checked"';
|
964 |
return false;
|
965 |
}
|
1002 |
register_activation_hook(__FILE__, 'adinj_activate_hook');
|
1003 |
// Content injection
|
1004 |
add_action('wp_enqueue_scripts', 'adinj_addsevjs_hook');
|
1005 |
+
add_filter('the_content', 'adinj_content_hook');
|
1006 |
+
add_action('wp_footer', 'adinj_footer_hook');
|
1007 |
add_action('wp_footer', 'adinj_print_referrers_hook');
|
1008 |
|
1009 |
?>
|
adshow.php
CHANGED
@@ -22,9 +22,9 @@ if (!function_exists('adshow_functions_exist')){
|
|
22 |
// and so that a problem doesn't disable the whole website.
|
23 |
function adshow_functions_exist(){
|
24 |
if (!defined('ADINJ_NO_CONFIG_FILE')){
|
25 |
-
if (!adshow_functions_exist_impl('adinj_config_add_tags_rnd')){ return false; }
|
26 |
-
if (!adshow_functions_exist_impl('adinj_config_add_tags_top')){ return false; }
|
27 |
-
if (!adshow_functions_exist_impl('adinj_config_add_tags_bottom')){ return false; }
|
28 |
if (!adshow_functions_exist_impl('adinj_config_sevisitors_only')){ return false; }
|
29 |
if (!adshow_functions_exist_impl('adinj_config_search_engine_referrers')){ return false; }
|
30 |
//if (!adshow_functions_exist_impl('adinj_config_block_ips')){ return false; } // TODO enable
|
@@ -68,67 +68,6 @@ function adinj_config_debug_mode() {
|
|
68 |
|
69 |
//////////////////////////////////////////////////////////////////////////////
|
70 |
|
71 |
-
// TODO delete
|
72 |
-
if (!function_exists('adshow_display_ad_file')){
|
73 |
-
function adshow_display_ad_file($adfile){
|
74 |
-
if (!adshow_functions_exist()){ return false; }
|
75 |
-
|
76 |
-
if (adinj_config_debug_mode()){
|
77 |
-
echo "<!--ADINJ DEBUG: adshow_display_ad_file($adfile)-->";
|
78 |
-
}
|
79 |
-
$plugin_dir = dirname(__FILE__);
|
80 |
-
$ad_path1 = $plugin_dir.'/ads/'.$adfile;
|
81 |
-
if (file_exists($ad_path1)){
|
82 |
-
adshow_display_ad_full_path($ad_path1);
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
|
86 |
-
$ad_path2 = dirname($plugin_dir).'/ad-injection-data/'.$adfile;
|
87 |
-
if (file_exists($ad_path2)){
|
88 |
-
adshow_display_ad_full_path($ad_path2);
|
89 |
-
return;
|
90 |
-
}
|
91 |
-
echo "
|
92 |
-
<!--ADINJ DEBUG: could not read ad from either:
|
93 |
-
$ad_path1
|
94 |
-
$ad_path2
|
95 |
-
If you have just upgraded you may need to re-save your ads to regenerate the ad files.
|
96 |
-
-->";
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
// TODO delete
|
101 |
-
if (!function_exists('adshow_display_ad_full_path')){
|
102 |
-
function adshow_display_ad_full_path($ad_path){
|
103 |
-
if (!adshow_functions_exist()){ return false; }
|
104 |
-
|
105 |
-
$showads = adshow_show_adverts();
|
106 |
-
if ($showads !== true){
|
107 |
-
if (adinj_config_debug_mode()){
|
108 |
-
echo "<!--ADINJ DEBUG: ad blocked at run time reason=$showads-->";
|
109 |
-
}
|
110 |
-
return;
|
111 |
-
}
|
112 |
-
if (file_exists($ad_path)){
|
113 |
-
$ad = file_get_contents($ad_path);
|
114 |
-
if ($ad === false) echo "<!--ADINJ DEBUG: could not read ad from file: $ad_path-->\n";
|
115 |
-
if (stripos($ad_path, 'random_1.txt') > 0){ // TODO something better than this
|
116 |
-
echo adinj_config_add_tags_rnd(adshow_eval_php($ad));
|
117 |
-
} else if (stripos($ad_path, 'top_1.txt') > 0){
|
118 |
-
echo adinj_config_add_tags_top(adshow_eval_php($ad));
|
119 |
-
} else if (stripos($ad_path, 'bottom_1.txt') > 0){
|
120 |
-
echo adinj_config_add_tags_bottom(adshow_eval_php($ad));
|
121 |
-
} else {
|
122 |
-
echo adshow_eval_php($ad);
|
123 |
-
}
|
124 |
-
} else {
|
125 |
-
echo "\n<!--ADINJ DEBUG: ad file does not exist: $ad_path.\nIf you have just upgraded you may need to re-save your ads to regenerate the ad files.\n-->";
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
//////////////////////////////////////////////////////////////////////////////
|
131 |
-
|
132 |
if (!function_exists('adshow_display_ad_file_v2')){
|
133 |
function adshow_display_ad_file_v2($adfiles, $adfiles_frequency = array(), $options = array(), $altfiles = array(), $altfiles_frequency = array()){
|
134 |
if (!adshow_functions_exist()){ return false; }
|
22 |
// and so that a problem doesn't disable the whole website.
|
23 |
function adshow_functions_exist(){
|
24 |
if (!defined('ADINJ_NO_CONFIG_FILE')){
|
25 |
+
if (!adshow_functions_exist_impl('adinj_config_add_tags_rnd')){ return false; } //TODO delete
|
26 |
+
if (!adshow_functions_exist_impl('adinj_config_add_tags_top')){ return false; } //TODO delete
|
27 |
+
if (!adshow_functions_exist_impl('adinj_config_add_tags_bottom')){ return false; } //TODO delete
|
28 |
if (!adshow_functions_exist_impl('adinj_config_sevisitors_only')){ return false; }
|
29 |
if (!adshow_functions_exist_impl('adinj_config_search_engine_referrers')){ return false; }
|
30 |
//if (!adshow_functions_exist_impl('adinj_config_block_ips')){ return false; } // TODO enable
|
68 |
|
69 |
//////////////////////////////////////////////////////////////////////////////
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
if (!function_exists('adshow_display_ad_file_v2')){
|
72 |
function adshow_display_ad_file_v2($adfiles, $adfiles_frequency = array(), $options = array(), $altfiles = array(), $altfiles_frequency = array()){
|
73 |
if (!adshow_functions_exist()){ return false; }
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-w
|
|
4 |
Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, widgets, sidebar, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free, blog, ad rotation, A:B testing, split testing, WP Super Cache, W3 Total Cache, WP Cache
|
5 |
Requires at least: 2.8.6
|
6 |
Tested up to: 3.1
|
7 |
-
Stable tag: 0.9.7.
|
8 |
|
9 |
Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
|
10 |
|
@@ -16,6 +16,7 @@ Ad Injection injects any kind of advert (e.g. Google AdSense, Amazon Associates,
|
|
16 |
|
17 |
* Archive and home page ads now fully supported with the same controls as ads for single posts/pages.
|
18 |
* Category, tag and author restrictions for top, random and bottom ads.
|
|
|
19 |
|
20 |
**New Features 0.9.6.x**
|
21 |
|
@@ -308,6 +309,10 @@ By default FeedWordPress prevents the syndicated post contents from being passed
|
|
308 |
|
309 |
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'.
|
310 |
|
|
|
|
|
|
|
|
|
311 |
= Some technical details =
|
312 |
|
313 |
* Plugin stores all its settings in a single option (adinj_options).
|
@@ -372,6 +377,11 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
|
|
372 |
|
373 |
== Changelog ==
|
374 |
|
|
|
|
|
|
|
|
|
|
|
375 |
= 0.9.7.6 =
|
376 |
* Category, tag and author exclusions now apply to home page posts.
|
377 |
* Fixes for widget category exclusions.
|
@@ -521,8 +531,8 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
|
|
521 |
|
522 |
== Upgrade Notice ==
|
523 |
|
524 |
-
= 0.9.7.
|
525 |
-
*
|
526 |
|
527 |
= 0.8.3 =
|
528 |
First public release.
|
4 |
Tags: ad injection, adsense, advert injection, advert, ad, injection, advertising, affiliate, inject, injection, insert, widget, widgets, sidebar, monetize, monetise, banner, Amazon, ClickBank, TradeDoubler, Google, adBrite, post, WordPress, automatically, plugin, Adsense Injection, free, blog, ad rotation, A:B testing, split testing, WP Super Cache, W3 Total Cache, WP Cache
|
5 |
Requires at least: 2.8.6
|
6 |
Tested up to: 3.1
|
7 |
+
Stable tag: 0.9.7.7
|
8 |
|
9 |
Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Restrict who sees ads by post length/age/referrer or IP. Cache compatible.
|
10 |
|
16 |
|
17 |
* Archive and home page ads now fully supported with the same controls as ads for single posts/pages.
|
18 |
* Category, tag and author restrictions for top, random and bottom ads.
|
19 |
+
* Footer ads.
|
20 |
|
21 |
**New Features 0.9.6.x**
|
22 |
|
309 |
|
310 |
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'.
|
311 |
|
312 |
+
= Will Ad Injection work with the multi-blog version of WordPress? =
|
313 |
+
|
314 |
+
The multi-user version of WordPress are not supported - yet, however I have heard that some people have got it to work when using the 'direct' insertion mode. I hope to make it work properly with multi-blog versions of WordPress in the future.
|
315 |
+
|
316 |
= Some technical details =
|
317 |
|
318 |
* Plugin stores all its settings in a single option (adinj_options).
|
377 |
|
378 |
== Changelog ==
|
379 |
|
380 |
+
= 0.9.7.7 =
|
381 |
+
* Footer ad support (only for themes that correctly use the wp_footer hook).
|
382 |
+
* Align and clear options for widgets.
|
383 |
+
* Word counting code now works for non-Latin languages.
|
384 |
+
|
385 |
= 0.9.7.6 =
|
386 |
* Category, tag and author exclusions now apply to home page posts.
|
387 |
* Fixes for widget category exclusions.
|
531 |
|
532 |
== Upgrade Notice ==
|
533 |
|
534 |
+
= 0.9.7.7 =
|
535 |
+
* Footer ad support. Clear and align options for widgets. And word counting for non-Latin languages.
|
536 |
|
537 |
= 0.8.3 =
|
538 |
First public release.
|
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="#misc">Misc settings</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);
|
@@ -21,6 +21,9 @@ DOCS;
|
|
21 |
|
22 |
$total_bottom_split = adinj_total_split('ad_code_bottom_', $ops);
|
23 |
$total_bottom_alt_split = adinj_total_split('ad_code_bottom_alt_', $ops);
|
|
|
|
|
|
|
24 |
?>
|
25 |
|
26 |
<style type="text/css">
|
@@ -70,6 +73,17 @@ DOCS;
|
|
70 |
echo '</table>';
|
71 |
adinj_postbox_end();
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
adinj_postbox_start(__("Misc options", 'adinj'), 'misc'); ?>
|
75 |
<table>
|
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="#misc">Misc settings</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);
|
21 |
|
22 |
$total_bottom_split = adinj_total_split('ad_code_bottom_', $ops);
|
23 |
$total_bottom_alt_split = adinj_total_split('ad_code_bottom_alt_', $ops);
|
24 |
+
|
25 |
+
$total_footer_split = adinj_total_split('ad_code_footer_', $ops);
|
26 |
+
$total_footer_alt_split = adinj_total_split('ad_code_footer_alt_', $ops);
|
27 |
?>
|
28 |
|
29 |
<style type="text/css">
|
73 |
echo '</table>';
|
74 |
adinj_postbox_end();
|
75 |
|
76 |
+
|
77 |
+
adinj_postbox_start(__("Footer adverts", 'adinj'), 'multiple_footer');
|
78 |
+
echo '<table border="0" cellspacing="5" class="adinjtable">';
|
79 |
+
for ($i=1; $i<=10; ++$i){
|
80 |
+
adinj_add_row_with_text_box('ad_code_footer_', $i, 'Ad code', $total_footer_split);
|
81 |
+
}
|
82 |
+
adinj_add_row_with_text_box('ad_code_footer_alt_', 1, 'Alt content', $total_footer_alt_split);
|
83 |
+
adinj_add_row_with_text_box('ad_code_footer_alt_', 2, 'Alt content', $total_footer_alt_split);
|
84 |
+
echo '</table>';
|
85 |
+
adinj_postbox_end();
|
86 |
+
|
87 |
|
88 |
adinj_postbox_start(__("Misc options", 'adinj'), 'misc'); ?>
|
89 |
<table>
|
ui-tab-main.php
CHANGED
@@ -71,18 +71,38 @@ function adinj_tab_main(){
|
|
71 |
$count_pages = wp_count_posts('page', 'readable');
|
72 |
$count_posts = wp_count_posts('post', 'readable');
|
73 |
?>
|
74 |
-
|
75 |
-
|
76 |
-
<
|
77 |
-
<tr
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
<p><span style="font-size:10px;"><b>Notes:</b> Your home page is the page displaying your latest posts. It may be different to your front page if you have configured your front page to be a static page.</span></p>
|
84 |
<p><span style="font-size:10px;">If you have <a href='options-reading.php'>set your front page</a> to be a static 'page' rather than your latest posts, the 'page' tick box will also apply to the front page.</span></p>
|
85 |
-
<p><span style="font-size:10px;">You must configure your individual widgets from the <a href="widgets.php">widgets control panel</a
|
86 |
<p></p>
|
87 |
|
88 |
<table border="0" class="adinjtable">
|
@@ -173,6 +193,14 @@ function adinj_tab_main(){
|
|
173 |
<?php adinj_condition_tables('bottom_', 'ui_bottom_conditions_show'); ?>
|
174 |
<p></p>
|
175 |
</td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
</table>
|
177 |
|
178 |
<?php adinj_postbox_end(); ?>
|
@@ -225,6 +253,29 @@ function adinj_tab_main(){
|
|
225 |
</td></tr>
|
226 |
</table>
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
<?php adinj_postbox_end(); ?>
|
229 |
|
230 |
|
@@ -313,6 +364,21 @@ function adinj_tab_main(){
|
|
313 |
adinj_testads();
|
314 |
}
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
function adinj_random_ad_limit_table(){
|
317 |
?>
|
318 |
<tr><td>No ads if shorter than:</td>
|
@@ -491,6 +557,15 @@ function adinj_side_status_box(){
|
|
491 |
<td><?php adinj_print_ad_dot('bottom', 'home') ?></td>
|
492 |
<td><?php adinj_print_ad_dot('bottom', 'archive') ?></td>
|
493 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
<tr>
|
495 |
<td style="text-align:right"><b>Widget</b></td>
|
496 |
<td></td>
|
71 |
$count_pages = wp_count_posts('page', 'readable');
|
72 |
$count_posts = wp_count_posts('post', 'readable');
|
73 |
?>
|
74 |
+
|
75 |
+
|
76 |
+
<table class="adinjstatustable">
|
77 |
+
<tr>
|
78 |
+
<td></td>
|
79 |
+
<td><b>Single</b></td>
|
80 |
+
<td><b>Page</b></td>
|
81 |
+
<td><b>Home</b></td>
|
82 |
+
<td><b>Archive</b></td>
|
83 |
+
<td><b>Front</b></td>
|
84 |
+
<td><b>404</b></td>
|
85 |
+
<td><b>Search</b></td>
|
86 |
+
</tr>
|
87 |
+
<?php
|
88 |
+
adinj_add_exclude_row('All ads');
|
89 |
+
adinj_add_exclude_row('Top', 'top_');
|
90 |
+
adinj_add_exclude_row('Random', 'random_');
|
91 |
+
adinj_add_exclude_row('Bottom', 'bottom_');
|
92 |
+
adinj_add_exclude_row('Footer', 'footer_');
|
93 |
+
adinj_add_exclude_row('Widget', 'widget_');
|
94 |
+
?>
|
95 |
</table>
|
96 |
+
|
97 |
+
front - <?php echo get_bloginfo('url'); ?><br />
|
98 |
+
home page (latest posts page - may or may not be same as front)<br />
|
99 |
+
page - <?php echo $count_pages->publish; ?> single page(s)<br />
|
100 |
+
single - <?php echo $count_posts->publish; ?> single post(s)<br />
|
101 |
+
archive - categories, tags, authors, dates<br />
|
102 |
+
|
103 |
<p><span style="font-size:10px;"><b>Notes:</b> Your home page is the page displaying your latest posts. It may be different to your front page if you have configured your front page to be a static page.</span></p>
|
104 |
<p><span style="font-size:10px;">If you have <a href='options-reading.php'>set your front page</a> to be a static 'page' rather than your latest posts, the 'page' tick box will also apply to the front page.</span></p>
|
105 |
+
<p><span style="font-size:10px;">You must configure your individual widgets from the <a href="widgets.php">widgets control panel</a>.</span></p>
|
106 |
<p></p>
|
107 |
|
108 |
<table border="0" class="adinjtable">
|
193 |
<?php adinj_condition_tables('bottom_', 'ui_bottom_conditions_show'); ?>
|
194 |
<p></p>
|
195 |
</td></tr>
|
196 |
+
|
197 |
+
<tr><td colspan="4"><h3>Footer ad</h3></td></tr>
|
198 |
+
<tr><td colspan="4">
|
199 |
+
<?php adinj_condition_tables('footer_', 'ui_footer_conditions_show'); ?>
|
200 |
+
<p></p>
|
201 |
+
|
202 |
+
</td></tr>
|
203 |
+
|
204 |
</table>
|
205 |
|
206 |
<?php adinj_postbox_end(); ?>
|
253 |
</td></tr>
|
254 |
</table>
|
255 |
|
256 |
+
|
257 |
+
<h3>Footer ad (injected into 'the_footer' hook - not supported by all themes)</h3>
|
258 |
+
<table border="0" class="adinjtable">
|
259 |
+
<tr><td>
|
260 |
+
<textarea name="ad_code_footer_1" rows="10" cols="60"><?php echo $ops['ad_code_footer_1']; ?></textarea>
|
261 |
+
<br />
|
262 |
+
Docs: footer ad information and troubleshooting
|
263 |
+
<?php adinj_add_show_hide_section('footer_docs_'.uniqid(), 'ui_footer_docs_show', 'ui_footer_docs_show', $ops); ?>
|
264 |
+
<blockquote>
|
265 |
+
<p><span style="font-size:10px;">Try a <a href="#468x60">468x60</a> or <a href="#728x90">728x90</a> banner.</span></p>
|
266 |
+
<p><span style="font-size:10px;">The footer ad will only work if your theme supports it.</span></p>
|
267 |
+
<p><span style="font-size:10px;">Your theme must include 'the_footer' hook in the correct part of the page. If the footer ad is appearing in the wrong place, you could try manually editing your theme to move 'the_footer' hook.</span></p>
|
268 |
+
</blockquote>
|
269 |
+
</div>
|
270 |
+
</td><td>
|
271 |
+
<?php
|
272 |
+
adinj_add_alignment_options('footer_');
|
273 |
+
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_footer'>Rotation:<br />".adinj_percentage_split('ad_code_footer_', 1, $ops)."</a></b>";
|
274 |
+
?>
|
275 |
+
</td></tr>
|
276 |
+
</table>
|
277 |
+
|
278 |
+
|
279 |
<?php adinj_postbox_end(); ?>
|
280 |
|
281 |
|
364 |
adinj_testads();
|
365 |
}
|
366 |
|
367 |
+
function adinj_add_exclude_row($name, $prefix=''){
|
368 |
+
?>
|
369 |
+
<tr>
|
370 |
+
<td><b><?php echo $name; ?></b></td>
|
371 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_single') ?></td>
|
372 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_page') ?></td>
|
373 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_home') ?></td>
|
374 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_archive') ?></td>
|
375 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_front') ?></td>
|
376 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_404') ?></td>
|
377 |
+
<td><?php adinj_add_checkbox($prefix.'exclude_search') ?></td>
|
378 |
+
</tr>
|
379 |
+
<?php
|
380 |
+
}
|
381 |
+
|
382 |
function adinj_random_ad_limit_table(){
|
383 |
?>
|
384 |
<tr><td>No ads if shorter than:</td>
|
557 |
<td><?php adinj_print_ad_dot('bottom', 'home') ?></td>
|
558 |
<td><?php adinj_print_ad_dot('bottom', 'archive') ?></td>
|
559 |
</tr>
|
560 |
+
<tr>
|
561 |
+
<td style="text-align:right"><b>Footer</b></td>
|
562 |
+
<td><?php echo adinj_count_live_ads('footer', $ops); ?></td>
|
563 |
+
<td><?php echo adinj_count_live_ads('footer_alt', $ops); ?></td>
|
564 |
+
<td><?php adinj_print_ad_dot('footer', 'single') ?></td>
|
565 |
+
<td><?php adinj_print_ad_dot('footer', 'page') ?></td>
|
566 |
+
<td><?php adinj_print_ad_dot('footer', 'home') ?></td>
|
567 |
+
<td><?php adinj_print_ad_dot('footer', 'archive') ?></td>
|
568 |
+
</tr>
|
569 |
<tr>
|
570 |
<td style="text-align:right"><b>Widget</b></td>
|
571 |
<td></td>
|