Ad Inserter – WordPress Ads Management with AdSense Header Integration - Version 1.6.5

Version Description

  • Fixed bug: Wrong counting of max insertions
  • Change: display position Before Title was renamed to Before Post
  • Added support for display position After Post
  • Added support for posts with no <p> tags (paragraphs separated with \r\n\r\n characters)
  • Added support for paragraph processing on homepage, category, archive and search pages
  • Added support for custom viewports
  • Added support for PHP function call counter
  • Added support to disable code block on error 404 pages
  • Added support to debug paragraph tags
Download this release

Release Info

Developer spacetime
Plugin Icon 128x128 Ad Inserter – WordPress Ads Management with AdSense Header Integration
Version 1.6.5
Comparing to
See all releases

Code changes from version 1.6.4 to 1.6.5

Files changed (10) hide show
  1. ad-inserter.php +332 -109
  2. class.php +259 -108
  3. constants.php +31 -12
  4. css/viewports.css +25 -0
  5. js/ad-inserter.js +86 -33
  6. readme.txt +217 -103
  7. screenshot-1.jpg +0 -0
  8. screenshot-10.jpg +0 -0
  9. screenshot-2.jpg +0 -0
  10. settings.php +231 -127
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 1.6.4
5
  Description: A simple solution to insert any code into Wordpress. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
6
  Author: Spacetime
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,17 @@ Plugin URI: http://igorfuna.com/software/web/ad-inserter-wordpress-plugin
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
 
 
 
 
 
14
  Ad Inserter 1.6.4 - 15 May 2016
15
  - Fixed bug: For shortcodes in posts the url was not checked
16
  - Optimizations for device detection
@@ -191,7 +202,7 @@ if (!defined ('AD_INSERTER_PLUGIN_DIR'))
191
  define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
192
 
193
  /* Version check */
194
- global $wp_version;
195
  $exit_msg = 'Ad Inserter requires WordPress 3.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>';
196
 
197
  if (version_compare ($wp_version, "3.0", "<")) {
@@ -208,7 +219,13 @@ $ad_interter_globals = array ();
208
  // Load options
209
  ai_load_options ();
210
 
211
- $device_detection = false;
 
 
 
 
 
 
212
  $client_side_detection = false;
213
 
214
  $block_object = array ();
@@ -217,13 +234,11 @@ for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
217
  $obj->load_options ($counter);
218
  $block_object [$counter] = $obj;
219
 
220
- if ($obj->get_display_for_devices() != AD_DISPLAY_ALL_DEVICES) {
221
- $device_detection = true;
222
- if ($obj->get_detection_client_side ()) $client_side_detection = true;
223
- }
224
  }
225
 
