Version Description
- Archive and home page ads now fully supported with the same controls as ads for single posts/pages.
- Category, tag and author restrictions for top, random and bottom ads.
Download this release
Release Info
Developer | reviewmylife |
Plugin | Ad Injection |
Version | 0.9.7 |
Comparing to | |
See all releases |
Code changes from version 0.9.6.6 to 0.9.7
- ad-injection-admin.php +295 -188
- ad-injection-widget.php +7 -7
- ad-injection.php +186 -104
- readme.txt +61 -3
- ui-tab-adrotation.php +80 -18
- ui-tab-debug.php +135 -0
- ui-tab-main.php +224 -496
ad-injection-admin.php
CHANGED
@@ -230,7 +230,12 @@ echo <<<HTML
|
|
230 |
}
|
231 |
</script>
|
232 |
<!--end of Ad Injection scripts-->
|
|
|
|
|
|
|
233 |
HTML;
|
|
|
|
|
234 |
}
|
235 |
|
236 |
function adinj_options_page(){
|
@@ -267,6 +272,12 @@ function adinj_options_page(){
|
|
267 |
echo '</div>';
|
268 |
adinj_tab_adrotation();
|
269 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
case "main":
|
271 |
default:
|
272 |
require_once(ADINJ_PATH . '/ui-tab-main.php');
|
@@ -320,7 +331,7 @@ function adinj_top_message_box(){
|
|
320 |
|
321 |
} else {
|
322 |
echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
|
323 |
-
echo "
|
324 |
echo '</strong></p></div>';
|
325 |
}
|
326 |
}
|
@@ -381,7 +392,7 @@ function adinj_admin_tabs( $current = 0 ) {
|
|
381 |
$current = 'main';
|
382 |
}
|
383 |
}
|
384 |
-
$tabs = array( 'main' => __( 'Main', 'ad-injection' ), 'adrotation' => __( 'Ad
|
385 |
$links = array();
|
386 |
foreach( $tabs as $tab => $name ) {
|
387 |
if ( $current == $tab ) {
|
@@ -404,23 +415,23 @@ function adinj_postbox_start($title, $anchor, $width='650px'){
|
|
404 |
<div class="metabox-holder">
|
405 |
<div class="postbox">
|
406 |
<input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
|
|
|
407 |
<?php
|
408 |
$anchorclick = $anchor.'_click';
|
409 |
$anchorupdate = $anchor.'_update';
|
410 |
$anchorhide = 'ui_'.$anchor.'_hide';
|
|
|
411 |
echo <<<HTML
|
|
|
412 |
<a href="#" onclick='javascript:$anchorclick();return false;' style="float:right;display:none" id="toggle-$anchor" class="button">Show/Hide</a>
|
413 |
<script type="text/javascript">
|
414 |
-
|
415 |
-
jQuery(
|
416 |
-
$anchorupdate();
|
417 |
-
jQuery('#toggle-$anchor').show();
|
418 |
-
});
|
419 |
|
420 |
function $anchorclick(){
|
421 |
-
jQuery('#$anchorhide').val(!jQuery('
|
|
|
422 |
$anchorupdate();
|
423 |
-
jQuery('.$anchor-box').slideToggle(300);
|
424 |
return false;
|
425 |
}
|
426 |
|
@@ -434,18 +445,14 @@ echo <<<HTML
|
|
434 |
</script>
|
435 |
HTML;
|
436 |
?>
|
437 |
-
|
438 |
<h3><?php $info = adinj_get_status($anchor); echo adinj_dot($info[0]); ?> <a name="<?php echo $anchor; ?>"></a><?php echo adinj_get_logo() . ' ' . $title; ?></h3>
|
439 |
-
<?php if($
|
440 |
-
|
441 |
-
document.write('<style type="text/css" media="screen">#<?php echo $anchor; ?>-box { display: none; }</style>');
|
442 |
-
</script>
|
443 |
-
<div id="<?php echo $anchor; ?>-box" class="<?php echo $anchor; ?>-box">
|
444 |
<?php } else { ?>
|
445 |
-
|
446 |
<?php } ?>
|
447 |
<div class="inside" style="margin:10px">
|
448 |
-
|
449 |
<?php
|
450 |
}
|
451 |
|
@@ -485,92 +492,6 @@ function adinj_get_status($name){
|
|
485 |
$status[0] = 'orange';
|
486 |
$status[1] = 'test mode';
|
487 |
}
|
488 |
-
} else if ($name == 'random'){
|
489 |
-
$count = adinj_count_live_ads('ad_code_random_', $ops);
|
490 |
-
if ($count == 0){
|
491 |
-
$status[0] = 'red';
|
492 |
-
$status[1] = 'no ads defined';
|
493 |
-
return $status;
|
494 |
-
}
|
495 |
-
$val = $ops['max_num_of_ads'];
|
496 |
-
if ($val == '0'){
|
497 |
-
$status[0] = 'red';
|
498 |
-
} else {
|
499 |
-
$status[0] = 'green';
|
500 |
-
}
|
501 |
-
$status[1] = 'single/page: ' . $val . ' <a href="#random_single">#</a>';
|
502 |
-
} else if ($name == 'random_home'){
|
503 |
-
$val = $ops['max_num_of_ads_home_page'];
|
504 |
-
if ($val == 0){
|
505 |
-
$status[0] = 'red';
|
506 |
-
} else {
|
507 |
-
$status[0] = 'green';
|
508 |
-
}
|
509 |
-
$status[1] = 'home: ' . $val .' <a href="#random_home">#</a>';
|
510 |
-
} else if ($name == 'random_pool'){
|
511 |
-
$count = adinj_count_live_ads('ad_code_random_', $ops);
|
512 |
-
$status[0] = $count == 0 ? 'red' : 'green';
|
513 |
-
$status[1] = "ad pool: " . $count." <a href='?page=ad-injection&tab=adrotation#multiple_random'>#</a>";
|
514 |
-
} else if ($name == 'top_pool'){
|
515 |
-
$count = adinj_count_live_ads('ad_code_top_', $ops);
|
516 |
-
$status[0] = $count == 0 ? 'red' : 'green';
|
517 |
-
$status[1] = "ad pool: " . $count." <a href='?page=ad-injection&tab=adrotation#multiple_top'>#</a>";
|
518 |
-
} else if ($name == 'bottom_pool'){
|
519 |
-
$count = adinj_count_live_ads('ad_code_bottom_', $ops);
|
520 |
-
$status[0] = $count == 0 ? 'red' : 'green';
|
521 |
-
$status[1] = "ad pool: " . $count." <a href='?page=ad-injection&tab=adrotation#multiple_bottom'>#</a>";
|
522 |
-
} else if ($name == 'random_alt_pool'){
|
523 |
-
$count = adinj_count_live_ads('ad_code_random_alt_', $ops);
|
524 |
-
$status[1] = "alt pool: " . $count." <a href='?page=ad-injection&tab=adrotation#ad_code_random_alt_1'>#</a>";
|
525 |
-
} else if ($name == 'top_alt_pool'){
|
526 |
-
$count = adinj_count_live_ads('ad_code_top_alt_', $ops);
|
527 |
-
$status[1] = "alt pool: " . $count." <a href='?page=ad-injection&tab=adrotation#ad_code_top_alt_1'>#</a>";
|
528 |
-
} else if ($name == 'bottom_alt_pool'){
|
529 |
-
$count = adinj_count_live_ads('ad_code_bottom_alt_', $ops);
|
530 |
-
$status[1] = "alt pool: " . $count." <a href='?page=ad-injection&tab=adrotation#ad_code_bottom_alt_1'>#</a>";
|
531 |
-
} else if ($name == 'topad'){
|
532 |
-
$count = adinj_count_live_ads('ad_code_top_', $ops);
|
533 |
-
if ($count == 0){
|
534 |
-
$status[0] = 'red';
|
535 |
-
$status[1] = 'no ad defined';
|
536 |
-
return $status;
|
537 |
-
}
|
538 |
-
$val = $ops['top_ad_if_longer_than'];
|
539 |
-
if (adinj_disabled($val)){
|
540 |
-
$status[0] = 'red';
|
541 |
-
$status[1] = 'off';
|
542 |
-
} else {
|
543 |
-
$status[0] = 'green';
|
544 |
-
$status[1] = 'on';
|
545 |
-
}
|
546 |
-
} else if ($name == 'bottomad'){
|
547 |
-
$count = adinj_count_live_ads('ad_code_bottom_', $ops);
|
548 |
-
if ($count == 0){
|
549 |
-
$status[0] = 'red';
|
550 |
-
$status[1] = 'no ad defined';
|
551 |
-
return $status;
|
552 |
-
}
|
553 |
-
$val = $ops['bottom_ad_if_longer_than'];
|
554 |
-
if (adinj_disabled($val)){
|
555 |
-
$status[0] = 'red';
|
556 |
-
$status[1] = 'off';
|
557 |
-
} else {
|
558 |
-
$status[0] = 'green';
|
559 |
-
$status[1] = 'on';
|
560 |
-
}
|
561 |
-
} else if ($name == 'widgets'){
|
562 |
-
if ($ops['widget_exclude_front'] == 'on' &&
|
563 |
-
$ops['widget_exclude_home'] == 'on' &&
|
564 |
-
$ops['widget_exclude_page'] == 'on' &&
|
565 |
-
$ops['widget_exclude_single'] == 'on' &&
|
566 |
-
$ops['widget_exclude_archive'] == 'on' &&
|
567 |
-
$ops['widget_exclude_search'] == 'on' &&
|
568 |
-
$ops['widget_exclude_404'] == 'on'){
|
569 |
-
$status[0] = 'red';
|
570 |
-
$status[1] = 'exclude from all';
|
571 |
-
} else {
|
572 |
-
$status[1] = 'see <a href="widgets.php">widgets</a> screen';
|
573 |
-
}
|
574 |
} else if ($name == 'mode'){
|
575 |
$status[1] = $ops['ad_insertion_mode'];
|
576 |
} else if ($name == 'restrictions'){
|
@@ -608,10 +529,50 @@ function adinj_green_or_red_dot($option){
|
|
608 |
}
|
609 |
}
|
610 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
function adinj_dot($colour){
|
612 |
return '<span style="color:'.$colour.'">●</span>';
|
613 |
}
|
614 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
function adinj_selection_box($name, $values, $type="", $selected_value=NULL){
|
616 |
$associative = false;
|
617 |
if (!array_key_exists(0, $values)){
|
@@ -624,17 +585,29 @@ function adinj_selection_box($name, $values, $type="", $selected_value=NULL){
|
|
624 |
$selected_value = $ops[$name];
|
625 |
}
|
626 |
|
627 |
-
echo "<select name='$name'>";
|
628 |
foreach ($values as $key=>$value){
|
629 |
$option_value = $value;
|
|
|
630 |
if ($associative){
|
631 |
$option_value = $key;
|
632 |
}
|
633 |
echo "<option value=\"$option_value\" ";
|
634 |
-
if($selected_value == $option_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
635 |
$typetxt = $type;
|
636 |
-
if (adinj_disabled($option_value) || $
|
637 |
-
|
|
|
|
|
|
|
|
|
638 |
}
|
639 |
echo "</select>";
|
640 |
}
|
@@ -658,23 +631,36 @@ function adinj_javascript_addtext(){
|
|
658 |
function adinj_add_show_hide_section($anchor, $show_op, $show_field_name, $ops){
|
659 |
$show_setting_id = $anchor.'_show';
|
660 |
$show_value = $ops[$show_op];
|
661 |
-
|
662 |
echo <<<HTML
|
663 |
<input type='hidden' id="$show_setting_id" name="$show_field_name" value='$show_value' />
|
664 |
-
<a href='#' onclick="javascript:adinj_toggle_click('$show_setting_id', '$anchor-button', '$anchor-box');return false;" style='
|
665 |
<br clear="all" />
|
666 |
|
667 |
<script type="text/javascript">
|
668 |
-
|
669 |
-
|
670 |
-
jQuery('a#$anchor-button').show();
|
671 |
-
if ('$show_value' == 'false') jQuery('#$anchor-box').hide();
|
672 |
-
});
|
673 |
</script>
|
674 |
-
|
675 |
-
<div id="$anchor-box">
|
676 |
HTML;
|
|
|
|
|
|
|
|
|
677 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
|
679 |
function adinj_condition_table($name, $description, $type, $ops, $dropdown_fieldname=NULL, $textarea_fieldname=NULL){
|
680 |
if ($dropdown_fieldname == NULL){
|
@@ -746,17 +732,15 @@ function adinj_add_alignment_options($prefix){
|
|
746 |
_e("Alignment", 'adinj');
|
747 |
echo "<br />";
|
748 |
adinj_selection_box($prefix.'align',
|
749 |
-
array(
|
750 |
-
|
751 |
echo "<br />";
|
752 |
-
|
753 |
_e("Clear (CSS)", 'adinj');
|
754 |
echo "<br />";
|
755 |
adinj_selection_box($prefix.'clear',
|
756 |
-
array(
|
757 |
-
|
|
|
758 |
echo "<br />";
|
759 |
-
|
760 |
adinj_add_margin_top_bottom_options($prefix);
|
761 |
}
|
762 |
|
@@ -773,18 +757,14 @@ function adinj_add_margin_top_bottom_options($prefix, $options=NULL, $topname=NU
|
|
773 |
$bname = $bottomname;
|
774 |
$bdefault = "margin_bottom";
|
775 |
}
|
776 |
-
|
777 |
_e("Margin top", 'adinj');
|
778 |
echo "<br />";
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
echo "<br />";
|
783 |
-
|
784 |
_e("Margin bottom", 'adinj');
|
785 |
echo "<br />";
|
786 |
-
adinj_selection_box($bname,
|
787 |
-
array(ADINJ_DISABLED, 0, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30), "(px)", $options[$bdefault]);
|
788 |
}
|
789 |
|
790 |
function adinj_add_padding_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){
|
@@ -800,18 +780,14 @@ function adinj_add_padding_top_bottom_options($prefix, $options=NULL, $topname=N
|
|
800 |
$bname = $bottomname;
|
801 |
$bdefault = "padding_bottom";
|
802 |
}
|
803 |
-
|
804 |
_e("Padding top", 'adinj');
|
805 |
echo "<br />";
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
echo "<br />";
|
810 |
-
|
811 |
_e("Padding bottom", 'adinj');
|
812 |
echo "<br />";
|
813 |
-
adinj_selection_box($bname,
|
814 |
-
array(ADINJ_DISABLED, 0, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30), "(px)", $options[$bdefault]);
|
815 |
}
|
816 |
|
817 |
function adinj_get_version(){
|
@@ -866,6 +842,91 @@ function is_supported_caching_plugin_active(){
|
|
866 |
|
867 |
//////////////////////////////////////////////////////////////////////////////
|
868 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
869 |
function adinj_percentage_split($name_stem, $num, $ops, $total=NULL){
|
870 |
// for old db - TODO delete later
|
871 |
if (adinj_db_version($ops) == 1){
|
@@ -907,7 +968,8 @@ function adinj_total_split($name_stem, $ops){
|
|
907 |
return $total;
|
908 |
}
|
909 |
|
910 |
-
function adinj_count_live_ads($
|
|
|
911 |
$total = 0;
|
912 |
for ($i=1; $i<=10; ++$i){
|
913 |
$split = $name_stem.$i.'_split';
|
@@ -920,6 +982,17 @@ function adinj_count_live_ads($name_stem, $ops){
|
|
920 |
return $total;
|
921 |
}
|
922 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
923 |
//////////////////////////////////////////////////////////////////////////////
|
924 |
|
925 |
// Hopefully run on install and upgrade
|
@@ -985,6 +1058,10 @@ function adinj_upgrade_db(){
|
|
985 |
$new_options['widget_exclude_404'] = 'on';
|
986 |
}
|
987 |
|
|
|
|
|
|
|
|
|
988 |
// 3. Bump up db version number.
|
989 |
$new_options['db_version'] = $new_dbversion;
|
990 |
|
@@ -1011,11 +1088,11 @@ function adinj_default_options(){
|
|
1011 |
'exclude_archive' => '',
|
1012 |
'exclude_search' => 'on',
|
1013 |
'exclude_404' => 'on',
|
1014 |
-
'global_category_condition_mode' =>
|
1015 |
'global_category_condition_entries' => '',
|
1016 |
-
'global_tag_condition_mode' =>
|
1017 |
'global_tag_condition_entries' => '',
|
1018 |
-
'global_author_condition_mode' =>
|
1019 |
'global_author_condition_entries' => '',
|
1020 |
'content_length_unit' => 'words',
|
1021 |
// Random ads
|
@@ -1043,28 +1120,50 @@ function adinj_default_options(){
|
|
1043 |
'ad_code_random_alt_2' => '',
|
1044 |
'ad_code_random_alt_1_split' => '100',
|
1045 |
'ad_code_random_alt_2_split' => '100',
|
1046 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1047 |
'no_random_ads_if_shorter_than' => '100',
|
1048 |
'one_ad_if_shorter_than' => '500',
|
1049 |
'two_ads_if_shorter_than' => '1000',
|
1050 |
-
'three_ads_if_shorter_than' =>
|
1051 |
-
'
|
1052 |
-
|
1053 |
-
'
|
1054 |
-
'
|
1055 |
-
'
|
1056 |
-
'
|
1057 |
-
'
|
1058 |
-
'
|
1059 |
-
'
|
1060 |
-
'
|
1061 |
-
'
|
1062 |
-
'
|
1063 |
-
|
1064 |
-
'
|
1065 |
-
'
|
1066 |
-
|
1067 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
1068 |
// Top ads
|
1069 |
'ad_code_top_1' => '',
|
1070 |
'ad_code_top_2' => '',
|
@@ -1090,16 +1189,18 @@ function adinj_default_options(){
|
|
1090 |
'ad_code_top_alt_2' => '',
|
1091 |
'ad_code_top_alt_1_split' => '100',
|
1092 |
'ad_code_top_alt_2_split' => '100',
|
1093 |
-
'top_align' =>
|
1094 |
-
'top_clear' =>
|
1095 |
-
'top_margin_top' => '
|
1096 |
-
'top_margin_bottom' => '
|
1097 |
-
'top_padding_top' =>
|
1098 |
-
'top_padding_bottom' =>
|
1099 |
-
'top_category_condition_mode' =>
|
1100 |
-
'top_category_condition_entries' => '',
|
1101 |
-
'top_tag_condition_mode' =>
|
1102 |
-
'top_tag_condition_entries' => '',
|
|
|
|
|
1103 |
// Bottom ads
|
1104 |
'ad_code_bottom_1' => '',
|
1105 |
'ad_code_bottom_2' => '',
|
@@ -1125,16 +1226,18 @@ function adinj_default_options(){
|
|
1125 |
'ad_code_bottom_alt_2' => '',
|
1126 |
'ad_code_bottom_alt_1_split' => '100',
|
1127 |
'ad_code_bottom_alt_2_split' => '100',
|
1128 |
-
'bottom_align' =>
|
1129 |
-
'bottom_clear' =>
|
1130 |
-
'bottom_margin_top' => '
|
1131 |
-
'bottom_margin_bottom' => '
|
1132 |
-
'bottom_padding_top' =>
|
1133 |
-
'bottom_padding_bottom' =>
|
1134 |
-
'bottom_category_condition_mode' =>
|
1135 |
-
'bottom_category_condition_entries' => '',
|
1136 |
-
'bottom_tag_condition_mode' =>
|
1137 |
-
'bottom_tag_condition_entries' => '',
|
|
|
|
|
1138 |
// widgets
|
1139 |
'widget_exclude_front' => '',
|
1140 |
'widget_exclude_home' => '',
|
@@ -1149,24 +1252,28 @@ function adinj_default_options(){
|
|
1149 |
'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/',
|
1150 |
'block_keywords' => 'off', //TODO change to blocked referrers?
|
1151 |
'blocked_keywords' => '', //TODO
|
1152 |
-
'block_ips' => '
|
1153 |
'blocked_ips' => '',
|
1154 |
// ui main tab
|
1155 |
'ui_global_hide' => 'false',
|
1156 |
-
'
|
1157 |
-
'
|
1158 |
-
'ui_bottomad_hide' => 'false',
|
1159 |
-
'ui_widgets_hide' => 'false',
|
1160 |
'ui_restrictions_hide' => 'false',
|
1161 |
-
'
|
1162 |
-
'ui_docs_hide' => 'false',
|
1163 |
'ui_testads_hide' => 'false',
|
1164 |
-
//
|
1165 |
'ui_conditions_show' => 'false',
|
|
|
|
|
|
|
1166 |
// ui ad rotation tab
|
1167 |
-
'
|
1168 |
'ui_multiple_top_hide' => 'false',
|
|
|
1169 |
'ui_multiple_bottom_hide' => 'false',
|
|
|
|
|
|
|
|
|
1170 |
// debug
|
1171 |
'debug_mode' => '',
|
1172 |
// version
|
230 |
}
|
231 |
</script>
|
232 |
<!--end of Ad Injection scripts-->
|
233 |
+
<script type="text/javascript">
|
234 |
+
document.write('<style type="text/css" media="screen">.hiddenbox { display: none; }</style>');
|
235 |
+
</script>
|
236 |
HTML;
|
237 |
+
|
238 |
+
|
239 |
}
|
240 |
|
241 |
function adinj_options_page(){
|
272 |
echo '</div>';
|
273 |
adinj_tab_adrotation();
|
274 |
break;
|
275 |
+
case "debug":
|
276 |
+
require_once(ADINJ_PATH . '/ui-tab-debug.php');
|
277 |
+
adinj_side_info_box();
|
278 |
+
echo '</div>';
|
279 |
+
adinj_tab_debug();
|
280 |
+
break;
|
281 |
case "main":
|
282 |
default:
|
283 |
require_once(ADINJ_PATH . '/ui-tab-main.php');
|
331 |
|
332 |
} else {
|
333 |
echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
|
334 |
+
echo "28th February 2011: Archives and home ads now fully supported - you can add top/random/bottom ads to them. Big UI updates to support this. And fixes for when/where widget ads appear. I'd recommend you re-check that your ads appear where you expect them to. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'<a href="'.adinj_feedback_url().'" target="_new">quick feedback form</a>.';
|
335 |
echo '</strong></p></div>';
|
336 |
}
|
337 |
}
|
392 |
$current = 'main';
|
393 |
}
|
394 |
}
|
395 |
+
$tabs = array( 'main' => __( 'Main', 'ad-injection' ), 'adrotation' => __( 'Ad codes / rotation / misc', 'ad-injection' ), 'debug' => __( 'Debug' ) );
|
396 |
$links = array();
|
397 |
foreach( $tabs as $tab => $name ) {
|
398 |
if ( $current == $tab ) {
|
415 |
<div class="metabox-holder">
|
416 |
<div class="postbox">
|
417 |
<input type="submit" style="float:right" class="button-primary" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
|
418 |
+
|
419 |
<?php
|
420 |
$anchorclick = $anchor.'_click';
|
421 |
$anchorupdate = $anchor.'_update';
|
422 |
$anchorhide = 'ui_'.$anchor.'_hide';
|
423 |
+
$hide = $ops[$anchorhide];
|
424 |
echo <<<HTML
|
425 |
+
<input type='hidden' id='$anchorhide' name='$anchorhide' value='$hide' />
|
426 |
<a href="#" onclick='javascript:$anchorclick();return false;' style="float:right;display:none" id="toggle-$anchor" class="button">Show/Hide</a>
|
427 |
<script type="text/javascript">
|
428 |
+
$anchorupdate();
|
429 |
+
jQuery('#toggle-$anchor').show();
|
|
|
|
|
|
|
430 |
|
431 |
function $anchorclick(){
|
432 |
+
jQuery('#$anchorhide').val(!jQuery('#$anchor-box').is(":hidden"));
|
433 |
+
jQuery('#$anchor-box').slideToggle(300);
|
434 |
$anchorupdate();
|
|
|
435 |
return false;
|
436 |
}
|
437 |
|
445 |
</script>
|
446 |
HTML;
|
447 |
?>
|
448 |
+
|
449 |
<h3><?php $info = adinj_get_status($anchor); echo adinj_dot($info[0]); ?> <a name="<?php echo $anchor; ?>"></a><?php echo adinj_get_logo() . ' ' . $title; ?></h3>
|
450 |
+
<?php if($hide == 'true'){ ?>
|
451 |
+
<div id="<?php echo $anchor; ?>-box" class="hiddenbox">
|
|
|
|
|
|
|
452 |
<?php } else { ?>
|
453 |
+
<div id="<?php echo $anchor; ?>-box">
|
454 |
<?php } ?>
|
455 |
<div class="inside" style="margin:10px">
|
|
|
456 |
<?php
|
457 |
}
|
458 |
|
492 |
$status[0] = 'orange';
|
493 |
$status[1] = 'test mode';
|
494 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
} else if ($name == 'mode'){
|
496 |
$status[1] = $ops['ad_insertion_mode'];
|
497 |
} else if ($name == 'restrictions'){
|
529 |
}
|
530 |
}
|
531 |
|
532 |
+
function adinj_print_ad_dot($adtype, $pagetype){
|
533 |
+
if (adinj_max_num_ads($adtype, $pagetype) > 0){
|
534 |
+
echo adinj_dot('green');
|
535 |
+
} else {
|
536 |
+
echo adinj_dot('red');
|
537 |
+
}
|
538 |
+
}
|
539 |
+
|
540 |
function adinj_dot($colour){
|
541 |
return '<span style="color:'.$colour.'">●</span>';
|
542 |
}
|
543 |
|
544 |
+
function adinj_max_num_ads($adtype, $pagetype){
|
545 |
+
$ops = adinj_options();
|
546 |
+
if (adinj_ticked('exclude_'.$pagetype)) return 0;
|
547 |
+
if ($adtype == 'widget'){
|
548 |
+
if (adinj_ticked('widget_exclude_'.$pagetype)) return 0;
|
549 |
+
}
|
550 |
+
if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom'){
|
551 |
+
if (adinj_count_live_ads($adtype, $ops) == 0) return 0;
|
552 |
+
}
|
553 |
+
if ($adtype == 'top' || $adtype == 'bottom'){
|
554 |
+
if ($pagetype == "single" || $pagetype == "page"){
|
555 |
+
if (!adinj_disabled($ops[$adtype.'_ad_if_longer_than'])) return 1;
|
556 |
+
} else if ($pagetype == 'home' || $pagetype == 'archive'){
|
557 |
+
if (!adinj_disabled($ops[$pagetype.'_'.$adtype.'_ad_if_longer_than'])) return $ops[$pagetype.'_max_num_'.$adtype.'_ads_per_page'];
|
558 |
+
} else if ($pagetype == "excerpt"){
|
559 |
+
//TODO
|
560 |
+
}
|
561 |
+
} else if ($adtype == "random"){
|
562 |
+
if ($pagetype == "single" || $pagetype == "page"){
|
563 |
+
return $ops['max_num_of_ads'];
|
564 |
+
} else if ($pagetype == 'home' || $pagetype == 'archive'){
|
565 |
+
if ($ops[$pagetype.'_max_num_random_ads_per_post'] > 0) return $ops[$pagetype.'_max_num_random_ads_per_page'];
|
566 |
+
} else if ($pagetype == "excerpt"){
|
567 |
+
//TODO
|
568 |
+
}
|
569 |
+
}
|
570 |
+
if ($adtype == 'widget'){
|
571 |
+
return 1;
|
572 |
+
}
|
573 |
+
return 0;
|
574 |
+
}
|
575 |
+
|
576 |
function adinj_selection_box($name, $values, $type="", $selected_value=NULL){
|
577 |
$associative = false;
|
578 |
if (!array_key_exists(0, $values)){
|
585 |
$selected_value = $ops[$name];
|
586 |
}
|
587 |
|
588 |
+
echo "<select name='$name' id='$name'>";
|
589 |
foreach ($values as $key=>$value){
|
590 |
$option_value = $value;
|
591 |
+
$display_value = $value;
|
592 |
if ($associative){
|
593 |
$option_value = $key;
|
594 |
}
|
595 |
echo "<option value=\"$option_value\" ";
|
596 |
+
if("$selected_value" == "$option_value" ||
|
597 |
+
"$selected_value" == ADINJ_ALWAYS_SHOW && "$option_value" == 'a' ||
|
598 |
+
"$selected_value" == ADINJ_DISABLED && "$option_value" == 'd' ||
|
599 |
+
"$selected_value" == ADINJ_RULE_DISABLED && "$option_value" == 'd' ||
|
600 |
+
"$selected_value" == ADINJ_ONLY_SHOW_IN && "$option_value" == 'o' ||
|
601 |
+
"$selected_value" == ADINJ_NEVER_SHOW_IN && "$option_value" == 'n'){
|
602 |
+
echo 'selected="selected"';
|
603 |
+
}
|
604 |
$typetxt = $type;
|
605 |
+
if (adinj_disabled($option_value) || adinj_alwaysshow($display_value)) $typetxt = "";
|
606 |
+
if ("$option_value" === 'd') { $display_value = ADINJ_DISABLED; }
|
607 |
+
if ("$option_value" === 'a') { $display_value = ADINJ_ALWAYS_SHOW; }
|
608 |
+
if ("$option_value" === 'o') { $display_value = ADINJ_ONLY_SHOW_IN; }
|
609 |
+
if ("$option_value" === 'n') { $display_value = ADINJ_NEVER_SHOW_IN; }
|
610 |
+
echo ">$display_value $typetxt</option>";
|
611 |
}
|
612 |
echo "</select>";
|
613 |
}
|
631 |
function adinj_add_show_hide_section($anchor, $show_op, $show_field_name, $ops){
|
632 |
$show_setting_id = $anchor.'_show';
|
633 |
$show_value = $ops[$show_op];
|
634 |
+
|
635 |
echo <<<HTML
|
636 |
<input type='hidden' id="$show_setting_id" name="$show_field_name" value='$show_value' />
|
637 |
+
<a href='#' onclick="javascript:adinj_toggle_click('$show_setting_id', '$anchor-button', '$anchor-box');return false;" style='display:none;width:10px;' id='$anchor-button' class='button'>+/-</a>
|
638 |
<br clear="all" />
|
639 |
|
640 |
<script type="text/javascript">
|
641 |
+
adinj_button_update('$show_setting_id', '$anchor-button');
|
642 |
+
jQuery('a#$anchor-button').show();
|
|
|
|
|
|
|
643 |
</script>
|
644 |
+
|
|
|
645 |
HTML;
|
646 |
+
if ($show_value == 'false'){
|
647 |
+
echo "<div id='$anchor-box' class='hiddenbox'>";
|
648 |
+
} else {
|
649 |
+
echo "<div id='$anchor-box'>";
|
650 |
}
|
651 |
+
}
|
652 |
+
|
653 |
+
function adinj_condition_tables($prefix, $show_setting){
|
654 |
+
$ops = adinj_options();
|
655 |
+
?>
|
656 |
+
Category tag, and author conditions
|
657 |
+
<?php
|
658 |
+
adinj_add_show_hide_section('ad_conditions_'.uniqid(), $show_setting, $show_setting, $ops);
|
659 |
+
adinj_condition_table($prefix.'category', 'category slugs. e.g: cat1, cat2, cat3', 'category', $ops);
|
660 |
+
adinj_condition_table($prefix.'tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag', $ops);
|
661 |
+
adinj_condition_table($prefix.'author', 'author nicknames. e.g: john, paul', 'author', $ops);
|
662 |
+
echo '</div>';
|
663 |
+
}
|
664 |
|
665 |
function adinj_condition_table($name, $description, $type, $ops, $dropdown_fieldname=NULL, $textarea_fieldname=NULL){
|
666 |
if ($dropdown_fieldname == NULL){
|
732 |
_e("Alignment", 'adinj');
|
733 |
echo "<br />";
|
734 |
adinj_selection_box($prefix.'align',
|
735 |
+
array('d', 'left', 'center', 'right', 'float left', 'float right', 'rand lcr', 'rand float lr', 'rand all'));
|
|
|
736 |
echo "<br />";
|
|
|
737 |
_e("Clear (CSS)", 'adinj');
|
738 |
echo "<br />";
|
739 |
adinj_selection_box($prefix.'clear',
|
740 |
+
array('d', 'left', 'right', 'both'));
|
741 |
+
echo "<br />";
|
742 |
+
adinj_add_padding_top_bottom_options($prefix);
|
743 |
echo "<br />";
|
|
|
744 |
adinj_add_margin_top_bottom_options($prefix);
|
745 |
}
|
746 |
|
757 |
$bname = $bottomname;
|
758 |
$bdefault = "margin_bottom";
|
759 |
}
|
|
|
760 |
_e("Margin top", 'adinj');
|
761 |
echo "<br />";
|
762 |
+
$margin_settings = array('d',0,1,2,3,4,5,7,10,15,20,30);
|
763 |
+
adinj_selection_box($tname, $margin_settings, "(px)", $options[$tdefault]);
|
|
|
764 |
echo "<br />";
|
|
|
765 |
_e("Margin bottom", 'adinj');
|
766 |
echo "<br />";
|
767 |
+
adinj_selection_box($bname, $margin_settings, "(px)", $options[$bdefault]);
|
|
|
768 |
}
|
769 |
|
770 |
function adinj_add_padding_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){
|
780 |
$bname = $bottomname;
|
781 |
$bdefault = "padding_bottom";
|
782 |
}
|
|
|
783 |
_e("Padding top", 'adinj');
|
784 |
echo "<br />";
|
785 |
+
$padding_settings = array('d',0,1,2,3,4,5,7,10,15,20,30);
|
786 |
+
adinj_selection_box($tname, $padding_settings, "(px)", $options[$tdefault]);
|
|
|
787 |
echo "<br />";
|
|
|
788 |
_e("Padding bottom", 'adinj');
|
789 |
echo "<br />";
|
790 |
+
adinj_selection_box($bname, $padding_settings, "(px)", $options[$bdefault]);
|
|
|
791 |
}
|
792 |
|
793 |
function adinj_get_version(){
|
842 |
|
843 |
//////////////////////////////////////////////////////////////////////////////
|
844 |
|
845 |
+
function adinj_testads(){
|
846 |
+
adinj_postbox_start(__("Test Adverts", 'adinj'), "testads", '95%');
|
847 |
+
?>
|
848 |
+
<p>You can copy and paste these adverts into the boxes above to test your ad setup before switching to your real ads.</p>
|
849 |
+
|
850 |
+
<h4><a name="468x60"></a>468x60 banner</h4>
|
851 |
+
|
852 |
+
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ff9999; width:468px; height:60px;">
|
853 |
+
<h5>TEST ADVERT 468x60 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
854 |
+
</div></textarea></p>
|
855 |
+
|
856 |
+
<div style="background-color:#99ffff; width:468px; height:60px;">
|
857 |
+
<h5>TEST ADVERT 468x60 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
858 |
+
</div><p></p>
|
859 |
+
|
860 |
+
<h4><a name="728x90"></a>728x90 banner</h4>
|
861 |
+
|
862 |
+
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ff9999; width:728px; height:90px;">
|
863 |
+
<h5>TEST ADVERT 728x90</h5>
|
864 |
+
<a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a><br />
|
865 |
+
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
866 |
+
</div></textarea></p>
|
867 |
+
|
868 |
+
<div style="background-color:#ff9999; width:728px; height:90px;">
|
869 |
+
<h5>TEST ADVERT 728x90</h5>
|
870 |
+
<a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a><br />
|
871 |
+
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
872 |
+
</div><p></p>
|
873 |
+
|
874 |
+
<h4>160x90 link unit</h4>
|
875 |
+
|
876 |
+
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ccff99; width:160px; height:90px;">
|
877 |
+
<h5>TEST ADVERT 160x90</h5>
|
878 |
+
<a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a><br />
|
879 |
+
<a href="http://www.advancedhtml.co.uk/">advancedhtml.co.uk</a>
|
880 |
+
</div></textarea></p>
|
881 |
+
|
882 |
+
<div style="background-color:#ccff99; width:160px; height:90px;">
|
883 |
+
<h5>TEST ADVERT 160x90</h5>
|
884 |
+
<a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a>
|
885 |
+
<a href="http://www.advancedhtml.co.uk/">advancedhtml.co.uk</a><br />
|
886 |
+
</div><p></p>
|
887 |
+
|
888 |
+
<h4><a name="468x15"></a>468x15 link unit</h4>
|
889 |
+
|
890 |
+
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#cccc99; width:468px; height:15px;">
|
891 |
+
<font size="-2"><b>TEST ADVERT 160x90</b> <a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a></font>
|
892 |
+
</div></textarea></p>
|
893 |
+
|
894 |
+
<div style="background-color:#cccc99; width:468px; height:15px;">
|
895 |
+
<font size="-2"><b>TEST ADVERT 468x15</b> <a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a></font>
|
896 |
+
</div><p></p>
|
897 |
+
|
898 |
+
<h4><a name="336x280"></a>336x280 large rectangle</h4>
|
899 |
+
|
900 |
+
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ccccff; width:336px; height:280px;">
|
901 |
+
<h5>TEST ADVERT 336x280 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
902 |
+
</div></textarea></p>
|
903 |
+
|
904 |
+
<div style="background-color:#ccccff; width:336px; height:280px;">
|
905 |
+
<h5>TEST ADVERT 336x280 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
906 |
+
</div><p></p>
|
907 |
+
|
908 |
+
<h4>468x60 banner with dynamic PHP</h4>
|
909 |
+
|
910 |
+
<p>The PHP will execute if you use a mfunc compatible caching plugin which is correctly configured, or if you don't use any caching plugin at all.</p>
|
911 |
+
|
912 |
+
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="5"><div style="background-color:#ffff99; width:468px; height:60px;">
|
913 |
+
<b>TEST ADVERT 468x60 with date() and rand()</b><br />
|
914 |
+
<?php echo "date=".date("Y-m-d H:i:s") ." rand=".rand(); ?><br />
|
915 |
+
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
916 |
+
</div></textarea></p>
|
917 |
+
|
918 |
+
<div style="background-color:#ffff99; width:468px; height:60px;">
|
919 |
+
<b>TEST ADVERT 468x60 with date() and rand()</b><br />
|
920 |
+
<?php echo "date=".date("Y-m-d H:i:s") ." rand=".rand(); ?><br />
|
921 |
+
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
922 |
+
</div><p></p>
|
923 |
+
|
924 |
+
<?php
|
925 |
+
adinj_postbox_end();
|
926 |
+
}
|
927 |
+
|
928 |
+
//////////////////////////////////////////////////////////////////////////////
|
929 |
+
|
930 |
function adinj_percentage_split($name_stem, $num, $ops, $total=NULL){
|
931 |
// for old db - TODO delete later
|
932 |
if (adinj_db_version($ops) == 1){
|
968 |
return $total;
|
969 |
}
|
970 |
|
971 |
+
function adinj_count_live_ads($adtype, $ops){
|
972 |
+
$name_stem = adinj_ad_name_stem($adtype);
|
973 |
$total = 0;
|
974 |
for ($i=1; $i<=10; ++$i){
|
975 |
$split = $name_stem.$i.'_split';
|
982 |
return $total;
|
983 |
}
|
984 |
|
985 |
+
function adinj_ad_name_stem($adtype){
|
986 |
+
if ($adtype == 'top') return 'ad_code_top_';
|
987 |
+
if ($adtype == 'random') return 'ad_code_random_';
|
988 |
+
if ($adtype == 'bottom') return 'ad_code_bottom_';
|
989 |
+
if ($adtype == 'top_alt') return 'ad_code_top_alt_';
|
990 |
+
if ($adtype == 'random_alt') return 'ad_code_random_alt_';
|
991 |
+
if ($adtype == 'bottom_alt') return 'ad_code_bottom_alt_';
|
992 |
+
// TODO widget?
|
993 |
+
return 'Error: adinj_ad_name_stem:'.$adtype;
|
994 |
+
}
|
995 |
+
|
996 |
//////////////////////////////////////////////////////////////////////////////
|
997 |
|
998 |
// Hopefully run on install and upgrade
|
1058 |
$new_options['widget_exclude_404'] = 'on';
|
1059 |
}
|
1060 |
|
1061 |
+
if ($stored_dbversion < 6){
|
1062 |
+
$new_options['home_max_num_random_ads_per_page'] = $stored_options['max_num_of_ads_home_page'];
|
1063 |
+
}
|
1064 |
+
|
1065 |
// 3. Bump up db version number.
|
1066 |
$new_options['db_version'] = $new_dbversion;
|
1067 |
|
1088 |
'exclude_archive' => '',
|
1089 |
'exclude_search' => 'on',
|
1090 |
'exclude_404' => 'on',
|
1091 |
+
'global_category_condition_mode' => 'o',
|
1092 |
'global_category_condition_entries' => '',
|
1093 |
+
'global_tag_condition_mode' => 'o',
|
1094 |
'global_tag_condition_entries' => '',
|
1095 |
+
'global_author_condition_mode' => 'o',
|
1096 |
'global_author_condition_entries' => '',
|
1097 |
'content_length_unit' => 'words',
|
1098 |
// Random ads
|
1120 |
'ad_code_random_alt_2' => '',
|
1121 |
'ad_code_random_alt_1_split' => '100',
|
1122 |
'ad_code_random_alt_2_split' => '100',
|
1123 |
+
'rnd_align' => 'd',
|
1124 |
+
'rnd_clear' => 'd',
|
1125 |
+
'rnd_margin_top' => 'd',
|
1126 |
+
'rnd_margin_bottom' => 'd',
|
1127 |
+
'rnd_padding_top' => 'd',
|
1128 |
+
'rnd_padding_bottom' => 'd',
|
1129 |
+
'start_from_paragraph' => 'd',
|
1130 |
+
'multiple_ads_at_same_position' => '',
|
1131 |
+
'random_category_condition_mode' => 'o',
|
1132 |
+
'random_category_condition_entries' => '',
|
1133 |
+
'random_tag_condition_mode' => 'o',
|
1134 |
+
'random_tag_condition_entries' => '',
|
1135 |
+
'random_author_condition_mode' => 'o',
|
1136 |
+
'random_author_condition_entries' => '',
|
1137 |
+
// single posts and pages
|
1138 |
+
'top_ad_if_longer_than' => 'd',
|
1139 |
+
'max_num_of_ads' => '2', // random ads
|
1140 |
'no_random_ads_if_shorter_than' => '100',
|
1141 |
'one_ad_if_shorter_than' => '500',
|
1142 |
'two_ads_if_shorter_than' => '1000',
|
1143 |
+
'three_ads_if_shorter_than' => 'd',
|
1144 |
+
'bottom_ad_if_longer_than' => 'd',
|
1145 |
+
// Home page ads
|
1146 |
+
'home_top_ad_if_longer_than' => 'd',
|
1147 |
+
'home_max_num_top_ads_per_page' => '1',
|
1148 |
+
'home_max_num_random_ads_per_post' => '1',
|
1149 |
+
'home_max_num_random_ads_per_page' => '3',
|
1150 |
+
'home_no_random_ads_if_shorter_than' => '100',
|
1151 |
+
'home_one_ad_if_shorter_than' => '500',
|
1152 |
+
'home_two_ads_if_shorter_than' => '1000',
|
1153 |
+
'home_three_ads_if_shorter_than' => 'd',
|
1154 |
+
'home_bottom_ad_if_longer_than' => 'd',
|
1155 |
+
'home_max_num_bottom_ads_per_page' => '1',
|
1156 |
+
// Archive ads
|
1157 |
+
'archive_top_ad_if_longer_than' => 'd',
|
1158 |
+
'archive_max_num_top_ads_per_page' => '1',
|
1159 |
+
'archive_max_num_random_ads_per_post' => '1',
|
1160 |
+
'archive_max_num_random_ads_per_page' => '3',
|
1161 |
+
'archive_no_random_ads_if_shorter_than' => '100',
|
1162 |
+
'archive_one_ad_if_shorter_than' => '500',
|
1163 |
+
'archive_two_ads_if_shorter_than' => '1000',
|
1164 |
+
'archive_three_ads_if_shorter_than' => 'd',
|
1165 |
+
'archive_bottom_ad_if_longer_than' => 'd',
|
1166 |
+
'archive_max_num_bottom_ads_per_page' => '1',
|
1167 |
// Top ads
|
1168 |
'ad_code_top_1' => '',
|
1169 |
'ad_code_top_2' => '',
|
1189 |
'ad_code_top_alt_2' => '',
|
1190 |
'ad_code_top_alt_1_split' => '100',
|
1191 |
'ad_code_top_alt_2_split' => '100',
|
1192 |
+
'top_align' => 'd',
|
1193 |
+
'top_clear' => 'd',
|
1194 |
+
'top_margin_top' => 'd',
|
1195 |
+
'top_margin_bottom' => 'd',
|
1196 |
+
'top_padding_top' => 'd',
|
1197 |
+
'top_padding_bottom' => 'd',
|
1198 |
+
'top_category_condition_mode' => 'o',
|
1199 |
+
'top_category_condition_entries' => '',
|
1200 |
+
'top_tag_condition_mode' => 'o',
|
1201 |
+
'top_tag_condition_entries' => '',
|
1202 |
+
'top_author_condition_mode' => 'o',
|
1203 |
+
'top_author_condition_entries' => '',
|
1204 |
// Bottom ads
|
1205 |
'ad_code_bottom_1' => '',
|
1206 |
'ad_code_bottom_2' => '',
|
1226 |
'ad_code_bottom_alt_2' => '',
|
1227 |
'ad_code_bottom_alt_1_split' => '100',
|
1228 |
'ad_code_bottom_alt_2_split' => '100',
|
1229 |
+
'bottom_align' => 'd',
|
1230 |
+
'bottom_clear' => 'd',
|
1231 |
+
'bottom_margin_top' => 'd',
|
1232 |
+
'bottom_margin_bottom' => 'd',
|
1233 |
+
'bottom_padding_top' => 'd',
|
1234 |
+
'bottom_padding_bottom' => 'd',
|
1235 |
+
'bottom_category_condition_mode' => 'o',
|
1236 |
+
'bottom_category_condition_entries' => '',
|
1237 |
+
'bottom_tag_condition_mode' => 'o',
|
1238 |
+
'bottom_tag_condition_entries' => '',
|
1239 |
+
'bottom_author_condition_mode' => 'o',
|
1240 |
+
'bottom_author_condition_entries' => '',
|
1241 |
// widgets
|
1242 |
'widget_exclude_front' => '',
|
1243 |
'widget_exclude_home' => '',
|
1252 |
'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/',
|
1253 |
'block_keywords' => 'off', //TODO change to blocked referrers?
|
1254 |
'blocked_keywords' => '', //TODO
|
1255 |
+
'block_ips' => 'off',
|
1256 |
'blocked_ips' => '',
|
1257 |
// ui main tab
|
1258 |
'ui_global_hide' => 'false',
|
1259 |
+
'ui_adsettings_hide' => 'false',
|
1260 |
+
'ui_adverts_hide' => 'false',
|
|
|
|
|
1261 |
'ui_restrictions_hide' => 'false',
|
1262 |
+
'ui_docsquickstart_hide' => 'false',
|
|
|
1263 |
'ui_testads_hide' => 'false',
|
|
|
1264 |
'ui_conditions_show' => 'false',
|
1265 |
+
'ui_top_conditions_show' => 'false',
|
1266 |
+
'ui_random_conditions_show' => 'false',
|
1267 |
+
'ui_bottom_conditions_show' => 'false',
|
1268 |
// ui ad rotation tab
|
1269 |
+
'ui_docs_adrotation_hide' => 'false',
|
1270 |
'ui_multiple_top_hide' => 'false',
|
1271 |
+
'ui_multiple_random_hide' => 'false',
|
1272 |
'ui_multiple_bottom_hide' => 'false',
|
1273 |
+
'ui_misc_hide' => 'true',
|
1274 |
+
'ui_docs_tags_hide' => 'true',
|
1275 |
+
// ui debug tab
|
1276 |
+
'ui_debugging_hide' => 'false',
|
1277 |
// debug
|
1278 |
'debug_mode' => '',
|
1279 |
// version
|
ad-injection-widget.php
CHANGED
@@ -116,15 +116,15 @@ class Ad_Injection_Widget extends WP_Widget {
|
|
116 |
'advert_alt_3' => '',
|
117 |
'advert_alt_3_split' => '100',
|
118 |
//settings
|
119 |
-
'margin_top' =>
|
120 |
-
'margin_bottom' =>
|
121 |
-
'padding_top' =>
|
122 |
-
'padding_bottom' =>
|
123 |
-
'widget_category_condition_mode' =>
|
124 |
'widget_category_condition_entries' => '',
|
125 |
-
'widget_tag_condition_mode' =>
|
126 |
'widget_tag_condition_entries' => '',
|
127 |
-
'widget_author_condition_mode' =>
|
128 |
'widget_author_condition_entries' => '',
|
129 |
//ui
|
130 |
'ui_ad_1_show' => 'true',
|
116 |
'advert_alt_3' => '',
|
117 |
'advert_alt_3_split' => '100',
|
118 |
//settings
|
119 |
+
'margin_top' => 'd',
|
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',
|
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 |
Author: reviewmylife
|
8 |
Author URI: http://www.reviewmylife.co.uk/
|
9 |
License: GPLv2
|
@@ -21,8 +21,11 @@ define('ADINJ_NO_CONFIG_FILE', 1);
|
|
21 |
// 2 = split testing support
|
22 |
// 3 = added front options
|
23 |
// 4 = new character counting option
|
24 |
-
// 5 = search/404 exclusion, increase db ad rotations to 10
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
// Files
|
28 |
// TODO will these paths work on windows?
|
@@ -39,7 +42,9 @@ define('ADINJ_ONLY_SHOW_IN', 'Only show in');
|
|
39 |
define('ADINJ_NEVER_SHOW_IN', 'Never show in');
|
40 |
|
41 |
// Global variables
|
42 |
-
$
|
|
|
|
|
43 |
$adinj_total_all_ads_used = 0;
|
44 |
$adinj_data = array();
|
45 |
|
@@ -208,39 +213,26 @@ function adinj_live_ads_array($type, $ads_option, &$ads, &$split, $output_type="
|
|
208 |
$op_stem = "";
|
209 |
$file_stem = "";
|
210 |
|
211 |
-
if ($type == 'random' || $type == 'top' || $type == 'bottom' ||
|
212 |
$type == 'random_alt' || $type == 'top_alt' || $type == 'bottom_alt'){
|
213 |
$op_stem = 'ad_code_'.$type.'_';
|
214 |
$file_stem = 'ad_'.$type.'_';
|
215 |
} else if (preg_match("/widget_[\d+]/i", $type)){
|
216 |
if (strpos($type, '_alt') === false){
|
217 |
$op_stem = 'advert_';
|
218 |
-
$file_stem = 'ad_'.$type.'_';
|
219 |
} else {
|
220 |
$op_stem = 'advert_alt_';
|
221 |
-
$file_stem = 'ad_'.$type.'_';
|
222 |
}
|
|
|
223 |
}
|
224 |
|
225 |
if (adinj_db_version($ads_option) == 1){
|
226 |
// old DB support (no ad rotation support) - TODO delete later
|
227 |
-
if ($type == 'random'){
|
228 |
-
if ($output_type == "string"){
|
229 |
-
$ads = "'ad_random_1.txt'";
|
230 |
-
} else {
|
231 |
-
$ads[] = 'ad_code_random_1';
|
232 |
-
}
|
233 |
-
} else if ($type == 'top'){
|
234 |
if ($output_type == "string"){
|
235 |
-
$ads = "'
|
236 |
} else {
|
237 |
-
$ads[] = '
|
238 |
-
}
|
239 |
-
} else if ($type == 'bottom'){
|
240 |
-
if ($output_type == "string"){
|
241 |
-
$ads = "'ad_bottom_1.txt'";
|
242 |
-
} else {
|
243 |
-
$ads[] = 'ad_code_bottom_1';
|
244 |
}
|
245 |
} else if (preg_match("/widget_[\d+]/i", $type)){
|
246 |
if ($output_type == "string"){
|
@@ -281,28 +273,18 @@ function adinj_formatting_options($adtype, $ops, $output_type="string"){
|
|
281 |
$padding_top = "";
|
282 |
$padding_bottom = "";
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
$padding_top = $ops[$adtype.'_padding_top'];
|
297 |
-
$padding_bottom = $ops[$adtype.'_padding_bottom'];
|
298 |
-
} else if (preg_match("/widget_[\d+]/i", $adtype)){
|
299 |
-
$align = $ops['align'];
|
300 |
-
$clear = $ops['clear'];
|
301 |
-
$margin_top = $ops['margin_top'];
|
302 |
-
$margin_bottom = $ops['margin_bottom'];
|
303 |
-
$padding_top = $ops['padding_top'];
|
304 |
-
$padding_bottom = $ops['padding_bottom'];
|
305 |
-
}
|
306 |
|
307 |
if (adinj_disabled($align)) $align = "";
|
308 |
if (adinj_disabled($clear)) $clear = "";
|
@@ -387,11 +369,21 @@ function adinj_adverts_disabled_flag(){
|
|
387 |
|
388 |
function adinj($content, $message){
|
389 |
if (!adinj_ticked('debug_mode')) return $content;
|
390 |
-
global $
|
391 |
$ops = adinj_options();
|
392 |
$para = adinj_paragraph_to_start_ads();
|
393 |
$mode = $ops['ad_insertion_mode'];
|
394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
if(is_single() || is_page()) {
|
396 |
$currentdate = time();
|
397 |
$postdate = get_the_time('U');
|
@@ -402,7 +394,9 @@ function adinj($content, $message){
|
|
402 |
<!--
|
403 |
[ADINJ DEBUG]
|
404 |
$message
|
405 |
-
\$
|
|
|
|
|
406 |
\$adinj_total_all_ads_used=$adinj_total_all_ads_used
|
407 |
paragraphtostartads=$para (fyi: -1 is disabled)
|
408 |
posttype=$posttype
|
@@ -414,7 +408,7 @@ injection mode=$mode
|
|
414 |
|
415 |
function adinj_ads_completely_disabled_from_page($content=NULL){
|
416 |
$ops = adinj_options();
|
417 |
-
if ($ops['ads_enabled'] == 'off' ||
|
418 |
$ops['ads_enabled'] == ''){
|
419 |
return "NOADS: Ads are not switched on";
|
420 |
}
|
@@ -438,15 +432,10 @@ function adinj_ads_completely_disabled_from_page($content=NULL){
|
|
438 |
|
439 |
// no ads on old posts/pages if rule is enabled
|
440 |
if((is_page() || is_single()) && !adinj_is_old_post()) return "NOADS: !is_old_post";
|
441 |
-
|
442 |
-
$category_ok = adinj_allowed_in_category('global', $ops);
|
443 |
-
if (!$category_ok) return "NOADS: blocked from category";
|
444 |
|
445 |
-
|
446 |
-
if (
|
447 |
-
|
448 |
-
$author_ok = adinj_allowed_in_author('global', $ops);
|
449 |
-
if (!$author_ok) return "NOADS: blocked from author";
|
450 |
|
451 |
// manual ad disabling tags
|
452 |
if ($content == NULL) return false;
|
@@ -458,54 +447,94 @@ function adinj_ads_completely_disabled_from_page($content=NULL){
|
|
458 |
return false;
|
459 |
}
|
460 |
|
461 |
-
function adinj_allowed_in_list($all_entries, $config_entries, $
|
462 |
if (is_array($all_entries)){
|
463 |
-
foreach($all_entries as $entry)
|
464 |
$string = $func($entry);
|
465 |
$decoded = rawurldecode($string); //allow UTF-8 encoded strings
|
466 |
if (in_array($string, $config_entries) || in_array($decoded, $config_entries)){
|
467 |
-
if ($
|
468 |
return true;
|
469 |
-
} else if ($
|
470 |
return false;
|
471 |
}
|
472 |
}
|
473 |
}
|
474 |
}
|
475 |
-
if ($
|
476 |
return false;
|
477 |
-
} else if ($
|
478 |
return true;
|
479 |
}
|
480 |
echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_list-->");
|
481 |
return true;
|
482 |
}
|
483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
function adinj_allowed_in_category($scope, $ops){
|
485 |
$cat_array = adinj_split_comma_list($ops[$scope.'_category_condition_entries']);
|
486 |
if (empty($cat_array)) return true;
|
487 |
-
|
488 |
-
$
|
489 |
-
|
490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
|
493 |
function adinj_allowed_in_tag($scope, $ops){
|
494 |
$conditions = adinj_split_comma_list($ops[$scope.'_tag_condition_entries']);
|
495 |
if (empty($conditions)) return true;
|
496 |
-
|
497 |
-
$
|
498 |
-
|
499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
}
|
501 |
|
502 |
function adinj_allowed_in_author($scope, $ops){
|
503 |
$conditions = adinj_split_comma_list($ops[$scope.'_author_condition_entries']);
|
504 |
if (empty($conditions)) return true;
|
505 |
-
|
506 |
-
$
|
507 |
-
|
508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
}
|
510 |
|
511 |
//function parameters
|
@@ -518,14 +547,14 @@ function adinj_split_comma_list($list){
|
|
518 |
}
|
519 |
|
520 |
function adinj_inject_hook($content){
|
521 |
-
global $adinj_total_rand_ads_used;
|
522 |
if (is_feed()) return $content; // TODO feed specific ads
|
523 |
|
524 |
adinj_upgrade_db_if_necessary();
|
525 |
|
|
|
526 |
if(!is_archive && (is_page() || is_single())){
|
527 |
// TODO hack for no random ads bug
|
528 |
-
$
|
529 |
}
|
530 |
|
531 |
$reason = adinj_ads_completely_disabled_from_page($content);
|
@@ -565,19 +594,22 @@ function adinj_inject_hook($content){
|
|
565 |
if ($debug_on) $debug .= "\nnum words: = $length";
|
566 |
}
|
567 |
# Insert top and bottom ads if necesary
|
568 |
-
if(
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
|
|
|
|
576 |
}
|
|
|
577 |
if ($ad_include !== false) $content = $ad_include.$content;
|
578 |
|
579 |
$num_rand_ads_to_insert = adinj_num_rand_ads_to_insert($length);
|
580 |
-
if ($num_rand_ads_to_insert <= 0) return adinj($content, "
|
581 |
$ad = adinj_ad_code_random();
|
582 |
if (empty($ad)) return adinj($content, "no random ad defined");
|
583 |
|
@@ -621,7 +653,7 @@ function adinj_inject_hook($content){
|
|
621 |
$paragraphmarker = "</p>";
|
622 |
if(stripos($content, $paragraphmarker) === false) return adinj($content, "no </p> tags");
|
623 |
|
624 |
-
if ($debug_on) $debug .= "\nTags=". htmlentities($debugtags);
|
625 |
|
626 |
// Generate a list of all potential injection points
|
627 |
if ($debug_on) $debug .= "\nPotential positions: ";
|
@@ -691,10 +723,10 @@ function adinj_inject_hook($content){
|
|
691 |
sort($inj_positions);
|
692 |
|
693 |
// Insert ads in reverse order
|
694 |
-
global $
|
695 |
for ($adnum=sizeof($inj_positions)-1; $adnum>=0; $adnum--){
|
696 |
$content = substr_replace($content, $ad, $inj_positions[$adnum], 0);
|
697 |
-
++$
|
698 |
++$adinj_total_all_ads_used;
|
699 |
}
|
700 |
|
@@ -727,43 +759,89 @@ function adinj_split_by_tag($content, $tag, &$debugtags){
|
|
727 |
return $ret;
|
728 |
}
|
729 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
730 |
function adinj_num_rand_ads_to_insert($content_length){
|
731 |
-
global $
|
732 |
$ops = adinj_options();
|
|
|
|
|
733 |
if (is_single() || is_page()){
|
734 |
-
$max_num_rand_ads_to_insert = $ops['max_num_of_ads'] - $
|
735 |
-
|
736 |
-
|
|
|
|
|
737 |
} else {
|
738 |
return 0;
|
739 |
-
//TODO Allow ads in other page types later
|
740 |
}
|
|
|
|
|
|
|
741 |
if ($max_num_rand_ads_to_insert <= 0) {
|
742 |
return 0;
|
743 |
}
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
$length = $content_length;
|
750 |
-
if (adinj_do_rule_if($ops['no_random_ads_if_shorter_than'], '>', $length)){
|
751 |
return 0;
|
752 |
}
|
753 |
-
if (adinj_do_rule_if($ops['one_ad_if_shorter_than'], '>', $length)){
|
754 |
return 1;
|
755 |
}
|
756 |
-
if (adinj_do_rule_if($ops['two_ads_if_shorter_than'], '>', $length)){
|
757 |
return min(2, $max_num_rand_ads_to_insert);
|
758 |
}
|
759 |
-
if (adinj_do_rule_if($ops['three_ads_if_shorter_than'], '>', $length)){
|
760 |
return min(3, $max_num_rand_ads_to_insert);
|
761 |
}
|
762 |
return $max_num_rand_ads_to_insert;
|
763 |
}
|
764 |
|
765 |
function adinj_do_rule_if($rule_value, $condition, $content_length){
|
766 |
-
if ($rule_value
|
767 |
if (adinj_disabled($rule_value)) return false;
|
768 |
if ($condition == '>'){
|
769 |
return ($rule_value > $content_length);
|
@@ -775,7 +853,11 @@ function adinj_do_rule_if($rule_value, $condition, $content_length){
|
|
775 |
}
|
776 |
|
777 |
function adinj_disabled($value){
|
778 |
-
return $value == ADINJ_RULE_DISABLED || $value == ADINJ_DISABLED || $value == '';
|
|
|
|
|
|
|
|
|
779 |
}
|
780 |
|
781 |
function adinj_ticked($option){
|
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
|
21 |
// 2 = split testing support
|
22 |
// 3 = added front options
|
23 |
// 4 = new character counting option
|
24 |
+
// 5 = search/404 exclusion, increase db ad rotations to 10 + author conditions
|
25 |
+
// 6 = archive/home options
|
26 |
+
// 7 = cat/tag/author restriction for top/random/bottom ads
|
27 |
+
// 8 = ui options for new layout
|
28 |
+
define('ADINJ_DB_VERSION', 8);
|
29 |
|
30 |
// Files
|
31 |
// TODO will these paths work on windows?
|
42 |
define('ADINJ_NEVER_SHOW_IN', 'Never show in');
|
43 |
|
44 |
// Global variables
|
45 |
+
$adinj_total_top_ads_used = 0;
|
46 |
+
$adinj_total_random_ads_used = 0;
|
47 |
+
$adinj_total_bottom_ads_used = 0;
|
48 |
$adinj_total_all_ads_used = 0;
|
49 |
$adinj_data = array();
|
50 |
|
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)){
|
221 |
if (strpos($type, '_alt') === false){
|
222 |
$op_stem = 'advert_';
|
|
|
223 |
} else {
|
224 |
$op_stem = 'advert_alt_';
|
|
|
225 |
}
|
226 |
+
$file_stem = 'ad_'.$type.'_';
|
227 |
}
|
228 |
|
229 |
if (adinj_db_version($ads_option) == 1){
|
230 |
// old DB support (no ad rotation support) - TODO delete later
|
231 |
+
if ($type == 'random'|| $type == 'top' || $type == 'bottom'){
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
if ($output_type == "string"){
|
233 |
+
$ads = "'ad_".$type."_1.txt'";
|
234 |
} else {
|
235 |
+
$ads[] = 'ad_code_'.$type.'_1';
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
}
|
237 |
} else if (preg_match("/widget_[\d+]/i", $type)){
|
238 |
if ($output_type == "string"){
|
273 |
$padding_top = "";
|
274 |
$padding_bottom = "";
|
275 |
|
276 |
+
$prefix = '';
|
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'];
|
283 |
+
$clear = $ops[$prefix.'clear'];
|
284 |
+
$margin_top = $ops[$prefix.'margin_top'];
|
285 |
+
$margin_bottom = $ops[$prefix.'margin_bottom'];
|
286 |
+
$padding_top = $ops[$prefix.'padding_top'];
|
287 |
+
$padding_bottom = $ops[$prefix.'padding_bottom'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
if (adinj_disabled($align)) $align = "";
|
290 |
if (adinj_disabled($clear)) $clear = "";
|
369 |
|
370 |
function adinj($content, $message){
|
371 |
if (!adinj_ticked('debug_mode')) return $content;
|
372 |
+
global $adinj_total_top_ads_used, $adinj_total_random_ads_used, $adinj_total_bottom_ads_used, $adinj_total_all_ads_used;
|
373 |
$ops = adinj_options();
|
374 |
$para = adinj_paragraph_to_start_ads();
|
375 |
$mode = $ops['ad_insertion_mode'];
|
376 |
+
|
377 |
+
$posttype = get_post_type() . ' (';
|
378 |
+
if (is_archive()) $posttype .= ' archive';
|
379 |
+
if (is_front_page()) $posttype .= ' front';
|
380 |
+
if (is_home()) $posttype .= ' home';
|
381 |
+
if (is_page()) $posttype .= ' page';
|
382 |
+
if (is_search()) $posttype .= ' search';
|
383 |
+
if (is_single()) $posttype .= ' single';
|
384 |
+
if (is_404()) $posttype .= ' 404';
|
385 |
+
$posttype .= ')';
|
386 |
+
|
387 |
if(is_single() || is_page()) {
|
388 |
$currentdate = time();
|
389 |
$postdate = get_the_time('U');
|
394 |
<!--
|
395 |
[ADINJ DEBUG]
|
396 |
$message
|
397 |
+
\$adinj_total_top_ads_used=$adinj_total_top_ads_used
|
398 |
+
\$adinj_total_random_ads_used=$adinj_total_random_ads_used
|
399 |
+
\$adinj_total_bottom_ads_used=$adinj_total_bottom_ads_used
|
400 |
\$adinj_total_all_ads_used=$adinj_total_all_ads_used
|
401 |
paragraphtostartads=$para (fyi: -1 is disabled)
|
402 |
posttype=$posttype
|
408 |
|
409 |
function adinj_ads_completely_disabled_from_page($content=NULL){
|
410 |
$ops = adinj_options();
|
411 |
+
if ($ops['ads_enabled'] == 'off' ||
|
412 |
$ops['ads_enabled'] == ''){
|
413 |
return "NOADS: Ads are not switched on";
|
414 |
}
|
432 |
|
433 |
// no ads on old posts/pages if rule is enabled
|
434 |
if((is_page() || is_single()) && !adinj_is_old_post()) return "NOADS: !is_old_post";
|
|
|
|
|
|
|
435 |
|
436 |
+
if (!adinj_allowed_in_category('global', $ops)) return "NOADS: globally blocked from category";
|
437 |
+
if (!adinj_allowed_in_tag('global', $ops)) return "NOADS: globally blocked from tag";
|
438 |
+
if (!adinj_allowed_in_author('global', $ops)) return "NOADS: globally blocked from author";
|
|
|
|
|
439 |
|
440 |
// manual ad disabling tags
|
441 |
if ($content == NULL) return false;
|
447 |
return false;
|
448 |
}
|
449 |
|
450 |
+
function adinj_allowed_in_list($all_entries, $config_entries, $mode, $func){
|
451 |
if (is_array($all_entries)){
|
452 |
+
foreach($all_entries as $entry){
|
453 |
$string = $func($entry);
|
454 |
$decoded = rawurldecode($string); //allow UTF-8 encoded strings
|
455 |
if (in_array($string, $config_entries) || in_array($decoded, $config_entries)){
|
456 |
+
if (adinj_mode_only_show_in($mode)){
|
457 |
return true;
|
458 |
+
} else if (adinj_mode_never_show_in($mode)){
|
459 |
return false;
|
460 |
}
|
461 |
}
|
462 |
}
|
463 |
}
|
464 |
+
if (adinj_mode_only_show_in($mode)){
|
465 |
return false;
|
466 |
+
} else if (adinj_mode_never_show_in($mode)){
|
467 |
return true;
|
468 |
}
|
469 |
echo ("<!--ADINJ DEBUG: error in adinj_allowed_in_list-->");
|
470 |
return true;
|
471 |
}
|
472 |
|
473 |
+
function adinj_mode_only_show_in($mode){
|
474 |
+
return ($mode == ADINJ_ONLY_SHOW_IN || $mode == 'o');
|
475 |
+
}
|
476 |
+
|
477 |
+
function adinj_mode_never_show_in($mode){
|
478 |
+
return ($mode == ADINJ_NEVER_SHOW_IN || $mode == 'n');
|
479 |
+
}
|
480 |
+
|
481 |
function adinj_allowed_in_category($scope, $ops){
|
482 |
$cat_array = adinj_split_comma_list($ops[$scope.'_category_condition_entries']);
|
483 |
if (empty($cat_array)) return true;
|
484 |
+
|
485 |
+
$mode = $ops[$scope.'_category_condition_mode'];
|
486 |
+
if (adinj_mode_only_show_in($mode) && !(is_single() || is_category())){
|
487 |
+
return false;
|
488 |
+
}
|
489 |
+
|
490 |
+
$postcategories = array();
|
491 |
+
if (is_single()){
|
492 |
+
global $post;
|
493 |
+
$postcategories = get_the_category($post->ID);
|
494 |
+
} else if (is_category()){
|
495 |
+
$postcategories[] = get_category(get_query_var('cat'));
|
496 |
+
} // else cat array is empty
|
497 |
+
return adinj_allowed_in_list($postcategories, $cat_array, $mode, 'adinj_category_nicename');
|
498 |
}
|
499 |
|
500 |
function adinj_allowed_in_tag($scope, $ops){
|
501 |
$conditions = adinj_split_comma_list($ops[$scope.'_tag_condition_entries']);
|
502 |
if (empty($conditions)) return true;
|
503 |
+
|
504 |
+
$mode = $ops[$scope.'_tag_condition_mode'];
|
505 |
+
if (adinj_mode_only_show_in($mode) && !(is_single() || is_tag())){
|
506 |
+
return false;
|
507 |
+
}
|
508 |
+
|
509 |
+
$tags = array();
|
510 |
+
if (is_single()){
|
511 |
+
global $post;
|
512 |
+
$tags = get_the_tags($post->ID);
|
513 |
+
} else if (is_tag()){
|
514 |
+
$tags[] = get_tag(get_query_var('tag_id'));
|
515 |
+
} // else tag array is empty
|
516 |
+
return adinj_allowed_in_list($tags, $conditions, $mode, 'adinj_tag_slug');
|
517 |
}
|
518 |
|
519 |
function adinj_allowed_in_author($scope, $ops){
|
520 |
$conditions = adinj_split_comma_list($ops[$scope.'_author_condition_entries']);
|
521 |
if (empty($conditions)) return true;
|
522 |
+
|
523 |
+
$mode = $ops[$scope.'_author_condition_mode'];
|
524 |
+
if (adinj_mode_only_show_in($mode) && !(is_single() || is_page() || is_author())){
|
525 |
+
return false;
|
526 |
+
}
|
527 |
+
|
528 |
+
$user = array();
|
529 |
+
if (is_single() || is_page()){
|
530 |
+
$data = get_the_author_meta('user_login');
|
531 |
+
$user[] = $data ; //need to make it into array
|
532 |
+
} else if (is_author()){
|
533 |
+
$curauth = get_userdata(get_query_var('author'));
|
534 |
+
$user[] = $curauth->user_login;
|
535 |
+
} // else author array is empty
|
536 |
+
|
537 |
+
return adinj_allowed_in_list($user, $conditions, $mode, 'adinj_author_data');
|
538 |
}
|
539 |
|
540 |
//function parameters
|
547 |
}
|
548 |
|
549 |
function adinj_inject_hook($content){
|
|
|
550 |
if (is_feed()) return $content; // TODO feed specific ads
|
551 |
|
552 |
adinj_upgrade_db_if_necessary();
|
553 |
|
554 |
+
global $adinj_total_random_ads_used, $adinj_total_top_ads_used, $adinj_total_bottom_ads_used;
|
555 |
if(!is_archive && (is_page() || is_single())){
|
556 |
// TODO hack for no random ads bug
|
557 |
+
$adinj_total_random_ads_used = 0;
|
558 |
}
|
559 |
|
560 |
$reason = adinj_ads_completely_disabled_from_page($content);
|
594 |
if ($debug_on) $debug .= "\nnum words: = $length";
|
595 |
}
|
596 |
# Insert top and bottom ads if necesary
|
597 |
+
if (adinj_num_top_ads_to_insert($length) > 0){
|
598 |
+
$content = $ad_include.adinj_ad_code_top().$content;
|
599 |
+
$ad_include = false;
|
600 |
+
++$adinj_total_top_ads_used;
|
601 |
+
++$adinj_total_all_ads_used;
|
602 |
+
}
|
603 |
+
if (adinj_num_bottom_ads_to_insert($length) > 0){
|
604 |
+
$content = $content.adinj_ad_code_bottom();
|
605 |
+
++$adinj_total_bottom_ads_used;
|
606 |
+
++$adinj_total_all_ads_used;
|
607 |
}
|
608 |
+
|
609 |
if ($ad_include !== false) $content = $ad_include.$content;
|
610 |
|
611 |
$num_rand_ads_to_insert = adinj_num_rand_ads_to_insert($length);
|
612 |
+
if ($num_rand_ads_to_insert <= 0) return adinj($content, "no random ads on this post");
|
613 |
$ad = adinj_ad_code_random();
|
614 |
if (empty($ad)) return adinj($content, "no random ad defined");
|
615 |
|
653 |
$paragraphmarker = "</p>";
|
654 |
if(stripos($content, $paragraphmarker) === false) return adinj($content, "no </p> tags");
|
655 |
|
656 |
+
if ($debug_on) $debug .= "\nTags=". htmlentities($debugtags);
|
657 |
|
658 |
// Generate a list of all potential injection points
|
659 |
if ($debug_on) $debug .= "\nPotential positions: ";
|
723 |
sort($inj_positions);
|
724 |
|
725 |
// Insert ads in reverse order
|
726 |
+
global $adinj_total_random_ads_used, $adinj_total_all_ads_used;
|
727 |
for ($adnum=sizeof($inj_positions)-1; $adnum>=0; $adnum--){
|
728 |
$content = substr_replace($content, $ad, $inj_positions[$adnum], 0);
|
729 |
+
++$adinj_total_random_ads_used;
|
730 |
++$adinj_total_all_ads_used;
|
731 |
}
|
732 |
|
759 |
return $ret;
|
760 |
}
|
761 |
|
762 |
+
function adinj_get_current_page_type_prefix(){
|
763 |
+
if (is_home()) return 'home_';
|
764 |
+
if (is_archive()) return 'archive_';
|
765 |
+
return '';
|
766 |
+
}
|
767 |
+
|
768 |
+
function adinj_num_top_ads_to_insert($content_length){
|
769 |
+
global $adinj_total_top_ads_used;
|
770 |
+
$ops = adinj_options();
|
771 |
+
$prefix = adinj_get_current_page_type_prefix();
|
772 |
+
$max_num_ads_to_insert = $ops[$prefix.'max_num_top_ads_per_page'] - $adinj_total_top_ads_used;
|
773 |
+
if ($max_num_ads_to_insert == 0) return 0;
|
774 |
+
|
775 |
+
if (!adinj_allowed_in_category('top', $ops)) return "NOADS: top ad blocked from category";
|
776 |
+
if (!adinj_allowed_in_tag('top', $ops)) return "NOADS: top ad blocked from tag";
|
777 |
+
if (!adinj_allowed_in_author('top', $ops)) return "NOADS: top ad blocked from author";
|
778 |
+
|
779 |
+
if (adinj_do_rule_if($ops[$prefix.'top_ad_if_longer_than'], '<', $content_length)){
|
780 |
+
return 1;
|
781 |
+
}
|
782 |
+
return 0;
|
783 |
+
}
|
784 |
+
|
785 |
+
function adinj_num_bottom_ads_to_insert($content_length){
|
786 |
+
global $adinj_total_bottom_ads_used;
|
787 |
+
$ops = adinj_options();
|
788 |
+
$prefix = adinj_get_current_page_type_prefix();
|
789 |
+
$max_num_ads_to_insert = $ops[$prefix.'max_num_bottom_ads_per_page'] - $adinj_total_bottom_ads_used;
|
790 |
+
if ($max_num_ads_to_insert == 0) return 0;
|
791 |
+
|
792 |
+
if (!adinj_allowed_in_category('bottom', $ops)) return "NOADS: bottom ad blocked from category";
|
793 |
+
if (!adinj_allowed_in_tag('bottom', $ops)) return "NOADS: bottom ad blocked from tag";
|
794 |
+
if (!adinj_allowed_in_author('bottom', $ops)) return "NOADS: bottom ad blocked from author";
|
795 |
+
|
796 |
+
if (adinj_do_rule_if($ops[$prefix.'bottom_ad_if_longer_than'], '<', $content_length)){
|
797 |
+
return 1;
|
798 |
+
}
|
799 |
+
return 0;
|
800 |
+
}
|
801 |
+
|
802 |
function adinj_num_rand_ads_to_insert($content_length){
|
803 |
+
global $adinj_total_random_ads_used; // a page can be more than one post
|
804 |
$ops = adinj_options();
|
805 |
+
$max_ads_in_post = 0;
|
806 |
+
$prefix = adinj_get_current_page_type_prefix();
|
807 |
if (is_single() || is_page()){
|
808 |
+
$max_num_rand_ads_to_insert = $ops['max_num_of_ads'] - $adinj_total_random_ads_used;
|
809 |
+
$max_ads_in_post = $max_num_rand_ads_to_insert;
|
810 |
+
} else if (is_home() || is_archive()){
|
811 |
+
$max_num_rand_ads_to_insert = $ops[$prefix.'max_num_random_ads_per_page'] - $adinj_total_random_ads_used;
|
812 |
+
$max_ads_in_post = $ops[$prefix.'max_num_random_ads_per_post'];
|
813 |
} else {
|
814 |
return 0;
|
|
|
815 |
}
|
816 |
+
|
817 |
+
$max_num_rand_ads_to_insert = min($max_num_rand_ads_to_insert, $max_ads_in_post);
|
818 |
+
|
819 |
if ($max_num_rand_ads_to_insert <= 0) {
|
820 |
return 0;
|
821 |
}
|
822 |
+
|
823 |
+
if (!adinj_allowed_in_category('random', $ops)) return "NOADS: random ad blocked from category";
|
824 |
+
if (!adinj_allowed_in_tag('random', $ops)) return "NOADS: random ad blocked from tag";
|
825 |
+
if (!adinj_allowed_in_author('random', $ops)) return "NOADS: random ad blocked from author";
|
826 |
+
|
827 |
$length = $content_length;
|
828 |
+
if (adinj_do_rule_if($ops[$prefix.'no_random_ads_if_shorter_than'], '>', $length)){
|
829 |
return 0;
|
830 |
}
|
831 |
+
if (adinj_do_rule_if($ops[$prefix.'one_ad_if_shorter_than'], '>', $length)){
|
832 |
return 1;
|
833 |
}
|
834 |
+
if (adinj_do_rule_if($ops[$prefix.'two_ads_if_shorter_than'], '>', $length)){
|
835 |
return min(2, $max_num_rand_ads_to_insert);
|
836 |
}
|
837 |
+
if (adinj_do_rule_if($ops[$prefix.'three_ads_if_shorter_than'], '>', $length)){
|
838 |
return min(3, $max_num_rand_ads_to_insert);
|
839 |
}
|
840 |
return $max_num_rand_ads_to_insert;
|
841 |
}
|
842 |
|
843 |
function adinj_do_rule_if($rule_value, $condition, $content_length){
|
844 |
+
if (adinj_alwaysshow($rule_value)) return true;
|
845 |
if (adinj_disabled($rule_value)) return false;
|
846 |
if ($condition == '>'){
|
847 |
return ($rule_value > $content_length);
|
853 |
}
|
854 |
|
855 |
function adinj_disabled($value){
|
856 |
+
return "$value" == ADINJ_RULE_DISABLED || "$value" == ADINJ_DISABLED || "$value" == 'd' || "$value" == '';
|
857 |
+
}
|
858 |
+
|
859 |
+
function adinj_alwaysshow($value){
|
860 |
+
return "$value" == ADINJ_ALWAYS_SHOW || "$value" == 'a';
|
861 |
}
|
862 |
|
863 |
function adinj_ticked($option){
|
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.
|
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 |
|
@@ -12,6 +12,11 @@ Injects any adverts (e.g. AdSense) into the WordPress posts or widget area. Rest
|
|
12 |
|
13 |
Ad Injection injects any kind of advert (e.g. Google AdSense, Amazon Associates, ClickBank, TradeDoubler, etc) into the existing content of your WordPress posts and pages. You can control the number of adverts based on the post length, and it can restrict who sees adverts by post age, visitor referrer and IP address. Adverts can be configured in the post (random, top, and bottom positions) or in any widget/sidebar area. There's support for A:B split testing / ad rotation. And the dynamic restrictions (by IP and referrer) work with WP Super Cache, W3 Total Cache and WP Cache.
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
**New Features 0.9.6.x**
|
16 |
|
17 |
* Ad rotation / A:B split testing support for random, top, bottom and widget/sidebar adverts.
|
@@ -213,6 +218,10 @@ You can try defining the 'clear' display setting so that multiple floated parts
|
|
213 |
|
214 |
If you always have a floated image at the top of the page you can set which paragraph the first random advert will start from. If you needed finer control over where the random adverts appear you can use the <!--adstart--> and <!--adend--> tags in the page.
|
215 |
|
|
|
|
|
|
|
|
|
216 |
= I have configured four Google AdSense ad units but only three are showing. Why? =
|
217 |
|
218 |
Google's AdSense TOS only allow allow three ad units, and three link units per page. If you have for example tried to insert four ad units on your page then Google will (probably) disable the forth one automatically. Read Google's AdSense [program policies](https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=48182 "AdSense program policies") for more info.
|
@@ -226,6 +235,32 @@ Don't worry - everything will still work except for:
|
|
226 |
|
227 |
If you aren't interested in these features then it doesn't matter! Just make sure you tick the box to say that you to use 'Direct static ad insertion' on the Ad Injection settings screen.
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
= How can I show different ads for different post authors? =
|
230 |
|
231 |
This is something I hope to build into the UI at some point. But in the mean time you can use PHP in the ad code boxes to do this: e.g.
|
@@ -238,6 +273,25 @@ This is John's Ad.
|
|
238 |
This is Paul's Ad.
|
239 |
<?php } ?>`
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
= Are there any known plugin conflicts? =
|
242 |
|
243 |
**WP Minify**
|
@@ -318,6 +372,10 @@ If you do get any errors please use the 'Report a bug or give feedback' link on
|
|
318 |
|
319 |
== Changelog ==
|
320 |
|
|
|
|
|
|
|
|
|
321 |
= 0.9.6.6 =
|
322 |
* Widgets can be conditionally included on pages by category, tag, and author.
|
323 |
* Widget ad pool size increased to 10.
|
@@ -443,8 +501,8 @@ Fix 'Something badly wrong in num_rand_ads_to_insert' message that occurs on pag
|
|
443 |
|
444 |
== Upgrade Notice ==
|
445 |
|
446 |
-
= 0.9.
|
447 |
-
|
448 |
|
449 |
= 0.8.3 =
|
450 |
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
|
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 |
|
12 |
|
13 |
Ad Injection injects any kind of advert (e.g. Google AdSense, Amazon Associates, ClickBank, TradeDoubler, etc) into the existing content of your WordPress posts and pages. You can control the number of adverts based on the post length, and it can restrict who sees adverts by post age, visitor referrer and IP address. Adverts can be configured in the post (random, top, and bottom positions) or in any widget/sidebar area. There's support for A:B split testing / ad rotation. And the dynamic restrictions (by IP and referrer) work with WP Super Cache, W3 Total Cache and WP Cache.
|
14 |
|
15 |
+
**New Features 0.9.7.x**
|
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 |
|
22 |
* Ad rotation / A:B split testing support for random, top, bottom and widget/sidebar adverts.
|
218 |
|
219 |
If you always have a floated image at the top of the page you can set which paragraph the first random advert will start from. If you needed finer control over where the random adverts appear you can use the <!--adstart--> and <!--adend--> tags in the page.
|
220 |
|
221 |
+
= I have set the ads to float but the text/headings aren't flowing around them =
|
222 |
+
|
223 |
+
Check your style sheet to see if either the text or headings have the 'clear' attribute set. This may be preventing your text / headings from flowing around the advert.
|
224 |
+
|
225 |
= I have configured four Google AdSense ad units but only three are showing. Why? =
|
226 |
|
227 |
Google's AdSense TOS only allow allow three ad units, and three link units per page. If you have for example tried to insert four ad units on your page then Google will (probably) disable the forth one automatically. Read Google's AdSense [program policies](https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=48182 "AdSense program policies") for more info.
|
235 |
|
236 |
If you aren't interested in these features then it doesn't matter! Just make sure you tick the box to say that you to use 'Direct static ad insertion' on the Ad Injection settings screen.
|
237 |
|
238 |
+
= How can I show different ads for different categories? =
|
239 |
+
|
240 |
+
If you want to show different ads for different categories using widgets you can set up filters for the different ads from the widget UI. If you want to show different top, random, or bottom adverts on different categories you can use some very simple PHP in the ad box (this will also work for the widgets as well if you don't like the UI method).
|
241 |
+
|
242 |
+
Note this will only work in the direct insertion mode. It won�t work in mfunc mode!
|
243 |
+
|
244 |
+
Example 1 - one category specific ad and a general ad.
|
245 |
+
|
246 |
+
`<?php if (in_category('japan')) { ?>
|
247 |
+
Japan advert
|
248 |
+
<?php } else { ?>
|
249 |
+
General advert
|
250 |
+
<?php } ?>`
|
251 |
+
|
252 |
+
Example 2 - Two different ads in two different categories. Pages which aren't in either category have no ads.
|
253 |
+
|
254 |
+
`<?php if (in_category('cheese')) { ?>
|
255 |
+
Cheese advert
|
256 |
+
<?php } else if (in_category('milk')) { ?>
|
257 |
+
Milk advert
|
258 |
+
<?php } ?>`
|
259 |
+
|
260 |
+
See http://codex.wordpress.org/Function_Reference/in_category for more information on in_category.
|
261 |
+
|
262 |
+
You can do the same for tags using has_tag. See http://codex.wordpress.org/Function_Reference/has_tag for info.
|
263 |
+
|
264 |
= How can I show different ads for different post authors? =
|
265 |
|
266 |
This is something I hope to build into the UI at some point. But in the mean time you can use PHP in the ad code boxes to do this: e.g.
|
273 |
This is Paul's Ad.
|
274 |
<?php } ?>`
|
275 |
|
276 |
+
Note this will only work in direct insertion mode. It won�t work in mfunc mode!
|
277 |
+
|
278 |
+
= How can I show different ads to people in different countries? =
|
279 |
+
|
280 |
+
If you install the Country Filter plugin (with the IP database) then you can use the following code in the direct ad insertion modes. This will not work in mfunc mode!
|
281 |
+
|
282 |
+
<?php if (function_exists('isCountryInFilter')) { ?>
|
283 |
+
<?php if(isCountryInFilter(array("uk"))) { ?>
|
284 |
+
|
285 |
+
UK advert
|
286 |
+
|
287 |
+
<?php } else { ?>
|
288 |
+
|
289 |
+
Global advert
|
290 |
+
|
291 |
+
<?php } } ?>
|
292 |
+
|
293 |
+
You can download the Country Filter plugin from http://wordpress.org/extend/plugins/country-filter/
|
294 |
+
|
295 |
= Are there any known plugin conflicts? =
|
296 |
|
297 |
**WP Minify**
|
372 |
|
373 |
== Changelog ==
|
374 |
|
375 |
+
= 0.9.7 =
|
376 |
+
* Archive and home page ads now fully supported with the same controls as ads for single posts/pages.
|
377 |
+
* Category, tag and author restrictions for top, random and bottom ads.
|
378 |
+
|
379 |
= 0.9.6.6 =
|
380 |
* Widgets can be conditionally included on pages by category, tag, and author.
|
381 |
* Widget ad pool size increased to 10.
|
501 |
|
502 |
== Upgrade Notice ==
|
503 |
|
504 |
+
= 0.9.7 =
|
505 |
+
Support for ads on archives and home page. Fixes for widget ads.
|
506 |
|
507 |
= 0.8.3 =
|
508 |
First public release.
|
ui-tab-adrotation.php
CHANGED
@@ -10,15 +10,7 @@ function adinj_tab_adrotation(){
|
|
10 |
$ops = adinj_options();
|
11 |
|
12 |
echo <<<DOCS
|
13 |
-
<p><a href="#
|
14 |
-
|
15 |
-
<p>Ad rotation / split testing and alternate content are advanced features. If you don't understand these features you probably don't need them and can therefore ignore this tab. In summary:</p>
|
16 |
-
|
17 |
-
<ul>
|
18 |
-
<li><b>Ad rotation / split testing:</b> You can define multiple adverts for the same ad space which are rotated according to the ratios you define. The percentage of views that each ad will be shows is displated beneath the ratio text box. For example if you define two ads and set both to have a ratio of '50' they will each be shown (roughly) 50% of the time. The numbers don't have to add up to 100 as the ratio is calculated based on the total. e.g. if you have two advert - one is set with a ratio of '1' and the other '3' the ratios will be 25% and 75%. Please remember this isn't strict ad rotation, it is random selection based on ratios so the ratios will be correct over a large sample of ad views, not a small sample.</li>
|
19 |
-
<li><b>Alternate content:</b> This is content that is displayed when ads are blocked for the user. Ads can only be blocked for specific users if you use one of the dynamic modes (mfunc or direct_dynamic). You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.</li>
|
20 |
-
</ul>
|
21 |
-
|
22 |
DOCS;
|
23 |
|
24 |
$total_rand_split = adinj_total_split('ad_code_random_', $ops);
|
@@ -36,16 +28,15 @@ DOCS;
|
|
36 |
</style>
|
37 |
|
38 |
<?php
|
39 |
-
adinj_postbox_start(__("
|
40 |
-
echo
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
adinj_postbox_end();
|
48 |
-
|
49 |
|
50 |
adinj_postbox_start(__("Top adverts", 'adinj'), 'multiple_top');
|
51 |
echo '<table border="0" cellspacing="5" class="adinjtable">';
|
@@ -58,6 +49,17 @@ DOCS;
|
|
58 |
adinj_postbox_end();
|
59 |
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
adinj_postbox_start(__("Bottom adverts", 'adinj'), 'multiple_bottom');
|
62 |
echo '<table border="0" cellspacing="5" class="adinjtable">';
|
63 |
for ($i=1; $i<=10; ++$i){
|
@@ -68,6 +70,29 @@ DOCS;
|
|
68 |
echo '</table>';
|
69 |
adinj_postbox_end();
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
function adinj_add_row_with_text_box($name_stem, $num, $title, $total){
|
@@ -88,5 +113,42 @@ echo <<<EOT
|
|
88 |
EOT;
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
?>
|
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);
|
28 |
</style>
|
29 |
|
30 |
<?php
|
31 |
+
adinj_postbox_start(__("Ad rotation / alt content docs", 'adinj'), 'docs_adrotation');
|
32 |
+
echo <<<DOCS
|
33 |
+
<p>Ad rotation / split testing and alternate content are advanced features. If you don't understand these features you probably don't need them and can therefore ignore this tab. In summary:</p>
|
34 |
+
<ul>
|
35 |
+
<li><b>Ad rotation / split testing:</b> You can define multiple adverts for the same ad space which are rotated according to the ratios you define. The percentage of views that each ad will be shows is displated beneath the ratio text box. For example if you define two ads and set both to have a ratio of '50' they will each be shown (roughly) 50% of the time. The numbers don't have to add up to 100 as the ratio is calculated based on the total. e.g. if you have two advert - one is set with a ratio of '1' and the other '3' the ratios will be 25% and 75%. Please remember this isn't strict ad rotation, it is random selection based on ratios so the ratios will be correct over a large sample of ad views, not a small sample.</li>
|
36 |
+
<li><b>Alternate content:</b> This is content that is displayed when ads are blocked for the user. Ads can only be blocked for specific users if you use one of the dynamic modes (mfunc or direct_dynamic). You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.</li>
|
37 |
+
</ul>
|
38 |
+
DOCS;
|
39 |
adinj_postbox_end();
|
|
|
40 |
|
41 |
adinj_postbox_start(__("Top adverts", 'adinj'), 'multiple_top');
|
42 |
echo '<table border="0" cellspacing="5" class="adinjtable">';
|
49 |
adinj_postbox_end();
|
50 |
|
51 |
|
52 |
+
adinj_postbox_start(__("Random adverts", 'adinj'), 'multiple_random');
|
53 |
+
echo '<table border="0" cellspacing="5" class="adinjtable">';
|
54 |
+
for ($i=1; $i<=10; ++$i){
|
55 |
+
adinj_add_row_with_text_box('ad_code_random_', $i, 'Ad code', $total_rand_split);
|
56 |
+
}
|
57 |
+
adinj_add_row_with_text_box('ad_code_random_alt_', 1, 'Alt content', $total_rand_alt_split);
|
58 |
+
adinj_add_row_with_text_box('ad_code_random_alt_', 2, 'Alt content', $total_rand_alt_split);
|
59 |
+
echo '</table>';
|
60 |
+
adinj_postbox_end();
|
61 |
+
|
62 |
+
|
63 |
adinj_postbox_start(__("Bottom adverts", 'adinj'), 'multiple_bottom');
|
64 |
echo '<table border="0" cellspacing="5" class="adinjtable">';
|
65 |
for ($i=1; $i<=10; ++$i){
|
70 |
echo '</table>';
|
71 |
adinj_postbox_end();
|
72 |
|
73 |
+
|
74 |
+
adinj_postbox_start(__("Misc options", 'adinj'), 'misc'); ?>
|
75 |
+
<table>
|
76 |
+
<tr>
|
77 |
+
<td>Content length counting method:</td>
|
78 |
+
<td>
|
79 |
+
<?php
|
80 |
+
adinj_selection_box("content_length_unit",
|
81 |
+
array('viewable' => 'viewable chars', 'all' => 'all chars', 'words' => 'words'));
|
82 |
+
?>
|
83 |
+
</td></tr>
|
84 |
+
<tr><td colspan="2"><p><span style="font-size:10px;">When defining conditions that refer to the length of the content; do you want to count viewable characters, all characters (which includes HTML tags), or number of words?</span></p></td></tr>
|
85 |
+
<tr><td>
|
86 |
+
<?php _e("Allow multiple random ads to be injected at the same positions.", 'adinj') ?></td><td><?php adinj_add_checkbox('multiple_ads_at_same_position') ?> (default is to inject ads at unique positions)
|
87 |
+
</td></tr>
|
88 |
+
</table>
|
89 |
+
<?php adinj_postbox_end();
|
90 |
+
|
91 |
+
adinj_docs_tags();
|
92 |
+
|
93 |
+
adinj_testads();
|
94 |
+
|
95 |
+
|
96 |
}
|
97 |
|
98 |
function adinj_add_row_with_text_box($name_stem, $num, $title, $total){
|
113 |
EOT;
|
114 |
}
|
115 |
|
116 |
+
function adinj_docs_tags(){
|
117 |
+
?>
|
118 |
+
|
119 |
+
<?php adinj_postbox_start(__("Supported in-page tags", 'adinj'), "docs_tags", '95%'); ?>
|
120 |
+
|
121 |
+
<p>These tags can be inserted into the page source to override the configured behaviour on single posts and pages. Because sometimes specific pages need to be treated differently.</p>
|
122 |
+
|
123 |
+
<ul>
|
124 |
+
<li><code><!--noadsense--></code> OR <code><!-no-adsense--></code> OR <code><!--NoAds--></code> OR <code><!--OffAds--></code> - disables all ads on this page. These tags are here to make this plugin compatible with the tags from Adsense Injection, Whydowork Adsense and Quick Adsense.</li>
|
125 |
+
</ul>
|
126 |
+
|
127 |
+
<p></p>
|
128 |
+
|
129 |
+
<ul>
|
130 |
+
<li><code><!--adsandwich--></code> - Inserts the top and bottom ad but no random ads. Disables all other ads.</li>
|
131 |
+
<li><code><!--adfooter--></code> - Insert a single ad at the very bottom. Disables all other ads.</li>
|
132 |
+
</ul>
|
133 |
+
|
134 |
+
<p></p>
|
135 |
+
|
136 |
+
<ol>
|
137 |
+
<li><code><!--adsensestart--></code> - Random ads will start from this point*. For compatibility with Adsense Injection.</li>
|
138 |
+
<li><code><!--adsenseend--></code> - Random ads will not be inserted after this point*. New tag but I've kept the Adsense Injection naming convention to make it fit with the above tag.</li>
|
139 |
+
<li><code><!--adstart--></code> - Random ads will start from this point*.</li>
|
140 |
+
<li><code><!--adend--></code> - Random ads will not be inserted after this point*.</li>
|
141 |
+
</ol>
|
142 |
+
|
143 |
+
<p>These four tags will not affect the top and bottom ad.</p>
|
144 |
+
|
145 |
+
<h4>Custom field for disabling adverts</h4>
|
146 |
+
|
147 |
+
<p>To disable all adverts on the page you can also set the custom <code>disable_adverts</code> field to '1' from the WordPress post editor.</p>
|
148 |
+
|
149 |
+
|
150 |
+
<?php adinj_postbox_end();
|
151 |
+
|
152 |
+
}
|
153 |
|
154 |
?>
|
ui-tab-debug.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Part of the Ad Injection plugin for WordPress
|
4 |
+
http://www.reviewmylife.co.uk/
|
5 |
+
*/
|
6 |
+
|
7 |
+
if (!is_admin()) return;
|
8 |
+
|
9 |
+
function adinj_tab_debug(){
|
10 |
+
$ops = adinj_options();
|
11 |
+
|
12 |
+
adinj_postbox_start(__("Debugging", 'adinj'), 'debugging');
|
13 |
+
|
14 |
+
adinj_add_checkbox('debug_mode') ?>Enable debug mode
|
15 |
+
|
16 |
+
<p>If you are not sure why ads aren't appearing, or why they are appearing, enable debug mode and look at the debug information (search for 'ADINJ DEBUG') in the HTML of your content pages.</p>
|
17 |
+
|
18 |
+
<?php
|
19 |
+
|
20 |
+
if (adinj_problem_with_wpminify_check()){
|
21 |
+
echo adinj_get_problem_with_wpminify_message();
|
22 |
+
}
|
23 |
+
|
24 |
+
adinj_debug_information();
|
25 |
+
?>
|
26 |
+
|
27 |
+
<p></p>
|
28 |
+
|
29 |
+
<p>If you want to restore all settings (excluding the ad contents) to their default values use this button.</p>
|
30 |
+
|
31 |
+
<input type="submit" name="adinj_action" value="<?php _e('Reset to Default', 'adinj') ?>" />
|
32 |
+
|
33 |
+
<p>You can delete the database settings if you are going to uninstall Ad Injection (they will be automatically deleted if you uninstall via WordPress as well).</p>
|
34 |
+
|
35 |
+
<input type="submit" name="adinj_action" value="<?php _e('Delete settings from DB', 'adinj') ?>" />
|
36 |
+
|
37 |
+
<p>This button will delete all your Ad Injection widgets.</p>
|
38 |
+
|
39 |
+
<input type="submit" name="adinj_action" value="<?php _e('Delete widget settings from DB', 'adinj') ?>" />
|
40 |
+
|
41 |
+
<?php
|
42 |
+
adinj_postbox_end();
|
43 |
+
}
|
44 |
+
|
45 |
+
function adinj_debug_information(){
|
46 |
+
$stored_options = adinj_options();
|
47 |
+
$default_options = adinj_default_options();
|
48 |
+
?>
|
49 |
+
<h4>Settings dump from database (all in 'adinj_options' option)</h4>
|
50 |
+
<table border="1" style="width:610px; table-layout:fixed; word-wrap:break-word;">
|
51 |
+
<tr><td><b>Name</b></td><td><b>Stored</b></td><td><b>Default</b></td></tr>
|
52 |
+
<?php
|
53 |
+
$main_length = 0;
|
54 |
+
if ($stored_options !== false){
|
55 |
+
$count = 0;
|
56 |
+
foreach ($stored_options as $key => $value){
|
57 |
+
if ($count % 2 == 0){
|
58 |
+
echo '<tr style="background-color:#cccccc"><td>';
|
59 |
+
} else {
|
60 |
+
echo '<tr><td>';
|
61 |
+
}
|
62 |
+
echo "$key";
|
63 |
+
$main_length += sizeof($key);
|
64 |
+
echo "</td><td>";
|
65 |
+
$value = htmlspecialchars($value);
|
66 |
+
$main_length += sizeof($value);
|
67 |
+
echo "$value";
|
68 |
+
echo "</td><td>";
|
69 |
+
echo $default_options[$key];
|
70 |
+
echo "</td></tr>";
|
71 |
+
$count++;
|
72 |
+
}
|
73 |
+
} else {
|
74 |
+
echo "<br />No options in database!";
|
75 |
+
}
|
76 |
+
echo '</table>';
|
77 |
+
|
78 |
+
?><h4>Widget settings dump from database (all in 'widget_adinj' option)</h4>
|
79 |
+
<table border="1" style="width:610px; word-wrap:break-word;">
|
80 |
+
<tr><td><b>Widget</b></td><td><b>Setting:Value</b></td></tr>
|
81 |
+
<?php
|
82 |
+
$widgetops = get_option('widget_adinj');
|
83 |
+
$widgets_length = 0;
|
84 |
+
$count = 0;
|
85 |
+
if (is_array($widgetops)){
|
86 |
+
foreach($widgetops as $key=>$val){
|
87 |
+
if ($count % 2 == 0){
|
88 |
+
echo '<tr style="background-color:#cccccc"><td style="vertical-align:top">';
|
89 |
+
} else {
|
90 |
+
echo '<tr><td style="vertical-align:top">';
|
91 |
+
}
|
92 |
+
echo $key;
|
93 |
+
$widgets_length += strlen($key);
|
94 |
+
echo "</td>";
|
95 |
+
echo '<td style="vertical-align:top">';
|
96 |
+
if (is_array($val)){
|
97 |
+
foreach($val as $subkey=>$subval){
|
98 |
+
echo $subkey.':'.htmlspecialchars($subval).'<br />';
|
99 |
+
$widgets_length += (strlen($subkey) + strlen($subval));
|
100 |
+
}
|
101 |
+
} else {
|
102 |
+
echo htmlspecialchars($val);
|
103 |
+
$widgets_length += strlen($val);
|
104 |
+
}
|
105 |
+
echo '</td></tr>';
|
106 |
+
++$count;
|
107 |
+
}
|
108 |
+
} else {
|
109 |
+
echo '<tr><td></td><td><b>No widget settings found</b></td></tr>';
|
110 |
+
}
|
111 |
+
echo '</table>';
|
112 |
+
|
113 |
+
echo '<h4>Other settings</h4><blockquote>';
|
114 |
+
|
115 |
+
echo 'ADINJ_PATH='.ADINJ_PATH.'<br />';
|
116 |
+
echo 'ADINJ_CONFIG_FILE='.ADINJ_CONFIG_FILE.'<br />';
|
117 |
+
echo 'ADINJ_AD_PATH='.ADINJ_AD_PATH.'<br />';
|
118 |
+
echo 'Plugin version='.adinj_get_version().'<br />';
|
119 |
+
echo 'Main settings length='.$main_length.' chars<br />';
|
120 |
+
echo 'All widgets length='.$widgets_length.' chars<br />';
|
121 |
+
echo '</blockquote>';
|
122 |
+
|
123 |
+
global $adinj_warning_msg_filewrite;
|
124 |
+
if (!empty($adinj_warning_msg_filewrite)){
|
125 |
+
echo "<h4>Errors on 'Save all settings'</h4><blockquote>$adinj_warning_msg_filewrite</blockquote";
|
126 |
+
}
|
127 |
+
|
128 |
+
global $adinj_warning_msg_chmod;
|
129 |
+
if (!empty($adinj_warning_msg_chmod)){
|
130 |
+
echo "<h4>Warnings on 'Save all settings'</h4><blockquote>$adinj_warning_msg_chmod</blockquote";
|
131 |
+
}
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
?>
|
ui-tab-main.php
CHANGED
@@ -10,10 +10,7 @@ function adinj_tab_main(){
|
|
10 |
$ops = adinj_options();
|
11 |
?>
|
12 |
|
13 |
-
<p><a href="#
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
<?php adinj_postbox_start(__("Global settings", 'adinj'), 'global'); ?>
|
19 |
|
@@ -34,17 +31,11 @@ function adinj_tab_main(){
|
|
34 |
return true;
|
35 |
});
|
36 |
});
|
|
|
|
|
|
|
37 |
</script>
|
38 |
-
|
39 |
-
<?php if ($ops['ads_enabled'] != 'test') { ?>
|
40 |
-
<script type="text/javascript">
|
41 |
-
document.write('<style type="text/css">#test_mode_warning { display: none; }</style>');
|
42 |
-
</script>
|
43 |
-
<?php } ?>
|
44 |
-
|
45 |
<div id="test_mode_warning"><span style="font-size:10px;color:red;">Warning: Turn any caching plugin *off* before using test mode. If you leave the caching plugin on, the test adverts will be cached and shown to your real visitors.</span><br /></div>
|
46 |
-
|
47 |
-
<p></p>
|
48 |
|
49 |
<style type="text/css">
|
50 |
.adinjtable td { vertical-align: top; }
|
@@ -66,271 +57,183 @@ function adinj_tab_main(){
|
|
66 |
?>
|
67 |
</select><?php _e(" (days)", 'adinj') ?> - only for single posts and pages</p>
|
68 |
</td></tr>
|
69 |
-
<tr>
|
70 |
-
<td>Don't show ads on these types:</td>
|
71 |
-
<td>
|
72 |
-
<?php adinj_add_checkbox('exclude_front') ?>front - <?php echo get_bloginfo('url'); ?><br />
|
73 |
-
<?php adinj_add_checkbox('exclude_home') ?>home - latest posts page (may be same as front)<br />
|
74 |
-
<?php
|
75 |
-
$count_pages = wp_count_posts('page', 'readable');
|
76 |
-
$count_posts = wp_count_posts('post', 'readable');
|
77 |
-
?>
|
78 |
-
<?php adinj_add_checkbox('exclude_page') ?>page - <?php echo $count_pages->publish; ?> page(s)<br />
|
79 |
-
<?php adinj_add_checkbox('exclude_single') ?>single -<?php echo $count_posts->publish; ?> single blog post(s)<br />
|
80 |
-
<?php adinj_add_checkbox('exclude_archive') ?>archive - only <a href="#widgets">widgets</a> currently appear on archives<br />
|
81 |
-
<?php adinj_add_checkbox('exclude_search') ?>search pages - widgets only for now<br />
|
82 |
-
<?php adinj_add_checkbox('exclude_404') ?>404 error pages - widgets only for now<br />
|
83 |
-
</td></tr>
|
84 |
-
<tr><td colspan="2"><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></td></tr>
|
85 |
-
<tr>
|
86 |
-
<td>Content length counting method:</td>
|
87 |
-
<td>
|
88 |
-
<?php
|
89 |
-
adinj_selection_box("content_length_unit",
|
90 |
-
array('viewable' => 'viewable chars', 'all' => 'all chars', 'words' => 'words'));
|
91 |
-
?>
|
92 |
-
</td></tr>
|
93 |
-
<tr><td colspan="2"><p><span style="font-size:10px;">When defining conditions that refer to the length of the content; do you want to count viewable characters, all characters (which includes HTML tags), or number of words?</span></p></td></tr>
|
94 |
</table>
|
95 |
-
|
96 |
-
<b>Category tag, and author conditions</b>
|
97 |
<?php
|
98 |
-
|
99 |
-
adinj_condition_table('global_category', 'category slugs. e.g: cat1, cat2, cat3', 'category', $ops);
|
100 |
-
adinj_condition_table('global_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag', $ops);
|
101 |
-
adinj_condition_table('global_author', 'author nicknames. e.g: john, paul', 'author', $ops);
|
102 |
-
echo '</div>';
|
103 |
-
|
104 |
adinj_postbox_end();
|
105 |
?>
|
106 |
|
107 |
|
108 |
-
<?php adinj_postbox_start(__("Randomly Injected ad code", 'adinj'), 'random'); ?>
|
109 |
|
110 |
-
|
111 |
-
<
|
112 |
-
<textarea name="ad_code_random_1" rows="10" cols="60"><?php echo $ops['ad_code_random_1']; ?></textarea>
|
113 |
-
</td><td style="vertical-align: top">
|
114 |
-
<?php
|
115 |
-
adinj_add_alignment_options('rnd_');
|
116 |
-
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_random'>Rotation:<br />".adinj_percentage_split('ad_code_random_', 1, $ops)."</a></b>";
|
117 |
-
|
118 |
-
?>
|
119 |
-
</td></tr>
|
120 |
-
<tr><td>
|
121 |
<?php
|
122 |
-
|
123 |
-
|
124 |
-
array(ADINJ_DISABLED, 1, 2, 3, 4, 5), " ");
|
125 |
?>
|
126 |
-
|
127 |
-
|
128 |
-
</td></tr>
|
|
|
|
|
|
|
|
|
|
|
129 |
</table>
|
130 |
-
|
131 |
-
|
132 |
-
<p><span style="font-size:10px;"
|
133 |
-
<p
|
134 |
-
</div>
|
135 |
-
|
136 |
-
<input type="submit" style="float:right" name="adinj_action" value="<?php _e('Save all settings', 'adinj') ?>" />
|
137 |
-
<h3><a name="random_single"></a><?php _e("Single posts and pages: Randomly Injected ad settings", 'adinj') ?></h3>
|
138 |
-
<div class="inside" style="margin:10px">
|
139 |
-
<p>These random ad injection settings are specific to single posts and pages only. To configure the number of home page ads go to the next section.</p>
|
140 |
-
|
141 |
-
<table border="0">
|
142 |
-
|
143 |
|
144 |
-
|
|
|
|
|
145 |
|
146 |
-
<tr><td>
|
147 |
-
<?php _e("Maximum number of randomly injected ads: ", 'adinj') ?></td><td>
|
148 |
-
<select name='max_num_of_ads'>
|
149 |
<?php
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
155 |
?>
|
156 |
-
</select> <?php echo adinj_getdefault('max_num_of_ads'); ?><br />
|
157 |
</td></tr>
|
158 |
|
159 |
-
<tr><td>
|
160 |
-
<?php
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
163 |
</td></tr>
|
164 |
|
165 |
-
|
|
|
|
|
166 |
<p></p>
|
167 |
-
|
168 |
-
|
169 |
-
<td>Random
|
170 |
-
<td
|
171 |
-
|
172 |
-
|
173 |
-
<td><center><b>3</b></center></td>
|
174 |
-
</tr>
|
175 |
-
<tr>
|
176 |
-
<td>If page shorter than:</td>
|
177 |
-
<td>
|
178 |
<?php
|
179 |
-
$
|
180 |
-
|
181 |
-
|
182 |
?>
|
183 |
-
</td>
|
184 |
-
<td>
|
185 |
<?php
|
186 |
-
adinj_selection_box("
|
187 |
-
|
|
|
|
|
|
|
188 |
?>
|
189 |
-
</td>
|
190 |
-
<td>
|
191 |
<?php
|
192 |
-
|
193 |
-
array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000), $unit);
|
194 |
?>
|
195 |
-
|
196 |
-
<td>
|
197 |
<?php
|
198 |
-
|
199 |
-
array(ADINJ_RULE_DISABLED,
|
200 |
?>
|
201 |
-
</td>
|
202 |
-
</tr>
|
203 |
-
|
204 |
-
|
205 |
-
</table>
|
206 |
-
|
207 |
-
<br clear="all" />
|
208 |
-
<p><span style="font-size:10px;"><b>Docs:</b> The 'random ad limit' rules are processed in order from left to right.</span></p>
|
209 |
-
|
210 |
</td></tr>
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
<p></p>
|
|
|
218 |
|
219 |
-
</
|
220 |
|
221 |
-
<
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
-
|
227 |
-
<select name='max_num_of_ads_home_page'>
|
228 |
<?php
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
echo ">$value</option>";
|
233 |
-
}
|
234 |
?>
|
235 |
-
</
|
236 |
|
237 |
-
<
|
|
|
|
|
|
|
|
|
238 |
|
239 |
<?php adinj_postbox_end(); ?>
|
240 |
|
241 |
|
242 |
-
|
243 |
-
<?php adinj_postbox_start(__("Optional top advert (single posts and pages only)", 'adinj'), 'topad'); ?>
|
244 |
|
245 |
-
<p><span style="font-size:10px;"><b>Purpose:</b> This ad is placed above your main post/page content (this is not a 'header' ad).</span></p>
|
246 |
|
247 |
-
<?php
|
248 |
-
_e("Only show top ad on pages longer than: ", 'adinj');
|
249 |
-
adinj_selection_box("top_ad_if_longer_than",
|
250 |
-
array(ADINJ_DISABLED, ADINJ_ALWAYS_SHOW, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000, 20000), $unit);
|
251 |
-
?>
|
252 |
-
|
253 |
-
<br clear="all" />
|
254 |
|
255 |
-
<
|
|
|
256 |
<tr><td>
|
257 |
<textarea name="ad_code_top_1" rows="10" cols="60"><?php echo $ops['ad_code_top_1']; ?></textarea>
|
258 |
-
|
|
|
|
|
259 |
<?php
|
260 |
-
adinj_add_alignment_options('top_');
|
261 |
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_top'>Rotation:<br />".adinj_percentage_split('ad_code_top_', 1, $ops)."</a></b>";
|
262 |
?>
|
263 |
</td></tr>
|
264 |
</table>
|
265 |
-
<span style="font-size:10px;">
|
266 |
-
|
267 |
-
<p><span style="font-size:10px;"><b>Docs:</b> The top ad will only appear on single posts and pages. It will not appear on multi-post pages. Try a <a href="#468x15">468x15</a> or <a href="#336x280">336x280</a> advert.</span></p>
|
268 |
-
|
269 |
-
<?php adinj_postbox_end(); ?>
|
270 |
-
|
271 |
-
|
272 |
-
<?php adinj_postbox_start(__("Optional bottom advert (single posts and pages only)", 'adinj'), 'bottomad'); ?>
|
273 |
-
|
274 |
-
<p><span style="font-size:10px;"><b>Purpose:</b> This ad is placed below your main post/page content (this is not a 'footer' ad).</span></p>
|
275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
<?php
|
277 |
-
|
278 |
-
|
279 |
-
array(ADINJ_DISABLED, ADINJ_ALWAYS_SHOW, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000, 20000), $unit);
|
280 |
?>
|
|
|
|
|
281 |
|
282 |
-
<
|
283 |
-
|
284 |
-
<table border="0">
|
285 |
<tr><td>
|
286 |
<textarea name="ad_code_bottom_1" rows="10" cols="60"><?php echo $ops['ad_code_bottom_1']; ?></textarea>
|
287 |
-
|
|
|
|
|
288 |
<?php
|
289 |
-
adinj_add_alignment_options('bottom_');
|
290 |
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_bottom'>Rotation:<br />".adinj_percentage_split('ad_code_bottom_', 1, $ops)."</a></b>";
|
291 |
?>
|
292 |
</td></tr>
|
293 |
</table>
|
294 |
-
<span style="font-size:10px;">The top ad is in addition to the quantity of other ads selected.</span>
|
295 |
-
|
296 |
-
<p><span style="font-size:10px;"><b>Docs:</b> The bottom ad will only appear on single posts and pages. It will not appear on multi-post pages. Try a <a href="#336x280">336x280</a> advert.</span></p>
|
297 |
-
|
298 |
|
299 |
<?php adinj_postbox_end(); ?>
|
300 |
|
301 |
|
302 |
-
<?php adinj_postbox_start(__("Widget settings (sidebar ads)", 'adinj'), 'widgets'); ?>
|
303 |
-
|
304 |
-
<p>You must configure your individual widgets from the <a href="widgets.php">widgets control panel</a>. However these settings are global to all widgets. Also note that the main set of <a href="#global">global settings</a> will override these ones.</p>
|
305 |
|
306 |
-
<table border="0">
|
307 |
-
|
308 |
-
<tr><td>
|
309 |
-
<p>Don't show widget ads on these types:</p>
|
310 |
-
</td><td>
|
311 |
-
<?php adinj_add_checkbox('widget_exclude_front') ?>front - <?php echo get_bloginfo('url'); ?><br />
|
312 |
-
<?php adinj_add_checkbox('widget_exclude_home') ?>home - latest posts page (may be same as front)<br />
|
313 |
-
<?php adinj_add_checkbox('widget_exclude_page') ?>page - <?php echo $count_pages->publish; ?> page(s)<br />
|
314 |
-
<?php adinj_add_checkbox('widget_exclude_single') ?>single - <?php echo $count_posts->publish; ?> single blog post(s)<br />
|
315 |
-
<?php adinj_add_checkbox('widget_exclude_archive') ?>archive - category, tag, author, and date types<br />
|
316 |
-
<?php adinj_add_checkbox('widget_exclude_search') ?>search pages<br />
|
317 |
-
<?php adinj_add_checkbox('widget_exclude_404') ?>404 error pages<br />
|
318 |
-
</td></tr>
|
319 |
-
<tr><td colspan="2"><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></td></tr>
|
320 |
-
|
321 |
-
</table>
|
322 |
-
|
323 |
-
|
324 |
-
<?php adinj_postbox_end(); ?>
|
325 |
-
|
326 |
|
327 |
<?php adinj_postbox_start(__("Ad insertion mode and dynamic ad display restrictions", 'adinj'), 'restrictions'); ?>
|
328 |
-
|
329 |
<h4>Ad insertion mode</h4>
|
330 |
-
|
331 |
<blockquote>
|
332 |
<p><input type="radio" name="ad_insertion_mode" value="mfunc" <?php if ($ops['ad_insertion_mode']=='mfunc') echo 'checked="checked"'; ?> /> <b>mfunc: Use mfunc tags for dynamic features</b> - Dynamic features will work with WP Super Cache, W3 Total Cache and WP Cache. Only select this mode if you are using one of those caching plugins.</p>
|
333 |
-
|
334 |
<?php if (!is_supported_caching_plugin_active()) {
|
335 |
echo '<p><b><span style="font-size:10px;color:red;">Note: A supported caching plugin does not appear to be active. If you are not using WP Super Cache / W3 Total Cache / WP Cache you should use one of the direct insertion modes below.</span></b></p>';
|
336 |
} ?>
|
@@ -356,7 +259,7 @@ function adinj_tab_main(){
|
|
356 |
</div>
|
357 |
|
358 |
<p><input type="radio" name="ad_insertion_mode" value="direct_dynamic" <?php if ($ops['ad_insertion_mode']=='direct_dynamic') echo 'checked="checked"'; ?> /> <b>direct_dynamic: Direct ad insertion with dynamic features</b> - Dynamic features will work if no caching is used. Only select this if you are not using any caching plugin.</p>
|
359 |
-
<p><input type="radio" name="ad_insertion_mode" value="direct_static" <?php if ($ops['ad_insertion_mode']=='direct_static') echo 'checked="checked"'; ?> /> <b>direct_static: Direct static ad insertion</b> - No dynamic feature support. Select this if you are are not using dynamic features or are using an incompatible caching plugin.</p>
|
360 |
</blockquote>
|
361 |
</div>
|
362 |
<p></p>
|
@@ -382,11 +285,12 @@ function adinj_tab_main(){
|
|
382 |
});
|
383 |
</script>
|
384 |
|
385 |
-
<?php if ($ops['ad_insertion_mode']
|
386 |
-
<
|
387 |
-
|
388 |
-
|
389 |
<?php } ?>
|
|
|
390 |
<div class="inside" style="margin:10px">
|
391 |
<blockquote><b><span style="font-size:10px;color:red;">Note: Dynamic ad blocking features (restricting ad views by referrer or IP address) are only available in the mfunc, or direct_dynamic modes.</span></b>
|
392 |
</blockquote>
|
@@ -399,9 +303,7 @@ function adinj_tab_main(){
|
|
399 |
</script>
|
400 |
<?php } ?>
|
401 |
<div id="dynamic_features" class="dynamic_features">
|
402 |
-
|
403 |
<div class="inside" style="margin:10px">
|
404 |
-
|
405 |
<h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
|
406 |
|
407 |
<blockquote>
|
@@ -413,7 +315,7 @@ function adinj_tab_main(){
|
|
413 |
<h4>Blocked IP addresses (dynamic feature)</h4>
|
414 |
|
415 |
<blockquote>
|
416 |
-
|
417 |
<textarea name="blocked_ips" rows="4" cols="70"><?php echo $ops['blocked_ips']; ?></textarea>
|
418 |
<p>Comma separated list e.g.: <br /><code>0.0.0.1, 0.0.0.2</code></p>
|
419 |
<p>Or you can list one IP per line with optional comments e.g.</p>
|
@@ -427,44 +329,55 @@ function adinj_tab_main(){
|
|
427 |
|
428 |
<?php adinj_postbox_end(); ?>
|
429 |
|
|
|
430 |
|
431 |
-
<?php
|
432 |
-
|
433 |
-
<?php adinj_add_checkbox('debug_mode') ?>Enable debug mode
|
434 |
|
435 |
-
|
436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
<?php
|
|
|
|
|
|
|
438 |
|
439 |
-
|
440 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
}
|
442 |
-
|
443 |
-
adinj_debug_information();
|
444 |
?>
|
445 |
-
|
446 |
-
<
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
<input type="submit" name="adinj_action" value="<?php _e('Delete settings from DB', 'adinj') ?>" />
|
455 |
-
|
456 |
-
<p>This button will delete all your Ad Injection widgets.</p>
|
457 |
-
|
458 |
-
<input type="submit" name="adinj_action" value="<?php _e('Delete widget settings from DB', 'adinj') ?>" />
|
459 |
-
|
460 |
-
<?php adinj_postbox_end(); ?>
|
461 |
-
|
462 |
-
|
463 |
-
<br clear="all" />
|
464 |
-
|
465 |
<?php
|
466 |
-
|
467 |
-
adinj_docs();
|
468 |
}
|
469 |
|
470 |
function adinj_counting_unit_description(){
|
@@ -520,6 +433,7 @@ function adinj_unknown_cache_msg(){
|
|
520 |
}
|
521 |
|
522 |
function adinj_side_status_box(){
|
|
|
523 |
?>
|
524 |
<div class="postbox-container" style="width:258px;">
|
525 |
<div class="metabox-holder">
|
@@ -530,9 +444,11 @@ function adinj_side_status_box(){
|
|
530 |
|
531 |
<style type="text/css">
|
532 |
.adinjstatustable td { vertical-align: top; }
|
|
|
533 |
</style>
|
534 |
|
535 |
<table border="0" cellpadding="2" class="adinjstatustable">
|
|
|
536 |
|
537 |
<tr><td style="text-align:right">
|
538 |
<b><a href="#global">Ads enabled</a></b>
|
@@ -540,61 +456,8 @@ function adinj_side_status_box(){
|
|
540 |
<?php
|
541 |
$info = adinj_get_status('global'); echo adinj_dot($info[0]).' '.$info[1];
|
542 |
if ($info[0] != 'red') { ?>
|
543 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_front'); ?> front
|
544 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_home'); ?> home
|
545 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_page'); ?> page
|
546 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_single'); ?> single
|
547 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_archive'); ?> archive
|
548 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_search'); ?> search
|
549 |
-
<br /> <?php echo adinj_green_or_red_dot('exclude_404'); ?> 404
|
550 |
-
</td></tr>
|
551 |
-
|
552 |
-
<tr><td style="text-align:right">
|
553 |
-
<b><a href="#random">Random ads</a></b>
|
554 |
-
</td><td>
|
555 |
-
<?php
|
556 |
-
$info = adinj_get_status('random'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
557 |
-
$info = adinj_get_status('random_home'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
558 |
-
$info = adinj_get_status('random_pool'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
559 |
-
$info = adinj_get_status('random_alt_pool'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
560 |
-
?>
|
561 |
-
</td></tr>
|
562 |
-
|
563 |
-
<tr><td style="text-align:right">
|
564 |
-
<b><a href="#topad">Top ad</a></b>
|
565 |
-
</td><td>
|
566 |
-
<?php
|
567 |
-
$info = adinj_get_status('topad'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
568 |
-
$info = adinj_get_status('top_pool'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
569 |
-
$info = adinj_get_status('top_alt_pool'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
570 |
-
?>
|
571 |
-
</td></tr>
|
572 |
-
|
573 |
-
<tr><td style="text-align:right">
|
574 |
-
<b><a href="#bottomad">Bottom ad</a></b>
|
575 |
-
</td><td>
|
576 |
-
<?php
|
577 |
-
$info = adinj_get_status('bottomad'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
578 |
-
$info = adinj_get_status('bottom_pool'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
579 |
-
$info = adinj_get_status('bottom_alt_pool'); echo adinj_dot($info[0]).' '.$info[1].'<br />';
|
580 |
-
?>
|
581 |
-
</td></tr>
|
582 |
-
|
583 |
-
<tr><td style="text-align:right; vertical-align:top">
|
584 |
-
<b><a href="#widgets">Widgets</a></b>
|
585 |
-
</td><td>
|
586 |
-
<?php $info = adinj_get_status('widgets'); echo adinj_dot($info[0]).' '.$info[1];
|
587 |
-
if ($info[0] != 'red') { ?>
|
588 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_front'); ?> front
|
589 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_home'); ?> home
|
590 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_page'); ?> page
|
591 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_single'); ?> single
|
592 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_archive'); ?> archive
|
593 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_search'); ?> search
|
594 |
-
<br /> <?php echo adinj_green_or_red_dot('widget_exclude_404'); ?> 404
|
595 |
-
<?php } ?>
|
596 |
</td></tr>
|
597 |
-
|
598 |
<tr><td style="text-align:right">
|
599 |
<b><a href="#restrictions">Mode</a></b>
|
600 |
</td><td>
|
@@ -608,10 +471,68 @@ function adinj_side_status_box(){
|
|
608 |
</td></tr>
|
609 |
|
610 |
<tr><td style="text-align:right">
|
611 |
-
<b><a href=
|
612 |
</td><td>
|
613 |
<?php $info = adinj_get_status('debugging'); echo adinj_dot($info[0]).' '.$info[1]; ?>
|
614 |
</td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
<tr><td>
|
616 |
</td><td>
|
617 |
</td></tr>
|
@@ -630,92 +551,13 @@ function adinj_side_status_box(){
|
|
630 |
<?php
|
631 |
}
|
632 |
|
633 |
-
|
634 |
-
$stored_options = adinj_options();
|
635 |
-
$default_options = adinj_default_options();
|
636 |
-
?>
|
637 |
-
<h4>Settings dump from database (all in 'adinj_options' option)</h4>
|
638 |
-
<table border="1" style="width:610px; table-layout:fixed; word-wrap:break-word;">
|
639 |
-
<tr><td><b>Name</b></td><td><b>Stored</b></td><td><b>Default</b></td></tr>
|
640 |
-
<?php
|
641 |
-
if ($stored_options !== false){
|
642 |
-
$count = 0;
|
643 |
-
foreach ($stored_options as $key => $value){
|
644 |
-
if ($count % 2 == 0){
|
645 |
-
echo '<tr style="background-color:#cccccc"><td>';
|
646 |
-
} else {
|
647 |
-
echo '<tr><td>';
|
648 |
-
}
|
649 |
-
echo "$key";
|
650 |
-
echo "</td><td>";
|
651 |
-
$value = htmlspecialchars($value);
|
652 |
-
echo "$value";
|
653 |
-
echo "</td><td>";
|
654 |
-
echo $default_options[$key];
|
655 |
-
echo "</td></tr>";
|
656 |
-
$count++;
|
657 |
-
}
|
658 |
-
} else {
|
659 |
-
echo "<br />No options in database!";
|
660 |
-
}
|
661 |
-
echo '</table>';
|
662 |
-
|
663 |
-
?><h4>Widget settings dump from database (all in 'widget_adinj' option)</h4>
|
664 |
-
<table border="1" style="width:610px; word-wrap:break-word;">
|
665 |
-
<tr><td><b>Widget</b></td><td><b>Setting:Value</b></td></tr>
|
666 |
-
<?php
|
667 |
-
$widgetops = get_option('widget_adinj');
|
668 |
-
$count = 0;
|
669 |
-
if (is_array($widgetops)){
|
670 |
-
foreach($widgetops as $key=>$val){
|
671 |
-
if ($count % 2 == 0){
|
672 |
-
echo '<tr style="background-color:#cccccc"><td style="vertical-align:top">';
|
673 |
-
} else {
|
674 |
-
echo '<tr><td style="vertical-align:top">';
|
675 |
-
}
|
676 |
-
echo $key;
|
677 |
-
echo "</td>";
|
678 |
-
echo '<td style="vertical-align:top">';
|
679 |
-
if (is_array($val)){
|
680 |
-
foreach($val as $subkey=>$subval){
|
681 |
-
echo $subkey.':'.htmlspecialchars($subval).'<br />';
|
682 |
-
}
|
683 |
-
} else {
|
684 |
-
echo htmlspecialchars($val);
|
685 |
-
}
|
686 |
-
echo '</td></tr>';
|
687 |
-
++$count;
|
688 |
-
}
|
689 |
-
} else {
|
690 |
-
echo '<tr><td></td><td><b>No widget settings found</b></td></tr>';
|
691 |
-
}
|
692 |
-
echo '</table>';
|
693 |
-
|
694 |
-
echo '<h4>Other settings</h4><blockquote>';
|
695 |
-
|
696 |
-
echo 'ADINJ_PATH='.ADINJ_PATH.'<br />';
|
697 |
-
echo 'ADINJ_CONFIG_FILE='.ADINJ_CONFIG_FILE.'<br />';
|
698 |
-
echo 'ADINJ_AD_PATH='.ADINJ_AD_PATH.'<br />';
|
699 |
-
echo 'Plugin version='.adinj_get_version();
|
700 |
-
echo '</blockquote>';
|
701 |
-
|
702 |
-
global $adinj_warning_msg_filewrite;
|
703 |
-
if (!empty($adinj_warning_msg_filewrite)){
|
704 |
-
echo "<h4>Errors on 'Save all settings'</h4><blockquote>$adinj_warning_msg_filewrite</blockquote";
|
705 |
-
}
|
706 |
-
|
707 |
-
global $adinj_warning_msg_chmod;
|
708 |
-
if (!empty($adinj_warning_msg_chmod)){
|
709 |
-
echo "<h4>Warnings on 'Save all settings'</h4><blockquote>$adinj_warning_msg_chmod</blockquote";
|
710 |
-
}
|
711 |
-
|
712 |
-
}
|
713 |
|
714 |
function adinj_docs(){
|
715 |
?>
|
716 |
<hr />
|
717 |
|
718 |
-
<?php adinj_postbox_start(__("Quick Start", 'adinj'), "
|
719 |
|
720 |
<p>1. Copy and paste your ad code into the ad code boxes.</p>
|
721 |
|
@@ -728,120 +570,6 @@ function adinj_docs(){
|
|
728 |
<p>5. If you are using a compatible ad insertion mode you may configure dynamic ad display restrictions. i.e. showing ads only to certain people (e.g. search engine visitors), or blocking ads from specific IPs.</p>
|
729 |
|
730 |
<p>6. Enable your ads (tick box at the very top).</p>
|
731 |
-
</div>
|
732 |
-
|
733 |
-
<h3><?php echo adinj_get_logo(); ?> Supported in-page tags</h3>
|
734 |
-
<div class="inside" style="margin:10px">
|
735 |
-
|
736 |
-
<p>These tags can be inserted into the page source to override the configured behaviour on single posts and pages. Because sometimes specific pages need to be treated differently.</p>
|
737 |
-
|
738 |
-
<ul>
|
739 |
-
<li><code><!--noadsense--></code> OR <code><!-no-adsense--></code> OR <code><!--NoAds--></code> OR <code><!--OffAds--></code> - disables all ads on this page. These tags are here to make this plugin compatible with the tags from Adsense Injection, Whydowork Adsense and Quick Adsense.</li>
|
740 |
-
</ul>
|
741 |
-
|
742 |
-
<p></p>
|
743 |
-
|
744 |
-
<ul>
|
745 |
-
<li><code><!--adsandwich--></code> - Inserts the top and bottom ad but no random ads. Disables all other ads.</li>
|
746 |
-
<li><code><!--adfooter--></code> - Insert a single ad at the very bottom. Disables all other ads.</li>
|
747 |
-
</ul>
|
748 |
-
|
749 |
-
<p></p>
|
750 |
-
|
751 |
-
<ol>
|
752 |
-
<li><code><!--adsensestart--></code> - Random ads will start from this point*. For compatibility with Adsense Injection.</li>
|
753 |
-
<li><code><!--adsenseend--></code> - Random ads will not be inserted after this point*. New tag but I've kept the Adsense Injection naming convention to make it fit with the above tag.</li>
|
754 |
-
<li><code><!--adstart--></code> - Random ads will start from this point*.</li>
|
755 |
-
<li><code><!--adend--></code> - Random ads will not be inserted after this point*.</li>
|
756 |
-
</ol>
|
757 |
-
|
758 |
-
<p>These four tags will not affect the top and bottom ad.</p>
|
759 |
-
|
760 |
-
<h4>Custom field for disabling adverts</h4>
|
761 |
-
|
762 |
-
<p>To disable all adverts on the page you can also set the custom <code>disable_adverts</code> field to '1' from the WordPress post editor.</p>
|
763 |
-
|
764 |
-
|
765 |
-
<?php adinj_postbox_end(); ?>
|
766 |
-
|
767 |
-
|
768 |
-
<?php adinj_postbox_start(__("Test Adverts", 'adinj'), "testads", '95%'); ?>
|
769 |
-
|
770 |
-
<p>You can copy and paste these adverts into the boxes above to test your ad setup before switching to your real ads.</p>
|
771 |
-
|
772 |
-
<h4><a name="468x60"></a>468x60 banner</h4>
|
773 |
-
|
774 |
-
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ff9999; width:468px; height:60px;">
|
775 |
-
<h5>TEST ADVERT 468x60 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
776 |
-
</div></textarea></p>
|
777 |
-
|
778 |
-
<div style="background-color:#99ffff; width:468px; height:60px;">
|
779 |
-
<h5>TEST ADVERT 468x60 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
780 |
-
</div><p></p>
|
781 |
-
|
782 |
-
<h4><a name="728x90"></a>728x90 banner</h4>
|
783 |
-
|
784 |
-
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ff9999; width:728px; height:90px;">
|
785 |
-
<h5>TEST ADVERT 728x90</h5>
|
786 |
-
<a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a><br />
|
787 |
-
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
788 |
-
</div></textarea></p>
|
789 |
-
|
790 |
-
<div style="background-color:#ff9999; width:728px; height:90px;">
|
791 |
-
<h5>TEST ADVERT 728x90</h5>
|
792 |
-
<a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a><br />
|
793 |
-
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
794 |
-
</div><p></p>
|
795 |
-
|
796 |
-
<h4>160x90 link unit</h4>
|
797 |
-
|
798 |
-
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ccff99; width:160px; height:90px;">
|
799 |
-
<h5>TEST ADVERT 160x90</h5>
|
800 |
-
<a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a><br />
|
801 |
-
<a href="http://www.advancedhtml.co.uk/">advancedhtml.co.uk</a>
|
802 |
-
</div></textarea></p>
|
803 |
-
|
804 |
-
<div style="background-color:#ccff99; width:160px; height:90px;">
|
805 |
-
<h5>TEST ADVERT 160x90</h5>
|
806 |
-
<a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a>
|
807 |
-
<a href="http://www.advancedhtml.co.uk/">advancedhtml.co.uk</a><br />
|
808 |
-
</div><p></p>
|
809 |
-
|
810 |
-
<h4><a name="468x15"></a>468x15 link unit</h4>
|
811 |
-
|
812 |
-
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#cccc99; width:468px; height:15px;">
|
813 |
-
<font size="-2"><b>TEST ADVERT 160x90</b> <a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a></font>
|
814 |
-
</div></textarea></p>
|
815 |
-
|
816 |
-
<div style="background-color:#cccc99; width:468px; height:15px;">
|
817 |
-
<font size="-2"><b>TEST ADVERT 468x15</b> <a href="http://www.reviewmylife.co.uk/">reviewmylife.co.uk</a></font>
|
818 |
-
</div><p></p>
|
819 |
-
|
820 |
-
<h4><a name="336x280"></a>336x280 large rectangle</h4>
|
821 |
-
|
822 |
-
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="4"><div style="background-color:#ccccff; width:336px; height:280px;">
|
823 |
-
<h5>TEST ADVERT 336x280 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
824 |
-
</div></textarea></p>
|
825 |
-
|
826 |
-
<div style="background-color:#ccccff; width:336px; height:280px;">
|
827 |
-
<h5>TEST ADVERT 336x280 - <a href="http://www.reviewmylife.co.uk/">www.reviewmylife.co.uk</a></h5>
|
828 |
-
</div><p></p>
|
829 |
-
|
830 |
-
<h4>468x60 banner with dynamic PHP</h4>
|
831 |
-
|
832 |
-
<p>The PHP will execute if you use a mfunc compatible caching plugin which is correctly configured, or if you don't use any caching plugin at all.</p>
|
833 |
-
|
834 |
-
<p><textarea onclick="javascript:this.focus();this.select();" style="min-height:50px;" cols="80" rows="5"><div style="background-color:#ffff99; width:468px; height:60px;">
|
835 |
-
<b>TEST ADVERT 468x60 with date() and rand()</b><br />
|
836 |
-
<?php echo "date=".date("Y-m-d H:i:s") ." rand=".rand(); ?><br />
|
837 |
-
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
838 |
-
</div></textarea></p>
|
839 |
-
|
840 |
-
<div style="background-color:#ffff99; width:468px; height:60px;">
|
841 |
-
<b>TEST ADVERT 468x60 with date() and rand()</b><br />
|
842 |
-
<?php echo "date=".date("Y-m-d H:i:s") ." rand=".rand(); ?><br />
|
843 |
-
<a href="http://www.advancedhtml.co.uk/">www.advancedhtml.co.uk</a>
|
844 |
-
</div><p></p>
|
845 |
|
846 |
<?php adinj_postbox_end();
|
847 |
|
10 |
$ops = adinj_options();
|
11 |
?>
|
12 |
|
13 |
+
<p><a href="#adsettings">Ad Placement settings</a> | <a href="#adverts">Adverts</a> | <a href="#restrictions">Ad insert mode/dynamic restrictions</a> | <a href="#docsquickstart">Quick Start</a> | <a href="#testads">Test ads</a></p>
|
|
|
|
|
|
|
14 |
|
15 |
<?php adinj_postbox_start(__("Global settings", 'adinj'), 'global'); ?>
|
16 |
|
31 |
return true;
|
32 |
});
|
33 |
});
|
34 |
+
if ('<?php echo $ops['ads_enabled'] ?>' != 'test') {
|
35 |
+
document.write('<style type="text/css">#test_mode_warning { display: none; }</style>');
|
36 |
+
}
|
37 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
<div id="test_mode_warning"><span style="font-size:10px;color:red;">Warning: Turn any caching plugin *off* before using test mode. If you leave the caching plugin on, the test adverts will be cached and shown to your real visitors.</span><br /></div>
|
|
|
|
|
39 |
|
40 |
<style type="text/css">
|
41 |
.adinjtable td { vertical-align: top; }
|
57 |
?>
|
58 |
</select><?php _e(" (days)", 'adinj') ?> - only for single posts and pages</p>
|
59 |
</td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
</table>
|
|
|
|
|
61 |
<?php
|
62 |
+
adinj_condition_tables('global_', 'ui_conditions_show');
|
|
|
|
|
|
|
|
|
|
|
63 |
adinj_postbox_end();
|
64 |
?>
|
65 |
|
66 |
|
|
|
67 |
|
68 |
+
<?php adinj_postbox_start(__("Ad placement settings", 'adinj'), 'adsettings'); ?>
|
69 |
+
<p><b>Exclude ads from page types</b></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
<?php
|
71 |
+
$count_pages = wp_count_posts('page', 'readable');
|
72 |
+
$count_posts = wp_count_posts('post', 'readable');
|
|
|
73 |
?>
|
74 |
+
<table><tr><td><b>all ads</b></td><td></td><td><b>widget ads</b></td></tr>
|
75 |
+
<tr><td><?php adinj_add_checkbox('exclude_front') ?></td><td>front - <?php echo get_bloginfo('url'); ?></td><td><?php adinj_add_checkbox('widget_exclude_front') ?></td></tr>
|
76 |
+
<tr><td><?php adinj_add_checkbox('exclude_home') ?></td><td>home page (latest posts page - may or may not be same as front)</td><td><?php adinj_add_checkbox('widget_exclude_home') ?></td></tr>
|
77 |
+
<tr><td><?php adinj_add_checkbox('exclude_page') ?></td><td>page - <?php echo $count_pages->publish; ?> single page(s)</td><td><?php adinj_add_checkbox('widget_exclude_page') ?></td></tr>
|
78 |
+
<tr><td><?php adinj_add_checkbox('exclude_single') ?></td><td>single - <?php echo $count_posts->publish; ?> single post(s)</td><td><?php adinj_add_checkbox('widget_exclude_single') ?></td></tr>
|
79 |
+
<tr><td><?php adinj_add_checkbox('exclude_archive') ?></td><td>archive - categories, tags, authors, dates</td><td><?php adinj_add_checkbox('widget_exclude_archive') ?></td></tr>
|
80 |
+
<tr><td><?php adinj_add_checkbox('exclude_search') ?></td><td>search (widgets only for now)</td><td><?php adinj_add_checkbox('widget_exclude_search') ?></td></tr>
|
81 |
+
<tr><td><?php adinj_add_checkbox('exclude_404') ?></td><td>404 (widgets only for now)</td><td><?php adinj_add_checkbox('widget_exclude_404') ?></td></tr>
|
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>. Ticking the 'all ads' box will also exclude the widget ads.</span></p>
|
86 |
+
<p></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
<table border="0" class="adinjtable">
|
89 |
+
<tr><td></td><td><b>Single/Page</b></td><td><b>Home</b></td><td><b>Archive</b></td></tr>
|
90 |
+
<tr><td colspan="4"><h3>Top ad</h3></td></tr>
|
91 |
|
92 |
+
<tr><td>Only show top ad on posts longer than:</td><td>
|
|
|
|
|
93 |
<?php
|
94 |
+
$unit = adinj_counting_unit_description();
|
95 |
+
$ad_if_longer_settings = array('d','a',100,200,300,500,1000,1500,2000,2500,3000,5000,10000,20000);
|
96 |
+
adinj_selection_box("top_ad_if_longer_than", $ad_if_longer_settings, $unit);
|
97 |
+
echo '</td><td>';
|
98 |
+
adinj_selection_box("home_top_ad_if_longer_than", $ad_if_longer_settings, $unit);
|
99 |
+
echo '</td><td>';
|
100 |
+
adinj_selection_box("archive_top_ad_if_longer_than", $ad_if_longer_settings, $unit);
|
101 |
?>
|
|
|
102 |
</td></tr>
|
103 |
|
104 |
+
<tr><td>Max num of top ads on whole page:</td><td>1</td><td>
|
105 |
+
<?php
|
106 |
+
$num_ads_array = array(0,1,2,3,4,5,6,7,8,9,10);
|
107 |
+
adinj_selection_box("home_max_num_top_ads_per_page", $num_ads_array);
|
108 |
+
echo '</td><td>';
|
109 |
+
adinj_selection_box("archive_max_num_top_ads_per_page", $num_ads_array);
|
110 |
+
?>
|
111 |
</td></tr>
|
112 |
|
113 |
+
|
114 |
+
<tr><td colspan="4">
|
115 |
+
<?php adinj_condition_tables('top_', 'ui_top_conditions_show'); ?>
|
116 |
<p></p>
|
117 |
+
</td></tr>
|
118 |
+
|
119 |
+
<tr><td colspan="4"><h3>Random ads</h3></td></tr>
|
120 |
+
<tr><td>Max num of random ads on whole page:</td><td>
|
121 |
+
n/a
|
122 |
+
</td><td>
|
|
|
|
|
|
|
|
|
|
|
123 |
<?php
|
124 |
+
adinj_selection_box("home_max_num_random_ads_per_page", $num_ads_array);
|
125 |
+
echo '</td><td>';
|
126 |
+
adinj_selection_box("archive_max_num_random_ads_per_page", $num_ads_array);
|
127 |
?>
|
128 |
+
</td></tr>
|
129 |
+
<tr><td>Max num of random ads per post:</td><td>
|
130 |
<?php
|
131 |
+
adinj_selection_box("max_num_of_ads", $num_ads_array);
|
132 |
+
echo '</td><td>';
|
133 |
+
adinj_selection_box("home_max_num_random_ads_per_post", $num_ads_array);
|
134 |
+
echo '</td><td>';
|
135 |
+
adinj_selection_box("archive_max_num_random_ads_per_post", $num_ads_array);
|
136 |
?>
|
137 |
+
</td></tr>
|
|
|
138 |
<?php
|
139 |
+
adinj_random_ad_limit_table();
|
|
|
140 |
?>
|
141 |
+
<tr><td colspan="4">
|
|
|
142 |
<?php
|
143 |
+
_e("Always put the first ad immediately after paragraph: ", 'adinj');
|
144 |
+
adinj_selection_box("start_from_paragraph", array(ADINJ_RULE_DISABLED,1,2,3,4,5), " ");
|
145 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
</td></tr>
|
147 |
+
<tr><td colspan="4">
|
148 |
+
<?php adinj_condition_tables('random_', 'ui_random_conditions_show'); ?>
|
|
|
|
|
|
|
|
|
149 |
<p></p>
|
150 |
+
</td></tr>
|
151 |
|
152 |
+
<tr><td colspan="4"><h3>Bottom ad</h3></td></tr>
|
153 |
|
154 |
+
<tr><td>Only show bottom ad on posts longer than:</td><td>
|
155 |
+
<?php
|
156 |
+
adinj_selection_box("bottom_ad_if_longer_than", $ad_if_longer_settings, $unit);
|
157 |
+
echo '</td><td>';
|
158 |
+
adinj_selection_box("home_bottom_ad_if_longer_than", $ad_if_longer_settings, $unit);
|
159 |
+
echo '</td><td>';
|
160 |
+
adinj_selection_box("archive_bottom_ad_if_longer_than", $ad_if_longer_settings, $unit);
|
161 |
+
?>
|
162 |
+
</td></tr>
|
163 |
|
164 |
+
<tr><td>Max num of bottom ads on whole page:</td><td>1</td><td>
|
|
|
165 |
<?php
|
166 |
+
adinj_selection_box("home_max_num_bottom_ads_per_page", $num_ads_array);
|
167 |
+
echo '</td><td>';
|
168 |
+
adinj_selection_box("archive_max_num_bottom_ads_per_page", $num_ads_array);
|
|
|
|
|
169 |
?>
|
170 |
+
</td></tr>
|
171 |
|
172 |
+
<tr><td colspan="4">
|
173 |
+
<?php adinj_condition_tables('bottom_', 'ui_bottom_conditions_show'); ?>
|
174 |
+
<p></p>
|
175 |
+
</td></tr>
|
176 |
+
</table>
|
177 |
|
178 |
<?php adinj_postbox_end(); ?>
|
179 |
|
180 |
|
|
|
|
|
181 |
|
|
|
182 |
|
183 |
+
<?php adinj_postbox_start(__("Adverts", 'adinj'), 'adverts'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
+
<h3>Top ad (above the post content - this is not a 'header' ad)</h3>
|
186 |
+
<table border="0" class="adinjtable">
|
187 |
<tr><td>
|
188 |
<textarea name="ad_code_top_1" rows="10" cols="60"><?php echo $ops['ad_code_top_1']; ?></textarea>
|
189 |
+
<br />
|
190 |
+
<p><span style="font-size:10px;"><b>Docs:</b> Try a <a href="#468x15">468x15</a> or <a href="#336x280">336x280</a> advert.</span></p>
|
191 |
+
</td><td>
|
192 |
<?php
|
193 |
+
adinj_add_alignment_options('top_');
|
194 |
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_top'>Rotation:<br />".adinj_percentage_split('ad_code_top_', 1, $ops)."</a></b>";
|
195 |
?>
|
196 |
</td></tr>
|
197 |
</table>
|
198 |
+
<p><span style="font-size:10px;">Be especially careful if you decide to use the 'float' layout options. Make sure that you don't have adverts floated over the top of other page elements, or vice-versa.</span></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
<h3>Random ad (inserted randomly between paragraphs)</h3>
|
201 |
+
<table border="0" class="adinjtable">
|
202 |
+
<tr><td>
|
203 |
+
<textarea name="ad_code_random_1" rows="10" cols="60"><?php echo $ops['ad_code_random_1']; ?></textarea>
|
204 |
+
<br />
|
205 |
+
<p><span style="font-size:10px;"><b>Docs:</b> Try a <a href="#468x60">468x60</a> or <a href="#728x90">728x90</a> banner.</span></p>
|
206 |
+
</td><td>
|
207 |
<?php
|
208 |
+
adinj_add_alignment_options('rnd_');
|
209 |
+
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_random'>Rotation:<br />".adinj_percentage_split('ad_code_random_', 1, $ops)."</a></b>";
|
|
|
210 |
?>
|
211 |
+
</td></tr>
|
212 |
+
</table>
|
213 |
|
214 |
+
<h3>Bottom ad (below the post content - this is not a 'footer' ad)</h3>
|
215 |
+
<table border="0" class="adinjtable">
|
|
|
216 |
<tr><td>
|
217 |
<textarea name="ad_code_bottom_1" rows="10" cols="60"><?php echo $ops['ad_code_bottom_1']; ?></textarea>
|
218 |
+
<br />
|
219 |
+
<p><span style="font-size:10px;"><b>Docs:</b> Try a <a href="#336x280">336x280</a> advert.</span></p>
|
220 |
+
</td><td>
|
221 |
<?php
|
222 |
+
adinj_add_alignment_options('bottom_');
|
223 |
echo "<br /><b><a href='?page=ad-injection&tab=adrotation#multiple_bottom'>Rotation:<br />".adinj_percentage_split('ad_code_bottom_', 1, $ops)."</a></b>";
|
224 |
?>
|
225 |
</td></tr>
|
226 |
</table>
|
|
|
|
|
|
|
|
|
227 |
|
228 |
<?php adinj_postbox_end(); ?>
|
229 |
|
230 |
|
|
|
|
|
|
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
<?php adinj_postbox_start(__("Ad insertion mode and dynamic ad display restrictions", 'adinj'), 'restrictions'); ?>
|
|
|
234 |
<h4>Ad insertion mode</h4>
|
|
|
235 |
<blockquote>
|
236 |
<p><input type="radio" name="ad_insertion_mode" value="mfunc" <?php if ($ops['ad_insertion_mode']=='mfunc') echo 'checked="checked"'; ?> /> <b>mfunc: Use mfunc tags for dynamic features</b> - Dynamic features will work with WP Super Cache, W3 Total Cache and WP Cache. Only select this mode if you are using one of those caching plugins.</p>
|
|
|
237 |
<?php if (!is_supported_caching_plugin_active()) {
|
238 |
echo '<p><b><span style="font-size:10px;color:red;">Note: A supported caching plugin does not appear to be active. If you are not using WP Super Cache / W3 Total Cache / WP Cache you should use one of the direct insertion modes below.</span></b></p>';
|
239 |
} ?>
|
259 |
</div>
|
260 |
|
261 |
<p><input type="radio" name="ad_insertion_mode" value="direct_dynamic" <?php if ($ops['ad_insertion_mode']=='direct_dynamic') echo 'checked="checked"'; ?> /> <b>direct_dynamic: Direct ad insertion with dynamic features</b> - Dynamic features will work if no caching is used. Only select this if you are not using any caching plugin.</p>
|
262 |
+
<p><input type="radio" name="ad_insertion_mode" value="direct_static" <?php if ($ops['ad_insertion_mode']=='direct_static') echo 'checked="checked"'; ?> /> <b><strike>direct_static: Direct static ad insertion</strike></b> - <font color="red">Warning: This mode will be removed very soon (March 2011). There will only be an 'mfunc' and a 'direct' mode to simplify things. I recommend you switch to 'direct_dynamic' if you are using this mode. If you aren't using dynamic features make sure the tick boxes below are unticked.</font> No dynamic feature support. Select this if you are are not using dynamic features or are using an incompatible caching plugin.</p>
|
263 |
</blockquote>
|
264 |
</div>
|
265 |
<p></p>
|
285 |
});
|
286 |
</script>
|
287 |
|
288 |
+
<?php if ($ops['ad_insertion_mode'] != 'direct_static') { ?>
|
289 |
+
<script type="text/javascript">
|
290 |
+
document.write('<style type="text/css" media="screen">#dynamic_features_msg { display: none; }</style>');
|
291 |
+
</script>
|
292 |
<?php } ?>
|
293 |
+
<div id="dynamic_features_msg" class="dynamic_features_msg">
|
294 |
<div class="inside" style="margin:10px">
|
295 |
<blockquote><b><span style="font-size:10px;color:red;">Note: Dynamic ad blocking features (restricting ad views by referrer or IP address) are only available in the mfunc, or direct_dynamic modes.</span></b>
|
296 |
</blockquote>
|
303 |
</script>
|
304 |
<?php } ?>
|
305 |
<div id="dynamic_features" class="dynamic_features">
|
|
|
306 |
<div class="inside" style="margin:10px">
|
|
|
307 |
<h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
|
308 |
|
309 |
<blockquote>
|
315 |
<h4>Blocked IP addresses (dynamic feature)</h4>
|
316 |
|
317 |
<blockquote>
|
318 |
+
<?php adinj_add_checkbox('block_ips') ?><?php _e("Exclude ads from these IP addresses.", 'adinj') ?><br />
|
319 |
<textarea name="blocked_ips" rows="4" cols="70"><?php echo $ops['blocked_ips']; ?></textarea>
|
320 |
<p>Comma separated list e.g.: <br /><code>0.0.0.1, 0.0.0.2</code></p>
|
321 |
<p>Or you can list one IP per line with optional comments e.g.</p>
|
329 |
|
330 |
<?php adinj_postbox_end(); ?>
|
331 |
|
332 |
+
<br clear="all" />
|
333 |
|
334 |
+
<?php
|
|
|
|
|
335 |
|
336 |
+
adinj_docs();
|
337 |
|
338 |
+
adinj_testads();
|
339 |
+
}
|
340 |
+
|
341 |
+
function adinj_random_ad_limit_table(){
|
342 |
+
?>
|
343 |
+
<tr><td>No ads if shorter than:</td>
|
344 |
<?php
|
345 |
+
$prefixes = array("", "home_", "archive_");
|
346 |
+
$unit = adinj_counting_unit_description();
|
347 |
+
$ad_limit_settings = array(ADINJ_RULE_DISABLED,100,200,300,500,1000,1500,2000,2500,3000);
|
348 |
|
349 |
+
foreach ($prefixes as $prefix){
|
350 |
+
echo '<td>';
|
351 |
+
adinj_selection_box($prefix."no_random_ads_if_shorter_than", $ad_limit_settings, $unit);
|
352 |
+
echo '</td>';
|
353 |
+
} ?>
|
354 |
+
</tr>
|
355 |
+
<tr><td>One ad if shorter than:</td>
|
356 |
+
<?php
|
357 |
+
foreach ($prefixes as $prefix){
|
358 |
+
echo '<td>';
|
359 |
+
adinj_selection_box($prefix."one_ad_if_shorter_than", $ad_limit_settings, $unit);
|
360 |
+
echo '</td>';
|
361 |
+
} ?>
|
362 |
+
</tr>
|
363 |
+
<tr><td>Two ads if shorter than:</td>
|
364 |
+
<?php
|
365 |
+
foreach ($prefixes as $prefix){
|
366 |
+
echo '<td>';
|
367 |
+
adinj_selection_box($prefix."two_ads_if_shorter_than", $ad_limit_settings, $unit);
|
368 |
+
echo '</td>';
|
369 |
}
|
|
|
|
|
370 |
?>
|
371 |
+
</tr>
|
372 |
+
<tr><td>Three ads if shorter than:</td>
|
373 |
+
<?php
|
374 |
+
foreach ($prefixes as $prefix){
|
375 |
+
echo '<td>';
|
376 |
+
adinj_selection_box($prefix."three_ads_if_shorter_than", $ad_limit_settings, $unit);
|
377 |
+
echo '</td>';
|
378 |
+
} ?>
|
379 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
<?php
|
|
|
|
|
381 |
}
|
382 |
|
383 |
function adinj_counting_unit_description(){
|
433 |
}
|
434 |
|
435 |
function adinj_side_status_box(){
|
436 |
+
$ops = adinj_options();
|
437 |
?>
|
438 |
<div class="postbox-container" style="width:258px;">
|
439 |
<div class="metabox-holder">
|
444 |
|
445 |
<style type="text/css">
|
446 |
.adinjstatustable td { vertical-align: top; }
|
447 |
+
.adinjstatustable td { padding: 2px; }
|
448 |
</style>
|
449 |
|
450 |
<table border="0" cellpadding="2" class="adinjstatustable">
|
451 |
+
|
452 |
|
453 |
<tr><td style="text-align:right">
|
454 |
<b><a href="#global">Ads enabled</a></b>
|
456 |
<?php
|
457 |
$info = adinj_get_status('global'); echo adinj_dot($info[0]).' '.$info[1];
|
458 |
if ($info[0] != 'red') { ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
</td></tr>
|
460 |
+
|
461 |
<tr><td style="text-align:right">
|
462 |
<b><a href="#restrictions">Mode</a></b>
|
463 |
</td><td>
|
471 |
</td></tr>
|
472 |
|
473 |
<tr><td style="text-align:right">
|
474 |
+
<b><a href='?page=ad-injection&tab=debug#debugging'>Debug mode</a></b>
|
475 |
</td><td>
|
476 |
<?php $info = adinj_get_status('debugging'); echo adinj_dot($info[0]).' '.$info[1]; ?>
|
477 |
</td></tr>
|
478 |
+
|
479 |
+
<tr><td colspan="2">
|
480 |
+
<p></p>
|
481 |
+
<b>Ad summary</a></b><br />
|
482 |
+
<table class="adinjstatustable">
|
483 |
+
<tr>
|
484 |
+
<td></td>
|
485 |
+
<td><b>Ads</b></td>
|
486 |
+
<td><b>Alt</b></td>
|
487 |
+
<td><b>S</b></td>
|
488 |
+
<td><b>P</b></td>
|
489 |
+
<td><b>H</b></td>
|
490 |
+
<td><b>A</b></td>
|
491 |
+
</tr>
|
492 |
+
<tr>
|
493 |
+
<td style="text-align:right"><b>Top</b></td>
|
494 |
+
<td><?php echo adinj_count_live_ads('top', $ops); ?></td>
|
495 |
+
<td><?php echo adinj_count_live_ads('top_alt', $ops); ?></td>
|
496 |
+
<td><?php adinj_print_ad_dot('top', 'single') ?></td>
|
497 |
+
<td><?php adinj_print_ad_dot('top', 'page') ?></td>
|
498 |
+
<td><?php adinj_print_ad_dot('top', 'home') ?></td>
|
499 |
+
<td><?php adinj_print_ad_dot('top', 'archive') ?></td>
|
500 |
+
</tr>
|
501 |
+
<tr>
|
502 |
+
<td style="text-align:right"><b>Random</b></td>
|
503 |
+
<td><?php echo adinj_count_live_ads('random', $ops); ?></td>
|
504 |
+
<td><?php echo adinj_count_live_ads('random_alt', $ops); ?></td>
|
505 |
+
<td><?php adinj_print_ad_dot('random', 'single') ?></td>
|
506 |
+
<td><?php adinj_print_ad_dot('random', 'page') ?></td>
|
507 |
+
<td><?php adinj_print_ad_dot('random', 'home') ?></td>
|
508 |
+
<td><?php adinj_print_ad_dot('random', 'archive') ?></td>
|
509 |
+
</tr>
|
510 |
+
<tr>
|
511 |
+
<td style="text-align:right"><b>Bottom</b></td>
|
512 |
+
<td><?php echo adinj_count_live_ads('bottom', $ops); ?></td>
|
513 |
+
<td><?php echo adinj_count_live_ads('bottom_alt', $ops); ?></td>
|
514 |
+
<td><?php adinj_print_ad_dot('bottom', 'single') ?></td>
|
515 |
+
<td><?php adinj_print_ad_dot('bottom', 'page') ?></td>
|
516 |
+
<td><?php adinj_print_ad_dot('bottom', 'home') ?></td>
|
517 |
+
<td><?php adinj_print_ad_dot('bottom', 'archive') ?></td>
|
518 |
+
</tr>
|
519 |
+
<tr>
|
520 |
+
<td style="text-align:right"><b>Widget</b></td>
|
521 |
+
<td></td>
|
522 |
+
<td></td>
|
523 |
+
<td><?php adinj_print_ad_dot('widget', 'single') ?></td>
|
524 |
+
<td><?php adinj_print_ad_dot('widget', 'page') ?></td>
|
525 |
+
<td><?php adinj_print_ad_dot('widget', 'home') ?></td>
|
526 |
+
<td><?php adinj_print_ad_dot('widget', 'archive') ?></td>
|
527 |
+
</tr>
|
528 |
+
</table>
|
529 |
+
<p>S=single post<br />
|
530 |
+
P=single page<br />
|
531 |
+
H=home<br />
|
532 |
+
A=archive<br />
|
533 |
+
<!--E=excerpt--></p>
|
534 |
+
</td></tr>
|
535 |
+
|
536 |
<tr><td>
|
537 |
</td><td>
|
538 |
</td></tr>
|
551 |
<?php
|
552 |
}
|
553 |
|
554 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
|
556 |
function adinj_docs(){
|
557 |
?>
|
558 |
<hr />
|
559 |
|
560 |
+
<?php adinj_postbox_start(__("Quick Start", 'adinj'), "docsquickstart", '95%'); ?>
|
561 |
|
562 |
<p>1. Copy and paste your ad code into the ad code boxes.</p>
|
563 |
|
570 |
<p>5. If you are using a compatible ad insertion mode you may configure dynamic ad display restrictions. i.e. showing ads only to certain people (e.g. search engine visitors), or blocking ads from specific IPs.</p>
|
571 |
|
572 |
<p>6. Enable your ads (tick box at the very top).</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
|
574 |
<?php adinj_postbox_end();
|
575 |
|