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

Version Description

  • Added support for insertion before/after multiple paragraphs
  • Added initial support for impression and click tracking (Pro only)
  • Few bug fixes and cosmetic changes
Download this release

Release Info

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

Code changes from version 2.1.5 to 2.1.6

Files changed (78) hide show
  1. ad-inserter.php +85 -196
  2. class.php +398 -872
  3. constants.php +28 -19
  4. css/ad-inserter.css +210 -4
  5. css/images/icon-gear-blue.png +0 -0
  6. css/images/icon-gear-red.png +0 -0
  7. css/images/icon-gear.png +0 -0
  8. css/images/icons.png +0 -0
  9. images/media.net_250x250_2.jpg +0 -0
  10. images/media.net_728x90.gif +0 -0
  11. includes/Mobile_Detect.php +49 -26
  12. includes/ace/{src-min-noconflict/ace.js → ace.js} +0 -0
  13. includes/ace/{src-min-noconflict/ext-beautify.js → ext-beautify.js} +0 -0
  14. includes/ace/{src-min-noconflict/ext-chromevox.js → ext-chromevox.js} +0 -0
  15. includes/ace/{src-min-noconflict/ext-elastic_tabstops_lite.js → ext-elastic_tabstops_lite.js} +0 -0
  16. includes/ace/{src-min-noconflict/ext-emmet.js → ext-emmet.js} +0 -0
  17. includes/ace/{src-min-noconflict/ext-error_marker.js → ext-error_marker.js} +0 -0
  18. includes/ace/{src-min-noconflict/ext-keybinding_menu.js → ext-keybinding_menu.js} +0 -0
  19. includes/ace/{src-min-noconflict/ext-language_tools.js → ext-language_tools.js} +0 -0
  20. includes/ace/{src-min-noconflict/ext-linking.js → ext-linking.js} +0 -0
  21. includes/ace/{src-min-noconflict/ext-modelist.js → ext-modelist.js} +0 -0
  22. includes/ace/{src-min-noconflict/ext-old_ie.js → ext-old_ie.js} +0 -0
  23. includes/ace/{src-min-noconflict/ext-searchbox.js → ext-searchbox.js} +0 -0
  24. includes/ace/{src-min-noconflict/ext-settings_menu.js → ext-settings_menu.js} +0 -0
  25. includes/ace/{src-min-noconflict/ext-spellcheck.js → ext-spellcheck.js} +0 -0
  26. includes/ace/{src-min-noconflict/ext-split.js → ext-split.js} +0 -0
  27. includes/ace/{src-min-noconflict/ext-static_highlight.js → ext-static_highlight.js} +0 -0
  28. includes/ace/{src-min-noconflict/ext-statusbar.js → ext-statusbar.js} +0 -0
  29. includes/ace/{src-min-noconflict/ext-textarea.js → ext-textarea.js} +0 -0
  30. includes/ace/{src-min-noconflict/ext-themelist.js → ext-themelist.js} +0 -0
  31. includes/ace/{src-min-noconflict/ext-whitespace.js → ext-whitespace.js} +0 -0
  32. includes/ace/{src-min-noconflict/keybinding-emacs.js → keybinding-emacs.js} +0 -0
  33. includes/ace/{src-min-noconflict/keybinding-vim.js → keybinding-vim.js} +0 -0
  34. includes/ace/{src-min-noconflict/mode-html.js → mode-html.js} +0 -0
  35. includes/ace/{src-min-noconflict/mode-php.js → mode-php.js} +0 -0
  36. includes/ace/{src-min-noconflict/theme-ad_inserter.js → theme-ad_inserter.js} +0 -0
  37. includes/ace/{src-min-noconflict/theme-ambiance.js → theme-ambiance.js} +0 -0
  38. includes/ace/{src-min-noconflict/theme-chaos.js → theme-chaos.js} +0 -0
  39. includes/ace/{src-min-noconflict/theme-chrome.js → theme-chrome.js} +0 -0
  40. includes/ace/{src-min-noconflict/theme-clouds.js → theme-clouds.js} +0 -0
  41. includes/ace/{src-min-noconflict/theme-clouds_midnight.js → theme-clouds_midnight.js} +0 -0
  42. includes/ace/{src-min-noconflict/theme-cobalt.js → theme-cobalt.js} +0 -0
  43. includes/ace/{src-min-noconflict/theme-crimson_editor.js → theme-crimson_editor.js} +0 -0
  44. includes/ace/{src-min-noconflict/theme-dawn.js → theme-dawn.js} +0 -0
  45. includes/ace/{src-min-noconflict/theme-disabled.js → theme-disabled.js} +0 -0
  46. includes/ace/{src-min-noconflict/theme-dreamweaver.js → theme-dreamweaver.js} +0 -0
  47. includes/ace/{src-min-noconflict/theme-eclipse.js → theme-eclipse.js} +0 -0
  48. includes/ace/{src-min-noconflict/theme-github.js → theme-github.js} +0 -0
  49. includes/ace/{src-min-noconflict/theme-idle_fingers.js → theme-idle_fingers.js} +0 -0
  50. includes/ace/{src-min-noconflict/theme-katzenmilch.js → theme-katzenmilch.js} +0 -0
  51. includes/ace/{src-min-noconflict/theme-kr_theme.js → theme-kr_theme.js} +0 -0
  52. includes/ace/{src-min-noconflict/theme-kuroir.js → theme-kuroir.js} +0 -0
  53. includes/ace/{src-min-noconflict/theme-merbivore.js → theme-merbivore.js} +0 -0
  54. includes/ace/{src-min-noconflict/theme-merbivore_soft.js → theme-merbivore_soft.js} +0 -0
  55. includes/ace/{src-min-noconflict/theme-mono_industrial.js → theme-mono_industrial.js} +0 -0
  56. includes/ace/{src-min-noconflict/theme-monokai.js → theme-monokai.js} +0 -0
  57. includes/ace/{src-min-noconflict/theme-pastel_on_dark.js → theme-pastel_on_dark.js} +0 -0
  58. includes/ace/{src-min-noconflict/theme-solarized_dark.js → theme-solarized_dark.js} +0 -0
  59. includes/ace/{src-min-noconflict/theme-solarized_light.js → theme-solarized_light.js} +0 -0
  60. includes/ace/{src-min-noconflict/theme-terminal.js → theme-terminal.js} +0 -0
  61. includes/ace/{src-min-noconflict/theme-textmate.js → theme-textmate.js} +0 -0
  62. includes/ace/{src-min-noconflict/theme-tomorrow.js → theme-tomorrow.js} +0 -0
  63. includes/ace/{src-min-noconflict/theme-tomorrow_night.js → theme-tomorrow_night.js} +0 -0
  64. includes/ace/{src-min-noconflict/theme-tomorrow_night_blue.js → theme-tomorrow_night_blue.js} +0 -0
  65. includes/ace/{src-min-noconflict/theme-tomorrow_night_bright.js → theme-tomorrow_night_bright.js} +0 -0
  66. includes/ace/{src-min-noconflict/theme-tomorrow_night_eighties.js → theme-tomorrow_night_eighties.js} +0 -0
  67. includes/ace/{src-min-noconflict/theme-twilight.js → theme-twilight.js} +0 -0
  68. includes/ace/{src-min-noconflict/theme-vibrant_ink.js → theme-vibrant_ink.js} +0 -0
  69. includes/ace/{src-min-noconflict/theme-xcode.js → theme-xcode.js} +0 -0
  70. includes/ace/{src-min-noconflict/worker-html.js → worker-html.js} +0 -0
  71. includes/ace/{src-min-noconflict/worker-php.js → worker-php.js} +0 -0
  72. includes/js/ad-inserter-check.js +7 -0
  73. includes/js/image-picker.min.js +14 -1
  74. includes/js/jquery.ui.spinner.js +0 -8
  75. js/ad-inserter.js +532 -31
  76. preview.php +2 -3
  77. readme.txt +24 -8
  78. settings.php +108 -83
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.1.5
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,11 @@ Plugin URI: http://adinserter.pro/documentation
11
  /*
12
  Change Log
13
 
 
 
 
 
 
14
  Ad Inserter 2.1.5 - 6 April 2017
15
  - Added support to avoid insertion inside <figure> and <li> elements (image captions, lists)
16
  - Added support for exceptions for custom post types
@@ -438,26 +443,29 @@ if (get_dynamic_blocks ()) {
438
  }
439
  }
440
 
441
- $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
442
- $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
443
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
444
- $ai_wp_data [SERVER_SIDE_DETECTION] = false;
445
- $ai_wp_data [CLIENT_SIDE_DETECTION] = false;
 
446
 
447
  for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
448
  $obj = $block_object [$counter];
449
 
450
- if ($obj->get_detection_server_side()) $ai_wp_data [SERVER_SIDE_DETECTION] = true;
451
- if ($obj->get_detection_client_side ()) $ai_wp_data [CLIENT_SIDE_DETECTION] = true;
 
 
452
  }
453
 
454
  $adH = $block_object [AI_HEADER_OPTION_NAME];
455
  $adF = $block_object [AI_FOOTER_OPTION_NAME];
456
- if ($adH->get_detection_server_side()) $ai_wp_data [SERVER_SIDE_DETECTION] = true;
457
- if ($adF->get_detection_server_side()) $ai_wp_data [SERVER_SIDE_DETECTION] = true;
458
 
459
 
460
- if ($ai_wp_data [SERVER_SIDE_DETECTION]) {
461
  require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
462
 
463
  $detect = new ai_Mobile_Detect;
@@ -485,12 +493,14 @@ add_action ('admin_notices', 'ai_admin_notice_hook');
485
  add_action ('wp', 'ai_wp_hook');
486
 
487
  if ($adH->get_enable_manual () ||
488
- $ai_wp_data [CLIENT_SIDE_DETECTION] ||
489
  get_remote_debugging () ||
490
  ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
491
  add_action ('wp_head', 'ai_wp_head_hook');
492
 
493
- if ($adF->get_enable_manual () || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE)
 
 
494
  add_action ('wp_footer', 'ai_wp_footer_hook');
495
 
496
  if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
@@ -947,11 +957,11 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
947
 
948
  if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
949
 
950
- wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
951
 
952
  if (AI_SYNTAX_HIGHLIGHTING) {
953
- wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/src-min-noconflict/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
954
- wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/src-min-noconflict/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
955
  }
956
  }
957
  }
@@ -959,10 +969,10 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
959
  function add_head_inline_styles_and_scripts () {
960
  global $ai_wp_data;
961
 
962
- if ($ai_wp_data [CLIENT_SIDE_DETECTION] || get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) {
963
  echo "<style type='text/css'>\n";
964
 
965
- if ($ai_wp_data [CLIENT_SIDE_DETECTION])
966
  echo get_viewport_css ();
967
 
968
  if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
@@ -1012,160 +1022,46 @@ function add_head_inline_styles_and_scripts () {
1012
  }
1013
 
1014
  function add_footer_inline_scripts () {
 
1015
 
1016
- if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1017
- echo "<script type='text/javascript'>\n";
1018
-
1019
- // $rotation_script = ' jQuery (function ($) {
1020
- // $("div.ai-rotate").each (function () {
1021
- // var rotate_options = $(".ai-rotate-option", this);
1022
- // var random_index = Math.floor (Math.random () * rotate_options.length);
1023
- // rotate_options.hide ();
1024
- // $(rotate_options [random_index]).css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
1025
- // $(this).css ({"position": ""});
1026
- // });
1027
- // });
1028
- //';
1029
-
1030
- echo 'jQuery(function($){$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);rotate_options.hide();$(rotate_options[random_index]).css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""});$(this).css({"position":""})})});';
1031
-
1032
- // echo 'jQuery (function ($) {
1033
- // function getParameterByName (name, url) {
1034
- // if (!url) {
1035
- // url = window.location.href;
1036
- // }
1037
- // name = name.replace(/[\[\]]/g, "\\$&");
1038
- // var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
1039
- // results = regex.exec(url);
1040
- // if (!results) return null;
1041
- // if (!results[2]) return "";
1042
- // return decodeURIComponent(results[2].replace(/\+/g, " "));
1043
- // }
1044
 
1045
- // var javascript_debugging = '.(get_javascript_debugging () ? "true" : "false").';
1046
- // var nonce = "'.wp_create_nonce ("adinserter_data").'";
1047
- // var site_url = "'.wp_make_link_relative (get_site_url()).'";
1048
- // var page = site_url+"/wp-admin/admin-ajax.php?action=ai_data&ip-data=ip-address-country&ai_check=" + nonce;
1049
-
1050
- // var debug_ip_address = getParameterByName ("ai-debug-ip-address");
1051
- // if (debug_ip_address != null) page += "&ai-debug-ip-address=" + debug_ip_address;
1052
- // var debug_ip_address = getParameterByName ("ai-debug-country");
1053
- // if (debug_ip_address != null) page += "&ai-debug-country=" + debug_ip_address;
1054
-
1055
- // var enable_block = false;
1056
-
1057
- // $.get (page, function (ip_data) {
1058
-
1059
- // if (javascript_debugging) console.log ("Ajax call data: " + ip_data);
1060
-
1061
- // $("div.ai-ip-data").each (function () {
1062
- // var ip_data_array = ip_data.split (",");
1063
- // var ip_address = ip_data_array [0];
1064
- // var country = ip_data_array [1];
1065
- // var block_div = $("." + $(this).attr ("class-name"));
1066
-
1067
- // enable_block = true;
1068
- // var found = false;
1069
-
1070
- // var ip_addresses_list = $(this).attr ("ip-addresses");
1071
- // if (typeof ip_addresses_list != "undefined") {
1072
- // var ip_address_array = ip_addresses_list.split (",");
1073
- // var ip_address_list_type = $(this).attr ("ip-address-list");
1074
-
1075
- // $.each (ip_address_array, function (index, list_ip_address) {
1076
- // if (list_ip_address.charAt (0) == "*") {
1077
- // if (list_ip_address.charAt (list_ip_address.length - 1) == "*") {
1078
- // list_ip_address = list_ip_address.substr (1, list_ip_address.length - 2);
1079
- // if (ip_address.indexOf (list_ip_address) != - 1) {
1080
- // found = true;
1081
- // return false;
1082
- // }
1083
- // } else {
1084
- // list_ip_address = list_ip_address.substr (1);
1085
- // if (ip_address.substr (- list_ip_address.length) == list_ip_address) {
1086
- // found = true;
1087
- // return false;
1088
- // }
1089
- // }
1090
- // }
1091
- // else if (list_ip_address.charAt (list_ip_address.length - 1) == "*") {
1092
- // list_ip_address = list_ip_address.substr (0, list_ip_address.length - 1);
1093
- // if (ip_address.indexOf (list_ip_address) == 0) {
1094
- // found = true;
1095
- // return false;
1096
- // }
1097
- // }
1098
- // else if (list_ip_address == "#" && ip_address == "") {
1099
- // found = true;
1100
- // return false;
1101
- // }
1102
-
1103
- // else if (list_ip_address == ip_address) {
1104
- // found = true;
1105
- // return false;
1106
- // }
1107
- // });
1108
-
1109
- // switch (ip_address_list_type) {
1110
- // case "B":
1111
- // if (found) enable_block = false;
1112
- // break;
1113
- // case "W":
1114
- // if (!found) enable_block = false;
1115
- // break;
1116
- // }
1117
- // }
1118
 
1119
- // if (enable_block) {
1120
- // var countries_list = $(this).attr ("countries");
1121
- // if (typeof countries_list != "undefined") {
1122
- // var country_array = countries_list.split (",");
1123
- // var country_list_type = $(this).attr ("country-list");
1124
-
1125
- // var found = false;
1126
-
1127
- // $.each (country_array, function (index, list_country) {
1128
- // if (list_country == country) {
1129
- // found = true;
1130
- // return false;
1131
- // }
1132
- // });
1133
- // switch (country_list_type) {
1134
- // case "B":
1135
- // if (found) enable_block = false;
1136
- // break;
1137
- // case "W":
1138
- // if (!found) enable_block = false;
1139
- // break;
1140
- // }
1141
- // }
1142
- // }
1143
 
1144
- // $(this).css ({"visibility": "", "position": "", "width": "", "height": "", "z-index": ""});
1145
- // block_div.css ({"visibility": "", "position": "", "z-index": ""});
1146
- // if (!enable_block) {
1147
- // $(this).hide ();
1148
- // block_div.hide ();
1149
- // }
1150
- // });
1151
- // }).fail (function(jqXHR, status, err) {
1152
- // if (javascript_debugging) console.log ("Ajax call failed, Status: " + status + ", Error: " + err);
1153
- // $("div.ai-ip-data").each (function () {
1154
- // $(this).css ({"display": "none", "visibility": "", "position": "", "width": "", "height": "", "z-index": ""});
1155
- // });
1156
- // });
1157
- // });
1158
- //';
 
 
 
1159
 
1160
- echo 'jQuery(function($){function getParameterByName(name,url){if(!url)url=window.location.href;name=name.replace(/[\[\]]/g,"\\$&");var regex=new RegExp("[?&]"+name+"(=([^&#]*)|&|#|$)"),results=regex.exec(url);if(!results)return null;if(!results[2])return"";return decodeURIComponent(results[2].replace(/\+/g," "))}var javascript_debugging='.(get_javascript_debugging () ? "true" : "false").';var nonce="'.wp_create_nonce ("adinserter_data").'";var site_url="'.wp_make_link_relative (get_site_url()).'";var page=site_url+"/wp-admin/admin-ajax.php?action=ai_data&ip-data=ip-address-country&ai_check="+
1161
- nonce;var debug_ip_address=getParameterByName("ai-debug-ip-address");if(debug_ip_address!=null)page+="&ai-debug-ip-address="+debug_ip_address;var debug_ip_address=getParameterByName("ai-debug-country");if(debug_ip_address!=null)page+="&ai-debug-country="+debug_ip_address;var enable_block=false;$.get(page,function(ip_data){if(javascript_debugging)console.log("Ajax call data: "+ip_data);$("div.ai-ip-data").each(function(){var ip_data_array=ip_data.split(",");var ip_address=ip_data_array[0];var country=
1162
- ip_data_array[1];var block_div=$("."+$(this).attr("class-name"));enable_block=true;var found=false;var ip_addresses_list=$(this).attr("ip-addresses");if(typeof ip_addresses_list!="undefined"){var ip_address_array=ip_addresses_list.split(",");var ip_address_list_type=$(this).attr("ip-address-list");$.each(ip_address_array,function(index,list_ip_address){if(list_ip_address.charAt(0)=="*")if(list_ip_address.charAt(list_ip_address.length-1)=="*"){list_ip_address=list_ip_address.substr(1,list_ip_address.length-
1163
- 2);if(ip_address.indexOf(list_ip_address)!=-1){found=true;return false}}else{list_ip_address=list_ip_address.substr(1);if(ip_address.substr(-list_ip_address.length)==list_ip_address){found=true;return false}}else if(list_ip_address.charAt(list_ip_address.length-1)=="*"){list_ip_address=list_ip_address.substr(0,list_ip_address.length-1);if(ip_address.indexOf(list_ip_address)==0){found=true;return false}}else if(list_ip_address=="#"&&ip_address==""){found=true;return false}else if(list_ip_address==
1164
- ip_address){found=true;return false}});switch(ip_address_list_type){case "B":if(found)enable_block=false;break;case "W":if(!found)enable_block=false;break}}if(enable_block){var countries_list=$(this).attr("countries");if(typeof countries_list!="undefined"){var country_array=countries_list.split(",");var country_list_type=$(this).attr("country-list");var found=false;$.each(country_array,function(index,list_country){if(list_country==country){found=true;return false}});switch(country_list_type){case "B":if(found)enable_block=
1165
- false;break;case "W":if(!found)enable_block=false;break}}}$(this).css({"visibility":"","position":"","width":"","height":"","z-index":""});block_div.css({"visibility":"","position":"","z-index":""});if(!enable_block){$(this).hide();block_div.hide()}})}).fail(function(jqXHR,status,err){if(javascript_debugging)console.log("Ajax call failed, Status: "+status+", Error: "+err);$("div.ai-ip-data").each(function(){$(this).css({"display":"none","visibility":"","position":"","width":"","height":"","z-index":""})})})});';
1166
 
1167
- echo "\n</script>\n";
 
1168
  }
 
 
 
 
 
 
1169
  }
1170
 
1171
  function ai_admin_notice_hook () {
@@ -1506,12 +1402,24 @@ function ai_write_debug_info ($write_processing_log = false) {
1506
  }
1507
  echo "\n";
1508
  echo 'POST TYPE: ', get_post_type (), "\n";
 
 
 
 
 
 
 
 
 
 
 
 
1509
  echo 'ID: ', get_the_ID(), "\n";
1510
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1511
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
1512
  if (function_exists ('ai_debug')) ai_debug ();
1513
- echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1514
- if ($ai_wp_data [CLIENT_SIDE_DETECTION] || 1) {
1515
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1516
  $viewport_name = get_viewport_name ($viewport);
1517
  $viewport_width = get_viewport_width ($viewport);
@@ -1520,8 +1428,8 @@ function ai_write_debug_info ($write_processing_log = false) {
1520
  }
1521
  }
1522
  }
1523
- echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1524
- if ($ai_wp_data [SERVER_SIDE_DETECTION]) {
1525
  echo 'SERVER-SIDE DEVICE: ';
1526
  if (AI_DESKTOP) echo "DESKTOP\n";
1527
  elseif (AI_TABLET) echo "TABLET\n";
@@ -1975,7 +1883,7 @@ function multisite_settings_page_enabled () {
1975
  if (!isset ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'])) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1976
  if ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] == '') $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1977
 
1978
- if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AD_SETTINGS_NOT_CHECKED;
1979
 
1980
  return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']);
1981
  }
@@ -2116,7 +2024,6 @@ function filter_option_hf ($option, $value){
2116
  }
2117
 
2118
  function ai_data () {
2119
- global $ai_db_options, $block_object;
2120
 
2121
  check_admin_referer ("adinserter_data", "ai_check");
2122
 
@@ -2127,37 +2034,17 @@ function ai_data () {
2127
  }
2128
  }
2129
 
2130
- elseif (isset ($_GET ["export"])) {
2131
- $block = $_GET ["export"];
2132
- if (is_numeric ($block)) {
2133
- if ($block == 0) echo base64_encode (serialize ($ai_db_options));
2134
- elseif ($block >= 1 && $block <= AD_INSERTER_BLOCKS) {
2135
- $obj = $block_object [$block];
2136
- echo base64_encode (serialize ($obj->wp_options));
2137
- }
2138
- }
2139
- }
2140
-
2141
  elseif (isset ($_GET ["image"])) {
2142
  header ("Content-Type: image/png");
2143
  header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
2144
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
2145
  }
2146
 
2147
- elseif (isset ($_GET ["ip-data"])) {
2148
- $client_ip_address = get_client_ip_address ();
2149
- if ($_GET ["ip-data"] == 'country') {
2150
- echo ip_to_country ($client_ip_address);
2151
- }
2152
- elseif ($_GET ["ip-data"] == 'ip-address') {
2153
- echo $client_ip_address;
2154
- }
2155
- elseif ($_GET ["ip-data"] == 'ip-address-country') {
2156
- echo $client_ip_address, ',', ip_to_country ($client_ip_address);
2157
- }
2158
  }
2159
 
2160
- die ();
2161
  }
2162
 
2163
  function ai_generate_extract (&$settings) {
@@ -2315,7 +2202,7 @@ function generate_viewport_css () {
2315
 
2316
 
2317
  function ai_settings () {
2318
- global $ai_db_options, $block_object;
2319
 
2320
  if (isset ($_POST [AI_FORM_SAVE])) {
2321
 
@@ -2491,6 +2378,8 @@ function ai_settings () {
2491
  delete_site_option (WP_OPTION_NAME, $options);
2492
  }
2493
 
 
 
2494
  if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
2495
 
2496
  $args = array (
@@ -3379,7 +3268,7 @@ function ai_widget_draw_debugger ($args, $instance, &$block) {
3379
  ai_write_debug_info ();
3380
  echo "</pre>";
3381
 
3382
- if ($ai_wp_data [CLIENT_SIDE_DETECTION]) {
3383
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
3384
  $viewport_name = get_viewport_name ($viewport);
3385
  if ($viewport_name != '') {
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.1.6
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.1.6 - 2017-05-12
15
+ - Added support for insertion before/after multiple paragraphs
16
+ - Added initial support for impression and click tracking (Pro only)
17
+ - Few bug fixes and cosmetic changes
18
+
19
  Ad Inserter 2.1.5 - 6 April 2017
20
  - Added support to avoid insertion inside <figure> and <li> elements (image captions, lists)
21
  - Added support for exceptions for custom post types
443
  }
444
  }
445
 
446
+ $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
447
+ $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
448
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
449
+ $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false;
450
+ $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false;
451
+ $ai_wp_data [AI_TRACKING] = false;
452
 
453
  for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
454
  $obj = $block_object [$counter];
455
 
456
+ if ($obj->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
457
+ if ($obj->get_detection_client_side ()) $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = true;
458
+
459
+ if ($obj->get_tracking ()) $ai_wp_data [AI_TRACKING] = true;
460
  }
461
 
462
  $adH = $block_object [AI_HEADER_OPTION_NAME];
463
  $adF = $block_object [AI_FOOTER_OPTION_NAME];
464
+ if ($adH->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
465
+ if ($adF->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
466
 
467
 
468
+ if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
469
  require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
470
 
471
  $detect = new ai_Mobile_Detect;
493
  add_action ('wp', 'ai_wp_hook');
494
 
495
  if ($adH->get_enable_manual () ||
496
+ $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
497
  get_remote_debugging () ||
498
  ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
499
  add_action ('wp_head', 'ai_wp_head_hook');
500
 
501
+ if ($adF->get_enable_manual () ||
502
+ $ai_wp_data [AI_TRACKING] ||
503
+ get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE)
504
  add_action ('wp_footer', 'ai_wp_footer_hook');
505
 
506
  if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
957
 
958
  if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
959
 
960
+ wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
961
 
962
  if (AI_SYNTAX_HIGHLIGHTING) {
963
+ wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
964
+ wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
965
  }
966
  }
967
  }
969
  function add_head_inline_styles_and_scripts () {
970
  global $ai_wp_data;
971
 
972
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) {
973
  echo "<style type='text/css'>\n";
974
 
975
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION])
976
  echo get_viewport_css ();
977
 
978
  if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
1022
  }
1023
 
1024
  function add_footer_inline_scripts () {
1025
+ global $ai_wp_data;
1026
 
1027
+ $inline_scripts = $ai_wp_data [AI_TRACKING] || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1028
 
1029
+ if ($inline_scripts) echo "<script type='text/javascript'>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1030
 
1031
+ if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1032
 
1033
+ $block_class_name = get_block_class_name ();
1034
+ if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1035
+
1036
+ echo 'jQuery (function ($) {
1037
+ var wrapping_div_class = ".', $block_class_name, '";
1038
+ $("div.ai-rotate").each (function () {
1039
+ var rotate_options = $(".ai-rotate-option", this);
1040
+ var random_index = Math.floor (Math.random () * rotate_options.length);
1041
+ rotate_options.hide ();
1042
+ $(rotate_options [random_index]).css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
1043
+ $(this).css ({"position": ""});
1044
+
1045
+ var wrapping_div = $(this).closest (wrapping_div_class);
1046
+ var data = JSON.parse (atob (wrapping_div.data ("ai")));
1047
+ if (typeof data !== "undefined" && data.constructor === Array) {
1048
+ data [1] = random_index + 1;
1049
+ wrapping_div.data ("ai", btoa (JSON.stringify (data)))
1050
+ }
1051
 
1052
+ });
1053
+ });
1054
+ ';
 
 
 
1055
 
1056
+ // echo 'jQuery(function($){$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);rotate_options.hide();$(rotate_options[random_index]).css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""});$(this).css({"position":""});var wrapping_div=$(this).parent();var version=wrapping_div.attr("version");if(typeof version!=="undefined"&&!isNaN(version))wrapping_div.attr("version",random_index+
1057
+ //1)})});';
1058
  }
1059
+
1060
+ if (function_exists ('add_footer_inline_scripts_2')) {
1061
+ add_footer_inline_scripts_2 ();
1062
+ }
1063
+
1064
+ if ($inline_scripts) echo "\n</script>\n";
1065
  }
1066
 
1067
  function ai_admin_notice_hook () {
1402
  }
1403
  echo "\n";
1404
  echo 'POST TYPE: ', get_post_type (), "\n";
1405
+ $category_data = get_the_category();
1406
+ $categories = array ();
1407
+ foreach ($category_data as $category) {
1408
+ $categories []= $category->slug;
1409
+ }
1410
+ echo 'CATEGORIES: ', implode (', ', $categories), "\n";
1411
+ $tag_data = wp_get_post_tags (get_the_ID());
1412
+ $tags = array ();
1413
+ foreach ($tag_data as $tag) {
1414
+ $tags []= $tag->slug;
1415
+ }
1416
+ echo 'TAGS: ', implode (', ', $tags), "\n";
1417
  echo 'ID: ', get_the_ID(), "\n";
1418
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1419
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
1420
  if (function_exists ('ai_debug')) ai_debug ();
1421
+ echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1422
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || 1) {
1423
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1424
  $viewport_name = get_viewport_name ($viewport);
1425
  $viewport_width = get_viewport_width ($viewport);
1428
  }
1429
  }
1430
  }
1431
+ echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [AI_SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1432
+ if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
1433
  echo 'SERVER-SIDE DEVICE: ';
1434
  if (AI_DESKTOP) echo "DESKTOP\n";
1435
  elseif (AI_TABLET) echo "TABLET\n";
1883
  if (!isset ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'])) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1884
  if ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] == '') $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1885
 
1886
+ if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AI_DISABLED;
1887
 
1888
  return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']);
1889
  }
2024
  }
2025
 
2026
  function ai_data () {
 
2027
 
2028
  check_admin_referer ("adinserter_data", "ai_check");
2029
 
2034
  }
2035
  }
2036
 
 
 
 
 
 
 
 
 
 
 
 
2037
  elseif (isset ($_GET ["image"])) {
2038
  header ("Content-Type: image/png");
2039
  header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
2040
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
2041
  }
2042
 
2043
+ elseif (function_exists ('ai_data_ajax')) {
2044
+ ai_data_ajax ();
 
 
 
 
 
 
 
 
 
2045
  }
2046
 
2047
+ wp_die ();
2048
  }
2049
 
2050
  function ai_generate_extract (&$settings) {
2202
 
2203
 
2204
  function ai_settings () {
2205
+ global $ai_db_options, $block_object, $wpdb;
2206
 
2207
  if (isset ($_POST [AI_FORM_SAVE])) {
2208
 
2378
  delete_site_option (WP_OPTION_NAME, $options);
2379
  }
2380
 
2381
+ $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
2382
+
2383
  if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
2384
 
2385
  $args = array (
3268
  ai_write_debug_info ();
3269
  echo "</pre>";
3270
 
3271
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) {
3272
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
3273
  $viewport_name = get_viewport_name ($viewport);
3274
  if ($viewport_name != '') {
class.php CHANGED
@@ -8,6 +8,7 @@ abstract class ai_BaseCodeBlock {
8
  var $client_side_ip_address_detection;
9
  var $w3tc_code;
10
  var $needs_class;
 
11
 
12
  function __construct () {
13
 
@@ -16,12 +17,13 @@ abstract class ai_BaseCodeBlock {
16
  $this->client_side_ip_address_detection = false;
17
  $this->w3tc_code = '';
18
  $this->needs_class = false;
 
19
 
20
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
21
- $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
22
- $this->wp_options [AI_OPTION_ENABLE_MANUAL] = AD_SETTINGS_NOT_CHECKED;
23
- $this->wp_options [AI_OPTION_ENABLE_404] = AD_SETTINGS_NOT_CHECKED;
24
- $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AD_SETTINGS_NOT_CHECKED;
25
  $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_DESKTOP_DEVICES;
26
  }
27
 
@@ -245,19 +247,19 @@ abstract class ai_BaseCodeBlock {
245
 
246
  public function get_enable_manual (){
247
  $enable_manual = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : '';
248
- if ($enable_manual == '') $enable_manual = AD_SETTINGS_NOT_CHECKED;
249
  return $enable_manual;
250
  }
251
 
252
  public function get_process_php (){
253
  $process_php = isset ($this->wp_options [AI_OPTION_PROCESS_PHP]) ? $this->wp_options [AI_OPTION_PROCESS_PHP] : '';
254
- if ($process_php == '') $process_php = AD_SETTINGS_NOT_CHECKED;
255
  return $process_php;
256
  }
257
 
258
  public function get_enable_404 (){
259
  $enable_404 = isset ($this->wp_options [AI_OPTION_ENABLE_404]) ? $this->wp_options [AI_OPTION_ENABLE_404] : '';
260
- if ($enable_404 == '') $enable_404 = AD_SETTINGS_NOT_CHECKED;
261
  return $enable_404;
262
  }
263
 
@@ -266,9 +268,9 @@ abstract class ai_BaseCodeBlock {
266
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
267
  $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
268
  } else $display_for_devices = '';
269
- if ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AD_SETTINGS_NOT_CHECKED; else
270
 
271
- $option = isset ($this->wp_options [AI_OPTION_DETECT_SERVER_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] : AD_SETTINGS_NOT_CHECKED;
272
  return $option;
273
  }
274
 
@@ -323,14 +325,25 @@ abstract class ai_BaseCodeBlock {
323
  $global_name = 'GENERATED_CODE';
324
  if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
325
 
 
326
  ob_start ();
327
- eval ("?>". $code . "<?php ");
328
- $code = ob_get_clean ();
329
- if (strpos ($code, __FILE__)) {
330
- if (preg_match ("/(.+) in ".str_replace ("/", "\/", __FILE__)."/", $code, $error_message))
331
- $code = "PHP error in " . AD_INSERTER_NAME . " code block ".$obj->number . " - " . $obj->get_ad_name() . "<br />\n" . $error_message [1];
332
  }
333
 
 
 
 
 
 
 
 
 
 
 
334
  // Cache generated code
335
  $obj->wp_options [$global_name] = $code;
336
 
@@ -352,6 +365,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
352
  parent::__construct();
353
 
354
  $this->wp_options [AI_OPTION_NAME] = AD_NAME;
 
355
  $this->wp_options [AI_OPTION_AUTOMATIC_INSERTION] = AI_AUTOMATIC_INSERTION_DISABLED;
356
  $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] = AD_ONE;
357
  $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] = AD_EMPTY_DATA;
@@ -359,7 +373,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
359
  $this->wp_options [AI_OPTION_MAX_WORDS] = AD_EMPTY_DATA;
360
  $this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS] = AD_EMPTY_DATA;
361
  $this->wp_options [AI_OPTION_MAX_PARAGRAPH_WORDS] = AD_EMPTY_DATA;
362
- $this->wp_options [AI_OPTION_COUNT_INSIDE_BLOCKQUOTE] = AD_SETTINGS_NOT_CHECKED;
363
  $this->wp_options [AI_OPTION_PARAGRAPH_TAGS] = DEFAULT_PARAGRAPH_TAGS;
364
  $this->wp_options [AI_OPTION_AVOID_PARAGRAPHS_ABOVE] = AD_EMPTY_DATA;
365
  $this->wp_options [AI_OPTION_AVOID_PARAGRAPHS_BELOW] = AD_EMPTY_DATA;
@@ -395,25 +409,25 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
395
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
396
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
397
  $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
398
- $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AD_SETTINGS_CHECKED;
399
- $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AD_SETTINGS_NOT_CHECKED;
400
- $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AD_SETTINGS_NOT_CHECKED;
401
- $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AD_SETTINGS_NOT_CHECKED;
402
- $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AD_SETTINGS_NOT_CHECKED;
403
- $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AD_SETTINGS_NOT_CHECKED;
404
- $this->wp_options [AI_OPTION_ENABLE_AJAX] = AD_SETTINGS_CHECKED;
405
- $this->wp_options [AI_OPTION_ENABLE_FEED] = AD_SETTINGS_NOT_CHECKED;
406
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
407
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
408
- $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AD_SETTINGS_NOT_CHECKED;
409
- $this->wp_options [AI_OPTION_ENABLE_WIDGET] = AD_SETTINGS_CHECKED;
410
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT] = AD_EMPTY_DATA;
411
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT_TYPE] = AD_DO_NOT_CONTAIN;
412
  $this->wp_options [AI_OPTION_CUSTOM_CSS] = AD_EMPTY_DATA;
413
  $this->wp_options [AI_OPTION_DISPLAY_FOR_USERS] = AD_DISPLAY_ALL_USERS;
414
- $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] = AD_SETTINGS_NOT_CHECKED;
415
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
416
- $this->wp_options [AI_OPTION_DETECT_VIEWPORT . '_' . $viewport] = AD_SETTINGS_NOT_CHECKED;
417
  }
418
  }
419
 
@@ -589,13 +603,23 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
589
  return $style;
590
  }
591
 
 
 
 
 
 
 
 
 
 
 
592
  public function get_alignment_style (){
593
  return $this->alignment_style ($this->get_alignment_type());
594
  }
595
 
596
  public function get_paragraph_number(){
597
  $option = isset ($this->wp_options [AI_OPTION_PARAGRAPH_NUMBER]) ? $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] : "";
598
- if ($option == '') $option = AD_ZERO;
599
  return $option;
600
  }
601
 
@@ -631,7 +655,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
631
 
632
  public function get_count_inside_blockquote(){
633
  $option = isset ($this->wp_options [AI_OPTION_COUNT_INSIDE_BLOCKQUOTE]) ? $this->wp_options [AI_OPTION_COUNT_INSIDE_BLOCKQUOTE] : "";
634
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
635
  return $option;
636
  }
637
 
@@ -692,13 +716,13 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
692
 
693
  public function get_display_settings_post(){
694
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_POSTS]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] : "";
695
- if ($option == '') $option = AD_SETTINGS_CHECKED;
696
  return $option;
697
  }
698
 
699
  public function get_display_settings_page(){
700
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] : "";
701
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
702
  return $option;
703
  }
704
 
@@ -706,7 +730,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
706
  global $ai_db_options;
707
 
708
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] : "";
709
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
710
 
711
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
712
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
@@ -717,7 +741,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
717
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
718
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
719
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
720
- $option = AD_SETTINGS_NOT_CHECKED;
721
  }
722
 
723
  return $option;
@@ -727,7 +751,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
727
  global $ai_db_options;
728
 
729
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] : "";
730
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
731
 
732
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
733
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
@@ -738,7 +762,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
738
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
739
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
740
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
741
- $option = AD_SETTINGS_NOT_CHECKED;
742
  }
743
 
744
  return $option;
@@ -748,7 +772,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
748
  global $ai_db_options;
749
 
750
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] : "";
751
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
752
 
753
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
754
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
@@ -759,7 +783,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
759
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
760
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
761
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
762
- $option = AD_SETTINGS_NOT_CHECKED;
763
  }
764
 
765
  return $option;
@@ -769,7 +793,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
769
  global $ai_db_options;
770
 
771
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] : "";
772
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
773
 
774
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
775
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
@@ -780,7 +804,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
780
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
781
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
782
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
783
- $option = AD_SETTINGS_NOT_CHECKED;
784
  }
785
 
786
  return $option;
@@ -788,20 +812,20 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
788
 
789
  public function get_enable_feed (){
790
  $enable_feed = isset ($this->wp_options [AI_OPTION_ENABLE_FEED]) ? $this->wp_options [AI_OPTION_ENABLE_FEED] : "";
791
- if ($enable_feed == '') $enable_feed = AD_SETTINGS_NOT_CHECKED;
792
  return $enable_feed;
793
  }
794
 
795
  public function get_enable_ajax (){
796
  $enable_ajax = isset ($this->wp_options [AI_OPTION_ENABLE_AJAX]) ? $this->wp_options [AI_OPTION_ENABLE_AJAX] : "";
797
- if ($enable_ajax == '') $enable_ajax = AD_SETTINGS_CHECKED;
798
  return $enable_ajax;
799
  }
800
 
801
  public function get_enable_manual (){
802
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
803
  if ($option == '') {
804
- $option = AD_SETTINGS_NOT_CHECKED;
805
  }
806
  return $option;
807
  }
@@ -810,14 +834,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
810
  global $ai_db_options;
811
 
812
  $enable_widget = isset ($this->wp_options [AI_OPTION_ENABLE_WIDGET]) ? $this->wp_options [AI_OPTION_ENABLE_WIDGET] : "";
813
- if ($enable_widget == '') $enable_widget = AD_SETTINGS_CHECKED;
814
 
815
  return $enable_widget;
816
  }
817
 
818
  public function get_enable_php_call (){
819
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_PHP_CALL]) ? $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] : "";
820
- if ($option == '') $option = AD_SETTINGS_NOT_CHECKED;
821
  return $option;
822
  }
823
 
@@ -859,14 +883,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
859
  public function get_detection_client_side(){
860
  global $ai_db_options;
861
 
862
- $option = isset ($this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] : AD_SETTINGS_NOT_CHECKED;
863
 
864
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
865
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
866
  $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
867
  } else $display_for_devices = '';
868
 
869
- if ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AD_SETTINGS_NOT_CHECKED;
870
  }
871
 
872
  return $option;
@@ -876,7 +900,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
876
  global $ai_db_options;
877
 
878
  $option_name = AI_OPTION_DETECT_VIEWPORT . '_' . $viewport;
879
- $option = isset ($this->wp_options [$option_name]) ? $this->wp_options [$option_name] : AD_SETTINGS_NOT_CHECKED;
880
 
881
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605' && $this->get_detection_client_side()) {
882
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
@@ -888,10 +912,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
888
  $display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) {
889
  switch ($viewport) {
890
  case 1:
891
- $option = AD_SETTINGS_CHECKED;
892
  break;
893
  default:
894
- $option = AD_SETTINGS_NOT_CHECKED;
895
  }
896
  }
897
  elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES ||
@@ -899,10 +923,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
899
  $display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) {
900
  switch ($viewport) {
901
  case 2:
902
- $option = AD_SETTINGS_CHECKED;
903
  break;
904
  default:
905
- $option = AD_SETTINGS_NOT_CHECKED;
906
  }
907
  }
908
  elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES ||
@@ -910,13 +934,13 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
910
  $display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) {
911
  switch ($viewport) {
912
  case 3:
913
- $option = AD_SETTINGS_CHECKED;
914
  break;
915
  default:
916
- $option = AD_SETTINGS_NOT_CHECKED;
917
  }
918
  }
919
- elseif ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AD_SETTINGS_NOT_CHECKED;
920
  }
921
 
922
  return $option;
@@ -978,7 +1002,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
978
 
979
  switch ($dynamic_blocks) {
980
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
981
- $processed_code = $ads [rand (0, count ($ads) - 1)];
 
982
  break;
983
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
984
  $processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
@@ -995,7 +1020,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
995
  $processed_code .= "</div>\n";
996
  break;
997
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
998
- $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($ads)).'\')); $ai_code = $ai_code [rand (0, count ($ai_code) - 1)]; $ai_enabled = true;';
999
  $processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1000
  $processed_code .= $this->w3tc_code.' echo $ai_code;';
1001
  $processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
@@ -1030,7 +1055,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1030
  }
1031
  break;
1032
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
1033
- if ($this->w3tc_code == '') $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($processed_code)).'\')); $ai_enabled = true;';
1034
 
1035
  $this->w3tc_code .= ' require_once \''.AD_INSERTER_PLUGIN_DIR.'includes/geo/Ip2Country.php\';';
1036
 
@@ -1286,12 +1311,31 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1286
 
1287
  if ($hidden_widgets) return $hidden_blocks; else {
1288
  if ($this->client_side_ip_address_detection) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
1289
- $wrapper_before = $hidden_blocks . "<div" . $class . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1290
  $wrapper_after = "</div>\n";
1291
 
1292
  if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
 
 
 
 
 
1293
  $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1294
- $code .= $this->w3tc_code.' if ($ai_enabled) echo unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_before)).'\')), $ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_after)).'\'));';
1295
  $code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1296
  return $code;
1297
  } else return $wrapper_before . $code . $wrapper_after;
@@ -1362,9 +1406,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1362
  if (strtolower ($special_element [0]) == "<$special_element_tag" && isset ($special_elements [$index + 1][0]) && strtolower ($special_elements [$index + 1][0]) == "</$special_element_tag") {
1363
 
1364
  if ($multibyte) {
1365
- $special_element_offsets []= array (mb_strlen (substr ($content, 0, $special_element [1])), mb_strlen (substr ($content, 0, $special_elements [$index + 1][1])));
1366
  } else {
1367
- $special_element_offsets []= array ($special_element [1], $special_elements [$index + 1][1]);
1368
  }
1369
  }
1370
  }
@@ -1475,160 +1519,188 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1475
  if (count ($paragraph_positions) == 0) return $content;
1476
 
1477
 
1478
- $position = $this->get_paragraph_number();
1479
-
1480
- if ($position > 0 && $position < 1) {
1481
- $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
1482
- }
1483
- elseif ($position <= 0) {
1484
- $position = rand (0, count ($paragraph_positions) - 1);
1485
- } else $position --;
1486
-
1487
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1488
  $paragraph_positions = array_reverse ($paragraph_positions);
1489
  }
1490
 
1491
 
1492
- $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
1493
- $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1494
 
1495
- if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) {
1496
- $avoid_text_above = $this->get_avoid_text_above();
1497
- $avoid_text_below = $this->get_avoid_text_below();
1498
- $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above)));
1499
- $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below)));
1500
 
1501
- $direction = $this->get_avoid_direction();
1502
- $max_checks = $this->get_avoid_try_limit();
 
 
 
1503
 
1504
- $checks = $max_checks;
1505
- $saved_position = $position;
1506
- do {
1507
- $found_above = false;
1508
- if ($position != 0 && $avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
1509
- $paragraph_position_above = $position - $avoid_paragraphs_above;
1510
- if ($paragraph_position_above < 0) $paragraph_position_above = 0;
1511
 
1512
- if ($multibyte) {
1513
- $paragraph_code = mb_substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
1514
- } else {
1515
- $paragraph_code = substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
1516
- }
 
 
1517
 
1518
- foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1519
- if (trim ($paragraph_text_above) == '') continue;
1520
  if ($multibyte) {
1521
- if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1522
- $found_above = true;
1523
- break;
1524
- }
1525
  } else {
1526
- if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
 
 
 
 
 
 
1527
  $found_above = true;
1528
  break;
1529
  }
1530
- }
 
 
 
 
 
 
1531
  }
1532
- }
1533
 
1534
- $found_below = false;
1535
- if ($avoid_paragraphs_below != 0 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1536
- $paragraph_position_below = $position + $avoid_paragraphs_below;
1537
 
1538
- if ($multibyte) {
1539
- if ($paragraph_position_below > count ($paragraph_positions) - 1)
1540
- $content_position_below = mb_strlen ($content); else
1541
- $content_position_below = $paragraph_positions [$paragraph_position_below];
1542
- $paragraph_code = mb_substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
1543
- } else {
1544
  if ($paragraph_position_below > count ($paragraph_positions) - 1)
1545
- $content_position_below = strlen ($content); else
1546
  $content_position_below = $paragraph_positions [$paragraph_position_below];
1547
- $paragraph_code = substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
1548
- }
 
 
 
 
 
1549
 
1550
- foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1551
- if (trim ($paragraph_text_below) == '') continue;
1552
 
1553
- if ($multibyte) {
1554
- if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1555
- $found_below = true;
1556
- break;
1557
- }
1558
- } else {
1559
- if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1560
  $found_below = true;
1561
  break;
1562
  }
1563
- }
 
 
 
 
 
 
1564
  }
1565
- }
1566
 
1567
 
1568
- // echo "position: $position = before #", $position + 1, "<br />\n";
1569
- // echo "checks: $checks<br />\n";
1570
- // echo "direction: $direction<br />\n";
1571
- // if ($found_above)
1572
- // echo "found_above<br />\n";
1573
- // if ($found_below)
1574
- // echo "found_below<br />\n";
1575
- // echo "=================<br />\n";
1576
-
1577
-
1578
- if ($found_above || $found_below) {
1579
- $ai_last_check = AI_CHECK_DO_NOT_INSERT;
1580
- if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
1581
-
1582
- switch ($direction) {
1583
- case AD_ABOVE: // Try above
1584
- $ai_last_check = AI_CHECK_AD_ABOVE;
1585
- if ($position == 0) return $content; // Already at the top - do not insert
1586
- $position --;
1587
- break;
1588
- case AD_BELOW: // Try below
1589
- $ai_last_check = AI_CHECK_AD_BELOW;
1590
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
1591
- $position ++;
1592
- break;
1593
- case AD_ABOVE_AND_THEN_BELOW: // Try first above and then below
1594
- if ($position == 0 || $checks == 0) {
1595
- // Try below
1596
- $direction = AD_BELOW;
1597
- $checks = $max_checks;
1598
- $position = $saved_position;
1599
- $ai_last_check = AI_CHECK_AD_BELOW;
1600
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
1601
- $position ++;
1602
- } else $position --;
1603
- break;
1604
- case AD_BELOW_AND_THEN_ABOVE: // Try first below and then above
1605
- if ($position >= count ($paragraph_positions) - 1 || $checks == 0) {
1606
- // Try above
1607
- $direction = AD_ABOVE;
1608
- $checks = $max_checks;
1609
- $position = $saved_position;
1610
  $ai_last_check = AI_CHECK_AD_ABOVE;
1611
  if ($position == 0) return $content; // Already at the top - do not insert
1612
  $position --;
1613
- } else $position ++;
1614
- break;
1615
- }
1616
- } else break; // Text not found - insert
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1617
 
1618
- // Try next position
1619
- if ($checks <= 0) return $content; // Suitable position not found - do not insert
1620
- $checks --;
1621
- } while (true);
1622
- }
1623
 
1624
- // Nothing to do
1625
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE;
1626
- if (count ($paragraph_positions) == 0) return $content;
 
1627
 
1628
- if ($position_preview) {
1629
  $offset = 0;
 
 
 
1630
  foreach ($paragraph_positions as $counter => $paragraph_position) {
1631
- $inserted_code = "[[AI_BP".($counter + 1)."]]";
 
 
1632
 
1633
  if ($multibyte) {
1634
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
@@ -1646,6 +1718,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1646
  }
1647
  }
1648
  }
 
1649
  return $content;
1650
  }
1651
 
@@ -1854,162 +1927,190 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1854
  if (count ($paragraph_positions) == 0) return $content;
1855
 
1856
 
1857
- $position = $this->get_paragraph_number();
1858
-
1859
- if ($position > 0 && $position < 1) {
1860
- $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
1861
- }
1862
- elseif ($position <= 0) {
1863
- $position = rand (0, count ($paragraph_positions) - 1);
1864
- } else $position --;
1865
-
1866
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1867
  $paragraph_positions = array_reverse ($paragraph_positions);
1868
  }
1869
 
1870
 
1871
- $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
1872
- $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
1873
 
1874
- if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) {
1875
- $avoid_text_above = $this->get_avoid_text_above();
1876
- $avoid_text_below = $this->get_avoid_text_below();
1877
- $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above)));
1878
- $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1879
 
1880
- $direction = $this->get_avoid_direction();
1881
- $max_checks = $this->get_avoid_try_limit();
 
 
 
 
 
1882
 
1883
- $checks = $max_checks;
1884
- $saved_position = $position;
1885
- do {
1886
- $found_above = false;
1887
- if ($avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
1888
- $paragraph_position_above = $position - $avoid_paragraphs_above;
1889
- if ($paragraph_position_above <= 0)
1890
- $content_position_above = 0; else
1891
- $content_position_above = $paragraph_positions [$paragraph_position_above] + 1;
1892
 
1893
- if ($multibyte) {
1894
- $paragraph_code = mb_substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
1895
- } else {
1896
- $paragraph_code = substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
1897
- }
1898
 
1899
- foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1900
- if (trim ($paragraph_text_above) == '') continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1901
 
1902
  if ($multibyte) {
1903
- if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1904
- $found_above = true;
1905
- break;
1906
- }
1907
  } else {
1908
- if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
 
 
 
 
 
 
 
1909
  $found_above = true;
1910
  break;
1911
  }
1912
- }
 
 
 
 
 
1913
 
 
1914
  }
1915
- }
1916
 
1917
- $found_below = false;
1918
- if ($avoid_paragraphs_below != 0 && $position != count ($paragraph_positions) - 1 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1919
- $paragraph_position_below = $position + $avoid_paragraphs_below;
1920
 
1921
- if ($multibyte) {
1922
- if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
1923
- $paragraph_code = mb_substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
1924
- } else {
1925
  if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
1926
- $paragraph_code = substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
1927
- }
 
 
 
1928
 
1929
- foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1930
- if (trim ($paragraph_text_below) == '') continue;
1931
 
1932
- if ($multibyte) {
1933
- if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1934
- $found_below = true;
1935
- break;
1936
- }
1937
- } else {
1938
- if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1939
  $found_below = true;
1940
  break;
1941
  }
1942
- }
 
 
 
 
 
1943
 
 
1944
  }
1945
- }
1946
 
1947
 
1948
- // echo "position: $position = after #", $position + 1, "<br />\n";
1949
- // echo "checks: $checks<br />\n";
1950
- // echo "direction: $direction<br />\n";
1951
- // if ($found_above)
1952
- // echo "found_above<br />\n";
1953
- // if ($found_below)
1954
- // echo "found_below<br />\n";
1955
- // echo "=================<br />\n";
1956
-
1957
-
1958
- if ($found_above || $found_below) {
1959
- $ai_last_check = AI_CHECK_DO_NOT_INSERT;
1960
- if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
1961
-
1962
- switch ($direction) {
1963
- case AD_ABOVE: // Try above
1964
- $ai_last_check = AI_CHECK_AD_ABOVE;
1965
- if ($position == 0) return $content; // Already at the top - do not insert
1966
- $position --;
1967
- break;
1968
- case AD_BELOW: // Try below
1969
- $ai_last_check = AI_CHECK_AD_BELOW;
1970
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
1971
- $position ++;
1972
- break;
1973
- case AD_ABOVE_AND_THEN_BELOW: // Try first above and then below
1974
- if ($position == 0 || $checks == 0) {
1975
- // Try below
1976
- $direction = AD_BELOW;
1977
- $checks = $max_checks;
1978
- $position = $saved_position;
1979
- $ai_last_check = AI_CHECK_AD_BELOW;
1980
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
1981
- $position ++;
1982
- } else $position --;
1983
- break;
1984
- case AD_BELOW_AND_THEN_ABOVE: // Try first below and then above
1985
- if ($position >= count ($paragraph_positions) - 1 || $checks == 0) {
1986
- // Try above
1987
- $direction = AD_ABOVE;
1988
- $checks = $max_checks;
1989
- $position = $saved_position;
1990
  $ai_last_check = AI_CHECK_AD_ABOVE;
1991
  if ($position == 0) return $content; // Already at the top - do not insert
1992
  $position --;
1993
- } else $position ++;
1994
- break;
1995
- }
1996
- } else break; // Text not found - insert
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1997
 
1998
- // Try next position
1999
- if ($checks <= 0) return $content; // Suitable position not found - do not insert
2000
- $checks --;
2001
- } while (true);
2002
- }
2003
 
2004
- // Nothing to do
2005
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE;
2006
- if (count ($paragraph_positions) == 0) return $content;
 
2007
 
2008
 
2009
- if ($position_preview) {
2010
  $offset = 0;
 
 
 
2011
  foreach ($paragraph_positions as $counter => $paragraph_position) {
2012
- $inserted_code = "[[AI_AP".($counter + 1)."]]";
 
 
2013
 
2014
  if ($multibyte) {
2015
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
@@ -2028,6 +2129,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2028
  }
2029
 
2030
  }
 
2031
  return $content;
2032
  }
2033
 
@@ -2059,582 +2161,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2059
  }
2060
 
2061
 
2062
- /*
2063
- public function before_paragraph ($content, $position_preview = false) {
2064
- global $ai_wp_data, $ai_last_check;
2065
-
2066
- if (get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS) {
2067
- return ($this->before_paragraph_mb ($content, $position_preview));
2068
- }
2069
-
2070
- $paragraph_positions = array ();
2071
-
2072
- $paragraph_tags = trim ($this->get_paragraph_tags());
2073
- if ($paragraph_tags == '') return $content;
2074
-
2075
- $paragraph_start_strings = explode (",", $paragraph_tags);
2076
-
2077
- $ai_last_check = AI_CHECK_PARAGRAPH_TAGS;
2078
- if (count ($paragraph_start_strings) == 0) return $content;
2079
-
2080
- foreach ($paragraph_start_strings as $paragraph_start_string) {
2081
- if (trim ($paragraph_start_string) == '') continue;
2082
-
2083
- $last_position = - 1;
2084
-
2085
- $paragraph_start_string = trim ($paragraph_start_string);
2086
- if ($paragraph_start_string == "#") {
2087
- $paragraph_start = "\r\n\r\n";
2088
- if (!in_array (0, $paragraph_positions)) $paragraph_positions [] = 0;
2089
- } else $paragraph_start = '<' . $paragraph_start_string;
2090
-
2091
- $paragraph_start_len = strlen ($paragraph_start);
2092
-
2093
- while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
2094
- $last_position = stripos ($content, $paragraph_start, $last_position + 1);
2095
- if ($paragraph_start_string == "#") $paragraph_positions [] = $last_position + 4; else
2096
- if ($content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ")
2097
- $paragraph_positions [] = $last_position;
2098
- }
2099
- }
2100
-
2101
- // Nothing to do
2102
- $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS;
2103
- if (count ($paragraph_positions) == 0) return $content;
2104
-
2105
- sort ($paragraph_positions);
2106
-
2107
- if (!$this->get_count_inside_blockquote ()) {
2108
- preg_match_all ('/<\/?blockquote/i', $content, $blockquotes, PREG_OFFSET_CAPTURE);
2109
-
2110
- $blockquote_offsets = array ();
2111
- $blockquotes = $blockquotes [0];
2112
- foreach ($blockquotes as $index => $blockquote) {
2113
- if (strtolower ($blockquote [0]) == '<blockquote' && isset ($blockquotes [$index + 1][0]) && strtolower ($blockquotes [$index + 1][0]) == '</blockquote') {
2114
- $blockquote_offsets []= array ($blockquote [1] + 11, $blockquotes [$index + 1][1]);
2115
- }
2116
- }
2117
-
2118
- if (count ($blockquote_offsets) != 0) {
2119
-
2120
- $filtered_paragraph_positions = array ();
2121
- $inside_blockquote = array ();
2122
-
2123
- foreach ($blockquote_offsets as $blockquote_offset) {
2124
- foreach ($paragraph_positions as $paragraph_position) {
2125
- if ($paragraph_position >= $blockquote_offset [0] && $paragraph_position <= $blockquote_offset [1]) $inside_blockquote [] = $paragraph_position;
2126
- }
2127
- }
2128
-
2129
- foreach ($paragraph_positions as $paragraph_position) {
2130
- if (!in_array ($paragraph_position, $inside_blockquote)) $filtered_paragraph_positions []= $paragraph_position;
2131
- }
2132
-
2133
- $paragraph_positions = $filtered_paragraph_positions;
2134
- }
2135
- }
2136
-
2137
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_BLOCKQUOTE_FIGURE;
2138
- if (count ($paragraph_positions) == 0) return $content;
2139
-
2140
- $paragraph_min_words = intval ($this->get_minimum_paragraph_words());
2141
- $paragraph_max_words = intval ($this->get_maximum_paragraph_words());
2142
-
2143
- if ($paragraph_min_words != 0 || $paragraph_max_words != 0) {
2144
- $filtered_paragraph_positions = array ();
2145
- foreach ($paragraph_positions as $index => $paragraph_position) {
2146
- $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
2147
- if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
2148
- }
2149
- $paragraph_positions = $filtered_paragraph_positions;
2150
- }
2151
-
2152
- // Nothing to do
2153
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS;
2154
- if (count ($paragraph_positions) == 0) return $content;
2155
-
2156
-
2157
- $paragraph_texts = explode (",", html_entity_decode ($this->get_paragraph_text()));
2158
- if ($this->get_paragraph_text() != "" && count ($paragraph_texts) != 0) {
2159
-
2160
- $filtered_paragraph_positions = array ();
2161
- $paragraph_text_type = $this->get_paragraph_text_type ();
2162
-
2163
- foreach ($paragraph_positions as $index => $paragraph_position) {
2164
- $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
2165
-
2166
- if ($paragraph_text_type == AD_CONTAIN) {
2167
- $found = true;
2168
- foreach ($paragraph_texts as $paragraph_text) {
2169
- if (trim ($paragraph_text) == '') continue;
2170
- if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
2171
- $found = false;
2172
- break;
2173
- }
2174
- }
2175
- if ($found) $filtered_paragraph_positions [] = $paragraph_position;
2176
- } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
2177
- $found = false;
2178
- foreach ($paragraph_texts as $paragraph_text) {
2179
- if (trim ($paragraph_text) == '') continue;
2180
- if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
2181
- $found = true;
2182
- break;
2183
- }
2184
- }
2185
- if (!$found) $filtered_paragraph_positions [] = $paragraph_position;
2186
- }
2187
- }
2188
-
2189
- $paragraph_positions = $filtered_paragraph_positions;
2190
- }
2191
-
2192
- // Nothing to do
2193
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT;
2194
- if (count ($paragraph_positions) == 0) return $content;
2195
-
2196
-
2197
- $position = $this->get_paragraph_number();
2198
-
2199
- if ($position > 0 && $position < 1) {
2200
- $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
2201
- }
2202
- elseif ($position <= 0) {
2203
- $position = rand (0, count ($paragraph_positions) - 1);
2204
- } else $position --;
2205
-
2206
- if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
2207
- $paragraph_positions = array_reverse ($paragraph_positions);
2208
- }
2209
-
2210
-
2211
- $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
2212
- $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
2213
-
2214
- if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) {
2215
- $avoid_text_above = $this->get_avoid_text_above();
2216
- $avoid_text_below = $this->get_avoid_text_below();
2217
- $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above)));
2218
- $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below)));
2219
-
2220
- $direction = $this->get_avoid_direction();
2221
- $max_checks = $this->get_avoid_try_limit();
2222
-
2223
- $checks = $max_checks;
2224
- $saved_position = $position;
2225
- do {
2226
- $found_above = false;
2227
- if ($position != 0 && $avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
2228
- $paragraph_position_above = $position - $avoid_paragraphs_above;
2229
- if ($paragraph_position_above < 0) $paragraph_position_above = 0;
2230
- $paragraph_code = substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
2231
- foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
2232
- if (trim ($paragraph_text_above) == '') continue;
2233
- if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
2234
- $found_above = true;
2235
- break;
2236
- }
2237
- }
2238
- }
2239
-
2240
- $found_below = false;
2241
- if ($avoid_paragraphs_below != 0 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
2242
- $paragraph_position_below = $position + $avoid_paragraphs_below;
2243
- if ($paragraph_position_below > count ($paragraph_positions) - 1)
2244
- $content_position_below = strlen ($content); else
2245
- $content_position_below = $paragraph_positions [$paragraph_position_below];
2246
- $paragraph_code = substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
2247
- foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
2248
- if (trim ($paragraph_text_below) == '') continue;
2249
- if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
2250
- $found_below = true;
2251
- break;
2252
- }
2253
- }
2254
- }
2255
-
2256
-
2257
- // echo "position: $position = before #", $position + 1, "<br />\n";
2258
- // echo "checks: $checks<br />\n";
2259
- // echo "direction: $direction<br />\n";
2260
- // if ($found_above)
2261
- // echo "found_above<br />\n";
2262
- // if ($found_below)
2263
- // echo "found_below<br />\n";
2264
- // echo "=================<br />\n";
2265
-
2266
-
2267
- if ($found_above || $found_below) {
2268
- $ai_last_check = AI_CHECK_DO_NOT_INSERT;
2269
- if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
2270
-
2271
- switch ($direction) {
2272
- case AD_ABOVE: // Try above
2273
- $ai_last_check = AI_CHECK_AD_ABOVE;
2274
- if ($position == 0) return $content; // Already at the top - do not insert
2275
- $position --;
2276
- break;
2277
- case AD_BELOW: // Try below
2278
- $ai_last_check = AI_CHECK_AD_BELOW;
2279
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
2280
- $position ++;
2281
- break;
2282
- case AD_ABOVE_AND_THEN_BELOW: // Try first above and then below
2283
- if ($position == 0 || $checks == 0) {
2284
- // Try below
2285
- $direction = AD_BELOW;
2286
- $checks = $max_checks;
2287
- $position = $saved_position;
2288
- $ai_last_check = AI_CHECK_AD_BELOW;
2289
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
2290
- $position ++;
2291
- } else $position --;
2292
- break;
2293
- case AD_BELOW_AND_THEN_ABOVE: // Try first below and then above
2294
- if ($position >= count ($paragraph_positions) - 1 || $checks == 0) {
2295
- // Try above
2296
- $direction = AD_ABOVE;
2297
- $checks = $max_checks;
2298
- $position = $saved_position;
2299
- $ai_last_check = AI_CHECK_AD_ABOVE;
2300
- if ($position == 0) return $content; // Already at the top - do not insert
2301
- $position --;
2302
- } else $position ++;
2303
- break;
2304
- }
2305
- } else break; // Text not found - insert
2306
-
2307
- // Try next position
2308
- if ($checks <= 0) return $content; // Suitable position not found - do not insert
2309
- $checks --;
2310
- } while (true);
2311
- }
2312
-
2313
- // Nothing to do
2314
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE;
2315
- if (count ($paragraph_positions) == 0) return $content;
2316
-
2317
- if ($position_preview) {
2318
- $offset = 0;
2319
- foreach ($paragraph_positions as $counter => $paragraph_position) {
2320
- $inserted_code = "[[AI_BP".($counter + 1)."]]";
2321
- if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
2322
- $content = substr_replace ($content, $inserted_code, $paragraph_position, 0);
2323
- } else {
2324
- $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset, 0);
2325
- $offset += strlen ($inserted_code);
2326
- }
2327
- }
2328
- return $content;
2329
- }
2330
-
2331
- $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER;
2332
- if (count ($paragraph_positions) >= intval ($this->get_paragraph_number_minimum())) {
2333
- $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER;
2334
- if (count ($paragraph_positions) > $position) {
2335
- $this->increment_block_counter ();
2336
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
2337
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
2338
- $content_position = $paragraph_positions [$position];
2339
- $content = substr_replace ($content, $this->get_code_for_insertion (), $content_position, 0);
2340
- $ai_last_check = AI_CHECK_INSERTED;
2341
- }
2342
- }
2343
- }
2344
-
2345
- return $content;
2346
- }
2347
-
2348
- public function after_paragraph ($content, $position_preview = false) {
2349
- global $ai_wp_data, $ai_last_check;
2350
-
2351
- if (get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS) {
2352
- return ($this->after_paragraph_mb ($content, $position_preview));
2353
- }
2354
-
2355
- $paragraph_positions = array ();
2356
- $last_content_position = strlen ($content) - 1;
2357
-
2358
- $paragraph_tags = trim ($this->get_paragraph_tags());
2359
- if ($paragraph_tags == '') return $content;
2360
-
2361
- $paragraph_end_strings = explode (",", $paragraph_tags);
2362
-
2363
- $ai_last_check = AI_CHECK_PARAGRAPH_TAGS;
2364
- if (count ($paragraph_end_strings) == 0) return $content;
2365
-
2366
- foreach ($paragraph_end_strings as $paragraph_end_string) {
2367
- if (trim ($paragraph_end_string) == '') continue;
2368
-
2369
- $last_position = - 1;
2370
-
2371
- $paragraph_end_string = trim ($paragraph_end_string);
2372
- if ($paragraph_end_string == "#") {
2373
- $paragraph_end = "\r\n\r\n";
2374
- if (!in_array ($last_content_position, $paragraph_positions)) $paragraph_positions [] = $last_content_position;
2375
- } else $paragraph_end = '</' . $paragraph_end_string . '>';
2376
-
2377
- while (stripos ($content, $paragraph_end, $last_position + 1) !== false) {
2378
- $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
2379
- if ($paragraph_end_string == "#") $paragraph_positions [] = $last_position - 4; else
2380
- $paragraph_positions [] = $last_position;
2381
- }
2382
- }
2383
-
2384
- // Nothing to do
2385
- $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS;
2386
- if (count ($paragraph_positions) == 0) return $content;
2387
-
2388
- sort ($paragraph_positions);
2389
-
2390
- if (!$this->get_count_inside_blockquote ()) {
2391
- preg_match_all ('/<\/?blockquote/i', $content, $blockquotes, PREG_OFFSET_CAPTURE);
2392
-
2393
- $blockquote_offsets = array ();
2394
- $blockquotes = $blockquotes [0];
2395
- foreach ($blockquotes as $index => $blockquote) {
2396
- if (strtolower ($blockquote [0]) == '<blockquote' && isset ($blockquotes [$index + 1][0]) && strtolower ($blockquotes [$index + 1][0]) == '</blockquote') {
2397
- $blockquote_offsets []= array ($blockquote [1] + 11, $blockquotes [$index + 1][1]);
2398
- }
2399
- }
2400
-
2401
- if (count ($blockquote_offsets) != 0) {
2402
-
2403
- $filtered_paragraph_positions = array ();
2404
- $inside_blockquote = array ();
2405
-
2406
- foreach ($blockquote_offsets as $blockquote_offset) {
2407
- foreach ($paragraph_positions as $paragraph_position) {
2408
- if ($paragraph_position >= $blockquote_offset [0] && $paragraph_position <= $blockquote_offset [1]) $inside_blockquote [] = $paragraph_position;
2409
- }
2410
- }
2411
-
2412
- foreach ($paragraph_positions as $paragraph_position) {
2413
- if (!in_array ($paragraph_position, $inside_blockquote)) $filtered_paragraph_positions []= $paragraph_position;
2414
- }
2415
-
2416
- $paragraph_positions = $filtered_paragraph_positions;
2417
- }
2418
- }
2419
-
2420
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_BLOCKQUOTE_FIGURE;
2421
- if (count ($paragraph_positions) == 0) return $content;
2422
-
2423
- $paragraph_min_words = intval ($this->get_minimum_paragraph_words());
2424
- $paragraph_max_words = intval ($this->get_maximum_paragraph_words());
2425
-
2426
- if ($paragraph_min_words != 0 || $paragraph_max_words != 0) {
2427
- $filtered_paragraph_positions = array ();
2428
- foreach ($paragraph_positions as $index => $paragraph_position) {
2429
- $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
2430
- if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
2431
- }
2432
- $paragraph_positions = $filtered_paragraph_positions;
2433
- }
2434
-
2435
- // Nothing to do
2436
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS;
2437
- if (count ($paragraph_positions) == 0) return $content;
2438
-
2439
-
2440
- $paragraph_texts = explode (",", html_entity_decode ($this->get_paragraph_text()));
2441
- if ($this->get_paragraph_text() != "" && count ($paragraph_texts) != 0) {
2442
-
2443
- $filtered_paragraph_positions = array ();
2444
- $paragraph_text_type = $this->get_paragraph_text_type ();
2445
-
2446
- foreach ($paragraph_positions as $index => $paragraph_position) {
2447
- $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
2448
-
2449
- if ($paragraph_text_type == AD_CONTAIN) {
2450
- $found = true;
2451
- foreach ($paragraph_texts as $paragraph_text) {
2452
- if (trim ($paragraph_text) == '') continue;
2453
- if (stripos ($paragraph_code, trim ($paragraph_text)) === false) {
2454
- $found = false;
2455
- break;
2456
- }
2457
- }
2458
- if ($found) $filtered_paragraph_positions [] = $paragraph_position;
2459
- } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
2460
- $found = false;
2461
- foreach ($paragraph_texts as $paragraph_text) {
2462
- if (trim ($paragraph_text) == '') continue;
2463
- if (stripos ($paragraph_code, trim ($paragraph_text)) !== false) {
2464
- $found = true;
2465
- break;
2466
- }
2467
- }
2468
- if (!$found) $filtered_paragraph_positions [] = $paragraph_position;
2469
- }
2470
- }
2471
-
2472
- $paragraph_positions = $filtered_paragraph_positions;
2473
- }
2474
-
2475
- // Nothing to do
2476
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT;
2477
- if (count ($paragraph_positions) == 0) return $content;
2478
-
2479
-
2480
- $position = $this->get_paragraph_number();
2481
-
2482
- if ($position > 0 && $position < 1) {
2483
- $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
2484
- }
2485
- elseif ($position <= 0) {
2486
- $position = rand (0, count ($paragraph_positions) - 1);
2487
- } else $position --;
2488
-
2489
- if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
2490
- $paragraph_positions = array_reverse ($paragraph_positions);
2491
- }
2492
-
2493
-
2494
- $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
2495
- $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
2496
-
2497
- if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) {
2498
- $avoid_text_above = $this->get_avoid_text_above();
2499
- $avoid_text_below = $this->get_avoid_text_below();
2500
- $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above)));
2501
- $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below)));
2502
-
2503
- $direction = $this->get_avoid_direction();
2504
- $max_checks = $this->get_avoid_try_limit();
2505
-
2506
- $checks = $max_checks;
2507
- $saved_position = $position;
2508
- do {
2509
- $found_above = false;
2510
- if ($avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
2511
- $paragraph_position_above = $position - $avoid_paragraphs_above;
2512
- if ($paragraph_position_above <= 0)
2513
- $content_position_above = 0; else
2514
- $content_position_above = $paragraph_positions [$paragraph_position_above] + 1;
2515
-
2516
- $paragraph_code = substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
2517
-
2518
- foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
2519
- if (trim ($paragraph_text_above) == '') continue;
2520
- if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
2521
- $found_above = true;
2522
- break;
2523
- }
2524
- }
2525
- }
2526
-
2527
- $found_below = false;
2528
- if ($avoid_paragraphs_below != 0 && $position != count ($paragraph_positions) - 1 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
2529
- $paragraph_position_below = $position + $avoid_paragraphs_below;
2530
- if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
2531
- $paragraph_code = substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
2532
- foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
2533
- if (trim ($paragraph_text_below) == '') continue;
2534
- if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
2535
- $found_below = true;
2536
- break;
2537
- }
2538
- }
2539
- }
2540
-
2541
-
2542
- // echo "position: $position = after #", $position + 1, "<br />\n";
2543
- // echo "checks: $checks<br />\n";
2544
- // echo "direction: $direction<br />\n";
2545
- // if ($found_above)
2546
- // echo "found_above<br />\n";
2547
- // if ($found_below)
2548
- // echo "found_below<br />\n";
2549
- // echo "=================<br />\n";
2550
-
2551
-
2552
- if ($found_above || $found_below) {
2553
- $ai_last_check = AI_CHECK_DO_NOT_INSERT;
2554
- if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
2555
-
2556
- switch ($direction) {
2557
- case AD_ABOVE: // Try above
2558
- $ai_last_check = AI_CHECK_AD_ABOVE;
2559
- if ($position == 0) return $content; // Already at the top - do not insert
2560
- $position --;
2561
- break;
2562
- case AD_BELOW: // Try below
2563
- $ai_last_check = AI_CHECK_AD_BELOW;
2564
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
2565
- $position ++;
2566
- break;
2567
- case AD_ABOVE_AND_THEN_BELOW: // Try first above and then below
2568
- if ($position == 0 || $checks == 0) {
2569
- // Try below
2570
- $direction = AD_BELOW;
2571
- $checks = $max_checks;
2572
- $position = $saved_position;
2573
- $ai_last_check = AI_CHECK_AD_BELOW;
2574
- if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
2575
- $position ++;
2576
- } else $position --;
2577
- break;
2578
- case AD_BELOW_AND_THEN_ABOVE: // Try first below and then above
2579
- if ($position >= count ($paragraph_positions) - 1 || $checks == 0) {
2580
- // Try above
2581
- $direction = AD_ABOVE;
2582
- $checks = $max_checks;
2583
- $position = $saved_position;
2584
- $ai_last_check = AI_CHECK_AD_ABOVE;
2585
- if ($position == 0) return $content; // Already at the top - do not insert
2586
- $position --;
2587
- } else $position ++;
2588
- break;
2589
- }
2590
- } else break; // Text not found - insert
2591
-
2592
- // Try next position
2593
- if ($checks <= 0) return $content; // Suitable position not found - do not insert
2594
- $checks --;
2595
- } while (true);
2596
- }
2597
-
2598
- // Nothing to do
2599
- $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE;
2600
- if (count ($paragraph_positions) == 0) return $content;
2601
-
2602
-
2603
- if ($position_preview) {
2604
- $offset = 0;
2605
- foreach ($paragraph_positions as $counter => $paragraph_position) {
2606
- $inserted_code = "[[AI_AP".($counter + 1)."]]";
2607
- if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
2608
- $content = substr_replace ($content, $inserted_code, $paragraph_position + 1, 0);
2609
- } else {
2610
- $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset + 1, 0);
2611
- $offset += strlen ($inserted_code);
2612
- }
2613
- }
2614
- return $content;
2615
- }
2616
-
2617
- $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER;
2618
- if (count ($paragraph_positions) >= intval ($this->get_paragraph_number_minimum())) {
2619
- $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER;
2620
- if (count ($paragraph_positions) > $position) {
2621
- $this->increment_block_counter ();
2622
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
2623
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
2624
- $content_position = $paragraph_positions [$position];
2625
- if ($content_position >= strlen ($content) - 1)
2626
- $content = $content . $this->get_code_for_insertion (); else
2627
- $content = substr_replace ($content, $this->get_code_for_insertion (), $content_position + 1, 0);
2628
- $ai_last_check = AI_CHECK_INSERTED;
2629
- }
2630
- }
2631
- }
2632
-
2633
- return $content;
2634
- }
2635
-
2636
- */
2637
-
2638
  // Deprecated