226
- if ($device_detection) {
227
  require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
228
 
229
  $detect = new ai_Mobile_Detect;
@@ -246,6 +261,7 @@ add_action ('admin_menu', 'ai_admin_menu_hook');
246
  add_filter ('the_content', 'ai_content_hook', $plugin_priority);
247
  add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
248
  add_action ('loop_start', 'ai_loop_start_hook');
 
249
  add_action ('init', 'ai_init_hook');
250
  //add_action ('admin_notices', 'ai_admin_notice_hook');
251
  add_action ('wp_head', 'ai_wp_head_hook');
@@ -279,7 +295,7 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
279
  global $ai_settings_page;
280
 
281
  if ($hook_suffix == $ai_settings_page) {
282
- wp_enqueue_script ('ad-inserter-js', plugins_url ('js/ad-inserter.js', __FILE__), array ('jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip'), AD_INSERTER_VERSION);
283
  wp_enqueue_style ('ad-inserter-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
284
  wp_enqueue_style ('ad-inserter', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
285
 
@@ -289,7 +305,8 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
289
  }
290
 
291
  function ai_enqueue_scripts_hook () {
292
- wp_enqueue_style ('ad-inserter-devices', plugins_url ( 'css/devices.css', __FILE__), false, AD_INSERTER_VERSION);
 
293
  }
294
 
295
  function ai_admin_notice_hook () {
@@ -519,8 +536,7 @@ function ai_wp_footer_hook () {
519
  }
520
  }
521
 
522
- function ai_plugin_options ($syntax_highlighter_theme = DEFAULT_SYNTAX_HIGHLIGHTER_THEME, $block_class_name = DEFAULT_BLOCK_CLASS_NAME, $minimum_user_role = DEFAULT_MINIMUM_USER_ROLE, $plugin_priority = DEFAULT_PLUGIN_PRIORITY){
523
- $plugin_options = array ();
524
 
525
  $version_array = explode (".", AD_INSERTER_VERSION);
526
  $version_string = "";
@@ -530,10 +546,15 @@ function ai_plugin_options ($syntax_highlighter_theme = DEFAULT_SYNTAX_HIGHLIGHT
530
 
531
  $plugin_options ['VERSION'] = $version_string;
532
 
533
- $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = $syntax_highlighter_theme;
534
- $plugin_options ['BLOCK_CLASS_NAME'] = $block_class_name;
535
- $plugin_options ['MINIMUM_USER_ROLE'] = $minimum_user_role;
536
 
 
 
 
 
 
 
 
537
  if (!is_numeric ($plugin_priority)) {
538
  $plugin_priority = DEFAULT_PLUGIN_PRIORITY;
539
  }
@@ -544,7 +565,53 @@ function ai_plugin_options ($syntax_highlighter_theme = DEFAULT_SYNTAX_HIGHLIGHT
544
  if ($plugin_priority > 999999) {
545
  $plugin_priority = 999999;
546
  }
547
- $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
 
549
  return ($plugin_options);
550
  }
@@ -563,6 +630,7 @@ function ai_get_option ($option_name) {
563
 
564
  function ai_load_options () {
565
  global $ai_db_options;
 
566
  $ai_db_options = get_option (WP_OPTION_NAME);
567
 
568
  if (is_array ($ai_db_options)) {
@@ -628,6 +696,49 @@ function get_plugin_priority () {
628
  return ($plugin_db_options ['PLUGIN_PRIORITY']);
629
  }
630
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  function filter_html_class ($str){
632
 
633
  $str = str_replace (array ("\\\""), array ("\""), $str);
@@ -640,7 +751,7 @@ function filter_string ($str){
640
 
641
  $str = str_replace (array ("\\\""), array ("\""), $str);
642
  $str = str_replace (array ("\"", "<", ">"), "", $str);
643
- $str = esc_html ($str);
644
 
645
  return $str;
646
  }
@@ -684,6 +795,7 @@ function filter_option_hf ($option, $value){
684
  if ($option == AI_OPTION_CODE ) {
685
  } elseif ($option == AI_OPTION_ENABLE_MANUAL) {
686
  } elseif ($option == AI_OPTION_PROCESS_PHP) {
 
687
  }
688
 
689
  return $value;
@@ -692,7 +804,7 @@ function filter_option_hf ($option, $value){
692
  function ai_settings () {
693
  global $ai_db_options, $block_object;
694
 
695
- if (isset ($_POST [AD_FORM_SAVE])) {
696
 
697
  check_admin_referer ('save_adinserter_settings');
698
 
@@ -768,7 +880,23 @@ function ai_settings () {
768
 
769
  $ai_options [AI_HEADER_OPTION_NAME] = $adH->wp_options;
770
  $ai_options [AI_FOOTER_OPTION_NAME] = $adF->wp_options;
771
- $ai_options [AI_GLOBAL_OPTION_NAME] = ai_plugin_options (filter_string ($_POST ['syntax-highlighter-theme']), filter_html_class ($_POST ['block-class-name']), filter_string ($_POST ['minimum-user-role']), filter_option ('plugin_priority', $_POST ['plugin_priority']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
  }
773
 
774
  if (!empty ($invalid_blocks)) {
@@ -782,6 +910,48 @@ function ai_settings () {
782
  // Reload options
783
  ai_load_options ();
784
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
785
  for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
786
  $obj = new ai_Block ($counter);
787
  $obj->load_options ($counter);
@@ -794,7 +964,7 @@ function ai_settings () {
794
 
795
  echo "<div class='updated' style='margin: 5px 15px 2px 0px; padding: 10px;'><strong>Settings saved.</strong></div>";
796
 
797
- } elseif (isset ($_POST [AD_FORM_CLEAR])) {
798
 
799
  check_admin_referer ('save_adinserter_settings');
800
 
@@ -836,7 +1006,7 @@ function ai_settings () {
836
 
837
 
838
  function adinserter ($ad_number = ""){
839
- global $block_object;
840
 
841
  if ($ad_number == "") return "";
842
 
@@ -849,6 +1019,12 @@ function adinserter ($ad_number = ""){
849
  // Load options from db
850
  $obj = $block_object [$ad_number];
851
 
 
 
 
 
 
 
852
  $display_for_users = $obj->get_display_for_users ();
853
 
854
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
@@ -856,7 +1032,7 @@ function adinserter ($ad_number = ""){
856
 
857
  $display_for_devices = $obj->get_display_for_devices ();
858
 
859
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
860
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
861
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
862
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
@@ -901,6 +1077,8 @@ function adinserter ($ad_number = ""){
901
  if (!$obj->get_display_settings_search()) return "";
902
  } elseif (is_archive()){
903
  if (!$obj->get_display_settings_archive()) return "";
 
 
904
  }
905
 
906
  if ($obj->get_ad_data() == AD_EMPTY_DATA) return "";
@@ -915,41 +1093,50 @@ function adinserter ($ad_number = ""){
915
 
916
  if (!$obj->check_referer ()) return "";
917
 
918
- if (!$obj->check_block_counter ()) return "";
 
 
 
 
 
919
 
920
- $block_class_name = get_block_class_name ();
921
 
922
- $device_class = "";
923
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
924
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
925
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
926
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
927
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
928
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
929
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
930
- }
931
 
932
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
933
- $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $ad_number. $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
934
 
935
  return $ad_code;
936
  }
937
 
938
 
939
  function ai_content_hook ($content = ''){
940
- global $block_object;
 
 
 
 
941
 
 
 
 
942
  for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
943
  $obj = $block_object [$counter];
944
 
945
  $display_type = $obj->get_display_type();
946
- $manual_insert = $obj->get_enable_manual ();
 
 
 
 
 
 
947
 
948
  if ($display_type != AD_SELECT_BEFORE_PARAGRAPH &&
949
  $display_type != AD_SELECT_AFTER_PARAGRAPH &&
950
  $display_type != AD_SELECT_BEFORE_CONTENT &&
951
- $display_type != AD_SELECT_AFTER_CONTENT &&
952
- !$manual_insert) continue;
953
 
954
  $display_for_users = $obj->get_display_for_users ();
955
 
@@ -958,7 +1145,7 @@ function ai_content_hook ($content = ''){
958
 
959
  $display_for_devices = $obj->get_display_for_devices ();
960
 
961
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
962
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
963
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
964
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
@@ -967,11 +1154,13 @@ function ai_content_hook ($content = ''){
967
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) continue;
968
  }
969
 
970
- //if empty data, continue next
971
  if ($obj->get_ad_data() == AD_EMPTY_DATA) {
972
  continue;
973
  }
974
 
 
 
975
  if (is_single ()) {
976
  if (!$obj->get_display_settings_post ()) continue;
977
 
@@ -998,7 +1187,35 @@ function ai_content_hook ($content = ''){
998
  elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
999
  if (!in_array ($obj->number, $selected_blocks)) continue;
1000
  }
1001
- } else continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1002
 
1003
  // Deprecated
1004
  if ($obj->display_disabled ($content)) continue;
@@ -1015,17 +1232,38 @@ function ai_content_hook ($content = ''){
1015
 
1016
  if (!$obj->check_block_counter ()) continue;
1017
 
 
 
1018
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH) {
1019
- $content = $obj->before_paragraph ($content);
1020
- } elseif ($display_type == AD_SELECT_AFTER_PARAGRAPH) {
1021
- $content = $obj->after_paragraph ($content);
1022
- } elseif ($display_type == AD_SELECT_BEFORE_CONTENT) {
 
 
 
 
1023
  $content = $obj->before_content ($content);
1024
- } elseif ($display_type == AD_SELECT_AFTER_CONTENT) {
 
 
1025
  $content = $obj->after_content ($content);
 
1026
  }
1027
  }
1028
 
 
 
 
 
 
 
 
 
 
 
 
 
1029
  return $content;
1030
  }
1031
 
@@ -1052,7 +1290,7 @@ function ai_excerpt_hook ($content = ''){
1052
 
1053
  $display_for_devices = $obj->get_display_for_devices ();
1054
 
1055
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
1056
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1057
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1058
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
@@ -1061,13 +1299,13 @@ function ai_excerpt_hook ($content = ''){
1061
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) continue;
1062
  }
1063
 
1064
- $excerpt_number = $obj->get_excerpt_number();
1065
- $excerpt_settings = array ();
1066
- if (strpos ($excerpt_number, ",") !== false) {
1067
- $excerpt_settings = explode (",", $excerpt_number);
1068
- } else $excerpt_settings []= $excerpt_number;
1069
 
1070
- if ($obj->get_excerpt_number() != 0 && !in_array ($excerpt_counter, $excerpt_settings)) continue;
1071
 
1072
  if (is_front_page ()){
1073
  if (!$obj->get_display_settings_home()) continue;
@@ -1081,6 +1319,9 @@ function ai_excerpt_hook ($content = ''){
1081
  elseif (is_archive()){
1082
  if (!$obj->get_display_settings_archive()) continue;
1083
  }
 
 
 
1084
 
1085
  //if empty data, continue with next
1086
  if ($obj->get_ad_data() == AD_EMPTY_DATA){
@@ -1098,22 +1339,12 @@ function ai_excerpt_hook ($content = ''){
1098
 
1099
  if (!$obj->check_referer ()) continue;
1100
 
1101
- if (!$obj->check_block_counter ()) continue;
1102
 
1103
  $block_class_name = get_block_class_name ();
1104
 
1105
- $device_class = "";
1106
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
1107
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
1108
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
1109
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
1110
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
1111
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
1112
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
1113
- }
1114
-
1115
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1116
- $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block_index . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1117
 
1118
  if ($display_type == AD_SELECT_BEFORE_EXCERPT)
1119
  $content = $ad_code . $content; else
@@ -1123,8 +1354,9 @@ function ai_excerpt_hook ($content = ''){
1123
  return $content;
1124
  }
1125
 
1126
- // Process Before Title postion
1127
- function ai_loop_start_hook ($query){
 
1128
  global $block_object;
1129
 
1130
  if (!method_exists ($query, 'is_main_query')) return;
@@ -1140,7 +1372,7 @@ function ai_loop_start_hook ($query){
1140
  for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
1141
  $obj = $block_object [$block_index];
1142
 
1143
- if ($obj->get_display_type () != AD_SELECT_BEFORE_TITLE) continue;
1144
 
1145
  $display_for_users = $obj->get_display_for_users ();
1146
 
@@ -1149,7 +1381,7 @@ function ai_loop_start_hook ($query){
1149
 
1150
  $display_for_devices = $obj->get_display_for_devices ();
1151
 
1152
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
1153
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1154
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1155
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
@@ -1192,6 +1424,9 @@ function ai_loop_start_hook ($query){
1192
  elseif (is_archive()){
1193
  if (!$obj->get_display_settings_archive()) continue;
1194
  }
 
 
 
1195
 
1196
  //if empty data, continue with next
1197
  if ($obj->get_ad_data() == AD_EMPTY_DATA) continue;
@@ -1206,27 +1441,28 @@ function ai_loop_start_hook ($query){
1206
 
1207
  if (!$obj->check_referer ()) continue;
1208
 
1209
- if (!$obj->check_block_counter ()) continue;
1210
 
1211
  $block_class_name = get_block_class_name ();
1212
 
1213
- $device_class = "";
1214
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
1215
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
1216
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
1217
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
1218
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
1219
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
1220
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
1221
- }
1222
-
1223
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code .= ai_getAdCode ($obj); else
1224
- $ad_code .= "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block_index . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1225
  }
1226
 
1227
  echo $ad_code;
1228
  }
1229
 
 
 
 
 
 
 
 
 
 
 
 
1230
 
1231
  function ai_getCode ($obj){
1232
  $code = $obj->get_ad_data();
@@ -1293,7 +1529,7 @@ function process_shortcodes ($atts) {
1293
 
1294
  $display_for_devices = $obj->get_display_for_devices ();
1295
 
1296
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
1297
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1298
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1299
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
@@ -1302,11 +1538,12 @@ function process_shortcodes ($atts) {
1302
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) return "";
1303
  }
1304
 
1305
- if (!$obj->check_block_counter ()) return "";
1306
-
1307
  if (is_page() || is_single()) {
1308
  if (!$obj->check_date ()) return "";
1309
  }
 
 
 
1310
 
1311
  if (!$obj->check_url ()) return "";
1312
 
@@ -1316,20 +1553,12 @@ function process_shortcodes ($atts) {
1316
 
1317
  if (!$obj->check_tag ()) return "";
1318
 
1319
- $block_class_name = get_block_class_name ();
1320
 
1321
- $device_class = "";
1322
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
1323
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
1324
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
1325
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
1326
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
1327
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
1328
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
1329
- }
1330
 
1331
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1332
- $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $device_class . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1333
  return ($ad_code);
1334
  }
1335
  }
@@ -1418,7 +1647,7 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1418
 
1419
  $display_for_devices = $obj->get_display_for_devices ();
1420
 
1421
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_server_side ()) {
1422
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return;
1423
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return;;
1424
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return;
@@ -1474,6 +1703,9 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1474
  elseif(is_archive()){
1475
  if (!$obj->get_display_settings_archive()) return;
1476
  }
 
 
 
1477
 
1478
  if (!$obj->check_category ()) return;
1479
 
@@ -1483,21 +1715,12 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1483
 
1484
  if (!$obj->check_referer ()) return;
1485
 
1486
- if (!$obj->check_block_counter ()) return;
1487
 
1488
  $block_class_name = get_block_class_name ();
1489
 
1490
- $device_class = "";
1491
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $obj->get_detection_client_side ()) {
1492
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = "ai-desktop";
1493
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = "ai-tablet-phone";
1494
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = "ai-tablet";
1495
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = "ai-phone";
1496
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = "ai-desktop-tablet";
1497
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = "ai-desktop-phone";
1498
- }
1499
-
1500
- if ($device_class != "") echo "<div class='" . $device_class . "'>";
1501
  echo $args ['before_widget'];
1502
 
1503
  if (!empty ($title)) {
@@ -1508,5 +1731,5 @@ function ai_widget_draw ($block, $obj, $args, $title = '') {
1508
  echo "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . "' style='" . $obj->get_alignmet_style (false) . "'>" . ai_getAdCode ($obj) . "</div>";
1509
 
1510
  echo $args ['after_widget'];
1511
- if ($device_class != "") echo "</div>";
1512
  }
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 1.6.5
5
  Description: A simple solution to insert any code into Wordpress. Simply enter any HTML, Javascript or PHP code and select where and how you want to display it.
6
  Author: Spacetime
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 1.6.5 - 1 August 2016
15
+ - Fixed bug: Wrong counting of max insertions
16
+ - Change: display position Before Title was renamed to Before Post
17
+ - Added support for display position After Post
18
+ - Added support for posts with no <p> tags (paragraphs separated with \r\n\r\n characters)
19
+ - Added support for paragraph processing on homepage, category, archive and search pages
20
+ - Added support for custom viewports
21
+ - Added support for PHP function call counter
22
+ - Added support to disable code block on error 404 pages
23
+ - Added support to debug paragraph tags
24
+
25
  Ad Inserter 1.6.4 - 15 May 2016
26
  - Fixed bug: For shortcodes in posts the url was not checked
27
  - Optimizations for device detection
202
  define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
203
 
204
  /* Version check */
205
+ global $wp_version, $version_string;
206
  $exit_msg = 'Ad Inserter requires WordPress 3.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>';
207
 
208
  if (version_compare ($wp_version, "3.0", "<")) {
219
  // Load options
220
  ai_load_options ();
221
 
222
+ $version_array = explode (".", AD_INSERTER_VERSION);
223
+ $version_string = "";
224
+ foreach ($version_array as $number) {
225
+ $version_string .= sprintf ("%02d", $number);
226
+ }
227
+
228
+ $server_side_detection = false;
229
  $client_side_detection = false;
230
 
231
  $block_object = array ();
234
  $obj->load_options ($counter);
235
  $block_object [$counter] = $obj;
236
 
237
+ if ($obj->get_detection_server_side()) $server_side_detection = true;
238
+ if ($obj->get_detection_client_side ()) $client_side_detection = true;
 
 
239
  }
240
 
241
+ if ($server_side_detection) {
242
  require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
243
 
244
  $detect = new ai_Mobile_Detect;
261
  add_filter ('the_content', 'ai_content_hook', $plugin_priority);
262
  add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
263
  add_action ('loop_start', 'ai_loop_start_hook');
264
+ add_action ('loop_end', 'ai_loop_end_hook');
265
  add_action ('init', 'ai_init_hook');
266
  //add_action ('admin_notices', 'ai_admin_notice_hook');
267
  add_action ('wp_head', 'ai_wp_head_hook');
295
  global $ai_settings_page;
296
 
297
  if ($hook_suffix == $ai_settings_page) {
298
+ wp_enqueue_script ('ad-inserter-js', plugins_url ('js/ad-inserter.js', __FILE__), array ('jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip'), filemtime (plugin_dir_path (__FILE__ ).'js/ad-inserter.js'));
299
  wp_enqueue_style ('ad-inserter-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
300
  wp_enqueue_style ('ad-inserter', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
301
 
305
  }
306
 
307
  function ai_enqueue_scripts_hook () {
308
+ // wp_enqueue_style ('ad-inserter-devices', plugins_url ( 'css/devices.css', __FILE__), false, AD_INSERTER_VERSION);
309
+ wp_enqueue_style ('ad-inserter-viewports', plugins_url ( 'css/viewports.css', __FILE__), false, filemtime (plugin_dir_path (__FILE__ ).'css/viewports.css'));
310
  }
311
 
312
  function ai_admin_notice_hook () {
536
  }
537
  }
538
 
539
+ function ai_plugin_options ($plugin_options = array ()) {
 
540
 
541
  $version_array = explode (".", AD_INSERTER_VERSION);
542
  $version_string = "";
546
 
547
  $plugin_options ['VERSION'] = $version_string;
548
 
549
+ if (!isset ($plugin_options ['SYNTAX_HIGHLIGHTER_THEME'])) $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
 
 
550
 
551
+ if (!isset ($plugin_options ['BLOCK_CLASS_NAME']) ||
552
+ $plugin_options ['BLOCK_CLASS_NAME'] == '') $plugin_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
553
+
554
+ if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
555
+
556
+ if (!isset ($plugin_options ['PLUGIN_PRIORITY'])) $plugin_options ['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY;
557
+ $plugin_priority = $plugin_options ['PLUGIN_PRIORITY'];
558
  if (!is_numeric ($plugin_priority)) {
559
  $plugin_priority = DEFAULT_PLUGIN_PRIORITY;
560
  }
565
  if ($plugin_priority > 999999) {
566
  $plugin_priority = 999999;
567
  }
568
+ $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
569
+
570
+ if (!isset ($plugin_options ['TAG_DEBUGGING'])) $plugin_options ['TAG_DEBUGGING'] = DEFAULT_TAG_DEBUGGING;
571
+
572
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
573
+ $viewport_name_option_name = 'VIEWPORT_NAME_' . $viewport;
574
+ $viewport_width_option_name = 'VIEWPORT_WIDTH_' . $viewport;
575
+
576
+ if (!isset ($plugin_options [$viewport_name_option_name])) $plugin_options [$viewport_name_option_name] =
577
+ defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : "VIEWPORT_" . $viewport;
578
+
579
+ if ($viewport == 1 && $plugin_options [$viewport_name_option_name] == '')
580
+ $plugin_options [$viewport_name_option_name] = constant ("DEFAULT_VIEWPORT_NAME_1");
581
+
582
+ if ($plugin_options [$viewport_name_option_name] != '') {
583
+ if (!isset ($plugin_options [$viewport_width_option_name])) $plugin_options [$viewport_width_option_name] =
584
+ defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) : 0;
585
+
586
+ $viewport_width = $plugin_options [$viewport_width_option_name];
587
+
588
+ if ($viewport > 1) {
589
+ $previous_viewport_option_width = $plugin_options ['VIEWPORT_WIDTH_' . ($viewport - 1)];
590
+ }
591
+
592
+ if (!is_numeric ($viewport_width)) {
593
+ if ($viewport == 1)
594
+ $viewport_width = constant ("DEFAULT_VIEWPORT_WIDTH_1"); else
595
+ $viewport_width = $previous_viewport_option_width - 1;
596
+
597
+ }
598
+ if ($viewport_width > 9999) {
599
+ $viewport_width = 9999;
600
+ }
601
+
602
+ if ($viewport > 1) {
603
+ if ($viewport_width >= $previous_viewport_option_width)
604
+ $viewport_width = $previous_viewport_option_width - 1;
605
+ }
606
+
607
+ $viewport_width = intval ($viewport_width);
608
+ if ($viewport_width < 0) {
609
+ $viewport_width = 0;
610
+ }
611
+
612
+ $plugin_options [$viewport_width_option_name] = $viewport_width;
613
+ } else $plugin_options [$viewport_width_option_name] = '';
614
+ }
615
 
616
  return ($plugin_options);
617
  }
630
 
631
  function ai_load_options () {
632
  global $ai_db_options;
633
+
634
  $ai_db_options = get_option (WP_OPTION_NAME);
635
 
636
  if (is_array ($ai_db_options)) {
696
  return ($plugin_db_options ['PLUGIN_PRIORITY']);
697
  }
698
 
699
+ function get_tag_debugging () {
700
+ global $ai_db_options;
701
+
702
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
703
+ if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
704
+
705
+ if (!isset ($plugin_db_options ['TAG_DEBUGGING']) || $plugin_db_options ['TAG_DEBUGGING'] == '') {
706
+ $plugin_db_options ['TAG_DEBUGGING'] = DEFAULT_TAG_DEBUGGING;
707
+ }
708
+
709
+ return ($plugin_db_options ['TAG_DEBUGGING']);
710
+ }
711
+
712
+ function get_viewport_name ($viewport_number) {
713
+ global $ai_db_options;
714
+
715
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
716
+ if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
717
+
718
+ $viewport_settins_name = 'VIEWPORT_NAME_' . $viewport_number;
719
+
720
+ if (!isset ($plugin_db_options [$viewport_settins_name])) {
721
+ $plugin_db_options [$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) : "VIEWPORT_" . $viewport_number;
722
+ }
723
+
724
+ return ($plugin_db_options [$viewport_settins_name]);
725
+ }
726
+
727
+ function get_viewport_width ($viewport_number) {
728
+ global $ai_db_options;
729
+
730
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
731
+ if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
732
+
733
+ $viewport_settins_name = 'VIEWPORT_WIDTH_' . $viewport_number;
734
+
735
+ if (!isset ($plugin_db_options [$viewport_settins_name])) {
736
+ $plugin_db_options [$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) : 0;
737
+ }
738
+
739
+ return ($plugin_db_options [$viewport_settins_name]);
740
+ }
741
+
742
  function filter_html_class ($str){
743
 
744
  $str = str_replace (array ("\\\""), array ("\""), $str);
751
 
752
  $str = str_replace (array ("\\\""), array ("\""), $str);
753
  $str = str_replace (array ("\"", "<", ">"), "", $str);
754
+ $str = trim (esc_html ($str));
755
 
756
  return $str;
757
  }
795
  if ($option == AI_OPTION_CODE ) {
796
  } elseif ($option == AI_OPTION_ENABLE_MANUAL) {
797
  } elseif ($option == AI_OPTION_PROCESS_PHP) {
798
+ } elseif ($option == AI_OPTION_ENABLE_404) {
799
  }
800
 
801
  return $value;
804
  function ai_settings () {
805
  global $ai_db_options, $block_object;
806
 
807
+ if (isset ($_POST [AI_FORM_SAVE])) {
808
 
809
  check_admin_referer ('save_adinserter_settings');
810
 
880
 
881
  $ai_options [AI_HEADER_OPTION_NAME] = $adH->wp_options;
882
  $ai_options [AI_FOOTER_OPTION_NAME] = $adF->wp_options;
883
+
884
+ $options = array ();
885
+
886
+ $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
887
+ $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
888
+ $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
889
+ $options ['PLUGIN_PRIORITY'] = filter_option ('plugin_priority', $_POST ['plugin_priority']);
890
+ $options ['TAG_DEBUGGING'] = filter_string ($_POST ['tag_debugging']);
891
+
892
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
893
+ if (isset ($_POST ['viewport-name-'.$viewport]))
894
+ $options ['VIEWPORT_NAME_'.$viewport] = filter_string ($_POST ['viewport-name-'.$viewport]);
895
+ if (isset ($_POST ['viewport-width-'.$viewport]))
896
+ $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
897
+ }
898
+
899
+ $ai_options [AI_GLOBAL_OPTION_NAME] = ai_plugin_options ($options);
900
  }
901
 
902
  if (!empty ($invalid_blocks)) {
910
  // Reload options
911
  ai_load_options ();
912
 
913
+ // Generate viewports.css file
914
+ $viewports = array ();
915
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
916
+ $viewport_name = get_viewport_name ($viewport);
917
+ $viewport_width = get_viewport_width ($viewport);
918
+ if ($viewport_name != '') {
919
+ $viewports []= array ('index' => $viewport, 'name' => $viewport_name, 'width' => $viewport_width);
920
+ }
921
+ }
922
+
923
+ $style = '';
924
+ if (count ($viewports) != 0) {
925
+ $style .= "/* " . AD_INSERTER_TITLE . " version " . AD_INSERTER_VERSION ." - viewport classes */\n\n";
926
+ $style .= "/* DO NOT MODIFY - This file is automatically generated when you save Ad Inserter settings */\n";
927
+ foreach ($viewports as $index => $viewport) {
928
+ $style .= "\n/* " . $viewport ['name'] . " */\n\n";
929
+ if ($viewport ['index'] == 1) {
930
+ foreach (array_reverse ($viewports) as $index2 => $viewport2) {
931
+ if ($viewport2 ['index'] != 1) {
932
+ $style .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n";
933
+ }
934
+ }
935
+ $style .= ".ai-viewport-1 { display: inherit !important;}\n";
936
+ $style .= ".ai-viewport-0 { display: none !important;}\n";
937
+ } else {
938
+ $style .= "@media ";
939
+ if ($index != count ($viewports) - 1)
940
+ $style .= "(min-width: " . $viewport ['width'] . "px) and ";
941
+ $style .= "(max-width: " . ($viewports [$index - 1]['width'] - 1) . "px) {\n";
942
+ foreach ($viewports as $index2 => $viewport2) {
943
+ if ($viewport2 ['index'] == 1)
944
+ $style .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n";
945
+ elseif ($viewport ['index'] == $viewport2 ['index'])
946
+ $style .= ".ai-viewport-" . $viewport2 ['index'] . " { display: inherit !important;}\n";
947
+
948
+ }
949
+ $style .= "}\n";
950
+ }
951
+ }
952
+ }
953
+ file_put_contents (plugin_dir_path (__FILE__ ).'css/viewports.css', $style);
954
+
955
  for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
956
  $obj = new ai_Block ($counter);
957
  $obj->load_options ($counter);
964
 
965
  echo "<div class='updated' style='margin: 5px 15px 2px 0px; padding: 10px;'><strong>Settings saved.</strong></div>";
966
 
967
+ } elseif (isset ($_POST [AI_FORM_CLEAR])) {
968
 
969
  check_admin_referer ('save_adinserter_settings');
970
 
1006
 
1007
 
1008
  function adinserter ($ad_number = ""){
1009
+ global $block_object, $ad_interter_globals;
1010
 
1011
  if ($ad_number == "") return "";
1012
 
1019
  // Load options from db
1020
  $obj = $block_object [$ad_number];
1021
 
1022
+ $globals_name = 'FUNCTION_CALL_COUNTER' . $ad_number;
1023
+
1024
+ if (!isset ($ad_interter_globals [$globals_name])) {
1025
+ $ad_interter_globals [$globals_name] = 1;
1026
+ } else $ad_interter_globals [$globals_name] ++;
1027
+
1028
  $display_for_users = $obj->get_display_for_users ();
1029
 
1030
  if ($display_for_users == AD_DISPLAY_LOGGED_IN_USERS && !is_user_logged_in ()) return "";
1032
 
1033
  $display_for_devices = $obj->get_display_for_devices ();
1034
 
1035
+ if ($obj->get_detection_server_side ()) {
1036
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1037
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1038
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
1077
  if (!$obj->get_display_settings_search()) return "";
1078
  } elseif (is_archive()){
1079
  if (!$obj->get_display_settings_archive()) return "";
1080
+ } elseif (is_404()){
1081
+ if (!$obj->get_enable_404()) return "";
1082
  }
1083
 
1084
  if ($obj->get_ad_data() == AD_EMPTY_DATA) return "";
1093
 
1094
  if (!$obj->check_referer ()) return "";
1095
 
1096
+ $counter_settings = $obj->get_excerpt_number();
1097
+ $numbers = array ();
1098
+ if (strpos ($counter_settings, ",") !== false) {
1099
+ $numbers = explode (",", $counter_settings);
1100
+ } else $numbers []= $counter_settings;
1101
+ if ($counter_settings != 0 && !in_array ($ad_interter_globals [$globals_name], $numbers)) return "";
1102
 
1103
+ if (!$obj->check_and_increment_block_counter ()) return "";
1104
 
1105
+ $block_class_name = get_block_class_name ();
 
 
 
 
 
 
 
 
1106
 
1107
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1108
+ $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $ad_number. $obj->get_viewport_classes () . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1109
 
1110
  return $ad_code;
1111
  }
1112
 
1113
 
1114
  function ai_content_hook ($content = ''){
1115
+ global $block_object, $ad_interter_globals;
1116
+
1117
+ if (!isset ($ad_interter_globals ['CONTENT_COUNTER'])) {
1118
+ $ad_interter_globals ['CONTENT_COUNTER'] = 1;
1119
+ } else $ad_interter_globals ['CONTENT_COUNTER'] ++;
1120
 
1121
+ $tag_debugging = get_tag_debugging ();
1122
+
1123
+ if ($tag_debugging != AI_OPTION_BEFORE_PROCESSING || !is_user_logged_in ())
1124
  for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
1125
  $obj = $block_object [$counter];
1126
 
1127
  $display_type = $obj->get_display_type();
1128
+ // $manual_insert = $obj->get_enable_manual ();
1129
+
1130
+ // if ($display_type != AD_SELECT_BEFORE_PARAGRAPH &&
1131
+ // $display_type != AD_SELECT_AFTER_PARAGRAPH &&
1132
+ // $display_type != AD_SELECT_BEFORE_CONTENT &&
1133
+ // $display_type != AD_SELECT_AFTER_CONTENT &&
1134
+ // !$manual_insert) continue;
1135
 
1136
  if ($display_type != AD_SELECT_BEFORE_PARAGRAPH &&
1137
  $display_type != AD_SELECT_AFTER_PARAGRAPH &&
1138
  $display_type != AD_SELECT_BEFORE_CONTENT &&
1139
+ $display_type != AD_SELECT_AFTER_CONTENT) continue;
 
1140
 
1141
  $display_for_users = $obj->get_display_for_users ();
1142
 
1145
 
1146
  $display_for_devices = $obj->get_display_for_devices ();
1147
 
1148
+ if ($obj->get_detection_server_side ()) {
1149
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1150
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1151
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
1154
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) continue;
1155
  }
1156
 
1157
+ //if empty data, continue with next block
1158
  if ($obj->get_ad_data() == AD_EMPTY_DATA) {
1159
  continue;
1160
  }
1161
 
1162
+ $blog_page = false;
1163
+
1164
  if (is_single ()) {
1165
  if (!$obj->get_display_settings_post ()) continue;
1166
 
1187
  elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
1188
  if (!in_array ($obj->number, $selected_blocks)) continue;
1189
  }
1190
+ }
1191
+ elseif (is_front_page ()){
1192
+ if (!$obj->get_display_settings_home()) continue;
1193
+ $blog_page = true;
1194
+ }
1195
+ elseif (is_category()){
1196
+ if (!$obj->get_display_settings_category()) continue;
1197
+ $blog_page = true;
1198
+ }
1199
+ elseif (is_search()){
1200
+ if (!$obj->get_display_settings_search()) continue;
1201
+ $blog_page = true;
1202
+ }
1203
+ elseif (is_archive()){
1204
+ if (!$obj->get_display_settings_archive()) continue;
1205
+ $blog_page = true;
1206
+ }
1207
+ elseif (is_404()){
1208
+ if (!$obj->get_enable_404()) continue;
1209
+ }
1210
+
1211
+ if ($blog_page) {
1212
+ $counter_settings = $obj->get_excerpt_number();
1213
+ $numbers = array ();
1214
+ if (strpos ($counter_settings, ",") !== false) {
1215
+ $numbers = explode (",", $counter_settings);
1216
+ } else $numbers []= $counter_settings;
1217
+ if ($counter_settings != 0 && !in_array ($ad_interter_globals ['CONTENT_COUNTER'], $numbers)) continue;
1218
+ }
1219
 
1220
  // Deprecated
1221
  if ($obj->display_disabled ($content)) continue;
1232
 
1233
  if (!$obj->check_block_counter ()) continue;
1234
 
1235
+ $inserted = false;
1236
+
1237
  if ($display_type == AD_SELECT_BEFORE_PARAGRAPH) {
1238
+ $content = $obj->before_paragraph ($content, $inserted);
1239
+ if ($inserted) $obj->increment_block_counter ();
1240
+ }
1241
+ elseif ($display_type == AD_SELECT_AFTER_PARAGRAPH) {
1242
+ $content = $obj->after_paragraph ($content, $inserted);
1243
+ if ($inserted) $obj->increment_block_counter ();
1244
+ }
1245
+ elseif ($display_type == AD_SELECT_BEFORE_CONTENT) {
1246
  $content = $obj->before_content ($content);
1247
+ $obj->increment_block_counter ();
1248
+ }
1249
+ elseif ($display_type == AD_SELECT_AFTER_CONTENT) {
1250
  $content = $obj->after_content ($content);
1251
+ $obj->increment_block_counter ();
1252
  }
1253
  }
1254
 
1255
+ if ($tag_debugging != AI_OPTION_DISABLED && is_user_logged_in ()) {
1256
+ $content = preg_replace ("/\r\n\r\n/", "\r\n\r\n<h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid #000; padding: 2px; margin: 12px 0;'>\\r\\n\\r\\n</h6>", $content);
1257
+
1258
+ $content = preg_replace ("/<p([^>]*?)>/i", "<h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid blue; padding: 2px; margin: 12px 0;'>&lt;p$1&gt;</h6><p$1>", $content);
1259
+ $content = preg_replace ("/<div([^>]*?)>/i", "<h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid #0a0; padding: 2px; margin: 12px 0;'>&lt;div$1&gt;</h6><div$1>", $content);
1260
+ $content = preg_replace ("/<(?!h6|a|br|strong|p|div)([a-z0-9]+)([^>]*?)>/i", "<h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid red; padding: 2px; margin: 12px 0;'>&lt;$1$2&gt;</h6><$1$2>", $content);
1261
+
1262
+ $content = preg_replace ("/<\/p>/i", "</p><h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid blue; padding: 2px; margin: 12px 0;'>&lt;/p&gt;</h6>", $content);
1263
+ $content = preg_replace ("/<\/div>/i", "</div><h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid #0a0; padding: 2px; margin: 12px 0;'>&lt;/div&gt;</h6>", $content);
1264
+ $content = preg_replace ("/<\/(?!h6|a|br|strong|p|div)([a-z0-9]+)>/i", "</$1><h6 style='display: block; font-family: Courier, \"Courier New\", monospace; font-weight: bold; font-size: 12px; border: 1px solid red; padding: 2px; margin: 12px 0;'>&lt;/$1&gt;</h6>", $content);
1265
+ }
1266
+
1267
  return $content;
1268
  }
1269
 
1290
 
1291
  $display_for_devices = $obj->get_display_for_devices ();
1292
 
1293
+ if ($obj->get_detection_server_side ()) {
1294
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1295
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1296
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
1299
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) continue;
1300
  }
1301
 
1302
+ $counter_settings = $obj->get_excerpt_number();
1303
+ $numbers = array ();
1304
+ if (strpos ($counter_settings, ",") !== false) {
1305
+ $numbers = explode (",", $counter_settings);
1306
+ } else $numbers []= $counter_settings;
1307
 
1308
+ if ($counter_settings != 0 && !in_array ($excerpt_counter, $numbers)) continue;
1309
 
1310
  if (is_front_page ()){
1311
  if (!$obj->get_display_settings_home()) continue;
1319
  elseif (is_archive()){
1320
  if (!$obj->get_display_settings_archive()) continue;
1321
  }
1322
+ elseif (is_404()){
1323
+ if (!$obj->get_enable_404()) continue;
1324
+ }
1325
 
1326
  //if empty data, continue with next
1327
  if ($obj->get_ad_data() == AD_EMPTY_DATA){
1339
 
1340
  if (!$obj->check_referer ()) continue;
1341
 
1342
+ if (!$obj->check_and_increment_block_counter ()) continue;
1343
 
1344
  $block_class_name = get_block_class_name ();
1345
 
 
 
 
 
 
 
 
 
 
 
1346
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1347
+ $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block_index . $obj->get_viewport_classes () . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1348
 
1349
  if ($display_type == AD_SELECT_BEFORE_EXCERPT)
1350
  $content = $ad_code . $content; else
1354
  return $content;
1355
  }
1356
 
1357
+ // Process Before / After Post postion
1358
+
1359
+ function ai_before_after_post ($query, $display_type){
1360
  global $block_object;
1361
 
1362
  if (!method_exists ($query, 'is_main_query')) return;
1372
  for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
1373
  $obj = $block_object [$block_index];
1374
 
1375
+ if ($obj->get_display_type () != $display_type) continue;
1376
 
1377
  $display_for_users = $obj->get_display_for_users ();
1378
 
1381
 
1382
  $display_for_devices = $obj->get_display_for_devices ();
1383
 
1384
+ if ($obj->get_detection_server_side ()) {
1385
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) continue;
1386
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) continue;
1387
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) continue;
1424
  elseif (is_archive()){
1425
  if (!$obj->get_display_settings_archive()) continue;
1426
  }
1427
+ elseif (is_404()){
1428
+ if (!$obj->get_enable_404()) continue;
1429
+ }
1430
 
1431
  //if empty data, continue with next
1432
  if ($obj->get_ad_data() == AD_EMPTY_DATA) continue;
1441
 
1442
  if (!$obj->check_referer ()) continue;
1443
 
1444
+ if (!$obj->check_and_increment_block_counter ()) continue;
1445
 
1446
  $block_class_name = get_block_class_name ();
1447
 
 
 
 
 
 
 
 
 
 
 
1448
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code .= ai_getAdCode ($obj); else
1449
+ $ad_code .= "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block_index . $obj->get_viewport_classes () . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1450
  }
1451
 
1452
  echo $ad_code;
1453
  }
1454
 
1455
+ // Process Before Post postion
1456
+ function ai_loop_start_hook ($query){
1457
+ ai_before_after_post ($query, AD_SELECT_BEFORE_POST);
1458
+ }
1459
+
1460
+
1461
+ // Process After Post postion
1462
+ function ai_loop_end_hook ($query){
1463
+ ai_before_after_post ($query, AD_SELECT_AFTER_POST);
1464
+ }
1465
+
1466
 
1467
  function ai_getCode ($obj){
1468
  $code = $obj->get_ad_data();
1529
 
1530
  $display_for_devices = $obj->get_display_for_devices ();
1531
 
1532
+ if ($obj->get_detection_server_side ()) {
1533
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return "";
1534
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return "";
1535
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return "";
1538
  if ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES && !(AI_DESKTOP || AI_PHONE)) return "";
1539
  }
1540
 
 
 
1541
  if (is_page() || is_single()) {
1542
  if (!$obj->check_date ()) return "";
1543
  }
1544
+ elseif (is_404()){
1545
+ if (!$obj->get_enable_404()) return "";
1546
+ }
1547
 
1548
  if (!$obj->check_url ()) return "";
1549
 
1553
 
1554
  if (!$obj->check_tag ()) return "";
1555
 
1556
+ if (!$obj->check_and_increment_block_counter ()) return "";
1557
 
1558
+ $block_class_name = get_block_class_name ();
 
 
 
 
 
 
 
 
1559
 
1560
  if ($obj->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($obj); else
1561
+ $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . $obj->get_viewport_classes () . "' style='" . $obj->get_alignmet_style() . "'>" . ai_getAdCode ($obj) . "</div>";
1562
  return ($ad_code);
1563
  }
1564
  }
1647
 
1648
  $display_for_devices = $obj->get_display_for_devices ();
1649
 
1650
+ if ($obj->get_detection_server_side ()) {
1651
  if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES && !AI_DESKTOP) return;
1652
  if ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES && !AI_MOBILE) return;;
1653
  if ($display_for_devices == AD_DISPLAY_TABLET_DEVICES && !AI_TABLET) return;
1703
  elseif(is_archive()){
1704
  if (!$obj->get_display_settings_archive()) return;
1705
  }
1706
+ elseif (is_404()){
1707
+ if (!$obj->get_enable_404()) return;
1708
+ }
1709
 
1710
  if (!$obj->check_category ()) return;
1711
 
1715
 
1716
  if (!$obj->check_referer ()) return;
1717
 
1718
+ if (!$obj->check_and_increment_block_counter ()) return;
1719
 
1720
  $block_class_name = get_block_class_name ();
1721
 
1722
+ $viewport_classes = $obj->get_viewport_classes ();
1723
+ if ($viewport_classes != "") echo "<div class='" . $viewport_classes . "'>";
 
 
 
 
 
 
 
 
 
1724
  echo $args ['before_widget'];
1725
 
1726
  if (!empty ($title)) {
1731
  echo "<div class='" . $block_class_name . " " . $block_class_name . "-" . $block . "' style='" . $obj->get_alignmet_style (false) . "'>" . ai_getAdCode ($obj) . "</div>";
1732
 
1733
  echo $args ['after_widget'];
1734
+ if ($viewport_classes != "") echo "</div>";
1735
  }
class.php CHANGED
@@ -5,7 +5,6 @@ require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
5
  abstract class ai_BaseCodeBlock {
6
  var $wp_options;
7
 
8
- // function ai_BaseCodeBlock() {
9
  function __construct () {
10
 
11
  $this->wp_options = array ();
@@ -13,6 +12,7 @@ abstract class ai_BaseCodeBlock {
13
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
14
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
15
  $this->wp_options [AI_OPTION_ENABLE_MANUAL] = AD_SETTINGS_NOT_CHECKED;
 
16
  }
17
 
18
  public function load_options ($block) {
@@ -244,18 +244,22 @@ abstract class ai_BaseCodeBlock {
244
  if ($process_php == '') $process_php = AD_SETTINGS_NOT_CHECKED;
245
  return $process_php;
246
  }
 
 
 
 
 
 
247
  }
248
 
249
  abstract class ai_CodeBlock extends ai_BaseCodeBlock {
250
 
251
  var $number;
252
 
253
- // function ai_CodeBlock() {
254
  function __construct () {
255
 
256
  $this->number = 0;
257
 
258
- // parent::ai_BaseCodeBlock();
259
  parent::__construct();
260
 
261
  $this->wp_options [AI_OPTION_NAME] = AD_NAME;
@@ -279,12 +283,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
279
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
280
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
281
  $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
282
- $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AD_SETTINGS_CHECKED;
283
- $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AD_SETTINGS_NOT_CHECKED;
284
  $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AD_SETTINGS_CHECKED;
285
- $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_CHECKED;
286
- $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_CHECKED;
287
- $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_CHECKED;
 
 
288
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
289
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
290
  $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AD_SETTINGS_NOT_CHECKED;
@@ -292,15 +296,19 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
292
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT_TYPE] = AD_DO_NOT_CONTAIN;
293
  $this->wp_options [AI_OPTION_CUSTOM_CSS] = AD_EMPTY_DATA;
294
  $this->wp_options [AI_OPTION_DISPLAY_FOR_USERS] = AD_DISPLAY_ALL_USERS;
295
- $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_ALL_DEVICES;
296
  $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AD_SETTINGS_NOT_CHECKED;
297
- $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] = AD_SETTINGS_CHECKED;
 
 
 
298
  }
299
 
300
  public function get_display_type(){
301
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE]) ? $this->wp_options [AI_OPTION_DISPLAY_TYPE] : "";
302
  if ($option == '') $option = AD_SELECT_NONE;
303
  elseif ($option == AD_SELECT_MANUAL) $option = AD_SELECT_NONE;
 
304
  return $option;
305
  }
306
 
@@ -398,8 +406,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
398
  return $style;
399
  }
400
 
401
- public function get_display_settings_home(){
402
- $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] : "";
403
  if ($option == '') $option = AD_SETTINGS_CHECKED;
404
  return $option;
405
  }
@@ -410,29 +418,93 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
410
  return $option;
411
  }
412
 
413
- public function get_display_settings_post(){
414
- $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_POSTS]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] : "";
415
- if ($option == '') $option = AD_SETTINGS_CHECKED;
416
- return $option;
417
- }
418
 
419
- public function get_display_settings_category(){
420
- $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] : "";
421
- if ($option == '') $option = AD_SETTINGS_CHECKED;
422
- return $option;
423
- }
424
 
425
- public function get_display_settings_search(){
426
- $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] : "";
427
- if ($option == '') $option = AD_SETTINGS_CHECKED;
428
- return $option;
429
- }
430
 
431
- public function get_display_settings_archive(){
432
- $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] : "";
433
- if ($option == '') $option = AD_SETTINGS_CHECKED;
434
- return $option;
435
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
 
437
  public function get_enable_manual (){
438
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
@@ -463,8 +535,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
463
  }
464
 
465
  public function get_custom_css (){
466
- $option = isset ($this->wp_options [AI_OPTION_CUSTOM_CSS]) ? $this->wp_options [AI_OPTION_CUSTOM_CSS] : "";
467
- return $option;
 
 
 
 
 
 
468
  }
469
 
470
  public function get_display_for_users (){
@@ -479,20 +557,88 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
479
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
480
  $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
481
  } else $display_for_devices = '';
482
- if ($display_for_devices == '') $display_for_devices = AD_DISPLAY_ALL_DEVICES;
 
483
  return $display_for_devices;
484
  }
485
 
486
  public function get_detection_server_side(){
487
- $option = isset ($this->wp_options [AI_OPTION_DETECT_SERVER_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] : AD_SETTINGS_NOT_CHECKED;
 
 
 
 
 
 
488
  return $option;
489
  }
490
 
491
  public function get_detection_client_side(){
492
- $option = isset ($this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] : AD_SETTINGS_CHECKED;
 
 
 
 
 
 
 
 
 
 
 
493
  return $option;
494
  }
495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  public function get_ad_data_replaced(){
497
 
498
  $general_tag = isset ($this->wp_options [AI_OPTION_GENERAL_TAG]) ? $this->wp_options [AI_OPTION_GENERAL_TAG] : "";
@@ -740,7 +886,23 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
740
  return $option;
741
  }
742
 
743
- public function before_paragraph ($content) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
744
 
745
  $paragraph_positions = array ();
746
 
@@ -755,12 +917,18 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
755
  if (trim ($paragraph_start_string) == '') continue;
756
 
757
  $last_position = - 1;
758
- $paragraph_start = '<' . trim ($paragraph_start_string);
 
 
 
 
 
 
759
  $paragraph_start_len = strlen ($paragraph_start);
760
 
761
  while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
762
  $last_position = stripos ($content, $paragraph_start, $last_position + 1);
763
- if ($content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ")
764
  $paragraph_positions [] = $last_position;
765
  }
766
  }
@@ -830,7 +998,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
830
  $paragraph_positions = array_reverse ($paragraph_positions);
831
  }
832
 
833
- $text = str_replace (array ("\n", " "), " ", $content);
 
 
834
  $text = strip_tags ($text);
835
  $number_of_words = sizeof (explode (" ", $text));
836
 
@@ -841,26 +1011,19 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
841
 
842
  $display_for_devices = $this->get_display_for_devices ();
843
 
844
- $device_class = "";
845
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
846
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
847
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
848
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
849
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
850
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
851
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
852
- }
853
-
854
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = substr_replace ($content, ai_getAdCode ($this), $content_position, 0); else
855
- $content = substr_replace ($content, "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>", $content_position, 0);
 
 
856
  }
857
 
858
  return $content;
859
  }
860
 
861
- public function after_paragraph ($content) {
862
 
863
  $paragraph_positions = array ();
 
864
 
865
  $paragraph_tags = trim ($this->get_paragraph_tags());
866
  if ($paragraph_tags == '') return $content;
@@ -873,7 +1036,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
873
  if (trim ($paragraph_end_string) == '') continue;
874
 
875
  $last_position = - 1;
876
- $paragraph_end = '</' . trim ($paragraph_end_string) . '>';
 
 
 
 
 
877
 
878
  while (stripos ($content, $paragraph_end, $last_position + 1) !== false) {
879
  $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
@@ -946,7 +1114,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
946
  $paragraph_positions = array_reverse ($paragraph_positions);
947
  }
948
 
949
- $text = str_replace (array ("\n", " "), " ", $content);
 
 
950
  $text = strip_tags ($text);
951
  $number_of_words = sizeof (explode (" ", $text));
952
 
@@ -957,23 +1127,15 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
957
 
958
  $display_for_devices = $this->get_display_for_devices ();
959
 
960
- $device_class = "";
961
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
962
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
963
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
964
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
965
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
966
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
967
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
968
- }
969
-
970
  if ($content_position >= strlen ($content) - 1) {
971
- if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = $content = $content . ai_getAdCode ($this); else
972
- $content = $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
973
  } else {
974
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = substr_replace ($content, ai_getAdCode ($this), $content_position + 1, 0); else
975
- $content = substr_replace ($content, "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>", $content_position + 1, 0);
976
  }
 
 
977
  }
978
 
979
  return $content;
@@ -984,16 +1146,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
984
 
985
  $display_for_devices = $this->get_display_for_devices ();
986
 
987
- $device_class = "";
988
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
989
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
990
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
991
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
992
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
993
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
994
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
995
- }
996
-
997
  $text = str_replace (array ("\n", " "), " ", $content);
998
  $text = strip_tags ($text);
999
  $number_of_words = sizeof (explode (" ", $text));
@@ -1001,7 +1153,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1001
  if ($number_of_words < $this->get_minimum_words()) return $content;
1002
 
1003
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return ai_getAdCode ($this) . $content; else
1004
- return "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>" . $content;
1005
  }
1006
 
1007
  public function after_content ($content) {
@@ -1009,16 +1161,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1009
 
1010
  $display_for_devices = $this->get_display_for_devices ();
1011
 
1012
- $device_class = "";
1013
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
1014
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
1015
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
1016
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
1017
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
1018
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
1019
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
1020
- }
1021
-
1022
  $text = str_replace (array ("\n", " "), " ", $content);
1023
  $text = strip_tags ($text);
1024
  $number_of_words = sizeof (explode (" ", $text));
@@ -1026,7 +1168,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1026
  if ($number_of_words < $this->get_minimum_words()) return $content;
1027
 
1028
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return $content . ai_getAdCode ($this); else
1029
- return $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
1030
  }
1031
 
1032
  // Deprecated
@@ -1038,22 +1180,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1038
 
1039
  $display_for_devices = $this->get_display_for_devices ();
1040
 
1041
- $device_class = "";
1042
- if ($display_for_devices != AD_DISPLAY_ALL_DEVICES && $this->get_detection_client_side ()) {
1043
- if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES) $device_class = " ai-desktop";
1044
- elseif ($display_for_devices == AD_DISPLAY_MOBILE_DEVICES) $device_class = " ai-tablet-phone";
1045
- elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES) $device_class = " ai-tablet";
1046
- elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES) $device_class = " ai-phone";
1047
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) $device_class = " ai-desktop-tablet";
1048
- elseif ($display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) $device_class = " ai-desktop-phone";
1049
- }
1050
-
1051
  foreach ($tags [1] as $tag) {
1052
  $ad_tag = strtolower (trim ($tag));
1053
  $ad_name = strtolower (trim ($this->get_ad_name()));
1054
  if ($ad_tag == $ad_name || $ad_tag == $this->number) {
1055
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($this); else
1056
- $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $device_class . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
1057
  $content = preg_replace ("/{adinserter " . $tag . "}/", $ad_code, $content);
1058
  }
1059
  }