2639
  function manual ($content){
2640
 
8
  var $client_side_ip_address_detection;
9
  var $w3tc_code;
10
  var $needs_class;
11
+ var $code_version;
12
 
13
  function __construct () {
14
 
17
  $this->client_side_ip_address_detection = false;
18
  $this->w3tc_code = '';
19
  $this->needs_class = false;
20
+ $this->code_version = 0;
21
 
22
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
23
+ $this->wp_options [AI_OPTION_PROCESS_PHP] = AI_DISABLED;
24
+ $this->wp_options [AI_OPTION_ENABLE_MANUAL] = AI_DISABLED;
25
+ $this->wp_options [AI_OPTION_ENABLE_404] = AI_DISABLED;
26
+ $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AI_DISABLED;
27
  $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_DESKTOP_DEVICES;
28
  }
29
 
247
 
248
  public function get_enable_manual (){
249
  $enable_manual = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : '';
250
+ if ($enable_manual == '') $enable_manual = AI_DISABLED;
251
  return $enable_manual;
252
  }
253
 
254
  public function get_process_php (){
255
  $process_php = isset ($this->wp_options [AI_OPTION_PROCESS_PHP]) ? $this->wp_options [AI_OPTION_PROCESS_PHP] : '';
256
+ if ($process_php == '') $process_php = AI_DISABLED;
257
  return $process_php;
258
  }
259
 
260
  public function get_enable_404 (){
261
  $enable_404 = isset ($this->wp_options [AI_OPTION_ENABLE_404]) ? $this->wp_options [AI_OPTION_ENABLE_404] : '';
262
+ if ($enable_404 == '') $enable_404 = AI_DISABLED;
263
  return $enable_404;
264
  }
265
 
268
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
269
  $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
270
  } else $display_for_devices = '';
271
+ if ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AI_DISABLED; else
272
 
273
+ $option = isset ($this->wp_options [AI_OPTION_DETECT_SERVER_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] : AI_DISABLED;
274
  return $option;
275
  }
276
 
325
  $global_name = 'GENERATED_CODE';
326
  if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
327
 
328
+ $php_error = "";
329
  ob_start ();
330
+
331
+ try {
332
+ eval ("?>". $code . "<?php ");
333
+ } catch (Exception $e) {
334
+ $php_error = "PHP error in " . AD_INSERTER_NAME . " code block ".$obj->number . " - " . $obj->get_ad_name() . "<br />\n" . $e->getMessage();
335
  }
336
 
337
+ $processed_code = ob_get_clean ();
338
+
339
+ if (strpos ($processed_code, __FILE__) || $php_error != "") {
340
+ if (preg_match ("%(.+) in ".__FILE__."%", $processed_code, $error_message))
341
+ $code = "PHP error in " . AD_INSERTER_NAME . " code block ".$obj->number . " - " . $obj->get_ad_name() . "<br />\n" . $error_message [1];
342
+ elseif (preg_match ("%(.+) in ".__FILE__."%", $php_error, $error_message))
343
+ $code = "PHP error in " . AD_INSERTER_NAME . " code block ".$obj->number . " - " . $obj->get_ad_name() . "<br />\n" . $error_message [1];
344
+ else $code = $processed_code;
345
+ } else $code = $processed_code;
346
+
347
  // Cache generated code
348
  $obj->wp_options [$global_name] = $code;
349
 
365
  parent::__construct();
366
 
367
  $this->wp_options [AI_OPTION_NAME] = AD_NAME;
368
+ $this->wp_options [AI_OPTION_TRACKING] = AI_DISABLED;
369
  $this->wp_options [AI_OPTION_AUTOMATIC_INSERTION] = AI_AUTOMATIC_INSERTION_DISABLED;
370
  $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] = AD_ONE;
371
  $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] = AD_EMPTY_DATA;
373
  $this->wp_options [AI_OPTION_MAX_WORDS] = AD_EMPTY_DATA;
374
  $this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS] = AD_EMPTY_DATA;
375
  $this->wp_options [AI_OPTION_MAX_PARAGRAPH_WORDS] = AD_EMPTY_DATA;
376
+ $this->wp_options [AI_OPTION_COUNT_INSIDE_BLOCKQUOTE] = AI_DISABLED;
377
  $this->wp_options [AI_OPTION_PARAGRAPH_TAGS] = DEFAULT_PARAGRAPH_TAGS;
378
  $this->wp_options [AI_OPTION_AVOID_PARAGRAPHS_ABOVE] = AD_EMPTY_DATA;
379
  $this->wp_options [AI_OPTION_AVOID_PARAGRAPHS_BELOW] = AD_EMPTY_DATA;
409
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
410
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
411
  $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
412
+ $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AI_ENABLED;
413
+ $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AI_DISABLED;
414
+ $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AI_DISABLED;
415
+ $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] = AI_DISABLED;
416
+ $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] = AI_DISABLED;
417
+ $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AI_DISABLED;
418
+ $this->wp_options [AI_OPTION_ENABLE_AJAX] = AI_ENABLED;
419
+ $this->wp_options [AI_OPTION_ENABLE_FEED] = AI_DISABLED;
420
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
421
  $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
422
+ $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AI_DISABLED;
423
+ $this->wp_options [AI_OPTION_ENABLE_WIDGET] = AI_ENABLED;
424
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT] = AD_EMPTY_DATA;
425
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT_TYPE] = AD_DO_NOT_CONTAIN;
426
  $this->wp_options [AI_OPTION_CUSTOM_CSS] = AD_EMPTY_DATA;
427
  $this->wp_options [AI_OPTION_DISPLAY_FOR_USERS] = AD_DISPLAY_ALL_USERS;
428
+ $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] = AI_DISABLED;
429
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
430
+ $this->wp_options [AI_OPTION_DETECT_VIEWPORT . '_' . $viewport] = AI_DISABLED;
431
  }
432
  }
433
 
603
  return $style;
604
  }
605
 
606
+ public function get_tracking ($saved_value = false){
607
+ $tracking = AI_DISABLED;
608
+ if (function_exists ('get_global_tracking')) {
609
+ if (get_global_tracking () || $saved_value) {
610
+ $tracking = isset ($this->wp_options [AI_OPTION_TRACKING]) ? $this->wp_options [AI_OPTION_TRACKING] : AI_DISABLED;
611
+ }
612
+ }
613
+ return $tracking;
614
+ }
615
+
616
  public function get_alignment_style (){
617
  return $this->alignment_style ($this->get_alignment_type());
618
  }
619
 
620
  public function get_paragraph_number(){
621
  $option = isset ($this->wp_options [AI_OPTION_PARAGRAPH_NUMBER]) ? $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] : "";
622
+ // if ($option == '') $option = AD_ZERO;
623
  return $option;
624
  }
625
 
655
 
656
  public function get_count_inside_blockquote(){
657
  $option = isset ($this->wp_options [AI_OPTION_COUNT_INSIDE_BLOCKQUOTE]) ? $this->wp_options [AI_OPTION_COUNT_INSIDE_BLOCKQUOTE] : "";
658
+ if ($option == '') $option = AI_DISABLED;
659
  return $option;
660
  }
661
 
716
 
717
  public function get_display_settings_post(){
718
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_POSTS]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] : "";
719
+ if ($option == '') $option = AI_ENABLED;
720
  return $option;
721
  }
722
 
723
  public function get_display_settings_page(){
724
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] : "";
725
+ if ($option == '') $option = AI_DISABLED;
726
  return $option;
727
  }
728
 
730
  global $ai_db_options;
731
 
732
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] : "";
733
+ if ($option == '') $option = AI_DISABLED;
734
 
735
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
736
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
741
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
742
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
743
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
744
+ $option = AI_DISABLED;
745
  }
746
 
747
  return $option;
751
  global $ai_db_options;
752
 
753
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_CATEGORY_PAGES] : "";
754
+ if ($option == '') $option = AI_DISABLED;
755
 
756
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
757
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
762
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
763
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
764
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
765
+ $option = AI_DISABLED;
766
  }
767
 
768
  return $option;
772
  global $ai_db_options;
773
 
774
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_SEARCH_PAGES] : "";
775
+ if ($option == '') $option = AI_DISABLED;
776
 
777
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
778
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
783
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
784
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
785
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
786
+ $option = AI_DISABLED;
787
  }
788
 
789
  return $option;
793
  global $ai_db_options;
794
 
795
  $option = isset ($this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES]) ? $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] : "";
796
+ if ($option == '') $option = AI_DISABLED;
797
 
798
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
799
  if (isset ($this->wp_options [AI_OPTION_AUTOMATIC_INSERTION])) {
804
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
805
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
806
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT)
807
+ $option = AI_DISABLED;
808
  }
809
 
810
  return $option;
812
 
813
  public function get_enable_feed (){
814
  $enable_feed = isset ($this->wp_options [AI_OPTION_ENABLE_FEED]) ? $this->wp_options [AI_OPTION_ENABLE_FEED] : "";
815
+ if ($enable_feed == '') $enable_feed = AI_DISABLED;
816
  return $enable_feed;
817
  }
818
 
819
  public function get_enable_ajax (){
820
  $enable_ajax = isset ($this->wp_options [AI_OPTION_ENABLE_AJAX]) ? $this->wp_options [AI_OPTION_ENABLE_AJAX] : "";
821
+ if ($enable_ajax == '') $enable_ajax = AI_ENABLED;
822
  return $enable_ajax;
823
  }
824
 
825
  public function get_enable_manual (){
826
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
827
  if ($option == '') {
828
+ $option = AI_DISABLED;
829
  }
830
  return $option;
831
  }
834
  global $ai_db_options;
835
 
836
  $enable_widget = isset ($this->wp_options [AI_OPTION_ENABLE_WIDGET]) ? $this->wp_options [AI_OPTION_ENABLE_WIDGET] : "";
837
+ if ($enable_widget == '') $enable_widget = AI_ENABLED;
838
 
839
  return $enable_widget;
840
  }
841
 
842
  public function get_enable_php_call (){
843
  $option = isset ($this->wp_options [AI_OPTION_ENABLE_PHP_CALL]) ? $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] : "";