@@ -1270,7 +1402,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1270
  return !$return;
1271
  }
1272
 
1273
- function check_block_counter () {
1274
  global $ad_interter_globals;
1275
 
1276
  $global_name = 'BLOCK_' . $this->number . '_COUNTER';
@@ -1282,13 +1414,36 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1282
  $ad_interter_globals [$global_name] ++;
1283
  return true;
1284
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1285
  }
1286
 
 
1287
  class ai_Block extends ai_CodeBlock {
1288
 
1289
- // public function ai_Block ($number) {
1290
  public function __construct ($number) {
1291
- // parent::ai_CodeBlock();
1292
  parent::__construct();
1293
 
1294
  $this->number = $number;
@@ -1298,18 +1453,14 @@ class ai_Block extends ai_CodeBlock {
1298
 
1299
  class ai_AdH extends ai_BaseCodeBlock {
1300
 
1301
- // public function ai_AdH() {
1302
  public function __construct () {
1303
- // parent::ai_BaseCodeBlock();
1304
  parent::__construct();
1305
  }
1306
  }
1307
 
1308
  class ai_AdF extends ai_BaseCodeBlock {
1309
 
1310
- // public function ai_AdF() {
1311
  public function __construct () {
1312
- // parent::ai_BaseCodeBlock();
1313
  parent::__construct();
1314
  }
1315
  }
5
  abstract class ai_BaseCodeBlock {
6
  var $wp_options;
7
 
 
8
  function __construct () {
9
 
10
  $this->wp_options = array ();
12
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
13
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
14
  $this->wp_options [AI_OPTION_ENABLE_MANUAL] = AD_SETTINGS_NOT_CHECKED;
15
+ $this->wp_options [AI_OPTION_ENABLE_404] = AD_SETTINGS_NOT_CHECKED;
16
  }
17
 
18
  public function load_options ($block) {
244
  if ($process_php == '') $process_php = AD_SETTINGS_NOT_CHECKED;
245
  return $process_php;
246
  }
247
+
248
+ public function get_enable_404 (){
249
+ $enable_404 = isset ($this->wp_options [AI_OPTION_ENABLE_404]) ? $this->wp_options [AI_OPTION_ENABLE_404] : "";
250
+ if ($enable_404 == '') $enable_404 = AI_OPTION_ENABLE_404;
251
+ return $enable_404;
252
+ }
253
  }
254
 
255
  abstract class ai_CodeBlock extends ai_BaseCodeBlock {
256
 
257
  var $number;
258
 
 
259
  function __construct () {
260
 
261
  $this->number = 0;
262
 
 
263
  parent::__construct();
264
 
265
  $this->wp_options [AI_OPTION_NAME] = AD_NAME;
283
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
284
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
285
  $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
 
 
286
  $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AD_SETTINGS_CHECKED;
287
+ $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AD_SETTINGS_NOT_CHECKED;
288
+ $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AD_SETTINGS_NOT_CHECKED;
289
+ $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_NOT_CHECKED;
290
+ $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_NOT_CHECKED;
291
+ $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_NOT_CHECKED;
292
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
293
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
294
  $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AD_SETTINGS_NOT_CHECKED;
296
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT_TYPE] = AD_DO_NOT_CONTAIN;
297
  $this->wp_options [AI_OPTION_CUSTOM_CSS] = AD_EMPTY_DATA;
298
  $this->wp_options [AI_OPTION_DISPLAY_FOR_USERS] = AD_DISPLAY_ALL_USERS;
299
+ $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_DESKTOP_DEVICES;
300
  $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AD_SETTINGS_NOT_CHECKED;
301
+ $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] = AD_SETTINGS_NOT_CHECKED;
302
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
303
+ $this->wp_options [AI_OPTION_DETECT_VIEWPORT . '_' . $viewport] = AD_SETTINGS_NOT_CHECKED;
304
+ }
305
  }
306
 
307
  public function get_display_type(){
308
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE]) ? $this->wp_options [AI_OPTION_DISPLAY_TYPE] : "";
309
  if ($option == '') $option = AD_SELECT_NONE;
310
  elseif ($option == AD_SELECT_MANUAL) $option = AD_SELECT_NONE;
311
+ elseif ($option == AD_SELECT_BEFORE_TITLE) $option = AD_SELECT_BEFORE_POST;
312
  return $option;
313
  }
314
 
406
  return $style;
407
  }
408
 
409
+ public function get_display_settings_post(){
410
+ $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_POSTS]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] : "";
411
  if ($option == '') $option = AD_SETTINGS_CHECKED;
412
  return $option;
413
  }
418
  return $option;
419
  }
420
 
421
+ public function get_display_settings_home(){
422
+ global $ai_db_options;
 
 
 
423
 
424
+ $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] : "";
425
+ if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
 
 
 
426
 
427
+ if ($ai_db_options ['global']['VERSION'] < '010605') {
428
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE])) {
429
+ $display_type = $this->wp_options [AI_OPTION_DISPLAY_TYPE];
430
+ } else $display_type = '';
 
431
 
432
+ if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
433
+ $display_type == AD_SELECT_AFTER_PARAGRAPH ||
434
+ $display_type == AD_SELECT_BEFORE_CONTENT ||
435
+ $display_type == AD_SELECT_AFTER_CONTENT ||
436
+ $display_type == AD_SELECT_NONE)
437
+ $option = AD_SETTINGS_NOT_CHECKED;
438
+ }
439
+
440
+ return $option;
441
+ }
442
+
443
+ public function get_display_settings_category(){
444
+ global $ai_db_options;
445
+
446
+ $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] : "";
447
+ if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
448
+
449
+ if ($ai_db_options ['global']['VERSION'] < '010605') {
450
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE])) {
451
+ $display_type = $this->wp_options [AI_OPTION_DISPLAY_TYPE];
452
+ } else $display_type = '';
453
+
454
+ if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
455
+ $display_type == AD_SELECT_AFTER_PARAGRAPH ||
456
+ $display_type == AD_SELECT_BEFORE_CONTENT ||
457
+ $display_type == AD_SELECT_AFTER_CONTENT ||
458
+ $display_type == AD_SELECT_NONE)
459
+ $option = AD_SETTINGS_NOT_CHECKED;
460
+ }
461
+
462
+ return $option;
463
+ }
464
+
465
+ public function get_display_settings_search(){
466
+ global $ai_db_options;
467
+
468
+ $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] : "";
469
+ if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
470
+
471
+ if ($ai_db_options ['global']['VERSION'] < '010605') {
472
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE])) {
473
+ $display_type = $this->wp_options [AI_OPTION_DISPLAY_TYPE];
474
+ } else $display_type = '';
475
+
476
+ if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
477
+ $display_type == AD_SELECT_AFTER_PARAGRAPH ||
478
+ $display_type == AD_SELECT_BEFORE_CONTENT ||
479
+ $display_type == AD_SELECT_AFTER_CONTENT ||
480
+ $display_type == AD_SELECT_NONE)
481
+ $option = AD_SETTINGS_NOT_CHECKED;
482
+ }
483
+
484
+ return $option;
485
+ }
486
+
487
+ public function get_display_settings_archive(){
488
+ global $ai_db_options;
489
+
490
+ $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] : "";
491
+ if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
492
+
493
+ if ($ai_db_options ['global']['VERSION'] < '010605') {
494
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_TYPE])) {
495
+ $display_type = $this->wp_options [AI_OPTION_DISPLAY_TYPE];
496
+ } else $display_type = '';
497
+
498
+ if ($display_type == AD_SELECT_BEFORE_PARAGRAPH ||
499
+ $display_type == AD_SELECT_AFTER_PARAGRAPH ||
500
+ $display_type == AD_SELECT_BEFORE_CONTENT ||
501
+ $display_type == AD_SELECT_AFTER_CONTENT ||
502
+ $display_type == AD_SELECT_NONE)
503
+ $option = AD_SETTINGS_NOT_CHECKED;
504
+ }
505
+
506
+ return $option;
507
+ }
508
 