844
+ if ($option == '') $option = AI_DISABLED;
845
  return $option;
846
  }
847
 
883
  public function get_detection_client_side(){
884
  global $ai_db_options;
885
 
886
+ $option = isset ($this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE]) ? $this->wp_options [AI_OPTION_DETECT_CLIENT_SIDE] : AI_DISABLED;
887
 
888
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605') {
889
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
890
  $display_for_devices = $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES];
891
  } else $display_for_devices = '';
892
 
893
+ if ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AI_DISABLED;
894
  }
895
 
896
  return $option;
900
  global $ai_db_options;
901
 
902
  $option_name = AI_OPTION_DETECT_VIEWPORT . '_' . $viewport;
903
+ $option = isset ($this->wp_options [$option_name]) ? $this->wp_options [$option_name] : AI_DISABLED;
904
 
905
  if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] < '010605' && $this->get_detection_client_side()) {
906
  if (isset ($this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES])) {
912
  $display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) {
913
  switch ($viewport) {
914
  case 1:
915
+ $option = AI_ENABLED;
916
  break;
917
  default:
918
+ $option = AI_DISABLED;
919
  }
920
  }
921
  elseif ($display_for_devices == AD_DISPLAY_TABLET_DEVICES ||
923
  $display_for_devices == AD_DISPLAY_DESKTOP_TABLET_DEVICES) {
924
  switch ($viewport) {
925
  case 2:
926
+ $option = AI_ENABLED;
927
  break;
928
  default:
929
+ $option = AI_DISABLED;
930
  }
931
  }
932
  elseif ($display_for_devices == AD_DISPLAY_PHONE_DEVICES ||
934
  $display_for_devices == AD_DISPLAY_DESKTOP_PHONE_DEVICES) {
935
  switch ($viewport) {
936
  case 3:
937
+ $option = AI_ENABLED;
938
  break;
939
  default:
940
+ $option = AI_DISABLED;
941
  }
942
  }
943
+ elseif ($display_for_devices == AD_DISPLAY_ALL_DEVICES) $option = AI_DISABLED;
944
  }
945
 
946
  return $option;
1002
 
1003
  switch ($dynamic_blocks) {
1004
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
1005
+ $this->code_version = rand (1, count ($ads));
1006
+ $processed_code = $ads [$this->code_version - 1];
1007
  break;
1008
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1009
  $processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
1020
  $processed_code .= "</div>\n";
1021
  break;
1022
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
1023
+ $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($ads)).'\')); $ai_index = rand (1, count ($ai_code)); $ai_code = $ai_code [$ai_index - 1]; $ai_enabled = true;';
1024
  $processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1025
  $processed_code .= $this->w3tc_code.' echo $ai_code;';
1026
  $processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1055
  }
1056
  break;
1057
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
1058
+ if ($this->w3tc_code == '') $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($processed_code)).'\')); $ai_index = 0; $ai_enabled = true;';
1059
 
1060
  $this->w3tc_code .= ' require_once \''.AD_INSERTER_PLUGIN_DIR.'includes/geo/Ip2Country.php\';';
1061
 
1311
 
1312
  if ($hidden_widgets) return $hidden_blocks; else {
1313
  if ($this->client_side_ip_address_detection) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
1314
+
1315
+ $tracking_code_pre = '';
1316
+ $tracking_code_data = '';
1317
+ $tracking_code_post = '';
1318
+ $tracking_code = '';
1319
+ if ($this->get_tracking ()) {
1320
+ $tracking_code_pre = " data-ai='";
1321
+ $tracking_code_data = "[{$this->number},{$this->code_version}]";
1322
+ $tracking_code_post = "'";
1323
+
1324
+ $tracking_code = $tracking_code_pre . base64_encode ($tracking_code_data) . $tracking_code_post;
1325
+ }
1326
+
1327
+ $wrapper_before = $hidden_blocks . "<div" . $class . $tracking_code . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1328
+
1329
  $wrapper_after = "</div>\n";
1330
 
1331
  if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
1332
+
1333
+ if ($this->get_tracking ()) $tracking_code_data = '[#AI_DATA#]';
1334
+
1335
+ $wrapper_before = $hidden_blocks . "<div" . $class . $tracking_code_pre . $tracking_code_data . $tracking_code_post . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1336
+
1337
  $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1338
+ $code .= $this->w3tc_code.' if ($ai_enabled) echo str_replace (\'[#AI_DATA#]\', base64_encode ("[' . $this->number . ',$ai_index]"), unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_before)).'\'))), $ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_after)).'\'));';
1339
  $code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1340
  return $code;
1341
  } else return $wrapper_before . $code . $wrapper_after;
1406
  if (strtolower ($special_element [0]) == "<$special_element_tag" && isset ($special_elements [$index + 1][0]) && strtolower ($special_elements [$index + 1][0]) == "</$special_element_tag") {
1407
 
1408
  if ($multibyte) {
1409
+ $special_element_offsets []= array (mb_strlen (substr ($content, 0, $special_element [1])) + 1, mb_strlen (substr ($content, 0, $special_elements [$index + 1][1])));
1410
  } else {
1411
+ $special_element_offsets []= array ($special_element [1] + 1, $special_elements [$index + 1][1]);
1412
  }
1413
  }
1414
  }
1519
  if (count ($paragraph_positions) == 0) return $content;
1520
 
1521
 
 
 
 
 
 
 
 
 
 
1522
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1523
  $paragraph_positions = array_reverse ($paragraph_positions);
1524
  }
1525
 
1526
 
1527
+ $position = trim ($this->get_paragraph_number());
1528
+
1529
+ $positions = array ();
1530
+ if (!$position_preview) {
1531
+ if (strpos ($position, ',') !== false) {
1532
+ $positions = explode (',', str_replace (' ', '', $position));
1533
+ foreach ($positions as $index => $position) {
1534
+ if ($position > 0 && $position < 1) {
1535
+ $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
1536
+ }
1537
+ elseif ($position <= 0) {
1538
+ $positions [$index] = rand (0, count ($paragraph_positions) - 1);
1539
+ }
1540
+ }
1541
+ }
1542
+ elseif ($position == '') {
1543
+ foreach ($paragraph_positions as $index => $paragraph_position) {
1544
+ $positions []= $index + 1;
1545
+ }
1546
+ }
1547
+ }
1548
+
1549
+ if (empty ($positions)) {
1550
+ if ($position > 0 && $position < 1) {
1551
+ $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
1552
+ }
1553
+ elseif ($position <= 0) {
1554
+ $position = rand (0, count ($paragraph_positions) - 1);
1555
+ } else $position --;
1556
+
1557
 
1558
+ $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
1559
+ $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
 
 
 
1560
 
1561
+ if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) {
1562
+ $avoid_text_above = $this->get_avoid_text_above();
1563
+ $avoid_text_below = $this->get_avoid_text_below();
1564
+ $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above)));
1565
+ $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below)));
1566
 
1567
+ $direction = $this->get_avoid_direction();
1568
+ $max_checks = $this->get_avoid_try_limit();
 
 
 
 
 
1569
 
1570
+ $checks = $max_checks;
1571
+ $saved_position = $position;
1572
+ do {
1573
+ $found_above = false;
1574
+ if ($position != 0 && $avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
1575
+ $paragraph_position_above = $position - $avoid_paragraphs_above;
1576
+ if ($paragraph_position_above < 0) $paragraph_position_above = 0;
1577
 
 
 
1578
  if ($multibyte) {
1579
+ $paragraph_code = mb_substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
 
 
 
1580
  } else {
1581
+ $paragraph_code = substr ($content, $paragraph_positions [$paragraph_position_above], $paragraph_positions [$position] - $paragraph_positions [$paragraph_position_above]);
1582
+ }
1583
+
1584
+ foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1585
+ if (trim ($paragraph_text_above) == '') continue;
1586
+ if ($multibyte) {
1587
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1588
  $found_above = true;
1589
  break;
1590
  }
1591
+ } else {
1592
+ if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1593
+ $found_above = true;
1594
+ break;
1595
+ }
1596
+ }
1597
+ }
1598
  }
 
1599
 
1600
+ $found_below = false;
1601
+ if ($avoid_paragraphs_below != 0 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
1602
+ $paragraph_position_below = $position + $avoid_paragraphs_below;
1603
 
1604
+ if ($multibyte) {
 
 
 
 
 
1605
  if ($paragraph_position_below > count ($paragraph_positions) - 1)
1606
+ $content_position_below = mb_strlen ($content); else
1607
  $content_position_below = $paragraph_positions [$paragraph_position_below];
1608
+ $paragraph_code = mb_substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
1609
+ } else {
1610
+ if ($paragraph_position_below > count ($paragraph_positions) - 1)
1611
+ $content_position_below = strlen ($content); else
1612
+ $content_position_below = $paragraph_positions [$paragraph_position_below];
1613
+ $paragraph_code = substr ($content, $paragraph_positions [$position], $content_position_below - $paragraph_positions [$position]);
1614
+ }
1615
 
1616
+ foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
1617
+ if (trim ($paragraph_text_below) == '') continue;
1618
 
1619
+ if ($multibyte) {
1620
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
 
 
 
 
 
1621
  $found_below = true;
1622
  break;
1623
  }
1624
+ } else {
1625
+ if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
1626
+ $found_below = true;
1627
+ break;
1628
+ }
1629
+ }
1630
+ }
1631
  }
 
1632
 
1633
 
1634
+ // echo "position: $position = before #", $position + 1, "<br />\n";
1635
+ // echo "checks: $checks<br />\n";
1636
+ // echo "direction: $direction<br />\n";
1637
+ // if ($found_above)
1638
+ // echo "found_above<br />\n";
1639
+ // if ($found_below)
1640
+ // echo "found_below<br />\n";
1641
+ // echo "=================<br />\n";
1642
+
1643
+
1644
+ if ($found_above || $found_below) {
1645
+ $ai_last_check = AI_CHECK_DO_NOT_INSERT;
1646
+ if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
1647
+
1648
+ switch ($direction) {
1649
+ case AD_ABOVE: // Try above
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1650
  $ai_last_check = AI_CHECK_AD_ABOVE;
1651
  if ($position == 0) return $content; // Already at the top - do not insert
1652
  $position --;
1653
+ break;
1654
+ case AD_BELOW: // Try below
1655
+ $ai_last_check = AI_CHECK_AD_BELOW;
1656
+ if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
1657
+ $position ++;
1658
+ break;
1659
+ case AD_ABOVE_AND_THEN_BELOW: // Try first above and then below
1660
+ if ($position == 0 || $checks == 0) {
1661
+ // Try below
1662
+ $direction = AD_BELOW;
1663
+ $checks = $max_checks;
1664
+ $position = $saved_position;
1665
+ $ai_last_check = AI_CHECK_AD_BELOW;
1666
+ if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
1667
+ $position ++;
1668
+ } else $position --;
1669
+ break;
1670
+ case AD_BELOW_AND_THEN_ABOVE: // Try first below and then above
1671
+ if ($position >= count ($paragraph_positions) - 1 || $checks == 0) {
1672
+ // Try above
1673
+ $direction = AD_ABOVE;
1674
+ $checks = $max_checks;
1675
+ $position = $saved_position;
1676
+ $ai_last_check = AI_CHECK_AD_ABOVE;
1677
+ if ($position == 0) return $content; // Already at the top - do not insert
1678
+ $position --;
1679
+ } else $position ++;
1680
+ break;
1681
+ }
1682
+ } else break; // Text not found - insert
1683
 
1684
+ // Try next position
1685
+ if ($checks <= 0) return $content; // Suitable position not found - do not insert
1686
+ $checks --;
1687
+ } while (true);
1688
+ }
1689
 
1690
+ // Nothing to do
1691
+ $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE;
1692
+ if (count ($paragraph_positions) == 0) return $content;
1693
+ }
1694
 
1695
+ if ($position_preview || !empty ($positions)) {
1696
  $offset = 0;
1697
+ $code_for_insertion = $this->get_code_for_insertion ();
1698
+ if (!empty ($positions)) $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER;
1699
+
1700
  foreach ($paragraph_positions as $counter => $paragraph_position) {
1701
+ if ($position_preview) $inserted_code = "[[AI_BP".($counter + 1)."]]";
1702
+ elseif (!empty ($positions) && in_array ($counter + 1, $positions)) {$inserted_code = $code_for_insertion; $ai_last_check = AI_CHECK_INSERTED;}
1703
+ else continue;
1704
 
1705
  if ($multibyte) {
1706
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1718
  }
1719
  }
1720
  }
1721
+
1722
  return $content;
1723
  }
1724
 
1927
  if (count ($paragraph_positions) == 0) return $content;
1928
 
1929
 
 
 
 
 
 
 
 
 
 
1930
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
1931
  $paragraph_positions = array_reverse ($paragraph_positions);
1932
  }
1933
 
1934
 
1935
+ $position = $this->get_paragraph_number();
 
1936
 
1937
+ $positions = array ();
1938
+ if (!$position_preview) {
1939
+ if (strpos ($position, ',') !== false) {
1940
+ $positions = explode (',', str_replace (' ', '', $position));
1941
+ foreach ($positions as $index => $position) {
1942
+ if ($position > 0 && $position < 1) {
1943
+ $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
1944
+ }
1945
+ elseif ($position <= 0) {
1946
+ $positions [$index] = rand (0, count ($paragraph_positions) - 1);
1947
+ }
1948
+ }
1949
+ }
1950
+ elseif ($position == '') {
1951
+ foreach ($paragraph_positions as $index => $paragraph_position) {
1952
+ $positions []= $index + 1;
1953
+ }
1954
+ }
1955
+ }
1956
 
1957
+ if (empty ($positions)) {
1958
+ if ($position > 0 && $position < 1) {
1959
+ $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
1960
+ }
1961
+ elseif ($position <= 0) {
1962
+ $position = rand (0, count ($paragraph_positions) - 1);
1963
+ } else $position --;
1964
 
 
 
 
 
 
 
 
 
 
1965
 
1966
+ $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
1967
+ $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
 
 
 
1968
 
1969
+ if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) {
1970
+ $avoid_text_above = $this->get_avoid_text_above();
1971
+ $avoid_text_below = $this->get_avoid_text_below();
1972
+ $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above)));
1973
+ $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below)));
1974
+
1975
+ $direction = $this->get_avoid_direction();
1976
+ $max_checks = $this->get_avoid_try_limit();
1977
+
1978
+ $checks = $max_checks;
1979
+ $saved_position = $position;
1980
+ do {
1981
+ $found_above = false;
1982
+ if ($avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) {
1983
+ $paragraph_position_above = $position - $avoid_paragraphs_above;
1984
+ if ($paragraph_position_above <= 0)
1985
+ $content_position_above = 0; else
1986
+ $content_position_above = $paragraph_positions [$paragraph_position_above] + 1;
1987
 
1988
  if ($multibyte) {
1989
+ $paragraph_code = mb_substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
 
 
 
1990
  } else {
1991
+ $paragraph_code = substr ($content, $content_position_above, $paragraph_positions [$position] - $content_position_above);
1992
+ }
1993
+
1994
+ foreach ($avoid_paragraph_texts_above as $paragraph_text_above) {
1995
+ if (trim ($paragraph_text_above) == '') continue;
1996
+
1997
+ if ($multibyte) {
1998
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
1999
  $found_above = true;
2000
  break;
2001
  }
2002
+ } else {
2003
+ if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) {
2004
+ $found_above = true;
2005
+ break;
2006
+ }
2007
+ }
2008
 
2009
+ }
2010
  }
 
2011
 
2012
+ $found_below = false;
2013
+ if ($avoid_paragraphs_below != 0 && $position != count ($paragraph_positions) - 1 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) {
2014
+ $paragraph_position_below = $position + $avoid_paragraphs_below;
2015
 
2016
+ if ($multibyte) {
 
 
 
2017
  if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
2018
+ $paragraph_code = mb_substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
2019
+ } else {
2020
+ if ($paragraph_position_below > count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1;
2021
+ $paragraph_code = substr ($content, $paragraph_positions [$position] + 1, $paragraph_positions [$paragraph_position_below] - $paragraph_positions [$position]);
2022
+ }
2023
 
2024
+ foreach ($avoid_paragraph_texts_below as $paragraph_text_below) {
2025
+ if (trim ($paragraph_text_below) == '') continue;
2026
 
2027
+ if ($multibyte) {
2028
+ if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
 
 
 
 
 
2029
  $found_below = true;
2030
  break;
2031
  }
2032
+ } else {
2033
+ if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) {
2034
+ $found_below = true;
2035
+ break;
2036
+ }
2037
+ }
2038
 
2039
+ }
2040
  }
 
2041
 
2042
 
2043
+ // echo "position: $position = after #", $position + 1, "<br />\n";
2044
+ // echo "checks: $checks<br />\n";
2045
+ // echo "direction: $direction<br />\n";
2046
+ // if ($found_above)
2047
+ // echo "found_above<br />\n";
2048
+ // if ($found_below)
2049
+ // echo "found_below<br />\n";
2050
+ // echo "=================<br />\n";
2051
+
2052
+
2053
+ if ($found_above || $found_below) {
2054
+ $ai_last_check = AI_CHECK_DO_NOT_INSERT;
2055
+ if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
2056
+
2057
+ switch ($direction) {
2058
+ case AD_ABOVE: // Try above
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2059
  $ai_last_check = AI_CHECK_AD_ABOVE;
2060
  if ($position == 0) return $content; // Already at the top - do not insert
2061
  $position --;
2062
+ break;
2063
+ case AD_BELOW: // Try below
2064
+ $ai_last_check = AI_CHECK_AD_BELOW;
2065
+ if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
2066
+ $position ++;
2067
+ break;
2068
+ case AD_ABOVE_AND_THEN_BELOW: // Try first above and then below
2069
+ if ($position == 0 || $checks == 0) {
2070
+ // Try below
2071
+ $direction = AD_BELOW;
2072
+ $checks = $max_checks;
2073
+ $position = $saved_position;
2074
+ $ai_last_check = AI_CHECK_AD_BELOW;
2075
+ if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
2076
+ $position ++;
2077
+ } else $position --;
2078
+ break;
2079
+ case AD_BELOW_AND_THEN_ABOVE: // Try first below and then above
2080
+ if ($position >= count ($paragraph_positions) - 1 || $checks == 0) {
2081
+ // Try above
2082
+ $direction = AD_ABOVE;
2083
+ $checks = $max_checks;
2084
+ $position = $saved_position;
2085
+ $ai_last_check = AI_CHECK_AD_ABOVE;
2086
+ if ($position == 0) return $content; // Already at the top - do not insert
2087
+ $position --;
2088
+ } else $position ++;
2089
+ break;
2090
+ }
2091
+ } else break; // Text not found - insert
2092
 
2093
+ // Try next position
2094
+ if ($checks <= 0) return $content; // Suitable position not found - do not insert
2095
+ $checks --;
2096
+ } while (true);
2097
+ }
2098
 
2099
+ // Nothing to do
2100
+ $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE;
2101
+ if (count ($paragraph_positions) == 0) return $content;
2102
+ }
2103
 
2104
 
2105
+ if ($position_preview || !empty ($positions)) {
2106
  $offset = 0;
2107
+ $code_for_insertion = $this->get_code_for_insertion ();
2108
+ if (!empty ($positions)) $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER;
2109
+
2110
  foreach ($paragraph_positions as $counter => $paragraph_position) {
2111
+ if ($position_preview) $inserted_code = "[[AI_AP".($counter + 1)."]]";
2112
+ elseif (!empty ($positions) && in_array ($counter + 1, $positions)) {$inserted_code = $code_for_insertion; $ai_last_check = AI_CHECK_INSERTED;}
2113
+ else continue;
2114
 
2115
  if ($multibyte) {
2116
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
2129
  }
2130
 
2131
  }
2132
+
2133
  return $content;
2134
  }
2135
 
2161
  }
2162
 
2163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2164
  // Deprecated
2165
  function manual ($content){
2166
 
constants.php CHANGED
@@ -14,7 +14,7 @@ if (!defined( 'AD_INSERTER_NAME'))
14
  define ('AD_INSERTER_NAME', 'Ad Inserter');
15
 
16
  if (!defined( 'AD_INSERTER_VERSION'))
17
- define ('AD_INSERTER_VERSION', '2.1.5');
18
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -49,6 +49,7 @@ define ('AI_OPTION_CODE', 'code');
49
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
50
  define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
51
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
 
52
  define ('AI_OPTION_ENABLE_AJAX', 'enable_ajax');
53
  define ('AI_OPTION_ENABLE_FEED', 'enable_feed');
54
  define ('AI_OPTION_ENABLE_404', 'enable_404');
@@ -303,27 +304,34 @@ define('AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS', 1);
303
  define('AI_TEXT_STANDARD', 'Standard');
304
  define('AI_TEXT_MULTIBYTE', 'Multibyte');
305
 
 
 
 
 
 
 
306
  //Settings
307
- define('AD_SETTINGS_CHECKED', '1');
308
- define('AD_SETTINGS_NOT_CHECKED', '0');
309
 
310
  define('AI_COOKIE_TIME', 3600);
311
 
312
- define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
313
- define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
314
- define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
315
- define ('DEFAULT_PLUGIN_PRIORITY', 99999);
316
- define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
317
  define ('DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS', AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS);
318
- define ('DEFAULT_PARAGRAPH_TAGS', 'p');
319
- define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AD_SETTINGS_CHECKED);
320
- define ('DEFAULT_REMOTE_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
321
- define ('DEFAULT_JAVASCRIPT_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
322
- define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
323
- define ('DEFAULT_MULTISITE_WIDGETS', AD_SETTINGS_CHECKED);
324
- define ('DEFAULT_MULTISITE_PHP_PROCESSING', AD_SETTINGS_CHECKED);
325
- define ('DEFAULT_MULTISITE_EXCEPTIONS', AD_SETTINGS_CHECKED);
326
- define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AD_SETTINGS_NOT_CHECKED);
 
327
 
328
  define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
329
  define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
@@ -421,9 +429,10 @@ define ('AI_WP_USER', 1);
421
  define ('AI_WP_DEBUGGING', 2);
422
  define ('AI_WP_DEBUG_BLOCK', 3);
423
  define ('AI_WP_URL', 4);
424
- define ('SERVER_SIDE_DETECTION', 5);
425
- define ('CLIENT_SIDE_DETECTION', 6);
426
  define ('AI_CONTEXT', 7);
 
427
 
428
  define ('AI_CONTEXT_NONE', 0);
429
  define ('AI_CONTEXT_CONTENT', 1);
14
  define ('AD_INSERTER_NAME', 'Ad Inserter');
15
 
16
  if (!defined( 'AD_INSERTER_VERSION'))
17
+ define ('AD_INSERTER_VERSION', '2.1.6');
18
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
49
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
50
  define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
51
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
52
+ define ('AI_OPTION_TRACKING', 'tracking');
53
  define ('AI_OPTION_ENABLE_AJAX', 'enable_ajax');
54
  define ('AI_OPTION_ENABLE_FEED', 'enable_feed');
55
  define ('AI_OPTION_ENABLE_404', 'enable_404');
304
  define('AI_TEXT_STANDARD', 'Standard');
305
  define('AI_TEXT_MULTIBYTE', 'Multibyte');
306
 
307
+ // Tracking
308
+ define('AI_TRACKING_DISABLED', 0);
309
+ define('AI_TRACKING_INTERNAL', 1);
310
+
311
+ define('AI_TEXT_INTERNAL', 'Internal');
312
+
313
  //Settings
314
+ define('AI_ENABLED', '1');
315
+ define('AI_DISABLED', '0');
316
 
317
  define('AI_COOKIE_TIME', 3600);
318
 
319
+ define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
320
+ define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
321
+ define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
322
+ define ('DEFAULT_PLUGIN_PRIORITY', 99999);
323
+ define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
324
  define ('DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS', AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS);
325
+ define ('DEFAULT_PARAGRAPH_TAGS', 'p');
326
+ define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AI_ENABLED);
327
+ define ('DEFAULT_REMOTE_DEBUGGING', AI_DISABLED);
328
+ define ('DEFAULT_JAVASCRIPT_DEBUGGING', AI_DISABLED);
329
+ define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AI_ENABLED);
330
+ define ('DEFAULT_MULTISITE_WIDGETS', AI_ENABLED);
331
+ define ('DEFAULT_MULTISITE_PHP_PROCESSING', AI_ENABLED);
332
+ define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
333
+ define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
334
+ define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
335
 
336
  define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
337
  define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
429
  define ('AI_WP_DEBUGGING', 2);
430
  define ('AI_WP_DEBUG_BLOCK', 3);
431
  define ('AI_WP_URL', 4);
432
+ define ('AI_SERVER_SIDE_DETECTION', 5);
433
+ define ('AI_CLIENT_SIDE_DETECTION', 6);
434
  define ('AI_CONTEXT', 7);
435
+ define ('AI_TRACKING', 8);
436
 
437
  define ('AI_CONTEXT_NONE', 0);
438
  define ('AI_CONTEXT_CONTENT', 1);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
- #data {
2
- font-family: "2.1.5"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -28,12 +28,16 @@
28
  .ai-icon-gear {
29
  width: 16px;
30
  height: 16px;
31
- background-image: url(images/icon-gear.png);
32
  background-repeat: no-repeat;
33
  }
34
 
35
  .ai-icon-gear.on {
36
- background-image: url(images/icon-gear-blue.png);
 
 
 
 
37
  }
38
 