509
  public function get_enable_manual (){
510
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
535
  }
536
 
537
  public function get_custom_css (){
538
+ global $ai_db_options;
539
+
540
+ $option = isset ($this->wp_options [AI_OPTION_CUSTOM_CSS]) ? $this->wp_options [AI_OPTION_CUSTOM_CSS] : "";
541
+
542
+ // Fix for old bug
543
+ if ($ai_db_options ['global']['VERSION'] < '010605' && strpos ($option, "Undefined index")) $option = "";
544
+
545
+ return $option;
546
  }
547
 
548
  public function get_display_for_users (){
557
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
558
  $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
559
  } else $display_for_devices = '';
560
+ // convert old option
561
+ if ($display_for_devices == '' || $display_for_devices == AD_DISPLAY_ALL_DEVICES) $display_for_devices = AD_DISPLAY_DESKTOP_DEVICES;
562
  return $display_for_devices;
563
  }
564
 
565
  public function get_detection_server_side(){
566
+ // Check old settings for all devices
567
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
568
+ $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
569
+ } else $display_for_devices = '';
570
+ if ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AD_SETTINGS_NOT_CHECKED; else
571
+
572
+ $option = isset ($this->wp_options [AI_OPTION_DETECT_SERVER_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] : AD_SETTINGS_NOT_CHECKED;
573
  return $option;
574
  }
575
 
576
  public function get_detection_client_side(){
577
+ global $ai_db_options;
578
+
579
+ $option = isset ($this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] : AD_SETTINGS_NOT_CHECKED;
580
+
581
+ if ($ai_db_options ['global']['VERSION'] < '010605') {
582
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
583
+ $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
584
+ } else $display_for_devices = '';
585
+
586
+ if ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AD_SETTINGS_NOT_CHECKED;
587
+ }
588
+
589
  return $option;
590
  }
591
 
592
+ public function get_detection_viewport ($viewport){
593
+ global $ai_db_options;
594
+
595
+ $option_name = AI_OPTION_DETECT_VIEWPORT . '_' . $viewport;
596
+ $option = isset ($this->wp_options [$option_name]) ? $this->wp_options [$option_name] : AD_SETTINGS_NOT_CHECKED;
597
+
598
+ if ($ai_db_options ['global']['VERSION'] < '010605' && $this->get_detection_client_side()) {
599
+ if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
600
+ $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
601
+ } else $display_for_devices = '';
602
+
603
+ if ($display_for_devices == AD_DISPLAY_DESKTOP_DEVICES ||
604
+ $display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES ||
605
+ $display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) {
606
+ switch ($viewport) {
607
+ case 1:
608
+ $option = AD_SETTINGS_CHECKED;
609
+ break;
610
+ default:
611
+ $option = AD_SETTINGS_NOT_CHECKED;
612
+ }
613
+ }
614
+ elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES ||
615
+ $display_for_devices == AD_DISPLAY_MOBILE_DEVICES ||
616
+ $display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) {
617
+ switch ($viewport) {
618
+ case 2:
619
+ $option = AD_SETTINGS_CHECKED;
620
+ break;
621
+ default:
622
+ $option = AD_SETTINGS_NOT_CHECKED;
623
+ }
624
+ }
625
+ elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES ||
626
+ $display_for_devices == AD_DISPLAY_MOBILE_DEVICES ||
627
+ $display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) {
628
+ switch ($viewport) {
629
+ case 3:
630
+ $option = AD_SETTINGS_CHECKED;
631
+ break;
632
+ default:
633
+ $option = AD_SETTINGS_NOT_CHECKED;
634
+ }
635
+ }
636
+ elseif ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AD_SETTINGS_NOT_CHECKED;
637
+ }
638
+
639
+ return $option;
640
+ }
641
+
642
  public function get_ad_data_replaced(){
643
 
644
  $general_tag = isset ($this->wp_options [AI_OPTION_GENERAL_TAG]) ? $this->wp_options [AI_OPTION_GENERAL_TAG] : "";
886
  return $option;
887
  }
888
 
889
+ public function get_viewport_classes (){
890
+ $viewport_classes = "";
891
+ if ($this->get_detection_client_side ()) {
892
+ $all_viewports = true;
893
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
894
+ $viewport_name = get_viewport_name ($viewport);
895
+ if ($viewport_name != '') {
896
+ if ($this->get_detection_viewport ($viewport)) $viewport_classes .= " ai-viewport-" . $viewport; else $all_viewports = false;
897
+ }
898
+ }
899
+ if ($viewport_classes == "") $viewport_classes = " ai-viewport-0";
900
+ elseif ($all_viewports) $viewport_classes = "";
901
+ }
902
+ return ($viewport_classes);
903
+ }
904
+
905
+ public function before_paragraph ($content, &$inserted) {
906
 
907
  $paragraph_positions = array ();
908
 
917
  if (trim ($paragraph_start_string) == '') continue;
918
 
919
  $last_position = - 1;
920
+
921
+ $paragraph_start_string = trim ($paragraph_start_string);
922
+ if ($paragraph_start_string == "#") {
923
+ $paragraph_start = "\r\n\r\n";
924
+ if (!in_array (0, $paragraph_positions)) $paragraph_positions [] = 0;
925
+ } else $paragraph_start = '<' . $paragraph_start_string;
926
+
927
  $paragraph_start_len = strlen ($paragraph_start);
928
 
929
  while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
930
  $last_position = stripos ($content, $paragraph_start, $last_position + 1);
931
+ if ($paragraph_start_string == "#" || $content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ")
932
  $paragraph_positions [] = $last_position;
933
  }
934
  }
998
  $paragraph_positions = array_reverse ($paragraph_positions);
999
  }
1000
 
1001
+ $text = str_replace ("\r", "", $content);
1002
+ $text = str_replace (array ("\n", " "), " ", $text);
1003
+ $text = str_replace (" ", " ", $text);
1004
  $text = strip_tags ($text);
1005
  $number_of_words = sizeof (explode (" ", $text));
1006
 
1011
 
1012
  $display_for_devices = $this->get_display_for_devices ();
1013
 
 
 
 
 
 
 
 
 
 
 
1014
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = substr_replace ($content, ai_getAdCode ($this), $content_position, 0); else
1015
+ $content = substr_replace ($content, "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>", $content_position, 0);
1016
+
1017
+ $inserted = true;
1018
  }
1019
 
1020
  return $content;
1021
  }
1022
 
1023
+ public function after_paragraph ($content, &$inserted) {
1024
 
1025
  $paragraph_positions = array ();
1026
+ $last_content_position = strlen ($content) - 1;
1027
 
1028
  $paragraph_tags = trim ($this->get_paragraph_tags());
1029
  if ($paragraph_tags == '') return $content;
1036
  if (trim ($paragraph_end_string) == '') continue;
1037
 
1038
  $last_position = - 1;
1039
+
1040
+ $paragraph_end_string = trim ($paragraph_end_string);
1041
+ if ($paragraph_end_string == "#") {
1042
+ $paragraph_end = "\r\n\r\n";
1043
+ if (!in_array ($last_content_position, $paragraph_positions)) $paragraph_positions [] = $last_content_position;
1044
+ } else $paragraph_end = '</' . $paragraph_end_string . '>';
1045
 
1046
  while (stripos ($content, $paragraph_end, $last_position + 1) !== false) {
1047
  $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
1114
  $paragraph_positions = array_reverse ($paragraph_positions);
1115
  }
1116
 
1117
+ $text = str_replace ("\r", "", $content);
1118
+ $text = str_replace (array ("\n", " "), " ", $text);
1119
+ $text = str_replace (" ", " ", $text);
1120
  $text = strip_tags ($text);
1121
  $number_of_words = sizeof (explode (" ", $text));
1122
 
1127
 
1128
  $display_for_devices = $this->get_display_for_devices ();
1129
 
 
 
 
 
 
 
 
 
 
 
1130
  if ($content_position >= strlen ($content) - 1) {
1131
+ if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = $content . ai_getAdCode ($this); else
1132
+ $content = $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
1133
  } else {
1134
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $content = substr_replace ($content, ai_getAdCode ($this), $content_position + 1, 0); else
1135
+ $content = substr_replace ($content, "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>", $content_position + 1, 0);
1136
  }
1137
+
1138
+ $inserted = true;
1139
  }
1140
 
1141
  return $content;
1146
 
1147
  $display_for_devices = $this->get_display_for_devices ();
1148
 
 
 
 
 
 
 
 
 
 
 
1149
  $text = str_replace (array ("\n", " "), " ", $content);
1150
  $text = strip_tags ($text);
1151
  $number_of_words = sizeof (explode (" ", $text));
1153
  if ($number_of_words < $this->get_minimum_words()) return $content;
1154
 
1155
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return ai_getAdCode ($this) . $content; else
1156
+ return "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>" . $content;
1157
  }
1158
 
1159
  public function after_content ($content) {
1161
 
1162
  $display_for_devices = $this->get_display_for_devices ();
1163
 
 
 
 
 
 
 
 
 
 
 
1164
  $text = str_replace (array ("\n", " "), " ", $content);
1165
  $text = strip_tags ($text);
1166
  $number_of_words = sizeof (explode (" ", $text));
1168
  if ($number_of_words < $this->get_minimum_words()) return $content;
1169
 
1170
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) return $content . ai_getAdCode ($this); else
1171
+ return $content . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
1172
  }
1173
 
1174
  // Deprecated
1180
 
1181
  $display_for_devices = $this->get_display_for_devices ();
1182
 
 
 
 
 
 
 
 
 
 
 
1183
  foreach ($tags [1] as $tag) {
1184
  $ad_tag = strtolower (trim ($tag));
1185
  $ad_name = strtolower (trim ($this->get_ad_name()));
1186
  if ($ad_tag == $ad_name || $ad_tag == $this->number) {
1187
  if ($this->get_alignment_type() == AD_ALIGNMENT_NO_WRAPPING) $ad_code = ai_getAdCode ($this); else
1188
+ $ad_code = "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . $this->get_viewport_classes () . "' style='" . $this->get_alignmet_style() . "'>" . ai_getAdCode ($this) . "</div>";
1189
  $content = preg_replace ("/{adinserter " . $tag . "}/", $ad_code, $content);
1190
  }
1191
  }
1402
  return !$return;
1403
  }
1404
 
1405
+ function check_and_increment_block_counter () {
1406
  global $ad_interter_globals;
1407
 
1408
  $global_name = 'BLOCK_' . $this->number . '_COUNTER';
1414
  $ad_interter_globals [$global_name] ++;
1415
  return true;
1416
  }
1417
+
1418
+ function check_block_counter () {
1419
+ global $ad_interter_globals;
1420
+
1421
+ $global_name = 'BLOCK_' . $this->number . '_COUNTER';
1422
+ $max_insertions = $this->get_maximum_insertions ();
1423
+ if (!isset ($ad_interter_globals [$global_name])) {
1424
+ $ad_interter_globals [$global_name] = 0;
1425
+ }
1426
+ if ($max_insertions != 0 && $ad_interter_globals [$global_name] >= $max_insertions) return false;
1427
+ return true;
1428
+ }
1429
+
1430
+ function increment_block_counter () {
1431
+ global $ad_interter_globals;
1432
+
1433
+ $global_name = 'BLOCK_' . $this->number . '_COUNTER';
1434
+ if (!isset ($ad_interter_globals [$global_name])) {
1435
+ $ad_interter_globals [$global_name] = 0;
1436
+ }
1437
+ $ad_interter_globals [$global_name] ++;
1438
+ return;
1439
+ }
1440
+
1441
  }
1442
 