39
  a.simple-link {
@@ -132,6 +136,63 @@ a.clear-link, a.clear-link:hover, a.clear-link:focus {
132
  width: 735px;
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  #ai-settings {
136
  margin-right: 24px;
137
  }
@@ -166,6 +227,10 @@ a.clear-link, a.clear-link:hover, a.clear-link:focus {
166
  height: 386px;
167
  }
168
 
 
 
 
 
169
  @media (min-width: 783px) and (max-width: 828px) {
170
  .auto-fold #wpcontent, .auto-fold #wpfooter {
171
  margin-left: 20px;
@@ -234,6 +299,7 @@ div.automatic-insertion {
234
 
235
  ul.thumbnails.image_picker_selector li {
236
  margin: 0px 5px 4px 0px;
 
237
  }
238
 
239
  ul.thumbnails.image_picker_selector li .thumbnail {
@@ -253,3 +319,143 @@ div.automatic-insertion img {
253
  width: 56px;
254
  }
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ai-data {
2
+ font-family: "2.1.6"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
28
  .ai-icon-gear {
29
  width: 16px;
30
  height: 16px;
31
+ background: url('images/icons.png') 0 -40px;
32
  background-repeat: no-repeat;
33
  }
34
 
35
  .ai-icon-gear.on {
36
+ background: url('images/icons.png') -20px -40px;
37
+ }
38
+
39
+ .ai-icon-gear.red {
40
+ background: url('images/icons.png') -60px -40px;
41
  }
42
 
43
  a.simple-link {
136
  width: 735px;
137
  }
138
 
139
+ .ui-datepicker {
140
+ z-index: 202!important;
141
+ }
142
+
143
+ div.ai-chart-container {
144
+ position: relative;
145
+ margin: 8px 0;
146
+ }
147
+
148
+ div.ai-chart-container.versions {
149
+ display: inline-block;
150
+ margin: 20px 20px 0;
151
+ }
152
+
153
+ div.ai-chart {
154
+ width: 735px;
155
+ height: 140px;
156
+ }
157
+
158
+ div.versions div.ai-chart {
159
+ width: 200px;
160
+ height: 140px;
161
+ }
162
+
163
+ div.legend div.ai-chart {
164
+ height: 25px;
165
+ }
166
+
167
+ div.ai-chart-label {
168
+ position: absolute;
169
+ top: 13px;
170
+ left: 44px;
171
+ z-index: 202;
172
+ display: none;
173
+ }
174
+
175
+ div.ai-chart-container.versions div.ai-chart-label {
176
+ z-index: 1;
177
+ }
178
+
179
+ div.versions div.ai-chart-label {
180
+ top: -16px;
181
+ left: 80px;
182
+ }
183
+
184
+ .legend div.ai-chart-label {
185
+ top: 34px;
186
+ }
187
+
188
+ div.ai-tooltip {
189
+ z-index: 203;
190
+ }
191
+
192
+ div.ai-tooltip .version {
193
+ font-weight: bold;
194
+ }
195
+
196
  #ai-settings {
197
  margin-right: 24px;
198
  }
227
  height: 386px;
228
  }
229
 
230
+ textarea.simple-editor {
231
+ height: 388px;
232
+ }
233
+
234
  @media (min-width: 783px) and (max-width: 828px) {
235
  .auto-fold #wpcontent, .auto-fold #wpfooter {
236
  margin-left: 20px;
299
 
300
  ul.thumbnails.image_picker_selector li {
301
  margin: 0px 5px 4px 0px;
302
+ cursor: pointer;
303
  }
304
 
305
  ul.thumbnails.image_picker_selector li .thumbnail {
319
  width: 56px;
320
  }
321
 
322
+ .ai-toolbar-button {
323
+ display: table-cell;
324
+ vertical-align: top;
325
+ width: 28px;
326
+ padding: 0px 0 0 10px;
327
+ }
328
+
329
+ .ai-toolbar-button.text {
330
+ width: auto;
331
+ }
332
+
333
+ .checkbox-button {
334
+ background-image: none, linear-gradient(to bottom, #f6f6f6 0, #eaeaea 100%);
335
+ background-position: 50% 50%;
336
+ background-color: #e3e3e3;
337
+ border: solid 1px lightgrey;
338
+ border-radius: 5px;
339
+ -webkit-border-radius: 5px;
340
+ -moz-border-radius: 5px;
341
+ cursor: pointer;
342
+ padding: 2px 2px;
343
+ display: inline-block;
344
+ margin: 0;
345
+ font-family: inherit;
346
+ line-height: 1.66em;
347
+ text-align: center;
348
+ cursor: pointer;
349
+ text-decoration: none;
350
+ -webkit-box-sizing: border-box;
351
+ -moz-box-sizing: border-box;
352
+ box-sizing: border-box;
353
+ }
354
+
355
+ .text .checkbox-button {
356
+ font-size: 11px;
357
+ padding: 0px 5px 0px 4px;
358
+ margin-top: 2px;
359
+ }
360
+
361
+ .checkbox-icon {
362
+ background-position: center;
363
+ display: inline-block;
364
+ float: left;
365
+ width: 20px;
366
+ height: 20px;
367
+ overflow: hidden;
368
+ background-repeat: no-repeat;
369
+ font-size: 0;
370
+ line-height: 0;
371
+ text-indent: -3333px;
372
+ text-align: center;
373
+ vertical-align: middle;
374
+ }
375
+
376
+ .checkbox-icon.icon-tracking {
377
+ background: url('images/icons.png') -40px -20px;
378
+ }
379
+
380
+ .checkbox-icon.icon-tracking.on {
381
+ background: url('images/icons.png') -40px 0;
382
+ }
383
+
384
+ .tracking-disabled .checkbox-icon.icon-tracking.on {
385
+ background: url('images/icons.png') -40px -40px;
386
+ }
387
+
388
+ .checkbox-icon.icon-tablet {
389
+ background: url('images/icons.png') -20px -20px;
390
+ }
391
+
392
+ .checkbox-icon.icon-tablet.on {
393
+ background: url('images/icons.png') -20px 0;
394
+ }
395
+
396
+ .checkbox-icon.icon-php {
397
+ background: url('images/icons.png') 0 -20px;
398
+ }
399
+
400
+ .checkbox-icon.icon-php.on {
401
+ background: url('images/icons.png') 0 0;
402
+ }
403
+
404
+ .checkbox-icon.icon-enabled {
405
+ background: url('images/icons.png') -100px -20px;
406
+ }
407
+
408
+ .checkbox-icon.icon-enabled.on {
409
+ background: url('images/icons.png') -100px 0;
410
+ }
411
+
412
+ .checkbox-icon.icon-export-import {
413
+ background: url('images/icons.png') -80px -20px;
414
+ }
415
+
416
+ .checkbox-icon.icon-export-import.on {
417
+ background: url('images/icons.png') -80px 0;
418
+ }
419
+
420
+ .checkbox-icon.icon-statistics {
421
+ background: url('images/icons.png') -60px -20px;
422
+ }
423
+
424
+ .checkbox-icon.icon-statistics.on {
425
+ background: url('images/icons.png') -60px 0;
426
+ }
427
+
428
+ .checkbox-icon.icon-loading {
429
+ width: 12px;
430
+ height: 12px;
431
+ margin: 3px 0;
432
+ background: url('images/icons.png') -160px -20px;
433
+ }
434
+
435
+ .checkbox-icon.icon-loading.on {
436
+ background: url('images/icons.png') -160px 0;
437
+ }
438
+
439
+ .checkbox-icon.icon-auto-refresh {
440
+ width: 12px;
441
+ height: 12px;
442
+ margin: 3px 0;
443
+ background: url('images/icons.png') -180px -20px;
444
+ }
445
+
446
+ .checkbox-icon.icon-auto-refresh.on {
447
+ background: url('images/icons.png') -180px 0;
448
+ }
449
+
450
+ .checkbox-icon.icon-red {
451
+ width: 12px;
452
+ height: 12px;
453
+ margin-top: 6px;
454
+ background: url('images/icons.png') 0 -40px;
455
+ }
456
+
457
+ @media(max-width: 768px) {
458
+ .text .checkbox-button {
459
+ padding: 2px 5px 2px 4px;
460
+ }
461
+ }
css/images/icon-gear-blue.png DELETED
Binary file
css/images/icon-gear-red.png DELETED
Binary file
css/images/icon-gear.png DELETED
Binary file
css/images/icons.png ADDED
Binary file
images/media.net_250x250_2.jpg ADDED
Binary file
images/media.net_728x90.gif ADDED
Binary file
includes/Mobile_Detect.php CHANGED
@@ -22,7 +22,7 @@
22
  * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
23
  * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
24
  *
25
- * @version 2.8.19
26
  */
27
 
28
  class ai_Mobile_Detect
@@ -66,7 +66,7 @@ class ai_Mobile_Detect
66
  /**
67
  * Stores the version number of the current release.
68
  */
69
- const VERSION = '2.8.19';
70
 
71
  /**
72
  * A type for the version() method indicating a string return value.
@@ -174,10 +174,11 @@ class ai_Mobile_Detect
174
  // @todo: Is 'Dell Streak' a tablet or a phone? ;)
175
  'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
176
  'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto E\b',
177
- 'Samsung' => 'Samsung|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205',
178
  'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)',
179
  'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
180
  'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
 
181
  // http://www.micromaxinfo.com/mobiles/smartphones
182
  // Added because the codes might conflict with Acer Tablets.
183
  'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
@@ -190,7 +191,7 @@ class ai_Mobile_Detect
190
  // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
191
  'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
192
  // http://fr.wikomobile.com
193
- 'Wiko' => 'KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM',
194
  'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
195
  // Added simvalley mobile just for fun. They have some interesting devices.
196
  // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
@@ -218,10 +219,10 @@ class ai_Mobile_Detect
218
  'iPad' => 'iPad|iPad.*Mobile',
219
  // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
220
  // @see #442
221
- 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
222
- 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone.
223
  // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
224
- 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI)\b',
225
  // Only the Surface tablets with Windows RT are considered mobile.
226
  // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
227
  'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
@@ -229,7 +230,7 @@ class ai_Mobile_Detect
229
  'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
230
  // Watch out for PadFone, see #132.
231
  // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
232
- 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K017 |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C',
233
  'BlackBerryTablet' => 'PlayBook|RIM Tablet',
234
  'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
235
  'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
@@ -239,7 +240,7 @@ class ai_Mobile_Detect
239
  // http://us.acer.com/ac/en/US/content/group/tablets
240
  // http://www.acer.de/ac/de/DE/content/models/tablets/
241
  // Can conflict with Micromax and Motorola phones codes.
242
- 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b',
243
  // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
244
  // http://us.toshiba.com/tablets/tablet-finder
245
  // http://www.toshiba.co.jp/regza/tablet/
@@ -251,13 +252,13 @@ class ai_Mobile_Detect
251
  // Prestigio Tablets http://www.prestigio.com/support
252
  'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
253
  // http://support.lenovo.com/en_GB/downloads/default.page?#
254
- 'LenovoTablet' => 'Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
255
  // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
256
  'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
257
  // http://www.yarvik.com/en/matrix/tablets/
258
  'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
259
  'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
260
- 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
261
  // http://www.intenso.de/kategorie_en.php?kategorie=33
262
  // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
263
  'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
@@ -269,9 +270,11 @@ class ai_Mobile_Detect
269
  // http://www.allview.ro/produse/droseries/lista-tablete-pc/
270
  'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
271
  // http://wiki.archosfans.com/index.php?title=Main_Page
272
- 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
 
273
  // http://www.ainol.com/plugin.php?identifier=ainol&module=product
274
  'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
 
275
  // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
276
  // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
277
  // http://www.sony.jp/support/tablet/
@@ -283,7 +286,7 @@ class ai_Mobile_Detect
283
  // http://www.cobyusa.com/?p=pcat&pcat_id=3001
284
  'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
285
  // http://www.match.net.cn/products.asp
286
- 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733',
287
  // http://www.msi.com/support
288
  // @todo Research the Windows Tablets.
289
  'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
@@ -299,7 +302,7 @@ class ai_Mobile_Detect
299
  // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
300
  'FlyTablet' => 'IQ310|Fly Vision',
301
  // http://www.bqreaders.com/gb/tablets-prices-sale.html
302
- 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris E10)|Maxwell.*Lite|Maxwell.*Plus',
303
  // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
304
  // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
305
  'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
@@ -383,7 +386,7 @@ class ai_Mobile_Detect
383
  // @note: no need to add all the tablet codes since they are guided by the first regex.
384
  'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
385
  // Generic Vodafone tablets.
386
- 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7',
387
  // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
388
  // Aka: http://www.essentielb.fr/
389
  'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
@@ -404,7 +407,7 @@ class ai_Mobile_Detect
404
  // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
405
  'TecnoTablet' => 'TECNO P9',
406
  // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
407
- 'JXDTablet' => 'Android.*\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
408
  // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
409
  'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
410
  // http://www.intracon.eu/tablet
@@ -435,7 +438,10 @@ class ai_Mobile_Detect
435
  'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
436
  // @todo http://www.lavamobiles.com/tablets-data-cards
437
  'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
438
- 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382',
 
 
 
439
  // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
440
  'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
441
  // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
@@ -453,11 +459,15 @@ class ai_Mobile_Detect
453
  'UbislateTablet' => 'UbiSlate[\s]?7C',
454
  // http://www.pocketbook-int.com/ru/support
455
  'PocketBookTablet' => 'Pocketbook',
 
 
 
 
456
  // http://www.tesco.com/direct/hudl/
457
  'Hudl' => 'Hudl HT7S3|Hudl 2',
458
  // http://www.telstra.com.au/home-phone/thub-2/
459
  'TelstraTablet' => 'T-Hub2',
460
- 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bJolla\b|\bTP750\b'
461
  );
462
 
463
  /**
@@ -494,16 +504,23 @@ class ai_Mobile_Detect
494
  /**
495
  * List of mobile User Agents.
496
  *
 
 
 
 
 
497
  * @var array
498
  */
499
  protected static $browsers = array(
 
500
  // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
501
  'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
502
  'Dolfin' => '\bDolfin\b',
503
  'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
504
  'Skyfire' => 'Skyfire',
 
505
  'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
506
- 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile',
507
  'Bolt' => 'bolt',
508
  'TeaShark' => 'teashark',
509
  'Blazer' => 'Blazer',
@@ -511,7 +528,7 @@ class ai_Mobile_Detect
511
  'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
512
  // http://en.wikipedia.org/wiki/Midori_(web_browser)
513
  //'Midori' => 'midori',
514
- 'Tizen' => 'Tizen',
515
  'UCBrowser' => 'UC.*Browser|UCWEB',
516
  'baiduboxapp' => 'baiduboxapp',
517
  'baidubrowser' => 'baidubrowser',
@@ -528,6 +545,8 @@ class ai_Mobile_Detect
528
  // @reference: http://en.wikipedia.org/wiki/Minimo
529
  // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
530
  'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
 
 
531
  );
532
 
533
  /**
@@ -540,7 +559,7 @@ class ai_Mobile_Detect
540
  // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
541
  // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
542
  // https://developers.facebook.com/docs/sharing/best-practices
543
- 'Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom',
544
  'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
545
  'DesktopMode' => 'WPDesktop',
546
  'TV' => 'SonyDTV|HbbTV', // experimental
@@ -595,11 +614,12 @@ class ai_Mobile_Detect
595
  'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
596
  'Coast' => array('Coast/[VER]'),
597
  'Dolfin' => 'Dolfin/[VER]',
598
- // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference
599
- 'Firefox' => 'Firefox/[VER]',
600
  'Fennec' => 'Fennec/[VER]',
601
  // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
602
  // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
 
603
  'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
604
  // http://en.wikipedia.org/wiki/NetFront
605
  'NetFront' => 'NetFront/[VER]',
@@ -612,6 +632,7 @@ class ai_Mobile_Detect
612
  'MicroMessenger' => 'MicroMessenger/[VER]',
613
  'baiduboxapp' => 'baiduboxapp/[VER]',
614
  'baidubrowser' => 'baidubrowser/[VER]',
 
615
  'Iron' => 'Iron/[VER]',
616
  // @note: Safari 7534.48.3 is actually Version 5.1.
617
  // @note: On BlackBerry the Version is overwriten by the OS.
@@ -619,11 +640,13 @@ class ai_Mobile_Detect
619
  'Skyfire' => 'Skyfire/[VER]',
620
  'Tizen' => 'Tizen/[VER]',
621
  'Webkit' => 'webkit[ /][VER]',
 
622
 
623
  // Engine
624
  'Gecko' => 'Gecko/[VER]',
625
  'Trident' => 'Trident/[VER]',
626
  'Presto' => 'Presto/[VER]',
 
627
 
628
  // OS
629
  'iOS' => ' \bi?OS\b [VER][ ;]{1}',
@@ -675,7 +698,7 @@ class ai_Mobile_Detect
675
  * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
676
  *
677
  * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
678
- * the headers. The default null is left for backwards compatibilty.
679
  */
680
  public function setHttpHeaders($httpHeaders = null)
681
  {
@@ -756,11 +779,11 @@ class ai_Mobile_Detect
756
  return self::$uaHttpHeaders;
757
  }
758
 
759
-
760
  /**
761
  * Set CloudFront headers
762
  * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
763
- *
764
  * @param array $cfHeaders List of HTTP headers
765
  *
766
  * @return boolean If there were CloudFront headers to be set
22
  * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
23
  * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
24
  *
25
+ * @version 2.8.25
26
  */
27
 
28
  class ai_Mobile_Detect
66
  /**
67
  * Stores the version number of the current release.
68
  */
69
+ const VERSION = '2.8.25';
70
 
71
  /**
72
  * A type for the version() method indicating a string return value.
174
  // @todo: Is 'Dell Streak' a tablet or a phone? ;)
175
  'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
176
  'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto E\b',
177
+ 'Samsung' => '\bSamsung\b|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C',
178
  'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)',
179
  'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
180
  'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
181
+ 'NokiaLumia' => 'Lumia [0-9]{3,4}',
182
  // http://www.micromaxinfo.com/mobiles/smartphones
183
  // Added because the codes might conflict with Acer Tablets.
184
  'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
191
  // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
192
  'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
193
  // http://fr.wikomobile.com
194
+ 'Wiko' => 'KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM',
195
  'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
196
  // Added simvalley mobile just for fun. They have some interesting devices.
197
  // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
219
  'iPad' => 'iPad|iPad.*Mobile',
220
  // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
221
  // @see #442
222
+ 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
223
+ 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone.
224
  // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
225
+ 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)',
226
  // Only the Surface tablets with Windows RT are considered mobile.
227
  // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
228
  'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
230
  'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
231
  // Watch out for PadFone, see #132.
232
  // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
233
+ 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z',
234
  'BlackBerryTablet' => 'PlayBook|RIM Tablet',
235
  'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
236
  'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
240
  // http://us.acer.com/ac/en/US/content/group/tablets
241
  // http://www.acer.de/ac/de/DE/content/models/tablets/
242
  // Can conflict with Micromax and Motorola phones codes.
243
+ 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b|\bA3-A20\b|\bA3-A30',
244
  // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
245
  // http://us.toshiba.com/tablets/tablet-finder
246
  // http://www.toshiba.co.jp/regza/tablet/
252
  // Prestigio Tablets http://www.prestigio.com/support
253
  'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
254
  // http://support.lenovo.com/en_GB/downloads/default.page?#
255
+ 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
256
  // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
257
  'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
258
  // http://www.yarvik.com/en/matrix/tablets/
259
  'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
260
  'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
261
+ 'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
262
  // http://www.intenso.de/kategorie_en.php?kategorie=33
263
  // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
264
  'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
270
  // http://www.allview.ro/produse/droseries/lista-tablete-pc/
271
  'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
272
  // http://wiki.archosfans.com/index.php?title=Main_Page
273
+ // @note Rewrite the regex format after we add more UAs.
274
+ 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
275
  // http://www.ainol.com/plugin.php?identifier=ainol&module=product
276
  'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
277
+ 'NokiaLumiaTablet' => 'Lumia 2520',
278
  // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
279
  // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
280
  // http://www.sony.jp/support/tablet/
286
  // http://www.cobyusa.com/?p=pcat&pcat_id=3001
287
  'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
288
  // http://www.match.net.cn/products.asp
289
+ 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10',
290
  // http://www.msi.com/support
291
  // @todo Research the Windows Tablets.
292
  'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
302
  // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
303
  'FlyTablet' => 'IQ310|Fly Vision',
304
  // http://www.bqreaders.com/gb/tablets-prices-sale.html
305
+ 'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
306
  // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
307
  // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
308
  'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
386
  // @note: no need to add all the tablet codes since they are guided by the first regex.
387
  'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
388
  // Generic Vodafone tablets.
389
+ 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
390
  // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
391
  // Aka: http://www.essentielb.fr/
392
  'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
407
  // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
408
  'TecnoTablet' => 'TECNO P9',
409
  // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
410
+ 'JXDTablet' => 'Android.* \b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
411
  // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
412
  'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
413
  // http://www.intracon.eu/tablet
438
  'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
439
  // @todo http://www.lavamobiles.com/tablets-data-cards
440
  'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
441
+ // http://www.breezetablet.com/
442
+ 'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
443
+ // http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
444
+ 'MpmanTablet' => 'MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\bMPG7\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010',
445
  // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
446
  'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
447
  // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
459
  'UbislateTablet' => 'UbiSlate[\s]?7C',
460
  // http://www.pocketbook-int.com/ru/support
461
  'PocketBookTablet' => 'Pocketbook',
462
+ // http://www.kocaso.com/product_tablet.html
463
+ 'KocasoTablet' => '\b(TB-1207)\b',
464
+ // http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
465
+ 'HisenseTablet' => '\b(F5281|E2371)\b',
466
  // http://www.tesco.com/direct/hudl/
467
  'Hudl' => 'Hudl HT7S3|Hudl 2',
468
  // http://www.telstra.com.au/home-phone/thub-2/
469
  'TelstraTablet' => 'T-Hub2',
470
+ 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b'
471
  );
472
 
473
  /**
504
  /**
505
  * List of mobile User Agents.
506
  *
507
+ * IMPORTANT: This is a list of only mobile browsers.
508
+ * Mobile Detect 2.x supports only mobile browsers,
509
+ * it was never designed to detect all browsers.
510
+ * The change will come in 2017 in the 3.x release for PHP7.
511
+ *
512
  * @var array
513
  */
514
  protected static $browsers = array(
515
+ //'Vivaldi' => 'Vivaldi',
516
  // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
517
  'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
518
  'Dolfin' => '\bDolfin\b',
519
  'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
520
  'Skyfire' => 'Skyfire',
521
+ 'Edge' => 'Mobile Safari/[.0-9]* Edge',
522
  'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
523
+ 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
524
  'Bolt' => 'bolt',
525
  'TeaShark' => 'teashark',
526
  'Blazer' => 'Blazer',
528
  'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
529
  // http://en.wikipedia.org/wiki/Midori_(web_browser)
530
  //'Midori' => 'midori',
531
+ //'Tizen' => 'Tizen',
532
  'UCBrowser' => 'UC.*Browser|UCWEB',
533
  'baiduboxapp' => 'baiduboxapp',
534
  'baidubrowser' => 'baidubrowser',
545
  // @reference: http://en.wikipedia.org/wiki/Minimo
546
  // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
547
  'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
548
+ // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
549
+ 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
550
  );
551
 
552
  /**
559
  // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
560
  // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
561
  // https://developers.facebook.com/docs/sharing/best-practices
562
+ 'Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom',
563
  'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
564
  'DesktopMode' => 'WPDesktop',
565
  'TV' => 'SonyDTV|HbbTV', // experimental
614
  'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
615
  'Coast' => array('Coast/[VER]'),
616
  'Dolfin' => 'Dolfin/[VER]',
617
+ // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
618
+ 'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
619
  'Fennec' => 'Fennec/[VER]',
620
  // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
621
  // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
622
+ 'Edge' => 'Edge/[VER]',
623
  'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
624
  // http://en.wikipedia.org/wiki/NetFront
625
  'NetFront' => 'NetFront/[VER]',
632
  'MicroMessenger' => 'MicroMessenger/[VER]',
633
  'baiduboxapp' => 'baiduboxapp/[VER]',
634
  'baidubrowser' => 'baidubrowser/[VER]',
635
+ 'SamsungBrowser' => 'SamsungBrowser/[VER]',
636
  'Iron' => 'Iron/[VER]',
637
  // @note: Safari 7534.48.3 is actually Version 5.1.
638
  // @note: On BlackBerry the Version is overwriten by the OS.
640
  'Skyfire' => 'Skyfire/[VER]',
641
  'Tizen' => 'Tizen/[VER]',
642
  'Webkit' => 'webkit[ /][VER]',
643
+ 'PaleMoon' => 'PaleMoon/[VER]',
644
 
645
  // Engine
646
  'Gecko' => 'Gecko/[VER]',
647
  'Trident' => 'Trident/[VER]',
648
  'Presto' => 'Presto/[VER]',
649
+ 'Goanna' => 'Goanna/[VER]',
650
 
651
  // OS
652
  'iOS' => ' \bi?OS\b [VER][ ;]{1}',
698
  * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
699
  *
700
  * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
701
+ * the headers. The default null is left for backwards compatibility.
702
  */
703
  public function setHttpHeaders($httpHeaders = null)
704
  {
779
  return self::$uaHttpHeaders;
780
  }
781
 
782
+
783
  /**
784
  * Set CloudFront headers
785
  * http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
786
+ *
787
  * @param array $cfHeaders List of HTTP headers
788
  *
789
  * @return boolean If there were CloudFront headers to be set
includes/ace/{src-min-noconflict/ace.js → ace.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-beautify.js → ext-beautify.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-chromevox.js → ext-chromevox.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-elastic_tabstops_lite.js → ext-elastic_tabstops_lite.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-emmet.js → ext-emmet.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-error_marker.js → ext-error_marker.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-keybinding_menu.js → ext-keybinding_menu.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-language_tools.js → ext-language_tools.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-linking.js → ext-linking.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-modelist.js → ext-modelist.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-old_ie.js → ext-old_ie.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-searchbox.js → ext-searchbox.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-settings_menu.js → ext-settings_menu.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-spellcheck.js → ext-spellcheck.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-split.js → ext-split.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-static_highlight.js → ext-static_highlight.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-statusbar.js → ext-statusbar.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-textarea.js → ext-textarea.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-themelist.js → ext-themelist.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/ext-whitespace.js → ext-whitespace.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/keybinding-emacs.js → keybinding-emacs.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/keybinding-vim.js → keybinding-vim.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/mode-html.js → mode-html.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/mode-php.js → mode-php.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-ad_inserter.js → theme-ad_inserter.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-ambiance.js → theme-ambiance.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-chaos.js → theme-chaos.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-chrome.js → theme-chrome.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-clouds.js → theme-clouds.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-clouds_midnight.js → theme-clouds_midnight.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-cobalt.js → theme-cobalt.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-crimson_editor.js → theme-crimson_editor.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-dawn.js → theme-dawn.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-disabled.js → theme-disabled.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-dreamweaver.js → theme-dreamweaver.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-eclipse.js → theme-eclipse.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-github.js → theme-github.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-idle_fingers.js → theme-idle_fingers.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-katzenmilch.js → theme-katzenmilch.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-kr_theme.js → theme-kr_theme.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-kuroir.js → theme-kuroir.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-merbivore.js → theme-merbivore.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-merbivore_soft.js → theme-merbivore_soft.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-mono_industrial.js → theme-mono_industrial.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-monokai.js → theme-monokai.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-pastel_on_dark.js → theme-pastel_on_dark.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-solarized_dark.js → theme-solarized_dark.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-solarized_light.js → theme-solarized_light.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-terminal.js → theme-terminal.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-textmate.js → theme-textmate.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-tomorrow.js → theme-tomorrow.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-tomorrow_night.js → theme-tomorrow_night.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-tomorrow_night_blue.js → theme-tomorrow_night_blue.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-tomorrow_night_bright.js → theme-tomorrow_night_bright.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-tomorrow_night_eighties.js → theme-tomorrow_night_eighties.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-twilight.js → theme-twilight.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-vibrant_ink.js → theme-vibrant_ink.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/theme-xcode.js → theme-xcode.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/worker-html.js → worker-html.js} RENAMED
File without changes
includes/ace/{src-min-noconflict/worker-php.js → worker-php.js} RENAMED
File without changes
includes/js/ad-inserter-check.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ $("#blocked-warning.warning-enabled").removeClass ('warning-enabled');
3
+ $("#blocked-warning").hide ();
4
+
5
+ var css_version = $('#ai-data').css ('font-family').replace(/[\"\']/g, '');
6
+ if (css_version.indexOf ('.') == - 1) $("#blocked-warning").show ();
7
+ });
includes/js/image-picker.min.js CHANGED
@@ -10,4 +10,17 @@
10
  // Version 0.3.0
11
  // Full source at https://github.com/rvera/image-picker
12
  // MIT License, https://github.com/rvera/image-picker/blob/master/LICENSE
13
- (function(){var t,e,i,s,l=function(t,e){return function(){return t.apply(e,arguments)}},n=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1};jQuery.fn.extend({imagepicker:function(e){return null==e&&(e={}),this.each(function(){var i;return i=jQuery(this),i.data("picker")&&i.data("picker").destroy(),i.data("picker",new t(this,s(e))),null!=e.initialized?e.initialized.call(i.data("picker")):void 0})}}),s=function(t){var e;return e={hide_select:!0,show_label:!1,initialized:void 0,changed:void 0,clicked:void 0,selected:void 0,limit:void 0,limit_reached:void 0},jQuery.extend(e,t)},i=function(t,e){return 0===jQuery(t).not(e).length&&0===jQuery(e).not(t).length},t=function(){function t(t,e){this.opts=null!=e?e:{},this.sync_picker_with_select=l(this.sync_picker_with_select,this),this.select=jQuery(t),this.multiple="multiple"===this.select.attr("multiple"),null!=this.select.data("limit")&&(this.opts.limit=parseInt(this.select.data("limit"))),this.build_and_append_picker()}return t.prototype.destroy=function(){var t,e,i,s;for(s=this.picker_options,e=0,i=s.length;i>e;e++)t=s[e],t.destroy();return this.picker.remove(),this.select.unbind("change"),this.select.removeData("picker"),this.select.show()},t.prototype.build_and_append_picker=function(){var t=this;return this.opts.hide_select&&this.select.hide(),this.select.change(function(){return t.sync_picker_with_select()}),null!=this.picker&&this.picker.remove(),this.create_picker(),this.select.after(this.picker),this.sync_picker_with_select()},t.prototype.sync_picker_with_select=function(){var t,e,i,s,l;for(s=this.picker_options,l=[],e=0,i=s.length;i>e;e++)t=s[e],t.is_selected()?l.push(t.mark_as_selected()):l.push(t.unmark_as_selected());return l},t.prototype.create_picker=function(){return this.picker=jQuery("<ul class='thumbnails image_picker_selector'></ul>"),this.picker_options=[],this.recursively_parse_option_groups(this.select,this.picker),this.picker},t.prototype.recursively_parse_option_groups=function(t,i){var s,l,n,r,c,o,h,a,p,u;for(a=t.children("optgroup"),r=0,o=a.length;o>r;r++)n=a[r],n=jQuery(n),s=jQuery("<ul></ul>"),s.append(jQuery("<li class='group_title'>"+n.attr("label")+"</li>")),i.append(jQuery("<li>").append(s)),this.recursively_parse_option_groups(n,s);for(p=function(){var i,s,n,r;for(n=t.children("option"),r=[],i=0,s=n.length;s>i;i++)l=n[i],r.push(new e(l,this,this.opts));return r}.call(this),u=[],c=0,h=p.length;h>c;c++)l=p[c],this.picker_options.push(l),l.has_image()&&u.push(i.append(l.node));return u},t.prototype.has_implicit_blanks=function(){var t;return function(){var e,i,s,l;for(s=this.picker_options,l=[],e=0,i=s.length;i>e;e++)t=s[e],t.is_blank()&&!t.has_image()&&l.push(t);return l}.call(this).length>0},t.prototype.selected_values=function(){return this.multiple?this.select.val()||[]:[this.select.val()]},t.prototype.toggle=function(t){var e,s,l;return s=this.selected_values(),l=""+t.value(),this.multiple?n.call(this.selected_values(),l)>=0?(e=this.selected_values(),e.splice(jQuery.inArray(l,s),1),this.select.val([]),this.select.val(e)):null!=this.opts.limit&&this.selected_values().length>=this.opts.limit?null!=this.opts.limit_reached&&this.opts.limit_reached.call(this.select):this.select.val(this.selected_values().concat(l)):this.has_implicit_blanks()&&t.is_selected()?this.select.val(""):this.select.val(l),i(s,this.selected_values())||(this.select.change(),null==this.opts.changed)?void 0:this.opts.changed.call(this.select,s,this.selected_values())},t}(),e=function(){function t(t,e,i){this.picker=e,this.opts=null!=i?i:{},this.clicked=l(this.clicked,this),this.option=jQuery(t),this.create_node()}return t.prototype.destroy=function(){return this.node.find(".thumbnail").unbind()},t.prototype.has_image=function(){return null!=this.option.data("img-src")},t.prototype.is_blank=function(){return!(null!=this.value()&&""!==this.value())},t.prototype.is_selected=function(){var t;return t=this.picker.select.val(),this.picker.multiple?jQuery.inArray(this.value(),t)>=0:this.value()===t},t.prototype.mark_as_selected=function(){return this.node.find(".thumbnail").addClass("selected")},t.prototype.unmark_as_selected=function(){return this.node.find(".thumbnail").removeClass("selected")},t.prototype.value=function(){return this.option.val()},t.prototype.label=function(){return this.option.data("img-label")?this.option.data("img-label"):this.option.text()},t.prototype.clicked=function(){return this.picker.toggle(this),null!=this.opts.clicked&&this.opts.clicked.call(this.picker.select,this),null!=this.opts.selected&&this.is_selected()?this.opts.selected.call(this.picker.select,this):void 0},t.prototype.create_node=function(){var t,e;return this.node=jQuery("<li/>"),t=jQuery("<img class='image_picker_image'/>"),t.attr("src",this.option.data("img-src")),e=jQuery("<div class='thumbnail'>"),e.click({option:this},function(t){return t.data.option.clicked()}),e.append(t),this.opts.show_label&&e.append(jQuery("<p/>").html(this.label())),this.node.append(e),this.node},t}()}).call(this);
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  // Version 0.3.0
11
  // Full source at https://github.com/rvera/image-picker
12
  // MIT License, https://github.com/rvera/image-picker/blob/master/LICENSE
13
+ (function(){var ImagePicker,ImagePickerOption,both_array_are_equal,sanitized_options,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},indexOf=[].indexOf||function(item){for(var i=0,l=this.length;i<l;i++)if(i in this&&this[i]===item)return i;return-1};jQuery.fn.extend({imagepicker:function(opts){if(opts==null)opts={};return this.each(function(){var select;select=jQuery(this);if(select.data("picker"))select.data("picker").destroy();select.data("picker",new ImagePicker(this,sanitized_options(opts)));
14
+ if(opts.initialized!=null)return opts.initialized.call(select.data("picker"))})}});sanitized_options=function(opts){var default_options;default_options={hide_select:true,show_label:false,initialized:void 0,changed:void 0,clicked:void 0,selected:void 0,limit:void 0,limit_reached:void 0};return jQuery.extend(default_options,opts)};both_array_are_equal=function(a,b){var i,j,len,x;if(!a||!b||a.length!==b.length)return false;a=a.slice(0);b=b.slice(0);a.sort();b.sort();for(i=j=0,len=a.length;j<len;i=++j){x=
15
+ a[i];if(b[i]!==x)return false}return true};ImagePicker=function(){function ImagePicker(select_element,opts1){this.opts=opts1!=null?opts1:{};this.sync_picker_with_select=bind(this.sync_picker_with_select,this);this.select=jQuery(select_element);this.multiple=this.select.attr("multiple")==="multiple";if(this.select.data("limit")!=null)this.opts.limit=parseInt(this.select.data("limit"));this.build_and_append_picker()}ImagePicker.prototype.destroy=function(){var j,len,option,ref;ref=this.picker_options;
16
+ for(j=0,len=ref.length;j<len;j++){option=ref[j];option.destroy()}this.picker.remove();this.select.off("change",this.sync_picker_with_select);this.select.removeData("picker");return this.select.show()};ImagePicker.prototype.build_and_append_picker=function(){if(this.opts.hide_select)this.select.hide();this.select.on("change",this.sync_picker_with_select);if(this.picker!=null)this.picker.remove();this.create_picker();this.select.after(this.picker);return this.sync_picker_with_select()};ImagePicker.prototype.sync_picker_with_select=
17
+ function(){var j,len,option,ref,results;ref=this.picker_options;results=[];for(j=0,len=ref.length;j<len;j++){option=ref[j];if(option.is_selected())results.push(option.mark_as_selected());else results.push(option.unmark_as_selected())}return results};ImagePicker.prototype.create_picker=function(){this.picker=jQuery("<ul class='thumbnails image_picker_selector'></ul>");this.picker_options=[];this.recursively_parse_option_groups(this.select,this.picker);return this.picker};ImagePicker.prototype.recursively_parse_option_groups=
18
+ function(scoped_dom,target_container){var container,j,k,len,len1,option,option_group,ref,ref1,results;ref=scoped_dom.children("optgroup");for(j=0,len=ref.length;j<len;j++){option_group=ref[j];option_group=jQuery(option_group);container=jQuery("<ul></ul>");container.append(jQuery("<li class='group_title'>"+option_group.attr("label")+"</li>"));target_container.append(jQuery("<li class='group'>").append(container));this.recursively_parse_option_groups(option_group,container)}ref1=function(){var l,len1,
19
+ ref1,results1;ref1=scoped_dom.children("option");results1=[];for(l=0,len1=ref1.length;l<len1;l++){option=ref1[l];results1.push(new ImagePickerOption(option,this,this.opts))}return results1}.call(this);results=[];for(k=0,len1=ref1.length;k<len1;k++){option=ref1[k];this.picker_options.push(option);if(!option.has_image())continue;results.push(target_container.append(option.node))}return results};ImagePicker.prototype.has_implicit_blanks=function(){var option;return function(){var j,len,ref,results;ref=
20
+ this.picker_options;results=[];for(j=0,len=ref.length;j<len;j++){option=ref[j];if(option.is_blank()&&!option.has_image())results.push(option)}return results}.call(this).length>0};ImagePicker.prototype.selected_values=function(){if(this.multiple)return this.select.val()||[];else return[this.select.val()]};ImagePicker.prototype.toggle=function(imagepicker_option,original_event){var new_values,old_values,selected_value;old_values=this.selected_values();selected_value=imagepicker_option.value().toString();
21
+ if(this.multiple)if(indexOf.call(this.selected_values(),selected_value)>=0){new_values=this.selected_values();new_values.splice(jQuery.inArray(selected_value,old_values),1);this.select.val([]);this.select.val(new_values)}else if(this.opts.limit!=null&&this.selected_values().length>=this.opts.limit){if(this.opts.limit_reached!=null)this.opts.limit_reached.call(this.select)}else this.select.val(this.selected_values().concat(selected_value));else if(this.has_implicit_blanks()&&imagepicker_option.is_selected())this.select.val("");
22
+ else this.select.val(selected_value);if(!both_array_are_equal(old_values,this.selected_values())){this.select.change();if(this.opts.changed!=null)return this.opts.changed.call(this.select,old_values,this.selected_values(),original_event)}};return ImagePicker}();ImagePickerOption=function(){function ImagePickerOption(option_element,picker,opts1){this.picker=picker;this.opts=opts1!=null?opts1:{};this.clicked=bind(this.clicked,this);this.option=jQuery(option_element);this.create_node()}ImagePickerOption.prototype.destroy=
23
+ function(){return this.node.find(".thumbnail").off("click",this.clicked)};ImagePickerOption.prototype.has_image=function(){return this.option.data("img-src")!=null};ImagePickerOption.prototype.is_blank=function(){return!(this.value()!=null&&this.value()!=="")};ImagePickerOption.prototype.is_selected=function(){var select_value;select_value=this.picker.select.val();if(this.picker.multiple)return jQuery.inArray(this.value(),select_value)>=0;else return this.value()===select_value};ImagePickerOption.prototype.mark_as_selected=
24
+ function(){return this.node.find(".thumbnail").addClass("selected")};ImagePickerOption.prototype.unmark_as_selected=function(){return this.node.find(".thumbnail").removeClass("selected")};ImagePickerOption.prototype.value=function(){return this.option.val()};ImagePickerOption.prototype.label=function(){if(this.option.data("img-label"))return this.option.data("img-label");else return this.option.text()};ImagePickerOption.prototype.clicked=function(event){this.picker.toggle(this,event);if(this.opts.clicked!=
25
+ null)this.opts.clicked.call(this.picker.select,this,event);if(this.opts.selected!=null&&this.is_selected())return this.opts.selected.call(this.picker.select,this,event)};ImagePickerOption.prototype.create_node=function(){var image,imgAlt,imgClass,thumbnail;this.node=jQuery("<li/>");image=jQuery("<img class='image_picker_image'/>");image.attr("src",this.option.data("img-src"));thumbnail=jQuery("<div class='thumbnail'>");imgClass=this.option.data("img-class");if(imgClass){this.node.addClass(imgClass);
26
+ image.addClass(imgClass);thumbnail.addClass(imgClass)}imgAlt=this.option.data("img-alt");if(imgAlt)image.attr("alt",imgAlt);imgTitle=this.option.data("img-title");if(imgTitle)image.attr("title",imgTitle);thumbnail.on("click",this.clicked);thumbnail.append(image);this.node.append(thumbnail);if(this.opts.show_label)this.node.append(jQuery("<p/>").html(this.label()));return this.node};return ImagePickerOption}()}).call(this);
includes/js/jquery.ui.spinner.js CHANGED
@@ -533,11 +533,3 @@ $.widget( "ui.spinner", {
533
 
534
  }( jQuery ) );
535
 
536
- jQuery(document).ready(function($) {
537
- $("#blocked-warning.warning-enabled").removeClass ('warning-enabled');
538
- $("#blocked-warning").hide ();
539
-
540
- var css_version = $('#data').css ('font-family').replace(/\"/g, '');
541
- if (css_version.indexOf ('.') == - 1) $("#blocked-warning").show ();
542
- });
543
-
533
 
534
  }( jQuery ) );
535
 
 
 
 
 
 
 
 
 
js/ad-inserter.js CHANGED
@@ -1,9 +1,9 @@
1
- var javascript_version = "2.1.5";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
5
  var active_tab = 1;
6
- var tabs_to_configure = new Array();
7
 
8
  var current_tab = 0;
9
  var next_tab = 0;
@@ -60,10 +60,6 @@ function SyntaxHighlight (id, block, settings) {
60
  this.valid = true;
61
  editDiv = jQuery('<div>', {
62
  position: 'absolute',
63
- // width: textarea.width() + 14,
64
- // width: 733,
65
- // height: textarea.height() + 4,
66
- // height: 384,
67
  'class': textarea.attr('class'),
68
  'id': 'editor-' + block
69
  }).insertBefore (textarea);
@@ -111,17 +107,321 @@ function change_block_alignment (block) {
111
  jQuery("select#block-alignment-" + block).change ();
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  jQuery(document).ready(function($) {
115
 
116
- shSettings ['theme'] = $('#data').attr ('theme');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  var geo_groups = 0;
119
- var geo_groups_text = $('#data-2').attr ('geo_groups');
120
  if (typeof geo_groups_text != 'undefined') {
121
  geo_groups = parseInt (geo_groups_text);
122
  }
123
 
124
- var debug = parseInt ($('#data').attr ('javascript_debugging'));
125
  var debug_title = false;
126
 
127
  if (debug) {
@@ -132,7 +432,6 @@ jQuery(document).ready(function($) {
132
 
133
  syntax_highlighting = typeof shSettings ['theme'] != 'undefined' && shSettings ['theme'] != 'disabled';
134
 
135
- var header = $('#ai-settings-' + 'header').length != 0;
136
  var header_id = 'name';
137
  var preview_top = (screen.height / 2) - (820 / 2);
138
 
@@ -228,6 +527,19 @@ jQuery(document).ready(function($) {
228
  } else editor.getSession ().setMode ("ace/mode/html");
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  function getDate (element) {
232
  var date;
233
  try {
@@ -272,16 +584,45 @@ jQuery(document).ready(function($) {
272
  }
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  function process_display_elements (block) {
276
 
277
  $("#paragraph-settings-"+block).hide();
278
  $("#content-settings-"+block).hide();
279
 
280
- // var display_type = '';
281
- // $("select#display-type-"+block+" option:selected").each(function() {
282
- // display_type += $(this).text();
283
- // });
284
-
285
  var automatic_insertion = $("select#display-type-"+block+" option:selected").attr('value');
286
 
287
  if (automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH) {
@@ -450,13 +791,7 @@ jQuery(document).ready(function($) {
450
  $('#ai-plugin-settings-tab-container').tabs();
451
  $('#ai-plugin-settings-tabs').show();
452
 
453
- $("#export-switch-0").button ({
454
- icons: {
455
- primary: "ui-icon-gear",
456
- secondary: "ui-icon-triangle-1-s"
457
- },
458
- text: false
459
- }).show ().click (function () {
460
  $("#export-container-0").toggle ();
461
 
462
  if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
@@ -483,6 +818,16 @@ jQuery(document).ready(function($) {
483
  for (var index = 1; index <= geo_groups; index ++) {
484
  generate_country_list ('group-country', index);
485
  }
 
 
 
 
 
 
 
 
 
 
486
  }
487
 
488
  function configure_tab (tab) {
@@ -687,6 +1032,9 @@ jQuery(document).ready(function($) {
687
 
688
  $("#name-label-"+tab).click (function () {
689
  var block = $(this).attr('id').replace ("name-label-", "");
 
 
 
690
  if (!$('#name-edit-'+block).is(':visible')) {
691
  $("#name-edit-"+block).css('display', 'table-cell').val ($("#name-label-"+block).text ()).focus ();
692
  $("#name-label-"+block).hide();
@@ -695,6 +1043,9 @@ jQuery(document).ready(function($) {
695
 
696
  $("#name-label-container-"+tab).click (function () {
697
  var block = $(this).attr('id').replace ("name-label-container-", "");
 
 
 
698
  if (!$('#name-edit-'+block).is(':visible')) {
699
  $("#name-edit-"+block).css('display', 'table-cell').val ($("#name-label-"+block).text ()).focus ();
700
  $("#name-label-"+block).hide();
@@ -726,12 +1077,7 @@ jQuery(document).ready(function($) {
726
  ignore_key = true;
727
  });
728
 
729
- $("#export-switch-"+tab).button ({
730
- icons: {
731
- secondary: "ui-icon-triangle-1-s"
732
- },
733
- text: false
734
- }).show ().click (function () {
735
  var block = $(this).attr ("id");
736
  block = block.replace ("export-switch-","");
737
  $("#export-container-" + block).toggle ();
@@ -746,6 +1092,116 @@ jQuery(document).ready(function($) {
746
  }
747
  });
748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749
  $("#device-detection-button-"+tab).button ({
750
  }).show ().click (function () {
751
  var block = $(this).attr ("id");
@@ -839,6 +1295,10 @@ jQuery(document).ready(function($) {
839
  });
840
 
841
  generate_country_list ('country', tab);
 
 
 
 
842
  }
843
 
844
  function generate_country_list (element_name_prefix, index) {
@@ -946,7 +1406,48 @@ jQuery(document).ready(function($) {
946
  if (tabs_to_configure.length != 0) setTimeout (configure_hidden_tab, 10); else if (debug_title) $("#plugin_name").css ("color", "#000");
947
  }
948
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
949
 
 
 
 
 
 
 
 
950
 
951
  if (debug) console.log ("READY");
952
  if (debug_title) $("#plugin_name").css ("color", "#f00");
@@ -969,12 +1470,12 @@ jQuery(document).ready(function($) {
969
  for (var tab = end; tab >= start; tab --) {
970
  if (tab != active_tab) tabs_array.push (tab);
971
  }
972
- // Concate existing tabs_to_configure (if tab was clicked before page was loaded)
973
  tabs_to_configure = tabs_array.concat (tabs_to_configure);
974
 
975
  setTimeout (configure_hidden_tab, 700);
976
 
977
- var plugin_version = $('#data').attr ('version');
978
  if (javascript_version != plugin_version) {
979
 
980
  // Check page HTML
@@ -993,7 +1494,7 @@ jQuery(document).ready(function($) {
993
  $("#javascript-warning").show ();
994
  }
995
 
996
- var css_version = $('#data').css ('font-family').replace(/\"/g, '');
997
  if (css_version.indexOf ('.') == - 1) $("#blocked-warning").show (); else
998
  if (css_version != plugin_version) {
999
 
1
+ var javascript_version = "2.1.6";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
5
  var active_tab = 1;
6
+ var tabs_to_configure = new Array();
7
 
8
  var current_tab = 0;
9
  var next_tab = 0;
60
  this.valid = true;
61
  editDiv = jQuery('<div>', {
62
  position: 'absolute',
 
 
 
 
63
  'class': textarea.attr('class'),
64
  'id': 'editor-' + block
65
  }).insertBefore (textarea);
107
  jQuery("select#block-alignment-" + block).change ();
108
  }
109
 
110
+
111
+ (function ($) {
112
+ $.widget("toggle.checkboxButton", {
113
+ _create : function() {
114
+ this._on(this.element, {
115
+ "change" : function(event) {
116
+ this.element.next ("label").find ('.checkbox-icon').toggleClass("on");
117
+ }
118
+ });
119
+ }
120
+ });
121
+ }(jQuery));
122
+
123
+
124
  jQuery(document).ready(function($) {
125
 
126
+ var header = $('#ai-settings-' + 'header').length != 0;
127
+
128
+ if (header) {
129
+ $.elycharts.templates['ai'] = {
130
+ type : "line",
131
+ margins : [10, 37, 20, 37],
132
+ defaultSeries : {
133
+ fill: true,
134
+ fillProps: {
135
+ opacity: .15
136
+ },
137
+ plotProps : {
138
+ "stroke-width" : 1,
139
+ },
140
+ },
141
+ series : {
142
+ serie1 : {
143
+ color : "#66f",
144
+ rounded : 0.8,
145
+ },
146
+ serie2 : {
147
+ color : "#888",
148
+ axis : "r",
149
+ fillProps: {
150
+ opacity: .1
151
+ },
152
+ }
153
+ },
154
+ defaultAxis : {
155
+ labels : true,
156
+ min: 0,
157
+ },
158
+ features : {
159
+ grid : {
160
+ draw : true,
161
+ forceBorder : true,
162
+ ny: 5,
163
+ ticks : {
164
+ active : [true, true, true],
165
+ size : [4, 0],
166
+ props : {
167
+ stroke: '#ccc',
168
+ }
169
+ }
170
+ },
171
+ },
172
+ interactive: false
173
+ }
174
+
175
+ $.elycharts.templates['ai-clicks'] = {
176
+ template: 'ai',
177
+ series : {
178
+ serie1 : {
179
+ color : "#0a0",
180
+ fillProps: {
181
+ opacity: .2
182
+ },
183
+ },
184
+ serie2 : {
185
+ color : "#888",
186
+ }
187
+ },
188
+ }
189
+
190
+ $.elycharts.templates['ai-impressions'] = {
191
+ template: 'ai',
192
+ series : {
193
+ serie1 : {
194
+ color : "#66f",
195
+ },
196
+ serie2 : {
197
+ color : "#888",
198
+ }
199
+ },
200
+ }
201
+
202
+ $.elycharts.templates['ai-ctr'] = {
203
+ template: 'ai',
204
+ series : {
205
+ serie1 : {
206
+ color : "#e22",
207
+ },
208
+ serie2 : {
209
+ color : "#888",
210
+ }
211
+ },
212
+ }
213
+
214
+ $.elycharts.templates['ai-versions'] = {
215
+ type : "line",
216
+ margins : [10, 37, 20, 37],
217
+ defaultSeries: {
218
+ color: "#0a0",
219
+ fillProps: {
220
+ opacity: .2
221
+ },
222
+ plotProps : {
223
+ "stroke-width" : 2,
224
+ },
225
+ tooltip : {
226
+ frameProps : {
227
+ opacity : 0.8
228
+ }
229
+ },
230
+ rounded : 0.8,
231
+ },
232
+ series: {
233
+ serie1: {
234
+ color : "#aaa",
235
+ axis : "l",
236
+ },
237
+ serie2 : {
238
+ color : "#0a0",
239
+ axis : "r",
240
+ },
241
+ serie3 : {
242
+ color: "#33f",
243
+ },
244
+ serie4 : {
245
+ color : "#e22",
246
+ },
247
+ serie5 : {
248
+ color : "#e2f",
249
+ },
250
+ serie6 : {
251
+ color : "#ec6400",
252
+ },
253
+ serie7 : {
254
+ color : "#00a3b5",
255
+ },
256
+ serie8 : {
257
+ color : "#7000ff",
258
+ },
259
+ serie9 : {
260
+ color : "#000",
261
+ },
262
+ },
263
+ defaultAxis : {
264
+ labels : true,
265
+ min: 0,
266
+ },
267
+ features : {
268
+ grid: {
269
+ draw: true,
270
+ forceBorder : true,
271
+ ny: 5,
272
+ ticks : {
273
+ active : [true, true, true],
274
+ size : [4, 0],
275
+ props : {
276
+ stroke: '#ccc',
277
+ }
278
+ }
279
+ },
280
+ },
281
+ interactive: true,
282
+ }
283
+
284
+ $.elycharts.templates['ai-versions-legend'] = {
285
+ template: 'ai-versions',
286
+ margins : [10, 37, 10, 37],
287
+ defaultSeries : {
288
+ fill: true,
289
+ fillProps: {
290
+ opacity: 0
291
+ },
292
+ plotProps : {
293
+ "stroke-width" : 0,
294
+ },
295
+ },
296
+ defaultAxis : {
297
+ labels : false,
298
+ },
299
+ features: {
300
+ grid: {
301
+ draw: false,
302
+ props: {
303
+ stroke: "transparent",
304
+ },
305
+ ticks : {
306
+ active : false,
307
+ }
308
+ },
309
+ legend: {
310
+ horizontal : true,
311
+ x : 20, // X | auto, (auto solo per horizontal = true)
312
+ y : 0,
313
+ width : 540, // X | auto, (auto solo per horizontal = true)
314
+ height : 20,
315
+ itemWidth : "auto", // fixed | auto, solo per horizontal = true
316
+ borderProps: { fill : "white", stroke: "black", "stroke-width": 0},
317
+ },
318
+ },
319
+ }
320
+
321
+ $.elycharts.templates['ai-pie'] = {
322
+ template: 'ai-versions',
323
+ type: "pie",
324
+ rPerc: 100,
325
+ startAngle: 270,
326
+ clockwise: true,
327
+ margins : [0, 0, 0, 0],
328
+ defaultSeries : {
329
+ tooltip: {
330
+ height: 55,
331
+ width: 120,
332
+ padding: [5, 5],
333
+ offset: [-15, -10],
334
+ frameProps: {
335
+ opacity: 0.95,
336
+ /* fill: "white", */
337
+ stroke: "#000"
338
+
339
+ }
340
+ },
341
+ plotProps : {
342
+ stroke : "white",
343
+ "stroke-width" : 0,
344
+ opacity : 1
345
+ },
346
+ values : [{
347
+ plotProps : {
348
+ fill : "#aaa"
349
+ }
350
+ }, {
351
+ plotProps : {
352
+ fill : "#0a0"
353
+ }
354
+ }, {
355
+ plotProps : {
356
+ fill : "#33f"
357
+ }
358
+ }, {
359
+ plotProps : {
360
+ fill : "#e22"
361
+ }
362
+ }, {
363
+ plotProps : {
364
+ fill : "#e2f"
365
+ }
366
+ }, {
367
+ plotProps : {
368
+ fill : "gray"
369
+ }
370
+ }, {
371
+ plotProps : {
372
+ fill : "#ec6400"
373
+ }
374
+ }, {
375
+ plotProps : {
376
+ fill : "#00a3b5"
377
+ }
378
+ }, {
379
+ plotProps : {
380
+ fill : "#7000ff"
381
+ }
382
+ }, {
383
+ plotProps : {
384
+ fill : "#000"
385
+ }
386
+ }]
387
+ }
388
+ }
389
+
390
+ $.elycharts.templates['ai-bar'] = {
391
+ template: 'ai-pie',
392
+ type: "line",
393
+ margins : [5, 0, 5, 30],
394
+ barMargins : 1,
395
+ defaultSeries : {
396
+ type: "bar",
397
+ axis: "l",
398
+ tooltip: {
399
+ height: 38,
400
+ }
401
+ },
402
+ features: {
403
+ grid: {
404
+ draw: [false, false],
405
+ props : {stroke: '#e0e0e0', "stroke-width": 0},
406
+ ticks : {
407
+ props : {stroke: '#e0e0e0', "stroke-width": 0},
408
+ }
409
+ },
410
+ },
411
+ }
412
+
413
+ }
414
+
415
+
416
+ shSettings ['theme'] = $('#ai-data').attr ('theme');
417
 