1443
+
1444
  class ai_Block extends ai_CodeBlock {
1445
 
 
1446
  public function __construct ($number) {
 
1447
  parent::__construct();
1448
 
1449
  $this->number = $number;
1453
 
1454
  class ai_AdH extends ai_BaseCodeBlock {
1455
 
 
1456
  public function __construct () {
 
1457
  parent::__construct();
1458
  }
1459
  }
1460
 
1461
  class ai_AdF extends ai_BaseCodeBlock {
1462
 
 
1463
  public function __construct () {
 
1464
  parent::__construct();
1465
  }
1466
  }
constants.php CHANGED
@@ -11,11 +11,14 @@ if (!defined( 'AD_INSERTER_TITLE'))
11
  define ('AD_INSERTER_TITLE', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
- define ('AD_INSERTER_VERSION', '1.6.4');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
18
 
 
 
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
21
 
@@ -43,12 +46,6 @@ if (!defined ('WP_PLUGIN_URL'))
43
  if (!defined ('WP_PLUGIN_DIR'))
44
  define ('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
45
 
46
- define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
47
- define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
48
- define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
49
- define ('DEFAULT_PLUGIN_PRIORITY', 99999);
50
- define ('DEFAULT_PARAGRAPH_TAGS', 'p');
51
-
52
  define ('AD_EMPTY_DATA', '');
53
  define ('AD_ZERO', '0');
54
  define ('AD_ONE', '1');
@@ -69,6 +66,7 @@ define ('AI_FOOTER_OPTION_NAME', 'f');
69
  define ('AI_OPTION_CODE', 'code');
70
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
71
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
 
72
 
73
  define ('AI_OPTION_NAME', 'name');
74
  define ('AI_OPTION_DISPLAY_TYPE', 'display_type');
@@ -107,6 +105,10 @@ define ('AI_OPTION_DISPLAY_FOR_USERS', 'display_for_users');
107
  define ('AI_OPTION_DISPLAY_FOR_DEVICES', 'display_for_devices');
108
  define ('AI_OPTION_DETECT_SERVER_SIDE', 'detect_server_side');
109
  define ('AI_OPTION_DETECT_CLIENT_SIDE', 'detect_client_side');
 
 
 
 
110
 
111
  define ('AI_OPTION_IMPORT', 'import');
112
 
@@ -114,8 +116,8 @@ define ('AI_OPTION_IMPORT', 'import');
114
  define('AD_EMPTY_VALUE','');
115
 
116
  //define constant variable form
117
- define('AD_FORM_SAVE','ad_save');
118
- define('AD_FORM_CLEAR','ad_clear');
119
 
120
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
121
  define('AD_SEPARATOR', '|rotate|');
@@ -125,7 +127,8 @@ define('AD_SELECT_SELECTED','selected');
125
 
126
  //Position options
127
  define('AD_SELECT_NONE','None');
128
- define('AD_SELECT_BEFORE_TITLE','Before Title');
 
129
  define('AD_SELECT_BEFORE_PARAGRAPH','Before Paragraph');
130
  define('AD_SELECT_AFTER_PARAGRAPH','After Paragraph');
131
  define('AD_SELECT_BEFORE_CONTENT','Before Content');
@@ -133,8 +136,9 @@ define('AD_SELECT_AFTER_CONTENT','After Content');
133
  define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
134
  define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
135
  define('AD_SELECT_WIDGET','Widget');
136
- // Deprecated
137
- define('AD_SELECT_MANUAL','Manual');
 
138
 
139
  //Display options
140
  define('AD_DISPLAY_ALL_USERS','all');
@@ -179,3 +183,18 @@ define('AD_DO_NOT_CONTAIN','do not contain');
179
  //Settings
180
  define('AD_SETTINGS_CHECKED', '1');
181
  define('AD_SETTINGS_NOT_CHECKED', '0');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  define ('AD_INSERTER_TITLE', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '1.6.5');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
18
 
19
+ if (!defined ('AD_INSERTER_VIEWPORTS'))
20
+ define ('AD_INSERTER_VIEWPORTS', 3);
21
+
22
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
23
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
24
 
46
  if (!defined ('WP_PLUGIN_DIR'))
47
  define ('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
48
 
 
 
 
 
 
 
49
  define ('AD_EMPTY_DATA', '');
50
  define ('AD_ZERO', '0');
51
  define ('AD_ONE', '1');
66
  define ('AI_OPTION_CODE', 'code');
67
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
68
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
69
+ define ('AI_OPTION_ENABLE_404', 'enable_404');
70
 
71
  define ('AI_OPTION_NAME', 'name');
72
  define ('AI_OPTION_DISPLAY_TYPE', 'display_type');
105
  define ('AI_OPTION_DISPLAY_FOR_DEVICES', 'display_for_devices');
106
  define ('AI_OPTION_DETECT_SERVER_SIDE', 'detect_server_side');
107
  define ('AI_OPTION_DETECT_CLIENT_SIDE', 'detect_client_side');
108
+ define ('AI_OPTION_DETECT_VIEWPORT', 'detect_viewport');
109
+ define ('AI_OPTION_BEFORE_PROCESSING', 'before_processing');
110
+ define ('AI_OPTION_AFTER_PROCESSING', 'after_processing');
111
+ define ('AI_OPTION_DISABLED', 'disabled');
112
 
113
  define ('AI_OPTION_IMPORT', 'import');
114
 
116
  define('AD_EMPTY_VALUE','');
117
 
118
  //define constant variable form
119
+ define('AI_FORM_SAVE','ai_save');
120
+ define('AI_FORM_CLEAR','ai_clear');
121
 
122
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
123
  define('AD_SEPARATOR', '|rotate|');
127
 
128
  //Position options
129
  define('AD_SELECT_NONE','None');
130
+ define('AD_SELECT_BEFORE_POST','Before Post');
131
+ define('AD_SELECT_AFTER_POST','After Post');
132
  define('AD_SELECT_BEFORE_PARAGRAPH','Before Paragraph');
133
  define('AD_SELECT_AFTER_PARAGRAPH','After Paragraph');
134
  define('AD_SELECT_BEFORE_CONTENT','Before Content');
136
  define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
137
  define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
138
  define('AD_SELECT_WIDGET','Widget');
139
+
140
+ define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
141
+ define('AD_SELECT_MANUAL','Manual'); // Deprecated
142
 
143
  //Display options
144
  define('AD_DISPLAY_ALL_USERS','all');
183
  //Settings
184
  define('AD_SETTINGS_CHECKED', '1');
185
  define('AD_SETTINGS_NOT_CHECKED', '0');
186
+
187
+ define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
188
+ define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
189
+ define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
190
+ define ('DEFAULT_PLUGIN_PRIORITY', 99999);
191
+ define ('DEFAULT_PARAGRAPH_TAGS', 'p');
192
+ define ('DEFAULT_TAG_DEBUGGING', AI_OPTION_DISABLED);
193
+
194
+ define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
195
+ define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
196
+ define ('DEFAULT_VIEWPORT_NAME_3', "Phone");
197
+
198
+ define ('DEFAULT_VIEWPORT_WIDTH_1', 980);
199
+ define ('DEFAULT_VIEWPORT_WIDTH_2', 768);
200
+ define ('DEFAULT_VIEWPORT_WIDTH_3', 0);
css/viewports.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Ad Inserter version 1.6.5 - viewport classes */
2
+
3
+ /* DO NOT MODIFY - This file is automatically generated when you save Ad Inserter settings */
4
+
5
+ /* Desktop */
6
+
7
+ .ai-viewport-3 { display: none !important;}
8
+ .ai-viewport-2 { display: none !important;}
9
+ .ai-viewport-1 { display: inherit !important;}
10
+ .ai-viewport-0 { display: none !important;}
11
+
12
+ /* Tablet */
13
+
14
+ @media (min-width: 768px) and (max-width: 979px) {
15
+ .ai-viewport-1 { display: none !important;}
16
+ .ai-viewport-2 { display: inherit !important;}
17
+ }
18
+
19
+ /* Phone */
20
+
21
+ @media (max-width: 767px) {
22
+ .ai-viewport-1 { display: none !important;}
23
+ .ai-viewport-3 { display: inherit !important;}
24
+ }
25
+
js/ad-inserter.js CHANGED
@@ -26,7 +26,7 @@ function SyntaxHighlight (id, block, settings) {
26
  // height: textarea.height(),
27
  height: 384,
28
  'class': textarea.attr('class'),
29
- 'id': 'editor_' + block
30
  }).insertBefore (textarea);
31
 
32
  textarea.css('display', 'none');
@@ -37,7 +37,7 @@ function SyntaxHighlight (id, block, settings) {
37
 
38
  // copy back to textarea on form submit...
39
  form.submit (function () {
40
- var block = textarea.attr ("id").replace ("block_","");
41
  var editor_disabled = jQuery("#simple-editor-" + block).is(":checked");
42
  if (!editor_disabled) {
43
  textarea.val (session.getValue());
@@ -65,9 +65,12 @@ SyntaxHighlight.prototype.applySettings = function () {
65
 
66
  jQuery(document).ready(function($) {
67
 
 
 
 
68
  function configure_editor_language (block) {
69
 
70
- var editor = ace.edit ("editor_" + block);
71
 
72
  if ($("input#process-php-"+block).is(":checked")) {
73
  editor.getSession ().setMode ("ace/mode/php");
@@ -78,8 +81,7 @@ jQuery(document).ready(function($) {
78
 
79
  $("#paragraph-settings-"+block).hide();
80
 
81
- $("#excerpt-settings-"+block).hide();
82
- // $("#enabled-pages-"+block).hide();
83
 
84
  var display_type = '';
85
  $("select#display-type-"+block+" option:selected").each(function() {
@@ -87,23 +89,22 @@ jQuery(document).ready(function($) {
87
  });
88
  if (display_type == "Before Paragraph" || display_type == "After Paragraph") {
89
  $("#paragraph-settings-"+block).show();
 
 
 
 
 
90
  }
91
  if (display_type == "Before Excerpt" || display_type == "After Excerpt") {
92
  $("#paragraph-settings-"+block).hide();
93
- $("#excerpt-settings-"+block).show();
94
  }
95
- // if (display_type == "Before Excerpt" || display_type == "After Excerpt" || display_type == "Before Title" || display_type == "Widget" || $("#enable-php-call-"+block).is(":checked") || $("#enable-manual-"+block).is(":checked")) {
96
- // $("#enabled-pages-"+block).show();
97
- // }
98
 
99
- var display_for_devices = '';
100
- $("select#display-for-devices-"+block+" option:selected").each(function() {
101
- display_for_devices += $(this).text();
102
- });
103
- if (display_for_devices == "all") {
104
- $("#detection-type-"+block).hide();
105
- } else $("#detection-type-"+block).show();
106
 
 
107
  $("#custom-css-"+block).hide();
108
 
109
  var alignment = '';
@@ -112,22 +113,35 @@ jQuery(document).ready(function($) {
112
  });
113
  if (alignment == "Custom CSS") {
114
  $("#custom-css-"+block).show();
 
 
 
115
  }
116
 
117
  configure_editor_language (block);
118
  }
119
 
120
  function configure_editor (block) {
121
- syntax_highlighter = new SyntaxHighlight ('#block_' + block, block, shSettings);
122
  syntax_highlighter.editor.setPrintMarginColumn (1000);
123
 
 
 
 
 
 
 
 
 
 
 
124
  $('input#simple-editor-' + block).change (function () {
125
 
126
  block = $(this).attr ("id").replace ("simple-editor-","");
127
  var editor_disabled = $(this).is(":checked");
128
- var editor = ace.edit ("editor_" + block);
129
- var textarea = $("#block_" + block);
130
- var ace_editor = $("#editor_" + block);
131
 
132
  if (editor_disabled) {
133
  textarea.val (editor.session.getValue());
@@ -142,22 +156,23 @@ jQuery(document).ready(function($) {
142
  });
143
  }
144
 
145
- blocks = $('#ad_form').attr('blocks');
146
 
147
  for (block = 1; block <= blocks; block ++) {
148
  configure_editor (block);
149
  }
 
150
  configure_editor ('h');
151
  configure_editor ('f');
152
 
153
- $('#ai-tabs').tabs();
154
 
155
- $('#ai-tabs a').css ("width", "14px").css ("text-align", "center");
156
- $('#ad-tabs').css ("padding", ".2em 0 0 .6em");
157
 
158
  var active_tab = $("#ai-active-tab").attr ("value");
159
- var tab_index = $('#ai-tabs a[href="#tab-'+active_tab+'"]').parent().index();
160
- $("#ai-tabs").tabs("option", "active", tab_index);
161
 
162
  $('.ai-tab').click (function () {
163
  tab_index = $(this).attr ("id");
@@ -165,7 +180,7 @@ jQuery(document).ready(function($) {
165
  $("#ai-active-tab").attr ("value", tab_index);
166
 
167
  if (tab_index != 0) {
168
- var editor = ace.edit ("editor_" + tab_index);
169
  editor.getSession ().highlightLines (10000000);
170
  }
171
  });
@@ -179,7 +194,7 @@ jQuery(document).ready(function($) {
179
  $('#ai-settings').tooltip();
180
 
181
  $('#dummy-tabs').hide();
182
- $('#ad-tabs').show();
183
 
184
  $('#ai-settings input[type=submit], #ai-settings button').button().show ();
185
 
@@ -208,9 +223,32 @@ jQuery(document).ready(function($) {
208
  block = $(this).attr('id').replace ("display-for-devices-", "");
209
  process_display_elements (block);
210
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  process_display_elements (ad_block);
212
 
213
- $("#export_switch_"+ad_block).button ({
214
  icons: {
215
  primary: "ui-icon-gear",
216
  secondary: "ui-icon-triangle-1-s"
@@ -218,19 +256,34 @@ jQuery(document).ready(function($) {
218
  text: false
219
  }).show ().click (function () {
220
  tab_index = $(this).attr ("id");
221
- tab_index = tab_index.replace ("export_switch_","");
222
- $("#export_container_" + tab_index).toggle ();
223
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  }
225
 
226
- $("#export_switch_0").button ({
227
  icons: {
228
  primary: "ui-icon-gear",
229
  secondary: "ui-icon-triangle-1-s"
230
  },
231
  text: false
232
  }).show ().click (function () {
233
- $("#export_container_0").toggle ();
234
  });
235
 
236
  $("input#process-php-h").change (function() {
26
  // height: textarea.height(),
27
  height: 384,
28
  'class': textarea.attr('class'),
29
+ 'id': 'editor-' + block
30
  }).insertBefore (textarea);
31
 
32
  textarea.css('display', 'none');
37
 
38
  // copy back to textarea on form submit...
39
  form.submit (function () {
40
+ var block = textarea.attr ("id").replace ("block-","");
41
  var editor_disabled = jQuery("#simple-editor-" + block).is(":checked");
42
  if (!editor_disabled) {
43
  textarea.val (session.getValue());
65
 
66
  jQuery(document).ready(function($) {
67
 
68
+ var header = $('#ai_settings_header').length != 0;
69
+ var header_id = 'name';
70
+
71
  function configure_editor_language (block) {
72
 
73
+ var editor = ace.edit ("editor-" + block);
74
 
75
  if ($("input#process-php-"+block).is(":checked")) {
76
  editor.getSession ().setMode ("ace/mode/php");
81
 
82
  $("#paragraph-settings-"+block).hide();
83
 
84
+ $("#blog-page-settings-"+block).hide();
 
85
 
86
  var display_type = '';
87
  $("select#display-type-"+block+" option:selected").each(function() {
89
  });
90
  if (display_type == "Before Paragraph" || display_type == "After Paragraph") {
91
  $("#paragraph-settings-"+block).show();
92
+ if ($("#display-homepage-"+block).is(":checked") ||
93
+ $("#display-category-"+block).is(":checked") ||
94
+ $("#display-search-"+block).is(":checked") ||
95
+ $("#display-archive-"+block).is(":checked"))
96
+ $("#blog-page-settings-"+block).show();
97
  }
98
  if (display_type == "Before Excerpt" || display_type == "After Excerpt") {
99
  $("#paragraph-settings-"+block).hide();
100
+ $("#blog-page-settings-"+block).show();
101
  }
 
 
 
102
 
103
+ if ($("#enable-php-call-"+block).is(":checked")) {
104
+ $("#blog-page-settings-"+block).show();
105
+ }
 
 
 
 
106
 
107
+ $("#no-wrapping-warning").hide();
108
  $("#custom-css-"+block).hide();
109
 
110
  var alignment = '';
113
  });
114
  if (alignment == "Custom CSS") {
115
  $("#custom-css-"+block).show();
116
+ } else
117
+ if (alignment == "No Wrapping" && $("#client-side-detection-"+block).is(":checked")) {
118
+ $("#no-wrapping-warning").show();
119
  }
120
 
121
  configure_editor_language (block);
122
  }
123
 
124
  function configure_editor (block) {
125
+ syntax_highlighter = new SyntaxHighlight ('#block-' + block, block, shSettings);
126
  syntax_highlighter.editor.setPrintMarginColumn (1000);
127
 
128
+ if (!header && (block - 1) >> 4) {
129
+ $('#block' + '-' + block).removeAttr(header_id);
130
+ $('#display' + '-type-' + block).removeAttr(header_id);
131
+ }
132
+
133
+ if (!header && block >> 2) {
134
+ $('#option' + '-name-' + block).removeAttr(header_id);
135
+ $('#option' + '-length-' + block).removeAttr(header_id);
136
+ }
137
+
138
  $('input#simple-editor-' + block).change (function () {
139
 
140
  block = $(this).attr ("id").replace ("simple-editor-","");
141
  var editor_disabled = $(this).is(":checked");
142
+ var editor = ace.edit ("editor-" + block);
143
+ var textarea = $("#block-" + block);
144
+ var ace_editor = $("#editor-" + block);
145
 
146
  if (editor_disabled) {
147
  textarea.val (editor.session.getValue());
156
  });
157
  }
158
 
159
+ var blocks = $('#ai-form').attr('blocks');
160
 
161
  for (block = 1; block <= blocks; block ++) {
162
  configure_editor (block);
163
  }
164
+
165
  configure_editor ('h');
166
  configure_editor ('f');
167
 
168
+ $('#ai-tab-container').tabs();
169
 
170
+ $('#ai-tab-container a').css ("width", "14px").css ("text-align", "center");
171
+ $('#ai-tabs').css ("padding", ".2em 0 0 .6em");
172
 
173
  var active_tab = $("#ai-active-tab").attr ("value");
174
+ var tab_index = $('#ai-tab-container a[href="#tab-'+active_tab+'"]').parent().index();
175
+ $("#ai-tab-container").tabs("option", "active", tab_index);
176
 
177
  $('.ai-tab').click (function () {
178
  tab_index = $(this).attr ("id");
180
  $("#ai-active-tab").attr ("value", tab_index);
181
 
182
  if (tab_index != 0) {
183
+ var editor = ace.edit ("editor-" + tab_index);
184
  editor.getSession ().highlightLines (10000000);
185
  }
186
  });
194
  $('#ai-settings').tooltip();
195
 
196
  $('#dummy-tabs').hide();
197
+ $('#ai-tabs').show();
198
 
199
  $('#ai-settings input[type=submit], #ai-settings button').button().show ();
200
 
223
  block = $(this).attr('id').replace ("display-for-devices-", "");
224
  process_display_elements (block);
225
  });
226
+
227
+ $("#display-homepage-"+ad_block).change (function() {
228
+ block = $(this).attr('id').replace ("display-homepage-", "");
229
+ process_display_elements (block);
230
+ });
231
+ $("#display-category-"+ad_block).change (function() {
232
+ block = $(this).attr('id').replace ("display-category-", "");
233
+ process_display_elements (block);
234
+ });
235
+ $("#display-search-"+ad_block).change (function() {
236
+ block = $(this).attr('id').replace ("display-search-", "");
237
+ process_display_elements (block);
238
+ });
239
+ $("#display-archive-"+ad_block).change (function() {
240
+ block = $(this).attr('id').replace ("display-archive-", "");
241
+ process_display_elements (block);
242
+ });
243
+
244
+ $("#client-side-detection-"+ad_block).change (function() {
245
+ block = $(this).attr('id').replace ("client-side-detection-", "");
246
+ process_display_elements (block);
247
+ });
248
+
249
  process_display_elements (ad_block);
250
 
251
+ $("#export-switch-"+ad_block).button ({
252
  icons: {
253
  primary: "ui-icon-gear",
254
  secondary: "ui-icon-triangle-1-s"
256
  text: false
257
  }).show ().click (function () {
258
  tab_index = $(this).attr ("id");
259
+ tab_index = tab_index.replace ("export-switch-","");
260
+ $("#export-container-" + tab_index).toggle ();
261
  });
262
+
263
+ $("#device-detection-button-"+ad_block).button ({
264
+ }).show ().click (function () {
265
+ tab_index = $(this).attr ("id");
266
+ tab_index = tab_index.replace ("device-detection-button-","");
267
+ $("#device-detection-container-" + tab_index).toggle ();
268
+ });
269
+
270
+ $("#lists-button-"+ad_block).button ({
271
+ }).show ().click (function () {
272
+ tab_index = $(this).attr ("id");
273
+ tab_index = tab_index.replace ("lists-button-","");
274
+ $("#lists-container-" + tab_index).toggle ();
275
+ });
276
+
277
  }
278
 
279
+ $("#export-switch-0").button ({
280
  icons: {
281
  primary: "ui-icon-gear",
282
  secondary: "ui-icon-triangle-1-s"
283
  },
284
  text: false
285
  }).show ().click (function () {
286
+ $("#export-container-0").toggle ();
287
  });
288
 
289
  $("input#process-php-h").change (function() {
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Ad Inserter ===
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
- Tags: adsense, amazon, clickbank, ad, ads, html, javascript, php, code, widget, sidebar, responsive, rotating, banner, banner rotation, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 3.0
6
- Tested up to: 4.5.2
7
- Stable tag: 1.6.3
8
  License: GPLv3
9
 
10
  Insert any HTML/Javascript/PHP code into Wordpress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.
@@ -15,17 +15,44 @@ Need to install ads or widgets on Wordpress website?
15
 
16
  Ad Inserter is a simple yet powerful solution to insert any code into Wordpress. **Perfect for AdSense or contextual Amazon ads.** Simply enter any HTML/Javascript/PHP code and select where and how you want to display it.
17
 
 
 
18
  Automatic Display Options:
19
 
 
20
  * Display Before Content (before post or page text)
21
- * Display Before Selected Paragraph
22
- * Display After Selected Paragraph
23
  * Display After Content (after post or page text)
24
- * Display Before Title (does not work with all themes)
25
  * Display Before Excerpt (on blog pages)
26
  * Display After Excerpt (on blog pages)
27
 
28
- Paragraph number for Automatic Display Options Before and After Paragraph:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  * 0 means random paragraph position
31
  * value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
@@ -33,15 +60,18 @@ Paragraph number for Automatic Display Options Before and After Paragraph:
33
 
34
  Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain/do not contain certain text or count only paragraphs that have some minimum number of words. If more than one text is defined (comma separated) and "contain" is selected then the paragraph must contain ALL texts.
35
 
36
- You can also define paragraph tags. Normally only `<p>` tags are used. If you post contains also `<div>` or header tags you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
37
- **WARNING:** Each code block you insert on post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
38
- **After Paragraph** will not work if you specify tag names that have no closing tags!
 
 
39
 
40
  Additional Display Options:
41
 
42
- * As a Widget - Simply drag **Ad Inserter** widget to any postition, select code block and you're done
43
- * Manual - Insert shortcode [adinserter block="BLOCK_NUMBER"] or [adinserter name="BLOCK_NAME"] into post or page HTML code to display block with BLOCK_NAME name or BLOCK_NUMBER number at this position
44
- * PHP function call `<?php if (function_exists ('adinserter')) echo adinserter (BLOCK_NUMBER); ?>` - Insert code block BLOCK_NUMBER at any position in template file
 
45
 
46
  Additional Options:
47
 
@@ -55,39 +85,49 @@ Display Block to:
55
  * Logged in users
56
  * Not logged in users
57
 
58
- on:
59
 
60
- * All devices (default)
61
- * Desktop devices
62
- * Mobile devices (tablets and phones)
63
- * Tablet devices
64
- * Phone devices
65
- * Desktop and tablet devices
66
- * Desktop and phone devices
67
 
68
- device type detection:
69
 
70
- * Server-side
71
- * Client-side (default)
72
 
73
- **IMPORTANT:** There are two types of device detection (desktop, tablet or phone): **server side** and **client-side**.
 
 
74
 
75
- **Server-side** detection of mobile/desktop devices works only when Ad Inserter plugin is called. It is called by Wordpress when it needs to generate a page. However, when you are using caching, it saves created page for quicker serving. In such cases **the user might get (saved) page for wrong device**. To solve this issue use themes that generate separate pages for desktop and mobile devices or use Mobile Theme Switcher plugin.
76
 
77
- **PLEASE NOTE:** Use server-side device type detection only when you need to generate code blocks based on device type. In all other cases switch it off.
78
 
79
- **Client-side** detection of mobile/desktop devices works always as it is done in visitor's browser. CSS media queries and browser's screen width are used to show or hide Ad Inserter code blocks:
80
 
81
  * Desktop: 980 pixels or more
82
  * Tablet: from 768 pixels to 979 pixels
83
  * Phone: less than 768 pixels
84
 
85
- **PLEASE NOTE:** In most cases you should use **ONLY client-side** detection type. Works perfectly with responsive designs as they use CSS media queries.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  Block Alignment and Style:
88
 
89
  * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
90
- * Custom CSS (Custom CSS code for wrapping div)
91
  * None (simple div with thin margin)
92
  * Align Left
93
  * Align Right
@@ -97,16 +137,15 @@ Block Alignment and Style:
97
 
98
  Check <a href="https://wordpress.org/plugins/ad-inserter/screenshots/">screenshots</a> for explanation on alignment.
99
 
100
- **PLEASE NOTE:** If you are using **No Wrapping** style and need to hide code on some devices using client-side detection (CSS Media Queries) then you need to add appropriate class to your CSS code (ai-desktop, ai-tablet, ai-phone, ai-desktop-tablet, ai-desktop-phone or ai-tablet-phone).
 
101
 
102
  PHP processing: Enabled or Disabled
 
103
 
104
  Do not display ad if the number of paragraphs or the number of words is below limit (used only for position Before or After selected paragraph).
105
 
106
- Display ad only for posts published after N days.
107
-
108
- Do not display ads to users from certain referers (domains) e.g technorati.com, facebook.com,... (black list) or display ads only for certain referrers (white list). Use # for no referer (direct visit).
109
- Leave referrers list empty and set it to Black list to show ads for all referrers.
110
 
111
  Do not display ads in certain caregories e.g sport, news, science,... (black list) or display ads only in certain categories (white list).
112
  Leave category list empty and set it to Black list to show ads in all categories.
@@ -115,33 +154,43 @@ Leave category list empty and set it to Black list to show ads in all categories
115
  Do not display ads in posts with certain tags (black list) or display ads only in posts with certain tags (white list). Leave tag list empty and set it to Black list to show ads for all tags. Also make sure you have enabled display on **Archive pages**.
116
 
117
  Do not display ads on pages with certain urls (black list) or display ads only pages with certain urls (white list). Leave url list empty and set it to Black list to show ads on all urls.
 
118
  You can also use partial urls with *. To filter all urls starting with /url-start use `/url-start*`, to filter all urls that contain url-pattern use `*url-pattern*`, to filter all urls ending with url-end use `*url-end`.
119
  **WARNING:** Separate urls with SPACES.
120
 
 
 
 
 
 
121
  For all display positions you can also define Wordpress page types where the ads can be displayed:
122
 
 
 
123
  * Posts
124
  * Pages
125
 
126
  You can also disable ads on certain posts or pages. For each code block on posts or pages you first define default display settings. Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below). Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content).
127
 
128
- For display positions Before Excerpt, After Excerpt, Before Title and Widget you can select additional pages where the ads can be displayed:
129
 
130
  * Homepage
131
  * Category pages
132
  * Search Pages
133
  * Archive pages
134
 
135
- For display positions Before Excerpt and After Excerpt you can also specify comma separated list of excerpt numbers (1 - 9).
 
 
136
 
137
- Ad Inserter is perfect for displaying AdSense or Amazon ads. It can also be used to display various versions of <a href="https://support.google.com/adsense/answer/65083?ctx=as2&rd=2&ref_topic=23389">AdSense ads using channels</a> to test which format or color combination performs best.
138
 
139
  Support for Special Code Blocks:
140
 
141
  * Header scripts (tab #, scripts in the `<header>` section)
142
  * Footer scripts (tab #, scripts before the `</body>` tag)
143
 
144
- Wrapping divs for code blocks have 'code-block' and 'code-block-N' classes which can be used for custom styles. Class name 'code-block' can be changed in Ad Inserter settings. If you are using client-side device detection (CSS media queries) then the wrapping div for the code block will have also one of the following classes: ai-desktop, ai-tablet, ai-phone, ai-desktop-tablet, ai-desktop-phone or ai-tablet-phone.
145
 
146
  To configure syntax highlighting go to Ad Inserter Settings (tab #) and choose theme.
147
 
@@ -155,6 +204,18 @@ Default Ad Inserter plugin processing order is 99999. It is used to specify the
155
 
156
  **WARNING:** Text selection, Copy and Paste functions with the syntax highlighting editor do not work on mobile devices. If you need these functions you can temporarily swich to **Simple editor** using the checkbox above the code box.
157
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  == Installation ==
159
 
160
  Automatic installation: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
@@ -165,6 +226,18 @@ Manual installation:
165
  2. Activate the plugin through the 'Plugins' menu in WordPress
166
  3. Access Setting / Ad Inserter to configure it
167
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  == Frequently Asked Questions ==
169
 
170
  = I have activated Ad Inserter. How can I use it? =
@@ -175,15 +248,58 @@ Manual installation:
175
  4. Save settings.
176
 
177
 
178
- = How can I replace deprecated widgets with the new one? =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
- 0. This is needed ONLY if you have used widgets with Ad Inserter version 1.4.1 or older
181
- 1. Locate all code blocks that are configured as widgets.
182
- 2. Locate all widget positions (sidebars) where you have the old Ad Inserter widgets (warning message should list them).
183
- 3. Drag new "Ad Inserter" widget to the position where there is the old, deprecated widget.
184
- 4. Select code block for this widget to be the same as it is for the old one.
185
- 5. Drag the old, deprecated widget to the left to remove it.
186
- 6. Replace steps for all old widgets.
187
 
188
 
189
  = How can I replace deprecated tags {adinserter n} for manual insertion with new ones [adinserter block="n"] in all posts? =
@@ -212,22 +328,14 @@ In most cases you should use ONLY client-side detection. All code blocks are gen
212
 
213
  = How can I disable ads for direct visitors? =
214
 
215
- Blacklist `#` as referer.
216
-
 
217
 
218
- = How can I disable ads on 404 page? =
219
 
220
- Use the following PHP code (check Process PHP):
221
 
222
- `<?php
223
- if (!is_404()) {
224
- ?>
225
-
226
- AD CODE
227
-
228
- <?php
229
- }
230
- ?>`
231
 
232
 
233
  = How can I enable or disable ads on group of similar pages? =
@@ -241,6 +349,8 @@ Use `*` to define url pattern to whitelist (enable) or blacklist (disable).
241
 
242
  For example, to exclude ads on pages that have /shop/ in url (page address) blacklist the following url: `*/shop/*`
243
 
 
 
244
 
245
  = How can I put an ad in the middle of the post regardless of the number of paragraphs? =
246
 
@@ -295,7 +405,7 @@ Some HTML/Javascript code
295
  * {short_title} - Short title (first 3 words) of the post title
296
  * {category} - Category of the post (or short title if there is no category)
297
  * {short_category} - First words before "," or "and" of the category of the post (or short title if there is no category)
298
- * {tag} - The first tag or general tag if the post has no tags
299
  * {smart_tag} - Smart selection of post tag in the following order:
300
  * If there is no tag then the category is used;
301
  * If there is a two-word tag then it is used;
@@ -304,6 +414,8 @@ Some HTML/Javascript code
304
  * First three words of the first tag
305
  * General tag
306
  * {search_query} - Search engine query that brought visitor to your website (supports Google, Yahoo, Bing and Ask search engines), {smart_tag} is used when there is no search query. You need to disable caching to use this tag. Please note that most search queries are now encrypted.
 
 
307
 
308
 
309
  = How can I rotate few versions of the same ad? =
@@ -326,6 +438,8 @@ Configure ad block with the following options:
326
  * Paragraph Number: 1
327
  * Count only paragraphs that CONTAIN: `<span id="more-`
328
 
 
 
329
 
330
  = How can I insert code block directly into template php file? =
331
 
@@ -340,49 +454,26 @@ This would generate code as defined for the code block number 3.
340
  = How can I create contextual Amazon ad (to show items related to the post)? =
341
 
342
  Sign in to Amazon Associates, go to Widgets/Widget Source, choose ad type and set parameters.
343
- For titles and search terms use tags. For example, the code below would display 5 amazon items related to the post tag - check above for all possible tags.
344
-
345
- `<div style="height: 531px;">
346
- <script type="text/javascript">
347
- var amzn_wdgt={widget:"Search"};
348
- amzn_wdgt.tag="ad-inserter-20";
349
- amzn_wdgt.columns="1";
350
- amzn_wdgt.rows="5";
351
- amzn_wdgt.defaultSearchTerm="{smart_tag}";
352
- amzn_wdgt.searchIndex="All";
353
- amzn_wdgt.width="300";
354
- amzn_wdgt.showImage="True";
355
- amzn_wdgt.showPrice="True";
356
- amzn_wdgt.showRating="True";
357
- amzn_wdgt.design="2";
358
- amzn_wdgt.colorTheme="Default";
359
- amzn_wdgt.headerTextColor="#0000AA";
360
- amzn_wdgt.outerBackgroundColor="#FFFFFF";
361
- amzn_wdgt.borderColor="#FFFFFF";
362
- amzn_wdgt.marketPlace="US";
363
- </script>
364
- <script type="text/javascript" src="http://wms.assoc-amazon.com/20070822/US/js/AmazonWidgets.js">
365
  </script>
366
- </div>`
367
-
368
-
369
- Another example for nice contextual carousel below posts:
370
-
371
- `<div style="overflow: auto; width: 100%;">
372
- <script type='text/javascript'>
373
- var amzn_wdgt={widget:'Carousel'};
374
- amzn_wdgt.tag='ad-inserter-20';
375
- amzn_wdgt.widgetType='SearchAndAdd';
376
- amzn_wdgt.searchIndex='All';
377
- amzn_wdgt.keywords='{smart_tag}';
378
- amzn_wdgt.title='{title}';
379
- amzn_wdgt.width='460';
380
- amzn_wdgt.height='250';
381
- amzn_wdgt.marketPlace='US';
382
- </script>
383
- <script type='text/javascript' src='http://wms.assoc-amazon.com/20070822/US/js/swfobject_1_5.js'>
384
- </script>
385
- </div>`
386
 
387
 
388
  = Center alignment does not work for some ads! =
@@ -427,6 +518,18 @@ AD CODE RIGHT
427
 
428
  == Changelog ==
429
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  = 1.6.4 =
431
  - Fixed bug: For shortcodes in posts the url was not checked
432
  - Optimizations for device detection
@@ -600,6 +703,17 @@ AD CODE RIGHT
600
 
601
  == Upgrade Notice ==
602
 
 
 
 
 
 
 
 
 
 
 
 
603
  = 1.6.4 =
604
  Fixed bug: For shortcodes in posts the url was not checked;
605
  Optimizations for device detection
1
  === Ad Inserter ===
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
+ Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, banner rotation, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 3.0
6
+ Tested up to: 4.5.3
7
+ Stable tag: 1.6.4
8
  License: GPLv3
9
 
10
  Insert any HTML/Javascript/PHP code into Wordpress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.
15
 
16
  Ad Inserter is a simple yet powerful solution to insert any code into Wordpress. **Perfect for AdSense or contextual Amazon ads.** Simply enter any HTML/Javascript/PHP code and select where and how you want to display it.
17
 
18
+ Please make sure you have read **WARNINGS** on the bottom of this page!
19
+
20
  Automatic Display Options:
21
 
22
+ * Display Before Post (before post or posts on blog pages, previously named Before Title)
23
  * Display Before Content (before post or page text)
24
+ * Display Before Paragraph (on posts, pages and blog pages)
25
+ * Display After Paragraph (on posts, pages and blog pages)
26
  * Display After Content (after post or page text)
27
+ * Display After Post (after post or posts on blog pages)
28
  * Display Before Excerpt (on blog pages)
29
  * Display After Excerpt (on blog pages)
30
 
31
+ For single posts or pages display position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
32
+
33
+ For single posts or pages display position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.
34
+
35
+ Order of display positions in a typical post is the following:
36
+
37
+ * [Before Post]
38
+ * Post Title
39
+ * [Before Content]
40
+ * Paragraph 1
41
+ * Paragraph 2
42
+ * Paragraph ...
43
+ * Paragraph n - 1
44
+ * Paragraph n
45
+ * [After Content]
46
+ * Comments
47
+ * Output of some other plugins
48
+ * [After Post]
49
+
50
+ Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab #).
51
+
52
+ **Please Note** Paragraph processing works on **every** post or page according to settings. Therefore, if you enable display also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts,
53
+ Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings). To enable insertion only into specific post(s) on blog pages define Excerpt/Post number(s). You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.
54
+
55
+ Paragraph number for Automatic Display options Before and After Paragraph:
56
 
57
  * 0 means random paragraph position
58
  * value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
60
 
61
  Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain/do not contain certain text or count only paragraphs that have some minimum number of words. If more than one text is defined (comma separated) and "contain" is selected then the paragraph must contain ALL texts.
62
 
63
+ You can also define paragraph HTML tags. Normally only `<p>` tags are used. If your post contains also `<div>` or header tags, you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
64
+ **WARNING:** Each code block you insert in post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
65
+ **After Paragraph** will not work if you specify tag names that have no closing tags! Use # as tag separator if paragraphs have no tags and are separated with the \r\n\r\n characters.
66
+
67
+ On the Ad Inserter settings page (tab #) you also have option Tag Debugging. If enabled, it displays paragraph tags surrounded with a border. This way you can check where your code will be inserted. You can select to show paragraph tags before or after plugin processing. If Before Processing is selected Ad Inserter WILL NOT insert any code!
68
 
69
  Additional Display Options:
70
 
71
+ * As a Widget - Simply drag **Ad Inserter** widget to any widget postition, select code block and you're done.
72
+ * Manual - Insert shortcode [adinserter block="BLOCK_NUMBER"] or [adinserter name="BLOCK_NAME"] into post or page HTML code to display block with BLOCK_NAME name or BLOCK_NUMBER number at this position.
73
+ * PHP function call `<?php if (function_exists ('adinserter')) echo adinserter (BLOCK_NUMBER); ?>` - Insert code block BLOCK_NUMBER at any position in template file. With PHP function call counter (Excerpt/Post number) you can also define which call(s) to the function will actually insert code.
74
+ This is useful if you put a call to the `adinserter` function inside a loop in a template file (e.g. for homepage) and you need to insert ads only few times between posts.
75
 
76
  Additional Options:
77
 
85
  * Logged in users
86
  * Not logged in users
87
 
88
+ **WARNING:** If you are using caching this may not work as expected. The check works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
89
 
90
+ Devices:
 
 
 
 
 
 
91
 
92
+ **IMPORTANT:** There are two types of device detection: **server side** and **client-side**.
93
 
94
+ **Client-side** detection
 
95
 
96
+ * Desktop devices
97
+ * Tablet devices
98
+ * Phone devices
99
 
100
+ **Client-side** detection of mobile/desktop devices works always as it is done in visitor's browser. CSS media queries and viewport (browser's screen) width are used to show or hide Ad Inserter code blocks:
101
 
102
+ **PLEASE NOTE:** In most cases you should use **ONLY client-side** detection type. Works perfectly with responsive designs as they use CSS media queries.
103
 
104
+ Up to 3 viewport names and widths can be defined on the Ad Inserter Settings tab (#). Default values are:
105
 
106
  * Desktop: 980 pixels or more
107
  * Tablet: from 768 pixels to 979 pixels
108
  * Phone: less than 768 pixels
109
 
110
+
111
+ **Server-side** detection
112
+
113
+ * Desktop devices
114
+ * Mobile devices (tablets and phones)
115
+ * Tablet devices
116
+ * Phone devices
117
+ * Desktop and tablet devices
118
+ * Desktop and phone devices
119
+
120
+ **Server-side** detection of mobile/desktop devices works only when Ad Inserter plugin is called. It is called by Wordpress when it needs to generate a page. However, when you are using caching, it saves created page for quicker serving.
121
+ In such cases **the user might get (saved) page for wrong device**. To solve this issue use themes that generate separate pages for desktop and mobile devices or use Mobile Theme Switcher plugin.
122
+ Server-side detection uses User-Agent string combined with specific HTTP headers to detect the environment.
123
+
124
+ **PLEASE NOTE:** Use server-side device type detection only when you need to generate ONLY code blocks for specific device type. In all other cases switch it off.
125
+
126
 
127
  Block Alignment and Style:
128
 
129
  * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
130
+ * Custom CSS (You can define custom CSS code for wrapping div)
131
  * None (simple div with thin margin)
132
  * Align Left
133
  * Align Right
137
 
138
  Check <a href="https://wordpress.org/plugins/ad-inserter/screenshots/">screenshots</a> for explanation on alignment.
139
 
140
+ **PLEASE NOTE:** If you are using **No Wrapping** style and need to hide code on some devices using client-side detection (CSS Media Queries) then you need to add appropriate class to your CSS code (ai-viewport-1, ai-viewport-2, ai-viewport-3).
141
+ This doesn't apply to widgets as they always contain a wrapping div.
142
 
143
  PHP processing: Enabled or Disabled
144
+ Enable processing of PHP code. If there is an error in the PHP code, it will not break the website.
145
 
146
  Do not display ad if the number of paragraphs or the number of words is below limit (used only for position Before or After selected paragraph).
147
 
148
+ Display only for posts published after N days checks the date when the post was published.
 
 
 
149
 
150
  Do not display ads in certain caregories e.g sport, news, science,... (black list) or display ads only in certain categories (white list).
151
  Leave category list empty and set it to Black list to show ads in all categories.
154
  Do not display ads in posts with certain tags (black list) or display ads only in posts with certain tags (white list). Leave tag list empty and set it to Black list to show ads for all tags. Also make sure you have enabled display on **Archive pages**.
155
 
156
  Do not display ads on pages with certain urls (black list) or display ads only pages with certain urls (white list). Leave url list empty and set it to Black list to show ads on all urls.
157
+ Url used here is everything starting form the `/` after the domain name. For example: if web address is `http://domain.com/lorem-ipsum`, url to white/black-list is `/lorem-ipsum`
158
  You can also use partial urls with *. To filter all urls starting with /url-start use `/url-start*`, to filter all urls that contain url-pattern use `*url-pattern*`, to filter all urls ending with url-end use `*url-end`.
159
  **WARNING:** Separate urls with SPACES.
160
 
161
+ Do not display ads to users from certain referers (domains) e.g technorati.com, facebook.com,... (black list) or display ads only for certain referrers (white list). Use # for no referer (direct visit).
162
+ Leave referrers list empty and set it to Black list to show ads for all referrers.
163
+
164
+ **WARNING:** If you are using caching, referer check may not work as expected. It works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
165
+
166
  For all display positions you can also define Wordpress page types where the ads can be displayed:
167
 
168
+ Single pages:
169
+
170
  * Posts
171
  * Pages
172
 
173
  You can also disable ads on certain posts or pages. For each code block on posts or pages you first define default display settings. Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below). Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content).
174
 
175
+ Blog pages:
176
 
177
  * Homepage
178
  * Category pages
179
  * Search Pages
180
  * Archive pages
181
 
182
+ For blog pages and display positions Before Excerpt / After Excerpt and Before Post / After Post you can also specify excerpt/post number or comma separated list of excerpt/post numbers (1 - 9). You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.
183
+
184
+ By default code blocks will not be inserted on Error 404 page (Page Not Found). Check Error '404 Page checkbox' to enable code block on error 404 page.
185
 
186
+ Ad Inserter is perfect for displaying any kind of ads. It can also be used to display various versions of ad, for example <a href="https://support.google.com/adsense/answer/65083?ctx=as2&rd=2&ref_topic=23389" target="_blank">AdSense ads using channels</a> to test which format or color combination performs best.
187
 
188
  Support for Special Code Blocks:
189
 
190
  * Header scripts (tab #, scripts in the `<header>` section)
191
  * Footer scripts (tab #, scripts before the `</body>` tag)
192
 
193
+ Wrapping divs for code blocks have 'code-block' and 'code-block-N' classes which can be used for custom styles. Class name 'code-block' can be changed in Ad Inserter settings. If you are using client-side device detection (CSS media queries) then the wrapping div for the code block will have also some of the following classes: ai-viewport-1, ai-viewport-2, ai-viewport-3.
194
 
195
  To configure syntax highlighting go to Ad Inserter Settings (tab #) and choose theme.
196
 
204
 
205
  **WARNING:** Text selection, Copy and Paste functions with the syntax highlighting editor do not work on mobile devices. If you need these functions you can temporarily swich to **Simple editor** using the checkbox above the code box.
206
 
207
+ **WARNING:** Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button, make sure you have whitelisted Ad Inserter settings page.
208
+
209
+ **WARNING:** If you are using caching the inserted code may not appear imemdiately on the page. Make sure you have disabled caching when you are testing or debugging.
210
+ Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
211
+
212
+ **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check and server-side detection works only when the page is generated and Ad Inserter is called.
213
+ In such cases please make sure you have disabled caching when you are using such settings.
214
+
215
+ **WARNING:** Some code for ads may not display anything, either because of erros in the ad code or because of ad network issues.
216
+ Before you report problem please check source code of the page and make sure the code is not inserted where it should be.
217
+ The code may be inserted properly but you won't see anything. Try to add some text after the ad code to check if it appears at the expected ad position.
218
+
219
  == Installation ==
220
 
221
  Automatic installation: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
226
  2. Activate the plugin through the 'Plugins' menu in WordPress
227
  3. Access Setting / Ad Inserter to configure it
228
 
229
+ **WARNING:** Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button, make sure you have whitelisted Ad Inserter settings page.
230
+
231
+ **WARNING:** If you are using caching the inserted code may not appear imemdiately on the page. Make sure you have disabled caching when you are testing or debugging.
232
+ Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
233
+
234
+ **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check and server-side detection works only when the page is generated and Ad Inserter is called.
235
+ In such cases please make sure you have disabled caching when you are using such settings.
236
+
237
+ **WARNING:** Some code for ads may not display anything, either because of erros in the ad code or because of ad network issues.
238
+ Before you report problem please check source code of the page and make sure the code is not inserted where it should be.
239
+ The code may be inserted properly but you won't see anything. Try to add some text after the ad code to check if it appears at the expected ad position.
240
+
241
  == Frequently Asked Questions ==
242
 
243
  = I have activated Ad Inserter. How can I use it? =
248
  4. Save settings.
249
 
250
 
251
+ = Settings for ad before the first paragraph on all posts =
252
+
253
+ * Automatic Display: Before Paragraph
254
+ * On all Posts checked, other pages unchecked
255
+ * Paragraph number: 1
256
+
257
+
258
+ = Settings for ad before the second paragraph on all posts, but on the homepage only three ads in the first three post =
259
+
260
+ * Automatic Display: Before Paragraph
261
+ * On all Posts checked, Homepage checked, other pages unchecked
262
+ * Paragraph number: 2
263
+ * Excerpt/Post number(s): 1, 2, 3 (in some cases 2, 4, 6 - depends on the theme and needs some testing)
264
+
265
+
266
+ = Settings for ad wrapped with text of the third paragraph on all posts =
267
+
268
+ * Automatic Display: Before Paragraph
269
+ * On all Posts checked, other pages unchecked
270
+ * Block Alignment and Style: Float Left
271
+ * Paragraph number: 3
272
+
273
+
274
+ = Settings for centered ad in the middle of post paragraphs =
275
+
276
+ * Automatic Display: Before Paragraph
277
+ * On all Posts checked, other pages unchecked
278
+ * Block Alignment and Style: Center
279
+ * Paragraph number: 0.5
280
+
281
+
282
+ = Settings for ad above post excerpts on the Insurance category page =
283
+
284
+ * Automatic Display: Before Post
285
+ * Category pages checked, other pages unchecked
286
+ * Click Lists button to display lists
287
+ * Categories: Insurance, White List checked
288
+
289
+
290
+ = Settings for ad above the first and third post excerpts on the homepage =
291
+
292
+ * Automatic Display: Before Excerpt
293
+ * Homepage checked, other pages unchecked
294
+ * Excerpt/Post number(s): 1, 3
295
 
296
+
297
+ = Settings for ad above the post excerpts on the Cars tag page =
298
+
299
+ * Automatic Display: Before Post
300
+ * Archive pages checked, other pages unchecked
301
+ * Click Lists button to display lists
302
+ * Tags: Cars, White List checked
303
 
304
 
305
  = How can I replace deprecated tags {adinserter n} for manual insertion with new ones [adinserter block="n"] in all posts? =
328
 
329
  = How can I disable ads for direct visitors? =
330
 
331
+ Blacklist `#` as referer for visitors that enter web address directly into browser (no referer).
332
+ Blacklist `yourdomain.com` as referer for visitors that browse your website yourdomain.com.
333
+ To blacklist both enter `yourdomain.com, #`
334
 
 
335
 
336
+ = How can I disable ads on error 404 page? =
337
 
338
+ This is disabled by default. Uncheck Error 404 Page checkbox.
 
 
 
 
 
 
 
 
339
 
340
 
341
  = How can I enable or disable ads on group of similar pages? =
349
 
350
  For example, to exclude ads on pages that have /shop/ in url (page address) blacklist the following url: `*/shop/*`
351
 
352
+ **WARNING:** Separate urls with SPACES.
353
+
354
 
355
  = How can I put an ad in the middle of the post regardless of the number of paragraphs? =
356
 
405
  * {short_title} - Short title (first 3 words) of the post title
406
  * {category} - Category of the post (or short title if there is no category)
407
  * {short_category} - First words before "," or "and" of the category of the post (or short title if there is no category)
408
+ * {tag} - The first tag or general tag if the post has no tags (**works only inside posts**)
409
  * {smart_tag} - Smart selection of post tag in the following order:
410
  * If there is no tag then the category is used;
411
  * If there is a two-word tag then it is used;
414
  * First three words of the first tag
415
  * General tag
416
  * {search_query} - Search engine query that brought visitor to your website (supports Google, Yahoo, Bing and Ask search engines), {smart_tag} is used when there is no search query. You need to disable caching to use this tag. Please note that most search queries are now encrypted.
417
+ * {author} - Post author username (**works only inside posts**)
418
+ * {author_name} Post author name (**works only inside posts**)
419
 
420
 
421
  = How can I rotate few versions of the same ad? =
438
  * Paragraph Number: 1
439
  * Count only paragraphs that CONTAIN: `<span id="more-`
440
 
441
+ Check source code of your website for proper "read more" tag.
442
+
443
 
444
  = How can I insert code block directly into template php file? =
445
 
454
  = How can I create contextual Amazon ad (to show items related to the post)? =
455
 
456
  Sign in to Amazon Associates, go to Widgets/Widget Source, choose ad type and set parameters.
457
+ For titles and search terms use tags. For example, the code below would display amazon products related to the post tags - check above for all possible tags.
458
+
459
+
460
+ Example for Amazon Native Shopping Ads:
461
+
462
+ `<script type="text/javascript">
463
+ amzn_assoc_placement = "adunit0";
464
+ amzn_assoc_search_bar = "true";
465
+ amzn_assoc_tracking_id = "ad-inserter-20";
466
+ amzn_assoc_search_bar_position = "top";
467
+ amzn_assoc_ad_mode = "search";
468
+ amzn_assoc_ad_type = "smart";
469
+ amzn_assoc_marketplace = "amazon";
470
+ amzn_assoc_region = "US";
471
+ amzn_assoc_title = "Search Results from Amazon";
472
+ amzn_assoc_default_search_phrase = "{smart_tag}";
473
+ amzn_assoc_default_category = "All";
474
+ amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
 
 
 
 
475
  </script>
476
+ <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
 
478
 
479
  = Center alignment does not work for some ads! =
518
 
519
  == Changelog ==
520
 
521
+
522
+ = 1.6.5 =
523
+ - Fixed bug: Wrong counting of max insertions
524
+ - Change: display position Before Title was renamed to Before Post
525
+ - Added support for display position After Post
526
+ - Added support for posts with no `<p>` tags (paragraphs separated with \r\n\r\n characters)
527
+ - Added support for paragraph processing on homepage, category, archive and search pages
528
+ - Added support for custom viewports
529
+ - Added support for PHP function call counter
530
+ - Added support to disable code block on error 404 pages
531
+ - Added support to debug paragraph tags
532
+
533
  = 1.6.4 =
534
  - Fixed bug: For shortcodes in posts the url was not checked
535
  - Optimizations for device detection
703
 
704
  == Upgrade Notice ==
705
 
706
+ = 1.6.5 =
707
+ Fixed bug: Wrong counting of max insertions;
708
+ Change: display position Before Title was renamed to Before Post;
709
+ Added support for display position After Post;
710
+ Added support for posts with no `<p>` tags (paragraphs separated with \r\n\r\n characters);
711
+ Added support for paragraph processing on homepage, category, archive and search pages;
712
+ Added support for custom viewports;
713
+ Added support for PHP function call counter;
714
+ Added support to disable code block on error 404 pages;
715
+ Added support to debug paragraph tags
716
+
717
  = 1.6.4 =
718
  Fixed bug: For shortcodes in posts the url was not checked;
719
  Optimizations for device detection
screenshot-1.jpg CHANGED
Binary file
screenshot-10.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file
settings.php CHANGED
@@ -23,6 +23,7 @@ function print_settings_form (){
23
 
24
  $syntax_highlighter_theme = get_syntax_highlighter_theme ();
25
  $block_class_name = get_block_class_name ();
 
26
 
27
  ?>
28
  <style>
@@ -75,7 +76,7 @@ function print_settings_form (){
75
  <?php
76
  if ($subpage == 'exceptions') {
77
  ?>
78
- <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ad_form" name="ad_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
79
  <div id="ai-exceptions" style="padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
80
 
81
  <table class="exceptions">
@@ -139,10 +140,10 @@ function print_settings_form (){
139
  } else {
140
  ?>
141
 
142
- <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ad_form" name="ad_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
143
- <div id="ai-tabs" style="width: 735px; padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
144
  <div id="dummy-tabs" style="height: <?php echo intval ((AD_INSERTER_BLOCKS + 1) / 17 + 0.9) * 29; ?>px; padding: .2em .2em 0; border: 1px solid white;"></div>
145
- <ul id="ad-tabs" style="display: none;">
146
  <?php
147
  for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
148
  $obj = $block_object [$ad_number];
@@ -169,6 +170,14 @@ function print_settings_form (){
169
  <?php
170
  for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
171
  $obj = $block_object [$ad_number];
 
 
 
 
 
 
 
 
172
  ?>
173
 
174
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;">
@@ -177,15 +186,15 @@ function print_settings_form (){
177
  </div>
178
 
179
  <div style="float: right; padding: 1px 5px;">
180
- <button class="import-export-button" id="export_switch_<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 20px;">&nbsp;</button>
181
- <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AD_FORM_SAVE; ?>" value="Save All Settings" type="submit" />
182
  </div>
183
 
184
  <div style="padding:0px 8px 16px 16px;">
185
  Block Name: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_NAME, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="100" />
186
  </div>
187
 
188
- <div id="export_container_<?php echo $ad_number; ?>" style="display: none; padding:8px;">
189
  <div style="display: inline-block; padding: 2px 10px; float: right;">
190
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
191
  <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="import-<?php echo $ad_number; ?>" />
@@ -212,48 +221,37 @@ function print_settings_form (){
212
  </div>
213
 
214
  <div style="padding:8px;">
215
- <textarea id="block_<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo str_replace ("&", "&amp;", $obj->get_ad_data()); ?></textarea>
216
  </div>
217
 
218
  <div style="padding:8px 8px 8px 16px;">
219
- Automatic Display:
220
- <select style="border-radius: 5px; margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:200px">
221
- <option value="<?php echo AD_SELECT_NONE; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_NONE; ?></option>
222
- <option value="<?php echo AD_SELECT_BEFORE_TITLE; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_TITLE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_TITLE; ?></option>
223
- <option value="<?php echo AD_SELECT_BEFORE_CONTENT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_CONTENT; ?></option>
224
- <option value="<?php echo AD_SELECT_BEFORE_PARAGRAPH; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_PARAGRAPH; ?></option>
225
- <option value="<?php echo AD_SELECT_AFTER_PARAGRAPH; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_PARAGRAPH; ?></option>
226
- <option value="<?php echo AD_SELECT_AFTER_CONTENT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_CONTENT; ?></option>
227
- <option value="<?php echo AD_SELECT_BEFORE_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_EXCERPT; ?></option>
228
- <option value="<?php echo AD_SELECT_AFTER_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_EXCERPT; ?></option>
229
- <option value="<?php echo AD_SELECT_WIDGET; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_WIDGET) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_WIDGET; ?></option>
230
- </select>
 
 
231
 
232
- <div style="padding: 8px 0 0 0;">
233
- For
234
- <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-users-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
235
- <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
236
- <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
237
- <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
238
- </select>
239
- users on
240
- <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
241
- <option value="<?php echo AD_DISPLAY_ALL_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_ALL_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_DEVICES; ?></option>
242
- <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
243
- <option value="<?php echo AD_DISPLAY_MOBILE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_MOBILE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_MOBILE_DEVICES; ?></option>
244
- <option value="<?php echo AD_DISPLAY_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_TABLET_DEVICES; ?></option>
245
- <option value="<?php echo AD_DISPLAY_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_PHONE_DEVICES; ?></option>
246
- <option value="<?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?></option>
247
- <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
248
- </select>
249
- devices
250
- <span id="detection-type-<?php echo $ad_number; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Detection:
251
- <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
252
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device type detection when page is created (and cached) - turn it off unless you know what you are doing." <?php if ($obj->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">server-side</label>
253
-
254
- <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
255
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device type detection in visitor's browser - uses CSS media queries to hide or show code blocks. Usually this is what you need." <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">client-side</label>
256
- </span>
257
  </div>
258
 
259
  <div style="padding: 8px 0 0 0;">
@@ -267,66 +265,99 @@ function print_settings_form (){
267
  <option value="<?php echo AD_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_CENTER; ?></option>
268
  <option value="<?php echo AD_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_LEFT; ?></option>
269
  <option value="<?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?></option>
270
- </select>
271
- <span id="custom-css-<?php echo $ad_number; ?>">&nbsp;&nbsp;&nbsp;CSS: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_custom_css() ?>" size="49" maxlength="160" title="Custom CSS code for wrapping div" /></span>
 
272
  </div>
273
  </div>
274
 
275
- <div style="padding:8px 8px 8px 8px; margin: 5px 0 0 5px; border: 1px solid #ddd; border-radius: 5px;">
276
- <div id="enabled-pages-<?php echo $ad_number; ?>" style="display: inline-block; vertical-align: top; float: right;">
277
  <div style="display: inline-block; margin-right: 20px; margin-top: 4px;">
278
  <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
279
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Homepage</label>
280
 
281
  <input style="border-radius: 5px; margin-left: 25px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
282
- <input style="border-radius: 5px; margin-left: 25px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Category pages</label>
283
 
284
  <br /><br />
285
 
286
  <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
287
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Search pages</label>
288
 
289
  <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
290
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Archive pages</label>
291
  </div>
292
  </div>
293
 
294
- <div style="display: inline-block; vertical-align: top; margin-right: 10px;">
295
 
296
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
297
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_post()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
298
 
299
- <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts and pages, exceptions can be configured on individual Post or Page editor pages" id="enabled-on-which-posts-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
300
- <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
301
- <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
302
- <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
303
- </select>
304
 
305
- &nbsp;&nbsp;<label for="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Posts</label>
306
- <br />
307
 
308
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
309
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_page()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
310
 
311
- <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts and pages, exceptions can be configured on individual Post or Page editor pages" id="enabled-on-which-pages-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
312
- <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
313
- <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
314
- <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
315
- </select>
316
 
317
- &nbsp;&nbsp;<label for="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Pages</label>
318
 
319
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  </div>
321
 
322
- <table style="padding:16px 8px 10px 16px;">
 
323
  <tbody>
324
  <tr>
325
  <td style="padding-right: 7px;">
326
  Categories:
327
  </td>
328
  <td style="padding-right: 7px;">
329
- <input style="border-radius: 5px;" title="Comma separated category names - if category name contains commas use category slug instead" type="text" name="<?php echo AI_OPTION_CATEGORY_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_block_cat() ?>" size="56" maxlength="500" />
330
  </td>
331
  <td style="padding-right: 7px;">
332
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
@@ -340,7 +371,7 @@ function print_settings_form (){
340
  Tags:
341
  </td>
342
  <td style="padding-right: 7px;">
343
- <input style="border-radius: 5px;" title="Comma separated tags" type="text" name="<?php echo AI_OPTION_TAG_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_block_tag() ?>" size="56" maxlength="500"/>
344
  </td>
345
  <td style="padding-right: 7px;">
346
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
@@ -354,7 +385,7 @@ function print_settings_form (){
354
  Urls:
355
  </td>
356
  <td style="padding-right: 7px;">
357
- <input style="border-radius: 5px;" title="SPACE separated urls starting with / (use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_url_list() ?>" size="56" maxlength="500"/>
358
  </td>
359
  <td style="padding-right: 7px;">
360
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
@@ -368,7 +399,7 @@ function print_settings_form (){
368
  Referers:
369
  </td>
370
  <td style="padding-right: 7px;">
371
- <input style="border-radius: 5px;" title="Comma separated domains, use # for no referer" type="text" name="<?php echo AI_OPTION_DOMAIN_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_domain_list() ?>" size="56" maxlength="500"/>
372
  </td>
373
  <td style="padding-right: 7px;">
374
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
@@ -379,48 +410,9 @@ function print_settings_form (){
379
  </tr>
380
  </tbody>
381
  </table>
382
-
383
- <div id="post_settings-<?php echo $ad_number; ?>" style="padding: 0px 38px 8px 16px; margin-top: 10px;">
384
- Minimum page/post words <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_minimum_words() ?>" size="4" maxlength="6" /> &nbsp;&nbsp;&nbsp;
385
- Display <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_after_day() ?>" size="2" maxlength="3" title="0 means publish immediately" /> days after post is published
386
- </div>
387
- <div style="padding:0px 0px 8px 16px; margin-top: 10px;">
388
- General tag: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_GENERAL_TAG, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_general_tag() ?>" size="16" maxlength="40" title="Used for {tags} when no page data is found" /> &nbsp;&nbsp;&nbsp;
389
- Max <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MAXIMUM_INSERTIONS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_maximum_insertions () ?>" size="2" maxlength="3" title="0 means unlimited" /> insertions
390
- </div>
391
-
392
- <div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 0 8px; margin: 0 0 10px 10px; border: 1px solid #ddd; border-radius: 5px;">
393
- <div style="display: inline-block; vertical-align: ">
394
- <div style="margin: 4px 0 4px 0; ">
395
- Paragraph number <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_number() ?>" size="2" maxlength="4" /> &nbsp; 0 means random paragraph, <span title="0.2 means paragraph at 20% of page height, 0.5 means paragraph halfway down the page, 0.9 means paragraph at 90% of page height, etc.">value between 0 and 1 means relative position on page.</span>
396
- </div>
397
- <div style="margin: 4px 0 4px 0; ">
398
- Count
399
- <select style="border-radius: 5px;" name="<?php echo AI_OPTION_DIRECTION_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">
400
- <option value="<?php echo AD_DIRECTION_FROM_TOP; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_TOP) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_TOP; ?></option>
401
- <option value="<?php echo AD_DIRECTION_FROM_BOTTOM; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_BOTTOM; ?></option>
402
- </select>
403
- paragraphs with tags
404
- <input style="border-radius: 5px;" title="Comma separated HTML tags, usually only 'p' tags are used" type="text" name="<?php echo AI_OPTION_PARAGRAPH_TAGS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_tags(); ?>" size="14" maxlength="50"/>&nbsp;&nbsp;&nbsp;
405
- Minimum number of paragraphs <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_PARAGRAPHS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_number_minimum() ?>" size="2" maxlength="3" />&nbsp;&nbsp;&nbsp;
406
- </div>
407
- <div style="margin: 4px 0 4px 0; ">
408
- Count only paragraphs that
409
- <select style="border-radius: 5px; margin-bottom: 3px;" name="<?php echo AI_OPTION_PARAGRAPH_TEXT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">
410
- <option value="<?php echo AD_CONTAIN; ?>" <?php echo ($obj->get_paragraph_text_type() == AD_CONTAIN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_CONTAIN; ?></option>
411
- <option value="<?php echo AD_DO_NOT_CONTAIN; ?>" <?php echo ($obj->get_paragraph_text_type() == AD_DO_NOT_CONTAIN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DO_NOT_CONTAIN; ?></option>
412
- </select>
413
- <input style="border-radius: 5px;" title="Comma separated text" type="text" name="<?php echo AI_OPTION_PARAGRAPH_TEXT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_text() ?>" size="26" maxlength="200" />
414
- with at least <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_PARAGRAPH_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_minimum_paragraph_words() ?>" size="4" maxlength="5" /> words
415
- </div>
416
- </div>
417
- </div>
418
-
419
- <div id="excerpt-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 0 0 10px 10px; border: 1px solid #ddd; border-radius: 5px;">
420
- Excerpt number(s) <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_excerpt_number() ?>" title= "Excerpt number or comma separated excerpt numbers, 0 means all excerpts" size="10" maxlength="20" />
421
  </div>
422
 
423
- <div style="padding:7px; text-align: left; margin-left: 10px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
424
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
425
  <input style="border-radius: 5px;" id="enable-manual-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
426
  <label for="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable manual insertion of this code block in posts and pages">
@@ -438,6 +430,67 @@ function print_settings_form (){
438
  &nbsp;&nbsp;
439
  <pre style= "margin: 0; display: inline; color: blue;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $ad_number; ?>); ?&gt;</pre>
440
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  </div>
442
 
443
  <?php
@@ -450,13 +503,13 @@ function print_settings_form (){
450
  </div>
451
 
452
  <div style="float: right; padding: 1px 5px;">
453
- <button class="import-export-button" id="export_switch_0" type="button" style="display: none; margin-right: 20px;">&nbsp;</button>
454
- <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AD_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="width:120px; font-weight: bold;" />
455
  </div>
456
 
457
  <div style="clear: both;"></div>
458
 
459
- <div id="export_container_0" style="display: none; padding: 8px;">
460
  <div style="display: inline-block; padding: 2px 10px; float: right;">
461
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" value="0" />
462
  <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" value="1" id="import-0" />
@@ -517,11 +570,15 @@ function print_settings_form (){
517
  </select>
518
  </div>
519
 
 
 
520
  <div style="padding:0px 0px 8px 16px;">
521
  Block Class Name:&nbsp;&nbsp;&nbsp;
522
  <input style="border-radius: 5px; margin-left: 0px;" title="CSS Class Name" type="text" id="block-class-name" name="block-class-name" value="<?php echo $block_class_name; ?>" size="15" maxlength="40" /> <span style= "margin: 3px 10px 0 0; display: inline; float: right;">Example: &nbsp;&nbsp; <pre style= "display: inline; color: blue;">&lt;div class="<?php echo $block_class_name; ?> <?php echo $block_class_name; ?>-n"&gt;<span style= "color: black;">BlockCode</span>&lt;/div&gt;</pre></span>
523
  </div>
524
 
 
 
525
  <div style="padding:0px 0px 8px 16px;">
526
  Minimum User Role for Page/Post Ad Inserter Exceptions Editing
527
  <select style="border-radius: 5px; margin-bottom: 3px;" id="minimum-user-role" name="minimum-user-role" style="width:300px">
@@ -529,21 +586,65 @@ function print_settings_form (){
529
  </select>
530
  </div>
531
 
 
 
532
  <div style="padding:0px 0px 8px 16px;">
533
  Plugin priority <input style="border-radius: 5px;" type="text" name="plugin_priority" value="<?php echo get_plugin_priority (); ?>" size="6" maxlength="6" />
534
  </div>
535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
536
  <hr />
537
 
538
  <div style="padding: 0;">
539
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
540
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="0" />
541
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="1" <?php if ($adH->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
542
- <label for="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" title="Enable or disable insertion of this code into header">Enable</label>
 
 
 
543
  </div>
544
 
545
  <div style="padding-left:4px;">
546
- <h3>Header Code</h3>
547
  </div>
548
 
549
  <div style="padding:0px 8px 22px 16px;">
@@ -564,7 +665,7 @@ function print_settings_form (){
564
  HTML / Javascript / CSS / PHP code
565
  </div>
566
  <div style="padding: 8px;">
567
- <textarea id="block_h" name="<?php echo AI_OPTION_CODE, '_block_h'; ?>" rows="36" cols="98" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo str_replace ("&", "&amp;", $adH->get_ad_data()); ?></textarea>
568
  </div>
569
  </div>
570
 
@@ -574,11 +675,14 @@ function print_settings_form (){
574
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
575
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="0" />
576
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="1" <?php if ($adF->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
577
- <label for="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" title="Enable or disable insertion of this code into footer">Enable</label>
 
 
 
578
  </div>
579
 
580
  <div style="padding-left:4px;">
581
- <h3>Footer Code</h3>
582
  </div>
583
 
584
  <div style="padding:0px 8px 22px 16px;">
@@ -599,7 +703,7 @@ function print_settings_form (){
599
  HTML / Javascript / PHP code
600
  </div>
601
  <div style="padding:8px;">
602
- <textarea id="block_f" name="<?php echo AI_OPTION_CODE, '_block_f'; ?>" rows="36" cols="98" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo str_replace ("&", "&amp;", $adF->get_ad_data()); ?></textarea>
603
  </div>
604
  </div>
605
 
@@ -610,10 +714,10 @@ function print_settings_form (){
610
 
611
  <div style="height: 30px; margin: 8px 0 0 0;">
612
  <div style="float: left; padding: 1px 1px; color: red;">
613
- <input onclick="if (confirm('Are you sure you want to reset all settings?')) return true; return false" name="<?php echo AD_FORM_CLEAR; ?>" value="Reset All Settings" type="submit" style="display: none; width:120px; font-weight: bold; color: #e44;" />
614
  </div>
615
  <div style="float: right; padding: 1px 1px;">
616
- <input name="<?php echo AD_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="display: none; border-radius: 5px; width:120px; font-weight: bold;" />
617
  </div>
618
  </div>
619
 
23
 
24
  $syntax_highlighter_theme = get_syntax_highlighter_theme ();
25
  $block_class_name = get_block_class_name ();
26
+ $tag_debugging = get_tag_debugging ();
27
 
28
  ?>
29
  <style>
76
  <?php
77
  if ($subpage == 'exceptions') {
78
  ?>
79
+ <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
80
  <div id="ai-exceptions" style="padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
81
 
82
  <table class="exceptions">
140
  } else {
141
  ?>
142
 
143
+ <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="ai-form" name="ai_form" style="float: left;" blocks="<?php echo AD_INSERTER_BLOCKS; ?>">
144
+ <div id="ai-tab-container" style="width: 735px; padding: 8px 8px 8px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
145
  <div id="dummy-tabs" style="height: <?php echo intval ((AD_INSERTER_BLOCKS + 1) / 17 + 0.9) * 29; ?>px; padding: .2em .2em 0; border: 1px solid white;"></div>
146
+ <ul id="ai-tabs" style="display: none;">
147
  <?php
148
  for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
149
  $obj = $block_object [$ad_number];
170
  <?php
171
  for ($ad_number = 1; $ad_number <= AD_INSERTER_BLOCKS; $ad_number ++){
172
  $obj = $block_object [$ad_number];
173
+
174
+ $show_devices = $obj->get_detection_client_side () == AD_SETTINGS_CHECKED || $obj->get_detection_server_side () == AD_SETTINGS_CHECKED;
175
+
176
+ $cat_list = $obj->get_ad_block_cat();
177
+ $tag_list = $obj->get_ad_block_tag();
178
+ $url_list = $obj->get_ad_url_list();
179
+ $domain_list = $obj->get_ad_domain_list();
180
+ $show_lists = $cat_list != '' || $tag_list != '' || $url_list != '' || $domain_list != '';
181
  ?>
182
 
183
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;">
186
  </div>
187
 
188
  <div style="float: right; padding: 1px 5px;">
189
+ <button id="export-switch-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 20px;">&nbsp;</button>
190
+ <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" />
191
  </div>
192
 
193
  <div style="padding:0px 8px 16px 16px;">
194
  Block Name: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_NAME, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="100" />
195
  </div>
196
 
197
+ <div id="export-container-<?php echo $ad_number; ?>" style="display: none; padding:8px;">
198
  <div style="display: inline-block; padding: 2px 10px; float: right;">
199
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
200
  <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" id="import-<?php echo $ad_number; ?>" />
221
  </div>
222
 
223
  <div style="padding:8px;">
224
+ <textarea id="block-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo str_replace ("&", "&amp;", $obj->get_ad_data()); ?></textarea>
225
  </div>
226
 
227
  <div style="padding:8px 8px 8px 16px;">
228
+ <div style="padding: 0 0 0 0;">
229
+ Automatic Display:
230
+ <select style="border-radius: 5px; margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:200px">
231
+ <option value="<?php echo AD_SELECT_NONE; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_NONE; ?></option>
232
+ <option value="<?php echo AD_SELECT_BEFORE_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_POST; ?></option>
233
+ <option value="<?php echo AD_SELECT_BEFORE_CONTENT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_CONTENT; ?></option>
234
+ <option value="<?php echo AD_SELECT_BEFORE_PARAGRAPH; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_PARAGRAPH; ?></option>
235
+ <option value="<?php echo AD_SELECT_AFTER_PARAGRAPH; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_PARAGRAPH; ?></option>
236
+ <option value="<?php echo AD_SELECT_AFTER_CONTENT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_CONTENT; ?></option>
237
+ <option value="<?php echo AD_SELECT_AFTER_POST; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_POST; ?></option>
238
+ <option value="<?php echo AD_SELECT_BEFORE_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_BEFORE_EXCERPT; ?></option>
239
+ <option value="<?php echo AD_SELECT_AFTER_EXCERPT; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_AFTER_EXCERPT; ?></option>
240
+ <option value="<?php echo AD_SELECT_WIDGET; ?>" <?php echo ($obj->get_display_type()==AD_SELECT_WIDGET) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_SELECT_WIDGET; ?></option>
241
+ </select>
242
 
243
+ &nbsp;for&nbsp;
244
+ <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-users-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
245
+ <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
246
+ <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
247
+ <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
248
+ </select>
249
+ users
250
+
251
+ <div style="float: right;">
252
+ <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)">Devices</button>
253
+ <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 0px;" title="White/Black-list Category, Tag, Url or Referer (domain)">Lists</button>
254
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  </div>
256
 
257
  <div style="padding: 8px 0 0 0;">
265
  <option value="<?php echo AD_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_CENTER; ?></option>
266
  <option value="<?php echo AD_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_LEFT; ?></option>
267
  <option value="<?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type()==AD_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ALIGNMENT_FLOAT_RIGHT; ?></option>
268
+ </select> &nbsp;&nbsp;&nbsp;
269
+ <span id="custom-css-<?php echo $ad_number; ?>" style="display: none;">CSS: <input style="border-radius: 7px;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_custom_css(); ?>" size="48" maxlength="160" title="Custom CSS code for wrapping div" /></span>
270
+ <span id="no-wrapping-warning" style="margin-top: 5px; display: none;"><span style="color: red;">WARNING:</span> <strong>No Wrapping</strong> style has no HTML code for client-side detection</span>
271
  </div>
272
  </div>
273
 
274
+ <div style="padding:8px 8px 8px 8px; margin: 8px 0 0 5px; border: 1px solid #ddd; border-radius: 5px;">
275
+ <div id="blog-pages-<?php echo $ad_number; ?>" style="display: inline-block; vertical-align: top; float: right;">
276
  <div style="display: inline-block; margin-right: 20px; margin-top: 4px;">
277
  <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
278
+ <input id= "display-homepage-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Homepage</label>
279
 
280
  <input style="border-radius: 5px; margin-left: 25px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
281
+ <input id= "display-category-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 25px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Category pages</label>
282
 
283
  <br /><br />
284
 
285
  <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
286
+ <input id= "display-search-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Search pages</label>
287
 
288
  <input style="border-radius: 5px; margin-left: 10px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
289
+ <input id= "display-archive-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> /> <label for="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Archive pages</label>
290
  </div>
291
  </div>
292
 
293
+ <div id="single-page-<?php echo $ad_number; ?>" style="display: inline-block; vertical-align: top; margin-right: 10px;">
294
 
295
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
296
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_post()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
297
 
298
+ <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts and pages, exceptions can be configured on individual Post or Page editor pages" id="enabled-on-which-posts-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
299
+ <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
300
+ <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
301
+ <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
302
+ </select>
303
 
304
+ &nbsp;&nbsp;<label for="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Posts</label>
305
+ <br />
306
 
307
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
308
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_display_settings_page()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
309
 
310
+ <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default display for posts and pages, exceptions can be configured on individual Post or Page editor pages" id="enabled-on-which-pages-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
311
+ <option value="<?php echo AD_ENABLED_ON_ALL; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL; ?></option>
312
+ <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
313
+ <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
314
+ </select>
315
 
316
+ &nbsp;&nbsp;<label for="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Pages</label>
317
 
318
  </div>
319
+
320
+ <div style="clear: both;"></div>
321
+ </div>
322
+
323
+ <div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:8px 8px 0 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px;">
324
+ <div style="margin: 4px 0 8px 0;">
325
+ Paragraph number <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_number() ?>" size="2" maxlength="4" /> &nbsp; 0 means random paragraph, <span title="0.2 means paragraph at 20% of page height, 0.5 means paragraph halfway down the page, 0.9 means paragraph at 90% of page height, etc.">value between 0 and 1 means relative position on page.</span>
326
+ </div>
327
+ <div style="margin: 4px 0 8px 0; ">
328
+ Count
329
+ <select style="border-radius: 5px;" name="<?php echo AI_OPTION_DIRECTION_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">
330
+ <option value="<?php echo AD_DIRECTION_FROM_TOP; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_TOP) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_TOP; ?></option>
331
+ <option value="<?php echo AD_DIRECTION_FROM_BOTTOM; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_BOTTOM; ?></option>
332
+ </select>
333
+ paragraphs with tags
334
+ <input style="border-radius: 5px;" title="Comma separated HTML tags, usually only 'p' tags are used" type="text" name="<?php echo AI_OPTION_PARAGRAPH_TAGS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_tags(); ?>" size="14" maxlength="50"/>&nbsp;&nbsp;&nbsp;
335
+ Minimum number of paragraphs <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_PARAGRAPHS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_number_minimum() ?>" size="2" maxlength="3" />&nbsp;&nbsp;&nbsp;
336
+ </div>
337
+ <div style="margin: 4px 0 8px 0; ">
338
+ Count only paragraphs that
339
+ <select style="border-radius: 5px; margin-bottom: 3px;" name="<?php echo AI_OPTION_PARAGRAPH_TEXT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">
340
+ <option value="<?php echo AD_CONTAIN; ?>" <?php echo ($obj->get_paragraph_text_type() == AD_CONTAIN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_CONTAIN; ?></option>
341
+ <option value="<?php echo AD_DO_NOT_CONTAIN; ?>" <?php echo ($obj->get_paragraph_text_type() == AD_DO_NOT_CONTAIN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DO_NOT_CONTAIN; ?></option>
342
+ </select>
343
+ <input style="border-radius: 5px;" title="Comma separated text" type="text" name="<?php echo AI_OPTION_PARAGRAPH_TEXT, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_paragraph_text() ?>" size="26" maxlength="200" />
344
+ with at least <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_PARAGRAPH_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_minimum_paragraph_words() ?>" size="4" maxlength="5" /> words
345
+ </div>
346
+ <div id="post-settings-<?php echo $ad_number; ?>" style="margin: 4px 0 8px 0;">
347
+ Minimum page/post words <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MIN_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_minimum_words() ?>" size="4" maxlength="6" /> &nbsp;&nbsp;&nbsp;
348
+ Display <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_after_day() ?>" size="2" maxlength="3" title="0 means publish immediately" /> days after post is published &nbsp;&nbsp;&nbsp;
349
+ </div>
350
  </div>
351
 
352
+ <div id="lists-container-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_lists) echo 'display: none;'; ?>">
353
+ <table style="padding:8px 8px 10px 8px;">
354
  <tbody>
355
  <tr>
356
  <td style="padding-right: 7px;">
357
  Categories:
358
  </td>
359
  <td style="padding-right: 7px;">
360
+ <input style="border-radius: 5px;" title="Comma separated category names - if category name contains commas use category slug instead" type="text" name="<?php echo AI_OPTION_CATEGORY_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $cat_list; ?>" size="54" maxlength="500" />
361
  </td>
362
  <td style="padding-right: 7px;">
363
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
371
  Tags:
372
  </td>
373
  <td style="padding-right: 7px;">
374
+ <input style="border-radius: 5px;" title="Comma separated tags" type="text" name="<?php echo AI_OPTION_TAG_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $tag_list; ?>" size="54" maxlength="500"/>
375
  </td>
376
  <td style="padding-right: 7px;">
377
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
385
  Urls:
386
  </td>
387
  <td style="padding-right: 7px;">
388
+ <input style="border-radius: 5px;" title="SPACE separated urls starting with / after domain name (e.g. /permalink-url, use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $url_list; ?>" size="54" maxlength="500"/>
389
  </td>
390
  <td style="padding-right: 7px;">
391
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
399
  Referers:
400
  </td>
401
  <td style="padding-right: 7px;">
402
+ <input style="border-radius: 5px;" title="Comma separated domains, use # for no referer" type="text" name="<?php echo AI_OPTION_DOMAIN_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $domain_list; ?>" size="54" maxlength="500"/>
403
  </td>
404
  <td style="padding-right: 7px;">
405
  <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> <?php echo AD_BLACK_LIST; ?>
410
  </tr>
411
  </tbody>
412
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  </div>
414
 
415
+ <div style="padding:7px; margin: 8px 0 8px 5px; text-align: left; border: 1px solid #ddd; border-radius: 5px;">
416
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
417
  <input style="border-radius: 5px;" id="enable-manual-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
418
  <label for="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable manual insertion of this code block in posts and pages">
430
  &nbsp;&nbsp;
431
  <pre style= "margin: 0; display: inline; color: blue;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $ad_number; ?>); ?&gt;</pre>
432
  </div>
433
+
434
+ <div id="blog-page-settings-<?php echo $ad_number; ?>" style="padding: 8px 8px 8px 8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px;">
435
+ Excerpt/Post number(s) <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_excerpt_number() ?>" title= "Single number or comma separated numbers, 0 means all / no limits" size="10" maxlength="20" /> on blog pages / PHP function call counter
436
+ </div>
437
+
438
+ <div style="margin: 8px 0 8px 5px; padding:8px; border: 1px solid #ddd; border-radius: 5px;">
439
+ General tag: <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_GENERAL_TAG, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_ad_general_tag() ?>" size="16" maxlength="40" title="Used for {tags} when no page data is found" /> &nbsp;&nbsp;&nbsp;
440
+ Max <input style="border-radius: 5px;" type="text" name="<?php echo AI_OPTION_MAXIMUM_INSERTIONS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="<?php echo $obj->get_maximum_insertions () ?>" size="2" maxlength="3" title="0 means unlimited" /> insertions &nbsp;&nbsp;&nbsp;
441
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
442
+ <input style="border-radius: 5px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" <?php if ($obj->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
443
+ <label for="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable display of this code block on error 404 (Not Found) page">Display on Error 404 Page</label>
444
+ </div>
445
+
446
+ <div id="device-detection-container-<?php echo $ad_number; ?>" style="padding:8px 8px 8px 8px; margin: 5px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; <?php if (!$show_devices) echo 'display: none;'; ?>">
447
+ <table>
448
+ <tr>
449
+ <td>
450
+ <div style="margin-bottom: 5px;">
451
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
452
+ <input id="client-side-detection-<?php echo $ad_number; ?>" style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device type detection in visitor's browser - uses CSS media queries to hide or show code blocks. Usually this is what you need." <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
453
+ <label for="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Use client-side detection to display only on:</label>
454
+ </div>
455
+
456
+ <div style="margin: 5px 0 0 40px;">
457
+
458
+ <?php
459
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
460
+ $viewport_name = get_viewport_name ($viewport);
461
+ if ($viewport_name != '') {
462
+ ?>
463
+ <div style="margin: 8px 0;">
464
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
465
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device min width <?php echo get_viewport_width ($viewport); ?> px" <?php if ($obj->get_detection_viewport ($viewport)==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
466
+ <label for="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo $viewport_name; ?></label>
467
+ </div>
468
+ <?php
469
+ }
470
+ }
471
+ ?>
472
+ </div>
473
+ </td><td style="padding-left: 40px; vertical-align: top;">
474
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
475
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" title="Device type detection when the page is created (and cached) - turn it off unless you know what you are doing." <?php if ($obj->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
476
+
477
+ <label for="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>">Use server-side detection to display only on </label>
478
+ <div style="margin: 0 0 10px 40px;">
479
+ <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="width:160px">
480
+ <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
481
+ <option value="<?php echo AD_DISPLAY_MOBILE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_MOBILE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_MOBILE_DEVICES; ?></option>
482
+ <option value="<?php echo AD_DISPLAY_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_TABLET_DEVICES; ?></option>
483
+ <option value="<?php echo AD_DISPLAY_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_PHONE_DEVICES; ?></option>
484
+ <option value="<?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?></option>
485
+ <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
486
+ </select>
487
+ devices
488
+ </div>
489
+ </td>
490
+ </tr>
491
+ </table>
492
+ </div>
493
+
494
  </div>
495
 
496
  <?php
503
  </div>
504
 
505
  <div style="float: right; padding: 1px 5px;">
506
+ <button id="export-switch-0" type="button" style="display: none; margin-right: 20px;">&nbsp;</button>
507
+ <input style="display: none; border-radius: 5px; width:120px; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="width:120px; font-weight: bold;" />
508
  </div>
509
 
510
  <div style="clear: both;"></div>
511
 
512
+ <div id="export-container-0" style="display: none; padding: 8px;">
513
  <div style="display: inline-block; padding: 2px 10px; float: right;">
514
  <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" value="0" />
515
  <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_IMPORT, WP_FORM_FIELD_POSTFIX, '0'; ?>" value="1" id="import-0" />
570
  </select>
571
  </div>
572
 
573
+ <div style="clear: both;"></div>
574
+
575
  <div style="padding:0px 0px 8px 16px;">
576
  Block Class Name:&nbsp;&nbsp;&nbsp;
577
  <input style="border-radius: 5px; margin-left: 0px;" title="CSS Class Name" type="text" id="block-class-name" name="block-class-name" value="<?php echo $block_class_name; ?>" size="15" maxlength="40" /> <span style= "margin: 3px 10px 0 0; display: inline; float: right;">Example: &nbsp;&nbsp; <pre style= "display: inline; color: blue;">&lt;div class="<?php echo $block_class_name; ?> <?php echo $block_class_name; ?>-n"&gt;<span style= "color: black;">BlockCode</span>&lt;/div&gt;</pre></span>
578
  </div>
579
 
580
+ <div style="clear: both;"></div>
581
+
582
  <div style="padding:0px 0px 8px 16px;">
583
  Minimum User Role for Page/Post Ad Inserter Exceptions Editing
584
  <select style="border-radius: 5px; margin-bottom: 3px;" id="minimum-user-role" name="minimum-user-role" style="width:300px">
586
  </select>
587
  </div>
588
 
589
+ <div style="clear: both;"></div>
590
+
591
  <div style="padding:0px 0px 8px 16px;">
592
  Plugin priority <input style="border-radius: 5px;" type="text" name="plugin_priority" value="<?php echo get_plugin_priority (); ?>" size="6" maxlength="6" />
593
  </div>
594
 
595
+ <div style="clear: both;"></div>
596
+
597
+ <div style="padding:0px 0px 8px 16px;">
598
+ Tag Debugging:&nbsp;&nbsp;&nbsp;
599
+
600
+ <select
601
+ style="border-radius: 5px; width:150px"
602
+ id="tag_debugging"
603
+ name="tag_debugging"
604
+ value="Value">
605
+ <option value="disabled" <?php echo ($tag_debugging == AI_OPTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>>Disabled</option>
606
+ <option value="before_processing" <?php echo ($tag_debugging == AI_OPTION_BEFORE_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>>Before Processing</option>
607
+ <option value="after_processing" <?php echo ($tag_debugging == AI_OPTION_AFTER_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>>After Processing</option>
608
+ </select>
609
+ </div>
610
+
611
+ <hr />
612
+
613
+ <div style="padding:0px 0px 8px 16px;">
614
+ Viewport Settings used for client-side device detection
615
+ </div>
616
+
617
+ <?php
618
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
619
+ ?>
620
+
621
+ <div style="padding:0px 0px 8px 16px;">
622
+ Viewport <?php echo $viewport; ?> name:&nbsp;&nbsp;&nbsp;
623
+ <input style="border-radius: 5px; margin-left: 0px;" type="text" id="option-name-<?php echo $viewport; ?>" name="viewport-name-<?php echo $viewport; ?>" value="<?php echo get_viewport_name ($viewport); ?>" size="15" maxlength="40" />
624
+ <?php if ($viewport == AD_INSERTER_VIEWPORTS) echo '<span style="display: none;">' ?>
625
+ &nbsp;&nbsp; min width
626
+ <input style="border-radius: 5px;" type="text" id="option-length-<?php echo $viewport; ?>" name="viewport-width-<?php echo $viewport; ?>" value="<?php echo get_viewport_width ($viewport); ?>" size="4" maxlength="4" /> px
627
+ <?php if ($viewport == AD_INSERTER_VIEWPORTS) echo '</span>' ?>
628
+ </div>
629
+
630
+ <?php
631
+ }
632
+ ?>
633
+
634
  <hr />
635
 
636
  <div style="padding: 0;">
637
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
638
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="0" />
639
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="1" <?php if ($adH->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
640
+ <label for="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" title="Enable or disable insertion of this code into HTML page header">Enable</label> &nbsp;&nbsp;
641
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="0" />
642
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="1" <?php if ($adH->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
643
+ <label for="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" title="Enable or disable display of this code block into HTML page header of error 404 (Not Found) page">Error 404 Page</label>
644
  </div>
645
 
646
  <div style="padding-left:4px;">
647
+ <h3>HTML Page Header Code</h3>
648
  </div>
649
 
650
  <div style="padding:0px 8px 22px 16px;">
665
  HTML / Javascript / CSS / PHP code
666
  </div>
667
  <div style="padding: 8px;">
668
+ <textarea id="block-h" name="<?php echo AI_OPTION_CODE, '_block_h'; ?>" rows="36" cols="98" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo str_replace ("&", "&amp;", $adH->get_ad_data()); ?></textarea>
669
  </div>
670
  </div>
671
 
675
  <div style="float: right; padding-top: 5px; margin-right: 15px;">
676
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="0" />
677
  <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="1" <?php if ($adF->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
678
+ <label for="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" title="Enable or disable insertion of this code into HTML page footer">Enable</label> &nbsp;&nbsp;
679
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="0" />
680
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="1" <?php if ($adF->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
681
+ <label for="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" title="Enable or disable display of this code block into HTML page footer on error 404 (Not Found) page">Error 404 Page</label>
682
  </div>
683
 
684
  <div style="padding-left:4px;">
685
+ <h3>HTML Page Footer Code</h3>
686
  </div>
687
 
688
  <div style="padding:0px 8px 22px 16px;">
703
  HTML / Javascript / PHP code
704
  </div>
705
  <div style="padding:8px;">
706
+ <textarea id="block-f" name="<?php echo AI_OPTION_CODE, '_block_f'; ?>" rows="36" cols="98" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold; width: 719px; height: 384px;"><?php echo str_replace ("&", "&amp;", $adF->get_ad_data()); ?></textarea>
707
  </div>
708
  </div>
709
 
714
 
715
  <div style="height: 30px; margin: 8px 0 0 0;">
716
  <div style="float: left; padding: 1px 1px; color: red;">
717
+ <input onclick="if (confirm('Are you sure you want to reset all settings?')) return true; return false" name="<?php echo AI_FORM_CLEAR; ?>" value="Reset All Settings" type="submit" style="display: none; width:120px; font-weight: bold; color: #e44;" />
718
  </div>
719
  <div style="float: right; padding: 1px 1px;">
720
+ <input name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" style="display: none; border-radius: 5px; width:120px; font-weight: bold;" />
721
  </div>
722
  </div>
723