418
  var geo_groups = 0;
419
+ var geo_groups_text = $('#ai-data-2').attr ('geo_groups');
420
  if (typeof geo_groups_text != 'undefined') {
421
  geo_groups = parseInt (geo_groups_text);
422
  }
423
 
424
+ var debug = parseInt ($('#ai-data').attr ('javascript_debugging'));
425
  var debug_title = false;
426
 
427
  if (debug) {
432
 
433
  syntax_highlighting = typeof shSettings ['theme'] != 'undefined' && shSettings ['theme'] != 'disabled';
434
 
 
435
  var header_id = 'name';
436
  var preview_top = (screen.height / 2) - (820 / 2);
437
 
527
  } else editor.getSession ().setMode ("ace/mode/html");
528
  }
529
 
530
+ function disable_auto_refresh_statistics () {
531
+ $('span.icon-auto-refresh').each (function() {
532
+ $(this).removeClass ('on');
533
+ });
534
+ }
535
+
536
+ function reload_statistics (block) {
537
+ if ($("input#auto-refresh-"+block).next ().find ('.checkbox-icon').hasClass ('on')) {
538
+ $("input#load-custom-range-"+block).click ();
539
+ setTimeout (function() {reload_statistics (block);}, 60 * 1000);
540
+ }
541
+ }
542
+
543
  function getDate (element) {
544
  var date;
545
  try {
584
  }
585
  }
586
 
587
+ function process_chart_dates (block) {
588
+ var start_date_picker = $("input#chart-start-date-"+block);
589
+ var end_date_picker = $("input#chart-end-date-"+block);
590
+ var start_date = getDate (start_date_picker);
591
+ var end_date = getDate (end_date_picker);
592
+
593
+ start_date_picker.attr ('title', '');
594
+ start_date_picker.css ("border-color", "rgb(221, 221, 221)");
595
+ end_date_picker.attr ('title', '');
596
+ end_date_picker.css ("border-color", "rgb(221, 221, 221)");
597
+
598
+ if (start_date == null) {
599
+ end_date_picker.attr ('title', '');
600
+ } else
601
+ if (end_date == null) {
602
+ end_date_picker.attr ('title', '');
603
+ } else
604
+ if (end_date > start_date) {
605
+ var now = new Date();
606
+ var today_date = new Date (now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
607
+ if (today_date - start_date > 366 * 24 * 3600 * 1000) {
608
+ start_date_picker.attr ('title', 'Invalid start date - only data for 1 year back is available');
609
+ start_date_picker.css ("border-color", "#d00");
610
+ }
611
+ if (end_date - start_date > 366 * 24 * 3600 * 1000) {
612
+ end_date_picker.attr ('title', 'Invalid date range - only data for 1 year can be displayed');
613
+ end_date_picker.css ("border-color", "#d00");
614
+ }
615
+ } else {
616
+ end_date_picker.attr ('title', 'Invalid end date - must be after start date');
617
+ end_date_picker.css ("border-color", "#d00");
618
+ }
619
+ }
620
+
621
  function process_display_elements (block) {
622
 
623
  $("#paragraph-settings-"+block).hide();
624
  $("#content-settings-"+block).hide();
625
 
 
 
 
 
 
626
  var automatic_insertion = $("select#display-type-"+block+" option:selected").attr('value');
627
 
628
  if (automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH) {
791
  $('#ai-plugin-settings-tab-container').tabs();
792
  $('#ai-plugin-settings-tabs').show();
793
 
794
+ $("#export-switch-0").checkboxButton ().click (function () {
 
 
 
 
 
 
795
  $("#export-container-0").toggle ();
796
 
797
  if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
818
  for (var index = 1; index <= geo_groups; index ++) {
819
  generate_country_list ('group-country', index);
820
  }
821
+
822
+ $('#enable-header').checkboxButton ();
823
+ $('#enable-header-404').checkboxButton ();
824
+ $('#simple-editor-h').checkboxButton ();
825
+ $('#process-php-h').checkboxButton ();
826
+
827
+ $('#enable-footer').checkboxButton ();
828
+ $('#enable-footer-404').checkboxButton ();
829
+ $('#simple-editor-f').checkboxButton ();
830
+ $('#process-php-f').checkboxButton ();
831
  }
832
 
833
  function configure_tab (tab) {
1032
 
1033
  $("#name-label-"+tab).click (function () {
1034
  var block = $(this).attr('id').replace ("name-label-", "");
1035
+
1036
+ if ($("div#settings-" + block).is (':visible'))
1037
+
1038
  if (!$('#name-edit-'+block).is(':visible')) {
1039
  $("#name-edit-"+block).css('display', 'table-cell').val ($("#name-label-"+block).text ()).focus ();
1040
  $("#name-label-"+block).hide();
1043
 
1044
  $("#name-label-container-"+tab).click (function () {
1045
  var block = $(this).attr('id').replace ("name-label-container-", "");
1046
+
1047
+ if ($("div#settings-" + block).is (':visible'))
1048
+
1049
  if (!$('#name-edit-'+block).is(':visible')) {
1050
  $("#name-edit-"+block).css('display', 'table-cell').val ($("#name-label-"+block).text ()).focus ();
1051
  $("#name-label-"+block).hide();
1077
  ignore_key = true;
1078
  });
1079
 
1080
+ $("#export-switch-"+tab).checkboxButton ().click (function () {
 
 
 
 
 
1081
  var block = $(this).attr ("id");
1082
  block = block.replace ("export-switch-","");
1083
  $("#export-container-" + block).toggle ();
1092
  }
1093
  });
1094
 
1095
+ $("input#statistics-button-"+tab).checkboxButton ().click (function () {
1096
+ disable_auto_refresh_statistics ();
1097
+ var block = $(this).attr ("id");
1098
+ block = block.replace ("statistics-button-","");
1099
+ $("div#statistics-container-" + block).toggle ();
1100
+ $("div#settings-" + block).toggle ();
1101
+
1102
+ $("#toolbar-" + block + ' .ai-settings').toggle ();
1103
+ $("#toolbar-" + block + ' .ai-statistics').toggle ();
1104
+
1105
+ var container = $("div#statistics-container-" + block);
1106
+ if (container.is(':visible')) {
1107
+ $("#name-label-container-"+block).css ('cursor', 'default');
1108
+ if (!$(this).hasClass ('loaded')) {
1109
+ $("input#load-custom-range-"+block).click ();
1110
+ $(this).addClass ('loaded');
1111
+ }
1112
+ } else {
1113
+ $("#name-label-container-"+block).css ('cursor', 'pointer');
1114
+ }
1115
+ });
1116
+
1117
+ $("input#load-custom-range-"+tab).click (function () {
1118
+ var block = $(this).attr ("id");
1119
+ block = block.replace ("load-custom-range-","");
1120
+ var label = $(this).next ().find ('.checkbox-icon');
1121
+
1122
+ label.addClass ('on');
1123
+
1124
+ var nonce = $(this).attr ('nonce');
1125
+ var site_url = $(this).attr ('site-url');
1126
+ var start_date = $("input#chart-start-date-" + block).attr('value');
1127
+ var end_date = $("input#chart-end-date-" + block).attr('value');
1128
+ var container = $("div#statistics-elements-" + block);
1129
+
1130
+ var version_charts_container = $("div#ai-version-charts-" + block);
1131
+ var version_charts_container_visible = version_charts_container.is (':visible');
1132
+
1133
+ container.load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&statistics=" + block + "&start-date=" + start_date + "&end-date=" + end_date + "&ai_check=" + nonce, function (response, status, xhr) {
1134
+ label.removeClass ('on');
1135
+ if ( status == "error" ) {
1136
+ var message = "Error downloading data: " + xhr.status + " " + xhr.statusText ;
1137
+ $( "div#load-error-" + block).html (message);
1138
+ if (debug) console.log (message);
1139
+ } else {
1140
+ $( "div#load-error-" + block).html ('');
1141
+ if (debug) console.log ("Custom statistics loaded: " + block);
1142
+ configure_charts (container);
1143
+
1144
+ container.find ("label.ai-version-charts-button.not-configured").click (function () {
1145
+ $(this).removeClass ('not-configured');
1146
+ var version_charts_container = $(this).closest (".ai-charts").find ('div.ai-version-charts');
1147
+ version_charts_container.toggle ();
1148
+
1149
+ var not_configured_charts = version_charts_container.find ('.ai-chart.not-configured.hidden');
1150
+ if (not_configured_charts.length) {
1151
+ not_configured_charts.each (function() {
1152
+ $(this).removeClass ('hidden');
1153
+ });
1154
+ setTimeout (function() {configure_charts (version_charts_container);}, 10);
1155
+ }
1156
+ });
1157
+
1158
+ if (version_charts_container_visible) {
1159
+ container.find ("label.ai-version-charts-button.not-configured").click ();
1160
+ }
1161
+
1162
+ $("input#chart-start-date-"+block).css ('color', '#32373c');
1163
+ $("input#chart-end-date-"+block).css ('color', '#32373c');
1164
+ }
1165
+ });
1166
+ });
1167
+
1168
+ $("input#auto-refresh-"+tab).click (function () {
1169
+ var block = $(this).attr ("id");
1170
+ block = block.replace ("auto-refresh-","");
1171
+ var label = $(this).next ().find ('.checkbox-icon');
1172
+ label.toggleClass ('on');
1173
+ if (label.hasClass ('on')) {
1174
+ reload_statistics (block);
1175
+ }
1176
+ });
1177
+
1178
+ $("input#chart-start-date-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
1179
+ $("input#chart-end-date-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
1180
+
1181
+ $("input#chart-start-date-"+tab).change (function() {
1182
+ disable_auto_refresh_statistics ();
1183
+ var block = $(this).attr('id').replace ("chart-start-date-", "");
1184
+ $(this).css ('color', 'red');
1185
+ process_chart_dates (block);
1186
+ });
1187
+
1188
+ $("input#chart-end-date-"+tab).change (function() {
1189
+ disable_auto_refresh_statistics ();
1190
+ var block = $(this).attr('id').replace ("chart-end-date-", "");
1191
+ $(this).css ('color', 'red');
1192
+ process_chart_dates (block);
1193
+ });
1194
+
1195
+ $("div#custom-range-controls-"+tab+" span.data-range").click (function () {
1196
+ disable_auto_refresh_statistics ();
1197
+ var id = $(this).closest (".custom-range-controls").attr ("id");
1198
+ block = id.replace ("custom-range-controls-","");
1199
+ $("input#chart-start-date-"+block).attr ("value", $(this).data ("start-date"));
1200
+ $("input#chart-end-date-"+block).attr ("value", $(this).data ("end-date"));
1201
+ $("input#load-custom-range-"+block).click ();
1202
+ });
1203
+
1204
+
1205
  $("#device-detection-button-"+tab).button ({
1206
  }).show ().click (function () {
1207
  var block = $(this).attr ("id");
1295
  });
1296
 
1297
  generate_country_list ('country', tab);
1298
+
1299
+ $('#tracking-' + tab).checkboxButton ();
1300
+ $('#simple-editor-' + tab).checkboxButton ();
1301
+ $('#process-php-' + tab).checkboxButton ();
1302
  }
1303
 
1304
  function generate_country_list (element_name_prefix, index) {
1406
  if (tabs_to_configure.length != 0) setTimeout (configure_hidden_tab, 10); else if (debug_title) $("#plugin_name").css ("color", "#000");
1407
  }
1408
 
1409
+ function configure_chart (container) {
1410
+ if (!$(container).hasClass ('not-configured')) return;
1411
+ var template = $(container).data ('template');
1412
+ if (typeof template != 'undefined') {
1413
+ var values = $(container).data ('values-1');
1414
+ $(container).chart({
1415
+ template: template,
1416
+ labels: $(container).data ('labels'),
1417
+ values: {
1418
+ serie1: values,
1419
+ serie2: $(container).data ('values-2'),
1420
+ serie3: $(container).data ('values-3'),
1421
+ serie4: $(container).data ('values-4'),
1422
+ serie5: $(container).data ('values-5'),
1423
+ serie6: $(container).data ('values-6'),
1424
+ serie7: $(container).data ('values-7'),
1425
+ serie8: $(container).data ('values-8'),
1426
+ serie9: $(container).data ('values-9'),
1427
+ },
1428
+ legend: $(container).data ('legend'),
1429
+ tooltips: {serie1: $(container).data ('tooltips')},
1430
+ defaultAxis : {
1431
+ max: $(container).data ('max'),
1432
+ },
1433
+ features: {
1434
+ grid: {
1435
+ draw: values.length < 50,
1436
+ }
1437
+ }
1438
+ });
1439
+ $(container).removeClass ('not-configured');
1440
+ $(container).parent().find ('div.ai-chart-label').show ();
1441
+ }
1442
+ }
1443
 
1444
+ function configure_charts (container) {
1445
+ $(container).find ('.ai-chart.not-configured').each (function() {
1446
+ if (!$(this).hasClass ('hidden')) {
1447
+ configure_chart (this);
1448
+ }
1449
+ });
1450
+ }
1451
 
1452
  if (debug) console.log ("READY");
1453
  if (debug_title) $("#plugin_name").css ("color", "#f00");
1470
  for (var tab = end; tab >= start; tab --) {
1471
  if (tab != active_tab) tabs_array.push (tab);
1472
  }
1473
+ // Concatenate existing tabs_to_configure (if tab was clicked before page was loaded)
1474
  tabs_to_configure = tabs_array.concat (tabs_to_configure);
1475
 
1476
  setTimeout (configure_hidden_tab, 700);
1477
 
1478
+ var plugin_version = $('#ai-data').attr ('version');
1479
  if (javascript_version != plugin_version) {
1480
 
1481
  // Check page HTML
1494
  $("#javascript-warning").show ();
1495
  }
1496
 
1497
+ var css_version = $('#ai-data').css ('font-family').replace(/[\"\']/g, '');
1498
  if (css_version.indexOf ('.') == - 1) $("#blocked-warning").show (); else
1499
  if (css_version != plugin_version) {
1500
 
preview.php CHANGED
@@ -35,6 +35,7 @@ function generate_code_preview ($block) {
35
  <link rel='stylesheet' href='<?php echo plugins_url ('css/jquery.ui.spinner.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
36
  <link rel='stylesheet' href='<?php echo plugins_url ('css/image-picker.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
37
  <script src='<?php echo plugins_url ('includes/js/image-picker.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
 
38
  <link rel='stylesheet' href='<?php echo plugins_url ('css/ad-inserter.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
39
  <script>
40
 
@@ -633,7 +634,6 @@ function generate_code_preview ($block) {
633
 
634
  function show_blocked_warning () {
635
  jQuery("#blocked-warning.warning-enabled").show ();
636
- jQuery("#blocked-warning.warning-enabled .blocked-warning-text").css ('color', '#00f');
637
  }
638
 
639
  </script>
@@ -805,7 +805,7 @@ div.automatic-insertion img {
805
 
806
  </head>
807
  <body style='font-family: arial; text-align: justify; overflow-x: hidden;'>
808
- <div id="data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>"></div>
809
 
810
  <div style="margin: 0 -8px 10px; display: none;">
811
  <table class="screen" cellspacing=0 cellpadding=0>
@@ -836,7 +836,6 @@ div.automatic-insertion img {
836
  <h3 style="color: red;" title="Error loading page">PAGE BLOCKED</h3>
837
 
838
  <div style="clear: both;"></div>
839
-
840
  </div>
841
 
842
  <div style="margin: 10px -8px">
35
  <link rel='stylesheet' href='<?php echo plugins_url ('css/jquery.ui.spinner.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
36
  <link rel='stylesheet' href='<?php echo plugins_url ('css/image-picker.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
37
  <script src='<?php echo plugins_url ('includes/js/image-picker.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
38
+ <script src='<?php echo plugins_url ('includes/js/ad-inserter-check.js', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
39
  <link rel='stylesheet' href='<?php echo plugins_url ('css/ad-inserter.css', __FILE__); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
40
  <script>
41
 
634
 
635
  function show_blocked_warning () {
636
  jQuery("#blocked-warning.warning-enabled").show ();
 
637
  }
638
 
639
  </script>
805
 
806
  </head>
807
  <body style='font-family: arial; text-align: justify; overflow-x: hidden;'>
808
+ <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>"></div>
809
 
810
  <div style="margin: 0 -8px 10px; display: none;">
811
  <table class="screen" cellspacing=0 cellpadding=0>
836
  <h3 style="color: red;" title="Error loading page">PAGE BLOCKED</h3>
837
 
838
  <div style="clear: both;"></div>
 
839
  </div>
840
 
841
  <div style="margin: 10px -8px">
readme.txt CHANGED
@@ -3,11 +3,11 @@ Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: ads, adsense, amazon, automatic insertion, ad rotation, contextual ads, banners, amp, geo targeting, multisite, shortcodes, widgets
5
  Requires at least: 4.0
6
- Tested up to: 4.7.3
7
- Stable tag: 2.1.4
8
  License: GPLv3
9
 
10
- Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads including AdSense and Amazon. Powerful features, simple use.
11
 
12
  == Description ==
13
 
@@ -18,8 +18,9 @@ A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect
18
  > * 16 code blocks
19
  > * Syntax highlighting editor
20
  > * Code preview with visual CSS editor
21
- > * Automatic insertion: before / after post, content, paragraph or excerpt
22
  > * Automatic insertion before or after random paragraph
 
23
  > * Automatic insertion before or after any HTML element in post
24
  > * Automatic insertion at relative position in posts
25
  > * Clearance options to avoid insertion near images or headers
@@ -55,12 +56,13 @@ There is also <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</
55
 
56
  > * 64 code blocks
57
  > * GEO targeting (works also with caching)
58
- > * Black/White-list IP addresses or countries
59
  > * Sticky positions
60
  > * Scheduling with fallback option
61
  > * Export and import of settings
62
  > * Multisite options to limit settings on the sites
63
- > * 6 viewports
 
64
  > * Support via email
65
 
66
  **Quick Start**
@@ -148,7 +150,7 @@ Few very important things you need to know in order to <a href="http://adinserte
148
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
149
  * If you don't see inserted code block turn on **debugging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
150
 
151
- Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page and instructions for **Debugging**.
152
 
153
  **Settings**
154
 
@@ -491,7 +493,12 @@ For example, to exclude ads on pages that have /shop/ in url (page address) blac
491
 
492
  = How can I put an ad in the middle of the post regardless of the number of paragraphs? =
493
 
494
- Put 0.5 as paragraph number. Value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
 
 
 
 
 
495
 
496
 
497
  = I'd like to rotate my ad codes based on percentage, for example show one ad 75% of the time and another one 25% of the time. Is that possible? =
@@ -633,6 +640,11 @@ AD CODE RIGHT
633
 
634
  == Changelog ==
635
 
 
 
 
 
 
636
  = 2.1.5 =
637
  - Added support to avoid insertion inside `<figure>` and `<li>` elements (image captions, lists)
638
  - Added support for exceptions for custom post types
@@ -982,6 +994,10 @@ AD CODE RIGHT
982
 
983
  == Upgrade Notice ==
984
 
 
 
 
 
985
  = 2.1.5 =
986
  Added support to avoid insertion inside `<figure>` and `<li>` elements;
987
  Added support for exceptions for custom post types;
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
  Tags: ads, adsense, amazon, automatic insertion, ad rotation, contextual ads, banners, amp, geo targeting, multisite, shortcodes, widgets
5
  Requires at least: 4.0
6
+ Tested up to: 4.7.4
7
+ Stable tag: 2.1.5
8
  License: GPLv3
9
 
10
+ Insert any ad, HTML, Javascript, PHP, header or footer code. Perfect for all kinds of ads: AdSense, Amazon, AMP, widgets, shortcodes, ad rotation,...
11
 
12
  == Description ==
13
 
18
  > * 16 code blocks
19
  > * Syntax highlighting editor
20
  > * Code preview with visual CSS editor
21
+ > * Automatic insertion before / after post, content, paragraph or excerpt
22
  > * Automatic insertion before or after random paragraph
23
+ > * Automatic insertion before or after multiple paragraphs
24
  > * Automatic insertion before or after any HTML element in post
25
  > * Automatic insertion at relative position in posts
26
  > * Clearance options to avoid insertion near images or headers
56
 
57
  > * 64 code blocks
58
  > * GEO targeting (works also with caching)
59
+ > * Black/White-list IP addresses or countries (works also with caching)
60
  > * Sticky positions
61
  > * Scheduling with fallback option
62
  > * Export and import of settings
63
  > * Multisite options to limit settings on the sites
64
+ > * Post/page exception management
65
+ > * 6 custom viewports
66
  > * Support via email
67
 
68
  **Quick Start**
150
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
151
  * If you don't see inserted code block turn on **debugging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
152
 
153
+ Few examples for automatic insertion are described on the <a href="http://adinserter.pro/settings">Common settings</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page and instructions for **Debugging**.
154
 
155
  **Settings**
156
 
493
 
494
  = How can I put an ad in the middle of the post regardless of the number of paragraphs? =
495
 
496
+ Use Before paragraph automatic insertion and put 0.5 as paragraph number. Value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
497
+
498
+
499
+ = How can I put an ad before the second paragraph and one in the middle of post with single ad block? =
500
+
501
+ Use Before paragraph automatic insertion and put `2, 0.5` as paragraph number. You can specify multiple paragraphs as comma separated paragraph numbers (or relative postions).
502
 
503
 
504
  = I'd like to rotate my ad codes based on percentage, for example show one ad 75% of the time and another one 25% of the time. Is that possible? =
640
 
641
  == Changelog ==
642
 
643
+ = 2.1.6 =
644
+ - Added support for insertion before/after multiple paragraphs
645
+ - Added initial support for impression and click tracking (Pro only)
646
+ - Few bug fixes and cosmetic changes
647
+
648
  = 2.1.5 =
649
  - Added support to avoid insertion inside `<figure>` and `<li>` elements (image captions, lists)
650
  - Added support for exceptions for custom post types
994
 
995
  == Upgrade Notice ==
996
 
997
+ = 2.1.6 =
998
+ Added support for insertion before/after multiple paragraphs;
999
+ Few bug fixes and cosmetic changes
1000
+
1001
  = 2.1.5 =
1002
  Added support to avoid insertion inside `<figure>` and `<li>` elements;
1003
  Added support for exceptions for custom post types;
settings.php CHANGED
@@ -81,7 +81,7 @@ function generate_settings_form (){
81
  }
82
  ?>
83
 
84
- <div id="data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
85
  <?php
86
  if (function_exists ('ai_data_2')) ai_data_2 ();
87
  ?>
@@ -145,7 +145,7 @@ function generate_settings_form (){
145
  </div>
146
 
147
  <div id="ai-tab-container" class="ai-form" style="padding: 8px 8px 1px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
148
- <div id="dummy-tabs" style="height: 29px; padding: .2em .2em 0;"></div>
149
 
150
  <div id="ai-scroll-tabs" class="scroll_tabs_theme_light" style="display: none;">
151
  <?php
@@ -195,9 +195,9 @@ function generate_settings_form (){
195
  for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
196
  $obj = $block_object [$ad_number];
197
 
198
- $manual_widget [$ad_number] = $obj->get_enable_widget() == AD_SETTINGS_CHECKED;
199
- $manual_shortcode [$ad_number] = $obj->get_enable_manual() == AD_SETTINGS_CHECKED;
200
- $manual_php_function [$ad_number] = $obj->get_enable_php_call() == AD_SETTINGS_CHECKED;
201
  $manual [$ad_number] = ($manual_widget [$ad_number] && !empty ($sidebars_with_widget [$ad_number])) || $manual_shortcode [$ad_number] || $manual_php_function [$ad_number];
202
 
203
  $ad_name = $obj->get_ad_name();
@@ -267,7 +267,7 @@ function generate_settings_form (){
267
 
268
  $obj = $block_object [$ad_number];
269
 
270
- $show_devices = $obj->get_detection_client_side () == AD_SETTINGS_CHECKED || $obj->get_detection_server_side () == AD_SETTINGS_CHECKED;
271
  if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
272
 
273
  $cat_list = $obj->get_ad_block_cat();
@@ -285,7 +285,7 @@ function generate_settings_form (){
285
 
286
  $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
287
 
288
- $show_misc = $scheduling_active || intval ($obj->get_maximum_insertions ()) != 0 || intval ($obj->get_call_filter()) != 0 || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS || $obj->get_enable_404 () == AD_SETTINGS_CHECKED || $obj->get_enable_feed () == AD_SETTINGS_CHECKED;
289
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
290
 
291
  $automatic_insertion = $obj->get_automatic_insertion();
@@ -309,27 +309,30 @@ function generate_settings_form (){
309
 
310
  ?>
311
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;<?php echo $tab_visible ? "" : " display: none;" ?>">
312
- <div class="max-input" style="margin: 8px 0; height: 28px; margin-bottom: 2px;">
313
  <span id="name-label-container-<?php echo $ad_number; ?>" style="display: table-cell; padding: 0; font-weight: bold; cursor: pointer;">
314
  <input id="name-edit-<?php echo $ad_number; ?>" style="width: 100%; vertical-align: middle; font-size: 14px; border-radius: 4px; display: none;" type="text" name="<?php echo AI_OPTION_NAME, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_name(); ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="120" />
315
- <span id="name-label-<?php echo $ad_number; ?>" class="select" style="width: 100%; max-width: 440px; vertical-align: middle; font-size: 14px; display: inline-block; margin-top: 4px; margin-left: 7px; white-space: nowrap; overflow: hidden;"><?php echo $obj->get_ad_name() ?></span>
316
  </span>
317
- <?php if (function_exists ('ai_settings_top_buttons')) ai_settings_top_buttons ($ad_number); ?>
318
  <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
319
- <span style="display: table-cell; vertical-align: middle; width: 110px; padding: 2px 0 0 10px;">
320
- <input type="checkbox" style="border-radius: 5px;" value="0" id="simple-editor-<?php echo $ad_number; ?>" />
321
- <label for="simple-editor-<?php echo $ad_number; ?>" title="Toggle Syntax Highlighting / Simple editor for mobile devices">Simple editor</label>
322
  </span>
323
  <?php endif; ?>
324
- <span style="display: table-cell; vertical-align: middle; width: 110px; padding: 2px 0 0 10px;">
325
- <input type="hidden" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
326
- <input type="checkbox" style="border-radius: 5px;" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_process_php (); ?>" id="process-php-<?php echo $ad_number; ?>" <?php if ($obj->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
327
- <label for="process-php-<?php echo $ad_number; ?>" title="Process PHP code in block">Process PHP</label>
 
328
  </span>
 
329
  </div>
330
 
331
  <?php if (function_exists ('ai_settings_container')) ai_settings_container ($ad_number, $obj); ?>
332
 
 
 
333
  <div style="margin: 8px 0;">
334
  <textarea id="block-<?php echo $ad_number; ?>" class="simple-editor" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold;" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
335
  </div>
@@ -411,7 +414,7 @@ function generate_settings_form (){
411
  <tr>
412
  <td style="width: 70%">
413
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
414
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $ad_number; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
415
 
416
  <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default insertion for posts - exceptions can be configured on individual post 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; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
417
  <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>
@@ -434,12 +437,12 @@ function generate_settings_form (){
434
  </td>
435
  <td style="padding-left: 8px;">
436
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
437
- <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" default="<?php echo $default->get_display_settings_home(); ?>" <?php if ($obj->get_display_settings_home()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
438
  <label for="display-homepage-<?php echo $ad_number; ?>" title="Enable or disable insertion on homepage: latest posts (including sub-pages), static page or theme homepage">Homepage</label>
439
  </td>
440
  <td style="padding-left: 8px;">
441
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
442
- <input id= "display-category-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_category(); ?>" <?php if ($obj->get_display_settings_category()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
443
  <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)">Category pages</label>
444
  </td>
445
  </tr>
@@ -447,7 +450,7 @@ function generate_settings_form (){
447
  <tr>
448
  <td style="width: 70%">
449
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
450
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $ad_number; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
451
 
452
  <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default insertion for pages - exceptions can be configured on individual 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; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
453
  <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>
@@ -461,12 +464,12 @@ function generate_settings_form (){
461
  </td>
462
  <td style="padding-left: 8px;">
463
  <input style="border-radius: 5px;;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
464
- <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" default="<?php echo $default->get_display_settings_search(); ?>" <?php if ($obj->get_display_settings_search()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
465
  <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable insertion on search blog pages">Search pages</label>
466
  </td>
467
  <td style="padding-left: 8px;">
468
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
469
- <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" default="<?php echo $default->get_display_settings_archive(); ?>" <?php if ($obj->get_display_settings_archive()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
470
  <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable insertion on tag or archive blog pages">Tag / Archive pages</label>
471
  </td>
472
  </tr>
@@ -513,14 +516,14 @@ function generate_settings_form (){
513
  <div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:4px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;<?php echo $paragraph_settings ? "" : " display: none;" ?>">
514
  <div style="margin: 4px 0; height: 26px;">
515
  <div style="float: left; margin-top: 1px;">
516
- Paragraph number
517
  <input style="border-radius: 5px;" type="text"
518
  name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"
519
  default="<?php echo $default->get_paragraph_number(); ?>"
520
  value="<?php echo $obj->get_paragraph_number(); ?>"
521
- title="0 means random paragraph, value between 0 and 1 means relative position on page: 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 paragraphs, etc."
522
- size="2"
523
- maxlength="4" />
524
  </div>
525
 
526
  <div style="float: right;">
@@ -595,7 +598,7 @@ function generate_settings_form (){
595
  </span>
596
  <span style="display: table-cell; width: 1px; white-space: nowrap; padding-left: 20px;">
597
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_COUNT_INSIDE_BLOCKQUOTE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
598
- <input id= "ignore_blockquote-<?php echo $ad_number; ?>" style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_COUNT_INSIDE_BLOCKQUOTE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_count_inside_blockquote(); ?>" <?php if ($obj->get_count_inside_blockquote()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
599
  <label for="ignore_blockquote-<?php echo $ad_number; ?>" title="Count also paragraphs inside <?php echo SPECIAL_ELEMENT_TAGS; ?> elements">Count inside special elements</label>
600
  </span>
601
  </div>
@@ -813,7 +816,7 @@ function generate_settings_form (){
813
  <tr>
814
  <td style="padding: 4px 10px 4px 0;">
815
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
816
- <input style="border-radius: 5px;" id="enable-widget-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_widget(); ?>" <?php if ($obj->get_enable_widget () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
817
  <label for="enable-widget-<?php echo $ad_number; ?>" title="Enable or disable widget for this code block">
818
  Widget
819
  </label>
@@ -826,7 +829,7 @@ function generate_settings_form (){
826
  <tr>
827
  <td style="padding: 4px 10px 4px 0;">
828
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
829
- <input style="border-radius: 5px;" type="checkbox" id="enable-shortcode-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_manual(); ?>" <?php if ($obj->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
830
  <label for="enable-shortcode-<?php echo $ad_number; ?>" title="Enable or disable shortcode for manual insertion of this code block in posts and pages">
831
  Shortcode
832
  </label>
@@ -839,7 +842,7 @@ function generate_settings_form (){
839
  <tr>
840
  <td style="padding: 4px 10px 4px 0;">
841
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
842
- <input style="border-radius: 5px;" id="enable-php-call-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_php_call(); ?>" <?php if ($obj->get_enable_php_call () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
843
  <label for="enable-php-call-<?php echo $ad_number; ?>" title="Enable or disable PHP function call to insert this code block at any position in template file. If function is disabled for block it will return empty string.">
844
  PHP function
845
  </label>
@@ -898,17 +901,17 @@ function generate_settings_form (){
898
  </span>
899
  <span style="display: table-cell;">
900
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
901
- <input style="border-radius: 5px; margin-left: 10px;" id="enable-ajax-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_ajax(); ?>" <?php if ($obj->get_enable_ajax () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
902
  <label for="enable-ajax-<?php echo $ad_number; ?>" title="Enable or disable insertion in Ajax requests">Ajax</label>
903
  </span>
904
  <span style="display: table-cell;">
905
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
906
- <input style="border-radius: 5px; margin-left: 10px;" id="enable-feed-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_feed(); ?>" <?php if ($obj->get_enable_feed () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
907
  <label for="enable-feed-<?php echo $ad_number; ?>" title="Enable or disable insertion in feeds">Feed</label>
908
  </span>
909
  <span style="display: table-cell;">
910
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
911
- <input style="border-radius: 5px; margin-left: 10px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_404(); ?>" <?php if ($obj->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
912
  <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable insertion on page for Error 404: Page not found">404</label>
913
  </span>
914
  </div>
@@ -937,7 +940,7 @@ function generate_settings_form (){
937
  <td>
938
  <div style="margin-bottom: 5px;">
939
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
940
- <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" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
941
  <label for="client-side-detection-<?php echo $ad_number; ?>">Use client-side detection to show only on:</label>
942
  </div>
943
 
@@ -950,7 +953,7 @@ function generate_settings_form (){
950
  ?>
951
  <div style="margin: 8px 0;">
952
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
953
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="viewport-<?php echo $viewport, "-", $ad_number; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
954
  <label for="viewport-<?php echo $viewport, "-", $ad_number; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
955
  </div>
956
  <?php
@@ -960,7 +963,7 @@ function generate_settings_form (){
960
  </div>
961
  </td><td style="padding-left: 40px; vertical-align: top;">
962
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
963
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="server-side-detection-<?php echo $ad_number; ?>" value="1" default="<?php echo $default->get_detection_server_side(); ?>" <?php if ($obj->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
964
  <label for="server-side-detection-<?php echo $ad_number; ?>">Use server-side detection to insert code only for </label>
965
 
966
  <div style="margin: 10px 0 10px 40px;">
@@ -982,6 +985,8 @@ function generate_settings_form (){
982
  <div id="no-wrapping-warning-<?php echo $ad_number; ?>" style="padding:8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; display: none;">
983
  <span id="" style="margin-top: 5px;"><strong><span style="color: red;">WARNING:</span> No Wrapping</strong> style has no HTML code for client-side device detection!</span>
984
  </div>
 
 
985
  </div>
986
  <?php
987
  }
@@ -1157,22 +1162,18 @@ function generate_settings_form (){
1157
  <div id="tab-header" style="margin: 0px 0; padding: 0; ">
1158
  <div style="margin: 8px 0;">
1159
  <div style="float: right;">
1160
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="0" />
1161
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" id="enable-header" value="1" <?php if ($adH->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1162
- <label for="enable-header" title="Enable or disable insertion of this code into HTML page header">Enable</label>
1163
-
1164
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="0" />
1165
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" id="enable-header-404" value="1" <?php if ($adH->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1166
- <label for="enable-header-404" title="Enable or disable insertion of this code into HTML page header on page for Error 404: Page not found">Insert on Error 404 page</label>
1167
-
1168
  <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
1169
- <input type="checkbox" style="border-radius: 5px; margin-left: 10px;" value="0" id="simple-editor-h" />
1170
- <label for="simple-editor-h" title="Simple editor">Simple editor</label>
1171
  <?php endif; ?>
1172
 
1173
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="0" />
1174
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="1" id="process-php-h" <?php if ($adH->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1175
- <label for="process-php-h" title="Process PHP code">Process PHP</label>
 
 
 
 
1176
  </div>
1177
 
1178
  <div>
@@ -1194,7 +1195,7 @@ function generate_settings_form (){
1194
 
1195
  <div id="device-detection-settings-h" style="padding:8px 8px 8px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
1196
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_HEADER_OPTION_NAME; ?>" value="0" />
1197
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_HEADER_OPTION_NAME; ?>" id="server-side-detection-h" value="1" <?php if ($adH->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1198
  <label for="server-side-detection-h">Use server-side detection to insert code only for </label>
1199
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-h" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, AI_HEADER_OPTION_NAME; ?>" >
1200
  <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($adH->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
@@ -1205,28 +1206,30 @@ function generate_settings_form (){
1205
  <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($adH->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
1206
  </select>
1207
  devices
 
 
 
 
 
 
1208
  </div>
1209
  </div>
1210
 
1211
  <div id="tab-footer" style="margin: 0px 0; padding: 0; ">
1212
  <div style="margin: 8px 0;">
1213
  <div style="float: right;">
1214
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="0" />
1215
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" id="enable-footer" value="1" <?php if ($adF->get_enable_manual () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1216
- <label for="enable-footer" title="Enable or disable insertion of this code into HTML page footer">Enable</label>
1217
-
1218
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="0" />
1219
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" id="enable-footer-404" value="1" <?php if ($adF->get_enable_404 () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1220
- <label for="enable-footer-404" title="Enable or disable insertion of this code into HTML page footer on page for Error 404: Page not found">Insert on Error 404 page</label>
1221
-
1222
  <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
1223
- <input type="checkbox" style="border-radius: 5px; margin-left: 10px;" value="0" id="simple-editor-f" />
1224
- <label for="simple-editor-f" title="Simple editor">Simple editor</label>
1225
  <?php endif; ?>
1226
 
1227
- <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="0" />
1228
- <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="1" id="process-php-f" <?php if ($adF->get_process_php () == AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1229
- <label for="process-php-f" title="Process PHP code">Process PHP</label>
 
 
 
 
1230
  </div>
1231
 
1232
  <div>
@@ -1248,7 +1251,7 @@ function generate_settings_form (){
1248
 
1249
  <div id="device-detection-settings-f" style="padding:8px 8px 8px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
1250
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_FOOTER_OPTION_NAME; ?>" value="0" />
1251
- <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_FOOTER_OPTION_NAME; ?>" id="server-side-detection-f" value="1" <?php if ($adF->get_detection_server_side ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1252
  <label for="server-side-detection-f">Use server-side detection to insert code only for </label>
1253
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-f" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, AI_FOOTER_OPTION_NAME; ?>" >
1254
  <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($adF->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
@@ -1259,6 +1262,12 @@ function generate_settings_form (){
1259
  <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($adF->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
1260
  </select>
1261
  devices
 
 
 
 
 
 
1262
  </div>
1263
  </div>
1264
 
@@ -1267,20 +1276,20 @@ function generate_settings_form (){
1267
  <div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1268
  <div style="margin: 8px;">
1269
  <input style="border-radius: 5px;" type="hidden" name="admin_toolbar_debugging" value="0" />
1270
- <input style="border-radius: 5px;" type="checkbox" name="admin_toolbar_debugging" id="admin-toolbar-debugging" value="1" default="<?php echo DEFAULT_ADMIN_TOOLBAR_DEBUGGING; ?>" <?php if (get_admin_toolbar_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1271
  <label for="admin-toolbar-debugging" title="Enable or disable debugging functions in admin toolbar">Debugging functions in admin toolbar</label>
1272
  </div>
1273
 
1274
  <div style="margin: 8px;">
1275
  <input style="border-radius: 5px;" type="hidden" name="remote_debugging" value="0" />
1276
- <input style="border-radius: 5px;" type="checkbox" name="remote_debugging" id="remote-debugging" value="1" default="<?php echo DEFAULT_REMOTE_DEBUGGING; ?>" <?php if (get_remote_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1277
  <label for="remote-debugging" title="Enable Debugger widget and code insertion debugging (blocks, positions, tags, processing) by url parameters for non-logged in users. Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in administrators debugging is always enabled.">Remote debugging</label>
1278
  </div>
1279
 
1280
  <div id="system-debugging" style="display: none;">
1281
  <div style="margin: 8px;">
1282
  <input style="border-radius: 5px;" type="hidden" name="javascript_debugging" value="0" />
1283
- <input style="border-radius: 5px;" type="checkbox" name="javascript_debugging"id="javascript-debugging" value="1" default="<?php echo DEFAULT_JAVASCRIPT_DEBUGGING; ?>" <?php if (get_javascript_debugging ()==AD_SETTINGS_CHECKED) echo 'checked '; ?> />
1284
  <label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
1285
  </div>
1286
 
@@ -1293,22 +1302,39 @@ function generate_settings_form (){
1293
 
1294
  </div>
1295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1296
  <input id="ai-active-tab" type="hidden" name="ai-active-tab" value="<?php echo $active_tab; ?>" />
 
1297
 
1298
- <?php
1299
- wp_nonce_field ('save_adinserter_settings');
1300
- ?>
1301
  </form>
1302
 
1303
  </div>
1304
 
 
 
1305
  <?php
1306
  if ($subpage == 'main') {
1307
  if (function_exists ('ai_settings_side')) ai_settings_side (); else { ?>
1308
  <div style="float: left;">
1309
  <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1310
  <div style="float: left;">
1311
- <h2 style="display: inline-block; margin: 13px 0;">Ad Inserter Pro - Powerful Wordpress Plugin to Insert Any Code Anywhere</h2>
 
 
1312
  </div>
1313
 
1314
  <div id="header-buttons">
@@ -1318,8 +1344,17 @@ function generate_settings_form (){
1318
  <div style="clear: both;"></div>
1319
  </div>
1320
 
 
1321
  <div class="ai-form" style="padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
1322
- <a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" title="Automate ad placement in posts and pages" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="float: right; margin-top: 10px;" /></a>
 
 
 
 
 
 
 
 
1323
  <h3 style="text-align: justify;"><a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">Ad Inserter Pro</a> features:</h3>
1324
 
1325
  <ul>
@@ -1357,16 +1392,6 @@ function generate_settings_form (){
1357
  then you can simply upgrade to <a href="http://adinserter.pro/" style="text-decoration: none;" target="_blank">Ad Inserter Pro</a> (existing settings will be preserved).</p>
1358
  </div>
1359
 
1360
- <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1361
- <div style="float: left;">
1362
- <h2 style="display: inline-block; margin: 16px 0;">Follow Ad Inserter</h2>
1363
- <a href="https://twitter.com/AdInserter" class="clear-link" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>twitter.png" style="vertical-align: middle; margin: 0 10px 7px 10px;" title="Ad Inserter on Twitter" alt="Ad Inserter on Twitter" /></a>
1364
- <a href="https://www.facebook.com/AdInserter/" class="clear-link" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>facebook.png" style="vertical-align: middle; margin: 0 10px 7px 10px;" title="Ad Inserter on Facebook" alt="Ad Inserter on Facebook" /></a>
1365
- </div>
1366
-
1367
- <div style="clear: both;"></div>
1368
- </div>
1369
-
1370
  </div>
1371
  <?php
1372
  }
81
  }
82
  ?>
83
 
84
+ <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
85
  <?php
86
  if (function_exists ('ai_data_2')) ai_data_2 ();
87
  ?>
145
  </div>
146
 
147
  <div id="ai-tab-container" class="ai-form" style="padding: 8px 8px 1px 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
148
+ <div id="dummy-tabs" style="height: 30px; padding: .2em .2em 0;"></div>
149
 
150
  <div id="ai-scroll-tabs" class="scroll_tabs_theme_light" style="display: none;">
151
  <?php
195
  for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
196
  $obj = $block_object [$ad_number];
197
 
198
+ $manual_widget [$ad_number] = $obj->get_enable_widget() == AI_ENABLED;
199
+ $manual_shortcode [$ad_number] = $obj->get_enable_manual() == AI_ENABLED;
200
+ $manual_php_function [$ad_number] = $obj->get_enable_php_call() == AI_ENABLED;
201
  $manual [$ad_number] = ($manual_widget [$ad_number] && !empty ($sidebars_with_widget [$ad_number])) || $manual_shortcode [$ad_number] || $manual_php_function [$ad_number];
202
 
203
  $ad_name = $obj->get_ad_name();
267
 
268
  $obj = $block_object [$ad_number];
269
 
270
+ $show_devices = $obj->get_detection_client_side () == AI_ENABLED || $obj->get_detection_server_side () == AI_ENABLED;
271
  if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
272
 
273
  $cat_list = $obj->get_ad_block_cat();
285
 
286
  $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
287
 
288
+ $show_misc = $scheduling_active || intval ($obj->get_maximum_insertions ()) != 0 || intval ($obj->get_call_filter()) != 0 || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS || $obj->get_enable_404 () == AI_ENABLED || $obj->get_enable_feed () == AI_ENABLED;
289
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
290
 
291
  $automatic_insertion = $obj->get_automatic_insertion();
309
 
310
  ?>
311
  <div id="tab-<?php echo $ad_number; ?>" style="padding: 0;<?php echo $tab_visible ? "" : " display: none;" ?>">
312
+ <div id="toolbar-<?php echo $ad_number; ?>" class="max-input" style="margin: 8px 0; height: 28px; margin-bottom: 2px;">
313
  <span id="name-label-container-<?php echo $ad_number; ?>" style="display: table-cell; padding: 0; font-weight: bold; cursor: pointer;">
314
  <input id="name-edit-<?php echo $ad_number; ?>" style="width: 100%; vertical-align: middle; font-size: 14px; border-radius: 4px; display: none;" type="text" name="<?php echo AI_OPTION_NAME, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_name(); ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="120" />
315
+ <span id="name-label-<?php echo $ad_number; ?>" class="no-select" style="width: 100%; max-width: 440px; vertical-align: middle; font-size: 14px; display: inline-block; margin-top: 4px; margin-left: 7px; white-space: nowrap; overflow: hidden;"><?php echo $obj->get_ad_name() ?></span>
316
  </span>
 
317
  <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
318
+ <span class="ai-toolbar-button ai-settings">
319
+ <input type="checkbox" value="0" id="simple-editor-<?php echo $ad_number; ?>" style="display: none;" />
320
+ <label class="checkbox-button" for="simple-editor-<?php echo $ad_number; ?>" title="Toggle Syntax Highlighting / Simple editor for mobile devices"><span class="checkbox-icon icon-tablet"></span></label>
321
  </span>
322
  <?php endif; ?>
323
+ <?php if (function_exists ('ai_settings_top_buttons_1')) ai_settings_top_buttons_1 ($ad_number, $obj, $default); ?>
324
+ <span class="ai-toolbar-button ai-settings">
325
+ <input type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
326
+ <input type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_process_php (); ?>" id="process-php-<?php echo $ad_number; ?>" <?php if ($obj->get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
327
+ <label class="checkbox-button" for="process-php-<?php echo $ad_number; ?>" title="Process PHP code in block"><span class="checkbox-icon icon-php<?php if ($obj->get_process_php () == AI_ENABLED) echo ' on'; ?>"></span></label>
328
  </span>
329
+ <?php if (function_exists ('ai_settings_top_buttons_2')) ai_settings_top_buttons_2 ($ad_number, $obj, $default); ?>
330
  </div>
331
 
332
  <?php if (function_exists ('ai_settings_container')) ai_settings_container ($ad_number, $obj); ?>
333
 
334
+ <div id="settings-<?php echo $ad_number; ?>">
335
+
336
  <div style="margin: 8px 0;">
337
  <textarea id="block-<?php echo $ad_number; ?>" class="simple-editor" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold;" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
338
  </div>
414
  <tr>
415
  <td style="width: 70%">
416
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
417
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $ad_number; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />
418
 
419
  <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default insertion for posts - exceptions can be configured on individual post 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; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
420
  <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>
437
  </td>
438
  <td style="padding-left: 8px;">
439
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
440
+ <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" default="<?php echo $default->get_display_settings_home(); ?>" <?php if ($obj->get_display_settings_home()==AI_ENABLED) echo 'checked '; ?> />
441
  <label for="display-homepage-<?php echo $ad_number; ?>" title="Enable or disable insertion on homepage: latest posts (including sub-pages), static page or theme homepage">Homepage</label>
442
  </td>
443
  <td style="padding-left: 8px;">
444
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
445
+ <input id= "display-category-<?php echo $ad_number; ?>" style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_category(); ?>" <?php if ($obj->get_display_settings_category()==AI_ENABLED) echo 'checked '; ?> />
446
  <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)">Category pages</label>
447
  </td>
448
  </tr>
450
  <tr>
451
  <td style="width: 70%">
452
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
453
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $ad_number; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />
454
 
455
  <select style="border-radius: 5px; margin: 0 0 3px 10px;" title="Default insertion for pages - exceptions can be configured on individual 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; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
456
  <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>
464
  </td>
465
  <td style="padding-left: 8px;">
466
  <input style="border-radius: 5px;;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
467
+ <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" default="<?php echo $default->get_display_settings_search(); ?>" <?php if ($obj->get_display_settings_search()==AI_ENABLED) echo 'checked '; ?> />
468
  <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable insertion on search blog pages">Search pages</label>
469
  </td>
470
  <td style="padding-left: 8px;">
471
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
472
+ <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" default="<?php echo $default->get_display_settings_archive(); ?>" <?php if ($obj->get_display_settings_archive()==AI_ENABLED) echo 'checked '; ?> />
473
  <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable insertion on tag or archive blog pages">Tag / Archive pages</label>
474
  </td>
475
  </tr>
516
  <div id="paragraph-settings-<?php echo $ad_number; ?>" style="padding:4px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;<?php echo $paragraph_settings ? "" : " display: none;" ?>">
517
  <div style="margin: 4px 0; height: 26px;">
518
  <div style="float: left; margin-top: 1px;">
519
+ Paragraph number(s)
520
  <input style="border-radius: 5px;" type="text"
521
  name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"
522
  default="<?php echo $default->get_paragraph_number(); ?>"
523
  value="<?php echo $obj->get_paragraph_number(); ?>"
524
+ title="Paragraph number or comma separated paragraph numbers or empty (means all paragraphs): 1 to N means paragraph number, 0 means random paragraph, value between 0 and 1 means relative position on the page (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 paragraphs, etc.)"
525
+ size="8"
526
+ maxlength="24" />
527
  </div>
528
 
529
  <div style="float: right;">
598
  </span>
599
  <span style="display: table-cell; width: 1px; white-space: nowrap; padding-left: 20px;">
600
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_COUNT_INSIDE_BLOCKQUOTE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
601
+ <input id= "ignore_blockquote-<?php echo $ad_number; ?>" style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_COUNT_INSIDE_BLOCKQUOTE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_count_inside_blockquote(); ?>" <?php if ($obj->get_count_inside_blockquote()==AI_ENABLED) echo 'checked '; ?> />
602
  <label for="ignore_blockquote-<?php echo $ad_number; ?>" title="Count also paragraphs inside <?php echo SPECIAL_ELEMENT_TAGS; ?> elements">Count inside special elements</label>
603
  </span>
604
  </div>
816
  <tr>
817
  <td style="padding: 4px 10px 4px 0;">
818
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
819
+ <input style="border-radius: 5px;" id="enable-widget-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_widget(); ?>" <?php if ($obj->get_enable_widget () == AI_ENABLED) echo 'checked '; ?> />
820
  <label for="enable-widget-<?php echo $ad_number; ?>" title="Enable or disable widget for this code block">
821
  Widget
822
  </label>
829
  <tr>
830
  <td style="padding: 4px 10px 4px 0;">
831
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
832
+ <input style="border-radius: 5px;" type="checkbox" id="enable-shortcode-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_manual(); ?>" <?php if ($obj->get_enable_manual () == AI_ENABLED) echo 'checked '; ?> />
833
  <label for="enable-shortcode-<?php echo $ad_number; ?>" title="Enable or disable shortcode for manual insertion of this code block in posts and pages">
834
  Shortcode
835
  </label>
842
  <tr>
843
  <td style="padding: 4px 10px 4px 0;">
844
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
845
+ <input style="border-radius: 5px;" id="enable-php-call-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_php_call(); ?>" <?php if ($obj->get_enable_php_call () == AI_ENABLED) echo 'checked '; ?> />
846
  <label for="enable-php-call-<?php echo $ad_number; ?>" title="Enable or disable PHP function call to insert this code block at any position in template file. If function is disabled for block it will return empty string.">
847
  PHP function
848
  </label>
901
  </span>
902
  <span style="display: table-cell;">
903
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
904
+ <input style="border-radius: 5px; margin-left: 10px;" id="enable-ajax-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_ajax(); ?>" <?php if ($obj->get_enable_ajax () == AI_ENABLED) echo 'checked '; ?> />
905
  <label for="enable-ajax-<?php echo $ad_number; ?>" title="Enable or disable insertion in Ajax requests">Ajax</label>
906
  </span>
907
  <span style="display: table-cell;">
908
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
909
+ <input style="border-radius: 5px; margin-left: 10px;" id="enable-feed-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_feed(); ?>" <?php if ($obj->get_enable_feed () == AI_ENABLED) echo 'checked '; ?> />
910
  <label for="enable-feed-<?php echo $ad_number; ?>" title="Enable or disable insertion in feeds">Feed</label>
911
  </span>
912
  <span style="display: table-cell;">
913
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
914
+ <input style="border-radius: 5px; margin-left: 10px;" id="enable-404-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_404(); ?>" <?php if ($obj->get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
915
  <label for="enable-404-<?php echo $ad_number; ?>" title="Enable or disable insertion on page for Error 404: Page not found">404</label>
916
  </span>
917
  </div>
940
  <td>
941
  <div style="margin-bottom: 5px;">
942
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
943
+ <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" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
944
  <label for="client-side-detection-<?php echo $ad_number; ?>">Use client-side detection to show only on:</label>
945
  </div>
946
 
953
  ?>
954
  <div style="margin: 8px 0;">
955
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
956
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="viewport-<?php echo $viewport, "-", $ad_number; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
957
  <label for="viewport-<?php echo $viewport, "-", $ad_number; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
958
  </div>
959
  <?php
963
  </div>
964
  </td><td style="padding-left: 40px; vertical-align: top;">
965
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
966
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="server-side-detection-<?php echo $ad_number; ?>" value="1" default="<?php echo $default->get_detection_server_side(); ?>" <?php if ($obj->get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
967
  <label for="server-side-detection-<?php echo $ad_number; ?>">Use server-side detection to insert code only for </label>
968
 
969
  <div style="margin: 10px 0 10px 40px;">
985
  <div id="no-wrapping-warning-<?php echo $ad_number; ?>" style="padding:8px; margin: 8px 0 8px 5px; border: 1px solid #ddd; border-radius: 5px; display: none;">
986
  <span id="" style="margin-top: 5px;"><strong><span style="color: red;">WARNING:</span> No Wrapping</strong> style has no HTML code for client-side device detection!</span>
987
  </div>
988
+
989
+ </div>
990
  </div>
991
  <?php
992
  }
1162
  <div id="tab-header" style="margin: 0px 0; padding: 0; ">
1163
  <div style="margin: 8px 0;">
1164
  <div style="float: right;">
 
 
 
 
 
 
 
 
1165
  <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
1166
+ <input type="checkbox" value="0" id="simple-editor-h" style="display: none;" />
1167
+ <label class="checkbox-button" style="margin-left: 10px;" for="simple-editor-h" title="Toggle Syntax Highlighting / Simple editor for mobile devices"><span class="checkbox-icon icon-tablet"></span></label>
1168
  <?php endif; ?>
1169
 
1170
+ <input type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" value="0" />
1171
+ <input type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_h'; ?>" id="enable-header" value="1" <?php if ($adH->get_enable_manual () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
1172
+ <label class="checkbox-button" style="margin-left: 10px;" for="enable-header" title="Enable or disable insertion of this code into HTML page header"><span class="checkbox-icon icon-enabled<?php if ($adH->get_enable_manual () == AI_ENABLED) echo ' on'; ?>"></span></label>
1173
+
1174
+ <input type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="0" />
1175
+ <input type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_h'; ?>" value="1" id="process-php-h" <?php if ($adH->get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
1176
+ <label class="checkbox-button" style="margin-left: 10px;" for="process-php-h" title="Process PHP code"><span class="checkbox-icon icon-php<?php if ($adH->get_process_php () == AI_ENABLED) echo ' on'; ?>"></span></label>
1177
  </div>
1178
 
1179
  <div>
1195
 
1196
  <div id="device-detection-settings-h" style="padding:8px 8px 8px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
1197
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_HEADER_OPTION_NAME; ?>" value="0" />
1198
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_HEADER_OPTION_NAME; ?>" id="server-side-detection-h" value="1" <?php if ($adH->get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
1199
  <label for="server-side-detection-h">Use server-side detection to insert code only for </label>
1200
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-h" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, AI_HEADER_OPTION_NAME; ?>" >
1201
  <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($adH->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
1206
  <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($adH->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
1207
  </select>
1208
  devices
1209
+
1210
+ <span style="float: right; margin-top: 6px;">
1211
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" value="0" />
1212
+ <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_h'; ?>" id="enable-header-404" value="1" <?php if ($adH->get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
1213
+ <label for="enable-header-404" title="Enable or disable insertion of this code into HTML page header on page for Error 404: Page not found">Insert on Error 404 page</label>
1214
+ </span>
1215
  </div>
1216
  </div>
1217
 
1218
  <div id="tab-footer" style="margin: 0px 0; padding: 0; ">
1219
  <div style="margin: 8px 0;">
1220
  <div style="float: right;">
 
 
 
 
 
 
 
 
1221
  <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
1222
+ <input type="checkbox" value="0" id="simple-editor-f" style="display: none;" />
1223
+ <label class="checkbox-button" style="margin-left: 10px;" for="simple-editor-f" title="Toggle Syntax Highlighting / Simple editor for mobile devices"><span class="checkbox-icon icon-tablet"></span></label>
1224
  <?php endif; ?>
1225
 
1226
+ <input type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" value="0" />
1227
+ <input type="checkbox" name="<?php echo AI_OPTION_ENABLE_MANUAL, '_block_f'; ?>" id="enable-footer" value="1" <?php if ($adF->get_enable_manual () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
1228
+ <label class="checkbox-button" style="margin-left: 10px;" for="enable-footer" title="Enable or disable insertion of this code into HTML page footer"><span class="checkbox-icon icon-enabled<?php if ($adF->get_enable_manual () == AI_ENABLED) echo ' on'; ?>"></span></label>
1229
+
1230
+ <input type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="0" />
1231
+ <input type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, '_block_f'; ?>" value="1" id="process-php-f" <?php if ($adF->get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
1232
+ <label class="checkbox-button" style="margin-left: 10px;" for="process-php-f" title="Process PHP code"><span class="checkbox-icon icon-php<?php if ($adF->get_process_php () == AI_ENABLED) echo ' on'; ?>"></span></label>
1233
  </div>
1234
 
1235
  <div>
1251
 
1252
  <div id="device-detection-settings-f" style="padding:8px 8px 8px 8px; margin: 8px 0; border: 1px solid #ddd; border-radius: 5px;">
1253
  <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_FOOTER_OPTION_NAME; ?>" value="0" />
1254
+ <input style="border-radius: 5px;" type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, AI_FOOTER_OPTION_NAME; ?>" id="server-side-detection-f" value="1" <?php if ($adF->get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
1255
  <label for="server-side-detection-f">Use server-side detection to insert code only for </label>
1256
  <select style="border-radius: 5px; margin-bottom: 3px;" id="display-for-devices-f" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, AI_FOOTER_OPTION_NAME; ?>" >
1257
  <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($adF->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
1262
  <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($adF->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
1263
  </select>
1264
  devices
1265
+
1266
+ <span style="float: right; margin-top: 6px;">
1267
+ <input style="border-radius: 5px;" type="hidden" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" value="0" />
1268
+ <input style="border-radius: 5px; margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, '_block_f'; ?>" id="enable-footer-404" value="1" <?php if ($adF->get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
1269
+ <label for="enable-footer-404" title="Enable or disable insertion of this code into HTML page footer on page for Error 404: Page not found">Insert on Error 404 page</label>
1270
+ </span>
1271
  </div>
1272
  </div>
1273
 
1276
  <div id="tab-debugging" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1277
  <div style="margin: 8px;">
1278
  <input style="border-radius: 5px;" type="hidden" name="admin_toolbar_debugging" value="0" />
1279
+ <input style="border-radius: 5px;" type="checkbox" name="admin_toolbar_debugging" id="admin-toolbar-debugging" value="1" default="<?php echo DEFAULT_ADMIN_TOOLBAR_DEBUGGING; ?>" <?php if (get_admin_toolbar_debugging ()==AI_ENABLED) echo 'checked '; ?> />
1280
  <label for="admin-toolbar-debugging" title="Enable or disable debugging functions in admin toolbar">Debugging functions in admin toolbar</label>
1281
  </div>
1282
 
1283
  <div style="margin: 8px;">
1284
  <input style="border-radius: 5px;" type="hidden" name="remote_debugging" value="0" />
1285
+ <input style="border-radius: 5px;" type="checkbox" name="remote_debugging" id="remote-debugging" value="1" default="<?php echo DEFAULT_REMOTE_DEBUGGING; ?>" <?php if (get_remote_debugging ()==AI_ENABLED) echo 'checked '; ?> />
1286
  <label for="remote-debugging" title="Enable Debugger widget and code insertion debugging (blocks, positions, tags, processing) by url parameters for non-logged in users. Enable this option to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in administrators debugging is always enabled.">Remote debugging</label>
1287
  </div>
1288
 
1289
  <div id="system-debugging" style="display: none;">
1290
  <div style="margin: 8px;">
1291
  <input style="border-radius: 5px;" type="hidden" name="javascript_debugging" value="0" />
1292
+ <input style="border-radius: 5px;" type="checkbox" name="javascript_debugging"id="javascript-debugging" value="1" default="<?php echo DEFAULT_JAVASCRIPT_DEBUGGING; ?>" <?php if (get_javascript_debugging ()==AI_ENABLED) echo 'checked '; ?> />
1293
  <label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
1294
  </div>
1295
 
1302
 
1303
  </div>
1304
 
1305
+ <?php if (!function_exists ('ai_settings_side')) { ?>
1306
+
1307
+ <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1308
+ <div style="float: left;">
1309
+ <h2 style="display: inline-block; margin: 13px 0;">Looking for AdSense alternative?</h2>
1310
+ </div>
1311
+ <div style="clear: both;"></div>
1312
+ </div>
1313
+
1314
+ <div class="ai-form" style="height: 90px; margin: 8px 0; padding: 8px 4px 8px 12px;border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1315
+ <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>media.net_728x90.gif" /></a>
1316
+ </div>
1317
+
1318
+ <?php } ?>
1319
+
1320
  <input id="ai-active-tab" type="hidden" name="ai-active-tab" value="<?php echo $active_tab; ?>" />
1321
+ <?php wp_nonce_field ('save_adinserter_settings'); ?>
1322
 
 
 
 
1323
  </form>
1324
 
1325
  </div>
1326
 
1327
+
1328
+
1329
  <?php
1330
  if ($subpage == 'main') {
1331
  if (function_exists ('ai_settings_side')) ai_settings_side (); else { ?>
1332
  <div style="float: left;">
1333
  <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1334
  <div style="float: left;">
1335
+ <h2 style="display: inline-block; margin: 13px 0;">Follow Ad Inserter</h2>
1336
+ <a href="https://twitter.com/AdInserter" class="clear-link" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>twitter.png" style="vertical-align: middle; margin: 0 10px 6px 10px;" title="Ad Inserter on Twitter" alt="Ad Inserter on Twitter" /></a>
1337
+ <a href="https://www.facebook.com/AdInserter/" class="clear-link" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>facebook.png" style="vertical-align: middle; margin: 0 10px 6px 10px;" title="Ad Inserter on Facebook" alt="Ad Inserter on Facebook" /></a>
1338
  </div>
1339
 
1340
  <div id="header-buttons">
1344
  <div style="clear: both;"></div>
1345
  </div>
1346
 
1347
+
1348
  <div class="ai-form" style="padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
1349
+ <div style="float: right;" >
1350
+ <div>
1351
+ <a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" title="Automate ad placement in posts and pages" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="margin-top: 10px;" /></a>
1352
+ </div>
1353
+ <div>
1354
+ <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>media.net_250x250_2.jpg" style="margin-top: 10px;" /></a>
1355
+ </div>
1356
+ </div>
1357
+
1358
  <h3 style="text-align: justify;"><a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">Ad Inserter Pro</a> features:</h3>
1359
 
1360
  <ul>
1392
  then you can simply upgrade to <a href="http://adinserter.pro/" style="text-decoration: none;" target="_blank">Ad Inserter Pro</a> (existing settings will be preserved).</p>
1393
  </div>
1394
 
 
 
 
 
 
 
 
 
 
 
1395
  </div>
1396
  <?php
1397
  }