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

Version Description

  • Added support for ad blocking detection (experimental)
  • Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
  • Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
  • Added syntax highlighting for shortcodes and separators
  • Added option to define minimum number of words in paragraphs above
  • Added support for %N filter item to filter every N-th insertion
  • Added filter support when inserting for all paragraphs
  • Added style clear: both; to Default, Left, Right and Center alignments
  • Bug fix for errors when loading tracking charts (Pro only)
  • Many minor bug fixes, cosmetic changes and code improvements
Download this release

Release Info

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

Code changes from version 2.1.14 to 2.2.0

ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.1.14
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes into your website.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -12,6 +12,15 @@ Plugin URI: http://adinserter.pro/documentation
12
 
13
  Change Log
14
 
 
 
 
 
 
 
 
 
 
15
  Ad Inserter 2.1.14 - 2017-08-07
16
  - Fix for error when using older PHP versions (prior to 5.5)
17
 
@@ -22,9 +31,9 @@ Ad Inserter 2.1.12 - 2017-08-07
22
  - Added option to define tags inside which paragraphs are not counted
23
  - Added max insertions check when inserting for all paragraphs
24
  - Added support for inverted filter
25
- - Added option to define minimum number of words in paragraphs above (experimantal)
26
- - Added support for %N filter item to filter every N-th insertion (experimantal)
27
- - Added filter support when inserting for all paragraphs (experimantal)
28
  - Increased nonce lifespan to 48 hours when using tracking (Pro only)
29
  - Fixed wrong urls in debug menu when behind proxy
30
 
@@ -407,18 +416,49 @@ Ad Inserter 1.0.0 - 14/11/2010
407
  */
408
 
409
 
 
 
410
  if (!defined ('AD_INSERTER_PLUGIN_DIR'))
411
  define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
412
 
413
- /* Version check */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  global $wp_version, $version_string;
415
 
416
  if (version_compare ($wp_version, "4.0", "<")) {
417
  exit ('Ad Inserter requires WordPress 4.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>');
418
  }
419
 
420
- global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options, $block_insertion_log;
421
-
422
  //include required files
423
  require_once AD_INSERTER_PLUGIN_DIR.'class.php';
424
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
@@ -426,43 +466,38 @@ require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
426
  require_once AD_INSERTER_PLUGIN_DIR.'preview.php';
427
  require_once AD_INSERTER_PLUGIN_DIR.'preview-adb.php';
428
 
429
- if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
430
- if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
431
- ini_set ('display_errors', 1);
432
- error_reporting (E_ALL);
433
- }
434
- }
435
-
436
  $version_array = explode (".", AD_INSERTER_VERSION);
437
  $version_string = "";
438
  foreach ($version_array as $number) {
439
  $version_string .= sprintf ("%02d", $number);
440
  }
441
 
442
- $ai_wp_data [AI_WP_DEBUGGING] = 0;
443
  $ai_wp_data [AI_WP_URL] = remove_debug_parameters_from_url ();
444
 
445
- if (!is_admin()) {
446
- if (!isset ($_GET [AI_URL_DEBUG]))
447
- if (isset ($_GET [AI_URL_DEBUG_PROCESSING]) || (isset ($_COOKIE ['AI_WP_DEBUGGING']) && ($_COOKIE ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING) != 0)) {
448
- if (!isset ($_GET [AI_URL_DEBUG_PROCESSING]) || $_GET [AI_URL_DEBUG_PROCESSING] == 1) {
449
- $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_PROCESSING;
450
 
451
- $ai_total_plugin_time = 0;
452
- $start_time = microtime (true);
453
- $ai_total_php_time = 0;
454
- $ai_last_time = microtime (true);
455
- $ai_processing_log = array ();
456
- ai_log ("INITIALIZATION START");
457
- }
458
- }
459
- }
 
 
 
 
 
 
460
 
461
  $ad_inserter_globals = array ();
462
  $block_object = array ();
463
  $block_insertion_log = array ();
464
 
465
  ai_load_settings ();
 
466
 
467
  if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
468
  if (get_remote_debugging ()) {
@@ -475,21 +510,28 @@ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
475
  $ai_wp_data [AI_ADB_DETECTION] = $block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual ();
476
 
477
  if ($ai_wp_data [AI_ADB_DETECTION]) {
478
- define ('AI_ADB_2_NAME', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY).md5 (NONCE_KEY))), 0, 8));
479
  define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY.md5 (NONCE_KEY)))), 0, 8));
480
 
481
- $script = AD_INSERTER_PLUGIN_DIR.'includes/js/sponsors.js';
 
482
 
483
- $js_ok = false;
484
- if (file_exists ($script)) {
485
- if (strpos (file_get_contents ($script), AI_ADB_2_NAME) !== false) $js_ok = true;
486
- }
 
 
 
487
 
488
- if (!$js_ok) {
489
- file_put_contents ($script, 'window.' . AI_ADB_2_NAME . '=true;');
490
- define ('AI_ADB_2_FILE_RECREATED', true);
 
491
  }
492
 
 
 
493
  if (function_exists ('ai_check_files')) ai_check_files ();
494
  }
495
  }
@@ -510,7 +552,10 @@ if (get_dynamic_blocks ()) {
510
  }
511
  }
512
 
 
 
513
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
 
514
  $ai_wp_data [AI_WP_USER_SET] = false;
515
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
516
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
@@ -560,19 +605,6 @@ add_action ('admin_notices', 'ai_admin_notice_hook');
560
 
561
  add_action ('wp', 'ai_wp_hook');
562
 
563
- //if ($adH->get_enable_manual () ||
564
- // $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
565
- // get_remote_debugging () ||
566
- // ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 ||
567
- // ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
568
- add_action ('wp_head', 'ai_wp_head_hook');
569
-
570
- //if ($adF->get_enable_manual () ||
571
- // $ai_wp_data [AI_TRACKING] ||
572
- // get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
573
- // $ai_wp_data [AI_STICKY_WIDGETS])
574
- add_action ('wp_footer', 'ai_wp_footer_hook');
575
-
576
  if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
577
 
578
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
@@ -586,9 +618,12 @@ if (function_exists ('ai_hooks')) ai_hooks ();
586
 
587
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
588
  add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
589
- add_action ('wp_ajax_ai_data', 'ai_data');
590
- add_action ('wp_ajax_nopriv_ai_data', 'ai_data');
591
 
 
 
 
 
 
592
 
593
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
594
  $ai_total_plugin_time += microtime (true) - $start_time;
@@ -596,7 +631,6 @@ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
596
  }
597
 
598
 
599
-
600
  function ai_toolbar ($wp_admin_bar) {
601
  global $block_object, $ai_wp_data;
602
 
@@ -618,7 +652,10 @@ function ai_toolbar ($wp_admin_bar) {
618
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING) == 0) $debug_ad_blocking = 1; else $debug_ad_blocking = 0;
619
  $debug_ad_blocking_class = $debug_ad_blocking == 0 ? ' on' : '';
620
 
621
- $debug_settings_on = $debug_blocks == 0 || $debug_positions === '' || $debug_tags == 0 || $debug_processing == 0 || $debug_no_insertion == 0 || $debug_ad_blocking == 0;
 
 
 
622
 
623
  $debug_settings_class = $debug_settings_on ? ' on' : '';
624
  $top_menu_url = $debug_settings_on ? add_query_arg (AI_URL_DEBUG, '0', remove_debug_parameters_from_url ()) :
@@ -719,12 +756,20 @@ function ai_toolbar ($wp_admin_bar) {
719
  'href' => set_url_parameter (AI_URL_DEBUG_NO_INSERTION, $debug_no_insertion),
720
  ));
721
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
722
- $wp_admin_bar->add_node (array (
723
- 'id' => 'ai-toolbar-ad-blocking',
724
- 'parent' => 'ai-toolbar-settings',
725
- 'title' => '<span class="ab-icon'.$debug_ad_blocking_class.'"></span>Simulate Ad Blocking',
726
- 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING, $debug_ad_blocking),
727
- ));
 
 
 
 
 
 
 
 
728
  }
729
  $wp_admin_bar->add_node (array (
730
  'id' => 'ai-toolbar-processing',
@@ -754,15 +799,20 @@ function set_page_type () {
754
 
755
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
756
 
757
- if (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
758
- elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
759
- elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
760
- elseif (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
761
- elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
762
- elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
763
- elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
764
- elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
765
- elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
 
 
 
 
 
766
  }
767
 
768
  function ai_log_message ($message) {
@@ -799,7 +849,6 @@ function ai_block_insertion_status ($block, $ai_last_check) {
799
  case AI_CHECK_PAGE_TYPE_FEED: $status .= "ENABLED ON FEED"; break;
800
  case AI_CHECK_PAGE_TYPE_404: $status .= "ENABLED ON 404"; break;
801
 
802
-
803
  case AI_CHECK_DESKTOP_DEVICES: $status .= "DESKTOP DEVICES"; break;
804
  case AI_CHECK_MOBILE_DEVICES: $status .= "MOBILE DEVICES"; break;
805
  case AI_CHECK_TABLET_DEVICES: $status .= "TABLET DEVICES"; break;
@@ -822,8 +871,8 @@ function ai_block_insertion_status ($block, $ai_last_check) {
822
  case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break;
823
  case AI_CHECK_ADMINISTRATOR: $status .= "ADMINISTRATOR"; break;
824
 
825
- case AI_CHECK_ENABLED_ON_ALL_EXCEPT_ON_SELECTED: $status .= "ENABLED ON ALL EXCEPT ON SELECTED"; break;
826
- case AI_CHECK_ENABLED_ONLY_ON_SELECTED: $status .= "ENABLED ONLY ON SELECTED"; break;
827
  case AI_CHECK_DISABLED_MANUALLY: $status .= "DISABLED BY HTML COMMENT"; break;
828
 
829
  case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break;
@@ -879,7 +928,7 @@ function ai_log ($message = "") {
879
 
880
  function remove_debug_parameters_from_url ($url = false) {
881
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
882
- $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION, AI_URL_DEBUG_AD_BLOCKING);
883
  } else
884
  $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION);
885
 
@@ -940,6 +989,9 @@ function ai_wp_hook () {
940
  if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION]))
941
  if ($_GET [AI_URL_DEBUG_NO_INSERTION] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_NO_INSERTION; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_NO_INSERTION;
942
 
 
 
 
943
  if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING]))
944
  if ($_GET [AI_URL_DEBUG_AD_BLOCKING] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_AD_BLOCKING; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_AD_BLOCKING;
945
 
@@ -989,6 +1041,26 @@ function ai_wp_hook () {
989
  $ai_walker = new ai_Walker_Comment;
990
  }
991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
992
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
993
  $ai_total_plugin_time += microtime (true) - $start_time;
994
  ai_log ("WP HOOK END\n");
@@ -1003,7 +1075,8 @@ function ai_init_hook() {
1003
  ai_wp_hook ();
1004
  }
1005
 
1006
- add_shortcode ('adinserter', 'process_shortcodes');
 
1007
  }
1008
 
1009
  function ai_admin_menu_hook () {
@@ -1012,58 +1085,83 @@ function ai_admin_menu_hook () {
1012
  if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return;
1013
 
1014
  $ai_settings_page = add_submenu_page ('options-general.php', AD_INSERTER_NAME.' Options', AD_INSERTER_NAME, 'manage_options', basename(__FILE__), 'ai_settings');
1015
- add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
 
 
1016
  }
1017
 
 
 
 
 
 
1018
 
1019
  function ai_admin_enqueue_scripts ($hook_suffix) {
1020
  global $ai_settings_page;
1021
 
1022
  if ($hook_suffix == $ai_settings_page) {
1023
-
1024
- wp_enqueue_script ('ai-admin-js', plugins_url ('js/ad-inserter.js', __FILE__), array (
1025
- 'jquery',
1026
- 'jquery-ui-tabs',
1027
- 'jquery-ui-button',
1028
- 'jquery-ui-tooltip',
1029
- 'jquery-ui-datepicker',
1030
- 'jquery-ui-dialog',
1031
- ), AD_INSERTER_VERSION);
1032
- wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null);
1033
 
1034
  if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
1035
 
1036
- wp_enqueue_style ('ai-image-picker', plugins_url ('css/image-picker.css', __FILE__), array (), AD_INSERTER_VERSION);
1037
  wp_add_inline_style ('ai-image-picker', '.thumbnail {border-radius: 6px;}');
1038
- wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
1039
 
1040
- wp_add_inline_style ('ai-admin', '.notice {margin: 5px 0 15px;}');
1041
 
1042
  if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
1043
 
1044
- wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
 
 
 
 
 
1045
 
1046
  if (AI_SYNTAX_HIGHLIGHTING) {
1047
- wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1048
- wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
 
 
1049
 
1050
  if (get_syntax_highlighter_theme () == AI_SYNTAX_HIGHLIGHTER_THEME || isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] == AI_SYNTAX_HIGHLIGHTER_THEME)
1051
- wp_enqueue_script ('ai-ace-theme', plugins_url ('includes/ace/theme-ad_inserter.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1052
  }
 
 
 
 
 
 
 
 
 
1053
  }
 
 
 
 
 
 
 
 
 
 
 
1054
  }
1055
 
1056
  function add_head_inline_styles_and_scripts () {
1057
  global $ai_wp_data;
1058
 
1059
  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)) {
 
1060
  echo "<style type='text/css'>\n";
1061
 
1062
- if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION])
1063
- echo get_viewport_css ();
1064
 
1065
- if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
1066
- echo "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
1067
  content: '\\f111';
1068
  top: 2px;
1069
  color: rgba(240,245,250,.6)!important;
@@ -1093,7 +1191,10 @@ function add_head_inline_styles_and_scripts () {
1093
  #wp-admin-bar-ai-toolbar-no-insertion .ab-icon:before {
1094
  content: '\\f214';
1095
  }
1096
- #wp-admin-bar-ai-toolbar-ad-blocking .ab-icon:before {
 
 
 
1097
  content: '\\f160';
1098
  }
1099
  #wp-admin-bar-ai-toolbar-processing .ab-icon:before {
@@ -1108,389 +1209,117 @@ function add_head_inline_styles_and_scripts () {
1108
  ";
1109
 
1110
  echo "</style>\n";
 
1111
  }
1112
  }
1113
 
1114
- function ai_adb_replace_vars ($vars) {
1115
- global $block_object, $ai_wp_data;
1116
-
1117
- $adb = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
1118
-
1119
- $vars = str_replace ('AI0', ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING) != 0 ? 'true' : 'false', $vars);
1120
- $vars = str_replace ('AI1', get_javascript_debugging () ? 'true' : 'false', $vars);
1121
- $vars = str_replace ('AI2', "jQuery ('<div>', {attr: {'style': '" . str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_OVERLAY_CSS) . get_overlay_css () . "'}})", $vars);
1122
- $vars = str_replace ('AI3', "jQuery ('<div>', {attr: {'style': '" . str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_MESSAGE_CSS) . get_message_css () . "'}, html: '" .
1123
- str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), do_shortcode ($adb->ai_getCode ())) . "'});", $vars);
1124
- $vars = str_replace ('AI4', get_undismissible_message () ? 'true' : 'false', $vars);
1125
- $vars = str_replace ('AI5', get_no_action_period (true), $vars);
1126
- $vars = str_replace ('AI6', get_adb_action (true), $vars);
1127
- $vars = str_replace ('AI7', get_delay_action (true), $vars);
1128
- $vars = str_replace ('AI8', str_replace (' ', '', get_adb_selectors ()), $vars);
1129
-
1130
- $redirection_page = get_redirection_page ();
1131
- if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ());
1132
- $vars = str_replace ('AI9', $url, $vars);
1133
 
1134
- return $vars;
 
 
 
 
1135
  }
1136
 
1137
- function ai_adb_code () {
1138
- return "
1139
- var ai_adb_debugging = AI1;
1140
- var ai_adb_active = false;
1141
- var ai_adb_counter = 0;
1142
- var ai_adb_overlay = AI2;
1143
- var ai_adb_message_window = AI3;
1144
- var ai_adb_message_undismissible = AI4;
1145
- var ai_adb_action_cookie_name = 'aiADB';
1146
- var ai_adb_page_views_cookie_name = 'aiADB_PV';
1147
- var ai_adb_page_redirection_cookie_name = 'aiADB_PR';
1148
- var ai_adb_message_cookie_lifetime = AI5;
1149
- var ai_adb_action = AI6;
1150
- var ai_adb_page_views = AI7;
1151
- var ai_adb_selectors = 'AI8';
1152
- var ai_adb_redirection_url = 'AI9';
1153
-
1154
- var ai_adb_detected = function(n) {
1155
- if (ai_adb_debugging) console.log ('AI ad blocking DETECTED', n);
1156
- if (!ai_adb_active) {
1157
- ai_adb_active = true;
1158
- if (ai_adb_debugging) console.log ('AI ad blocking action check');
1159
-
1160
- (function ($) {
1161
-
1162
- // $.removeCookie (ai_adb_page_views_cookie_name, {path: '/' });
1163
- if (ai_adb_page_views != 0) {
1164
- var ai_adb_page_view_counter = 1;
1165
- var cookie = $.cookie (ai_adb_page_views_cookie_name);
1166
- if (typeof cookie != 'undefined') ai_adb_page_view_counter = parseInt (cookie) + 1;
1167
- if (ai_adb_debugging) console.log ('AI ad blocking page views cookie:', cookie, '- page view:', ai_adb_page_view_counter);
1168
-
1169
- if (ai_adb_page_view_counter < ai_adb_page_views) {
1170
- if (ai_adb_debugging) console.log ('AI ad blocking', ai_adb_page_views, 'page views not reached, no action');
1171
- $.cookie (ai_adb_page_views_cookie_name, ai_adb_page_view_counter, {expires: 365, path: '/'});
1172
- return;
1173
- }
1174
- }
1175
-
1176
- if (ai_adb_message_cookie_lifetime != 0 && (ai_adb_action != 1 || !ai_adb_message_undismissible)) {
1177
- var cookie = $.cookie (ai_adb_action_cookie_name);
1178
- if (ai_adb_debugging) console.log ('AI ad blocking cookie:', cookie);
1179
- if (typeof cookie != 'undefined' && cookie == '" . AI_ADB_COOKIE_VALUE . "') {
1180
- if (ai_adb_debugging) console.log ('AI ad blocking valid cookie detected, no action');
1181
- return;
1182
- }
1183
-
1184
- $.cookie (ai_adb_action_cookie_name, '" . AI_ADB_COOKIE_VALUE . "', {expires: ai_adb_message_cookie_lifetime, path: '/'});
1185
- } else $.removeCookie (ai_adb_action_cookie_name, {path: '/' });
1186
-
1187
- if (ai_adb_debugging) console.log ('AI ad blocking action', ai_adb_action);
1188
- switch (ai_adb_action) {
1189
- case 1:
1190
- if (!ai_adb_message_undismissible) {
1191
- ai_adb_overlay.click (function () {
1192
- $(this).remove();
1193
- ai_adb_message_window.remove();
1194
- }).css ('cursor', 'pointer');
1195
- ai_adb_message_window.click (function () {
1196
- $(this).remove();
1197
- ai_adb_overlay.remove();
1198
- }).css ('cursor', 'pointer');
1199
- window.onkeydown = function( event ) {
1200
- if (event.keyCode === 27 ) {
1201
- ai_adb_overlay.click ();
1202
- ai_adb_message_window.click ();
1203
- }
1204
- }
1205
- if (ai_adb_debugging) console.log ('AI ad blocking MESSAGE click detection installed');
1206
- } else {
1207
- // $.removeCookie (ai_adb_action_cookie_name, {path: '/' });
1208
- }
1209
-
1210
- if (ai_adb_debugging) console.log ('AI ad blocking MESSAGE');
1211
- $('body').prepend (ai_adb_overlay).prepend (ai_adb_message_window);
1212
-
1213
- break;
1214
- case 2:
1215
- if (ai_adb_redirection_url != '') {
1216
- if (ai_adb_debugging) console.log ('AI ad blocking REDIRECTION to', ai_adb_redirection_url);
1217
-
1218
- var redirect = true;
1219
- if (ai_adb_redirection_url.toLowerCase().substring (0, 4) == 'http') {
1220
- if (window.location.href == ai_adb_redirection_url) var redirect = false;
1221
- } else {
1222
- if (window.location.pathname == ai_adb_redirection_url) var redirect = false;
1223
- }
1224
-
1225
- if (redirect) {
1226
- var cookie = $.cookie (ai_adb_page_redirection_cookie_name);
1227
- if (typeof cookie == 'undefined') {
1228
- var date = new Date();
1229
- date.setTime (date.getTime() + (10 * 1000));
1230
- $.cookie (ai_adb_page_redirection_cookie_name, window.location.href, {expires: date, path: '/' });
1231
-
1232
- window.location.replace (ai_adb_redirection_url)
1233
- } else {
1234
- if (ai_adb_debugging) console.log ('AI ad blocking no redirection, cookie:', cookie);
1235
- }
1236
- } else {
1237
- if (ai_adb_debugging) console.log ('AI ad blocking already on page', window.location.href);
1238
- jQuery.removeCookie (ai_adb_page_redirection_cookie_name, {path: '/'});
1239
- }
1240
- }
1241
- break;
1242
- }
1243
-
1244
- $(window).ready(function () {
1245
- if (ai_adb_debugging) console.log ('AI ad blocking block actions');
1246
-
1247
- $('div.ai-adb-show').each (function () {
1248
- $(this).css ({'display': 'block', 'visibility': 'visible'});
1249
-
1250
- if (ai_adb_debugging) {
1251
- var debug_info = $(this).attr ('data');
1252
- console.log ('AI ad blocking SHOW', typeof debug_info != 'undefined' ? debug_info : '');
1253
- }
1254
- });
1255
-
1256
- $('div.ai-adb-hide').each (function () {
1257
- $(this).css ({'display': 'none', 'visibility': 'hidden'});
1258
-
1259
- if (ai_adb_debugging) {
1260
- var debug_info = $(this).attr ('data');
1261
- console.log ('AI ad blocking HIDE', typeof debug_info != 'undefined' ? debug_info : '');
1262
- }
1263
- });
1264
- });
1265
-
1266
-
1267
-
1268
- }(jQuery));
1269
 
 
 
 
 
1270
  }
1271
  }
1272
 
1273
-
1274
- var ai_adb_undetected = function(n) {
1275
- ai_adb_counter ++;
1276
- if (ai_adb_debugging) console.log ('AI ad blocking not detected', n, '- counter:', ai_adb_counter);
1277
-
1278
- if (!ai_adb_active && ai_adb_counter == 3) {
1279
- if (ai_adb_debugging) console.log ('AI ad blocking NOT DETECTED');
1280
-
1281
- // var redirected_page = false;
1282
- // if (ai_adb_redirection_url.toLowerCase().substring (0, 4) == 'http') {
1283
- // if (window.location.href == ai_adb_redirection_url) var redirected_page = true;
1284
- // } else {
1285
- // if (window.location.pathname == ai_adb_redirection_url) var redirected_page = true;
1286
- // }
1287
-
1288
- // if (redirected_page) {
1289
- // var cookie = jQuery.cookie (ai_adb_page_redirection_cookie_name);
1290
- // if (typeof cookie != 'undefined' && cookie.toLowerCase().substring (0, 4) == 'http') {
1291
- // if (ai_adb_debugging) console.log ('AI ad blocking returning to', cookie);
1292
- // jQuery.removeCookie (ai_adb_page_redirection_cookie_name, {path: '/'});
1293
- // window.location.replace (cookie);
1294
- // }
1295
- // }
1296
-
1297
- (function ($) {
1298
- $(window).ready(function () {
1299
- if (ai_adb_debugging) console.log ('AI ad blocking NOT DETECTED block actions');
1300
-
1301
- $('div.ai-adb-hide').each (function () {
1302
- $(this).css ({'display': 'block', 'visibility': 'visible'});
1303
-
1304
- if (ai_adb_debugging) {
1305
- var debug_info = $(this).attr ('data');
1306
- console.log ('AI ad blocking SHOW', typeof debug_info != 'undefined' ? debug_info : '');
1307
- }
1308
- });
1309
-
1310
- $('div.ai-adb-show').each (function () {
1311
- $(this).css ({'display': 'none', 'visibility': 'hidden'});
1312
-
1313
- if (ai_adb_debugging) {
1314
- var debug_info = $(this).attr ('data');
1315
- console.log ('AI ad blocking HIDE', typeof debug_info != 'undefined' ? debug_info : '');
1316
- }
1317
- });
1318
- });
1319
- });
1320
-
1321
  }
1322
  }
1323
 
1324
- if (AI0) jQuery (document).ready (function () {ai_adb_detected (0)});
1325
-
1326
- if (!document.getElementById ('" . AI_ADB_1_NAME . "')){
1327
- jQuery (document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (1)});
1328
- } else {
1329
- jQuery (document).ready (function () {ai_adb_undetected (1)});
1330
  }
1331
 
1332
- if (typeof window." . AI_ADB_2_NAME . " == 'undefined') {
1333
- jQuery (document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (2)});
1334
- } else {
1335
- jQuery (document).ready (function () {ai_adb_undetected (2)});
1336
  }
1337
-
1338
- jQuery (document).ready (function ($) {
1339
- $(window).ready (function () {
1340
- if ($('#banner-advert-container img').length > 0) {
1341
- if ($('#banner-advert-container img').outerHeight() === 0) {
1342
- $(document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (3)});
1343
- } else $(document).ready (function () {ai_adb_undetected (3)});
1344
- $('#banner-advert-container img').remove();
1345
- }
1346
-
1347
- if ((!ai_adb_active || ai_adb_debugging) && ai_adb_selectors != '') {
1348
- var ai_adb_el_counter = 0;
1349
- var ai_adb_el_zero = 0;
1350
- var ai_adb_selector = ai_adb_selectors.split (',');
1351
- $.each (ai_adb_selector, function (i) {
1352
- if (ai_adb_debugging) console.log ('AI ad blocking selector', ai_adb_selector [i]);
1353
- if ($(ai_adb_selector [i]).length != 0) {
1354
- $(ai_adb_selector [i]).each (function (n) {
1355
- if (ai_adb_debugging) console.log ('AI ad blocking element id=\'' + $(this).attr ('id') + '\' class=\'' + $(this).attr ('class') + '\' heights:', $(this).outerHeight (), $(this).innerHeight (), $(this).height ());
1356
- ai_adb_el_counter ++;
1357
- if ($(this).outerHeight () === 0) {
1358
- $ (document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (4)});
1359
- ai_adb_el_zero ++;
1360
- if (!ai_adb_debugging) return false;
1361
- }
1362
-
1363
- });
1364
-
1365
- }
1366
- });
1367
- if (ai_adb_el_counter != 0 && ai_adb_el_zero == 0) $(document).ready (function () {ai_adb_undetected (4)});
1368
- }
1369
- });
1370
- });
1371
-
1372
-
1373
- /*!
1374
- * jQuery Cookie Plugin v1.4.1
1375
- * https://github.com/carhartl/jquery-cookie
1376
- *
1377
- * Copyright 2013 Klaus Hartl
1378
- * Released under the MIT license
1379
- */
1380
- (function (factory) {
1381
- if (typeof define === 'function' && define.amd) {
1382
- // AMD
1383
- define(['jquery'], factory);
1384
- } else if (typeof exports === 'object') {
1385
- // CommonJS
1386
- factory(require('jquery'));
1387
- } else {
1388
- // Browser globals
1389
- factory(jQuery);
1390
  }
1391
- }(function ($) {
1392
 
1393
- var pluses = /\+/g;
1394
-
1395
- function encode(s) {
1396
- return config.raw ? s : encodeURIComponent(s);
 
 
1397
  }
1398
 
1399
- function decode(s) {
1400
- return config.raw ? s : decodeURIComponent(s);
 
 
 
 
1401
  }
1402
 
1403
- function stringifyCookieValue(value) {
1404
- return encode(config.json ? JSON.stringify(value) : String(value));
 
 
 
 
1405
  }
1406
 
1407
- function parseCookieValue(s) {
1408
- if (s.indexOf('\"') === 0) {
1409
- // This is a quoted cookie as according to RFC2068, unescape...
1410
- s = s.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, '\\\\');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1411
  }
1412
-
1413
- try {
1414
- // Replace server-side written pluses with spaces.
1415
- // If we can't decode the cookie, ignore it, it's unusable.
1416
- // If we can't parse the cookie, ignore it, it's unusable.
1417
- s = decodeURIComponent(s.replace(pluses, ' '));
1418
- return config.json ? JSON.parse(s) : s;
1419
- } catch(e) {}
1420
  }
1421
 
1422
- function read(s, converter) {
1423
- var value = config.raw ? s : parseCookieValue(s);
1424
- return $.isFunction(converter) ? converter(value) : value;
 
1425
  }
1426
 
1427
- var config = $.cookie = function (key, value, options) {
1428
-
1429
- // Write
1430
-
1431
- if (value !== undefined && !$.isFunction(value)) {
1432
- options = $.extend({}, config.defaults, options);
1433
-
1434
- if (typeof options.expires === 'number') {
1435
- var days = options.expires, t = options.expires = new Date();
1436
- t.setTime(+t + days * 864e+5);
1437
- }
1438
-
1439
- return (document.cookie = [
1440
- encode(key), '=', stringifyCookieValue(value),
1441
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
1442
- options.path ? '; path=' + options.path : '',
1443
- options.domain ? '; domain=' + options.domain : '',
1444
- options.secure ? '; secure' : ''
1445
- ].join(''));
1446
- }
1447
-
1448
- // Read
1449
-
1450
- var result = key ? undefined : {};
1451
-
1452
- // To prevent the for loop in the first place assign an empty array
1453
- // in case there are no cookies at all. Also prevents odd result when
1454
- // calling $.cookie().
1455
- var cookies = document.cookie ? document.cookie.split('; ') : [];
1456
-
1457
- for (var i = 0, l = cookies.length; i < l; i++) {
1458
- var parts = cookies[i].split('=');
1459
- var name = decode(parts.shift());
1460
- var cookie = parts.join('=');
1461
 
1462
- if (key && key === name) {
1463
- // If second argument (value) is a function it's a converter...
1464
- result = read(cookie, value);
1465
- break;
1466
- }
1467
-
1468
- // Prevent storing a cookie that we couldn't decode.
1469
- if (!key && (cookie = read(cookie)) !== undefined) {
1470
- result[name] = cookie;
1471
- }
1472
- }
1473
-
1474
- return result;
1475
- };
1476
-
1477
- config.defaults = {};
1478
-
1479
- $.removeCookie = function (key, options) {
1480
- if ($.cookie(key) === undefined) {
1481
- return false;
1482
- }
1483
-
1484
- // Must not alter options, thus extending a fresh object...
1485
- $.cookie(key, '', $.extend({}, options, { expires: -1 }));
1486
- return !$.cookie(key);
1487
- };
1488
-
1489
- }));
1490
-
1491
- ";
1492
 
1493
- return "";
 
1494
  }
1495
 
1496
  function add_footer_inline_scripts () {
@@ -1513,76 +1342,20 @@ function add_footer_inline_scripts () {
1513
  if ($inline_scripts) echo "<script type='text/javascript'>\n";
1514
 
1515
  if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1516
-
1517
  $block_class_name = get_block_class_name ();
1518
  if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
 
1519
 
1520
- // echo 'jQuery (function ($) {
1521
- // var wrapping_div_class = ".', $block_class_name, '";
1522
- // $("div.ai-rotate").each (function () {
1523
- // var rotate_options = $(".ai-rotate-option", this);
1524
- // var random_index = Math.floor (Math.random () * rotate_options.length);
1525
-
1526
- // var d = new Date();
1527
- // var n = d.getMilliseconds();
1528
- // if (n % 2) random_index = rotate_options.length - random_index - 1;
1529
-
1530
- // rotate_options.hide ();
1531
- // $(rotate_options [random_index]).css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
1532
- // $(this).css ({"position": ""});
1533
-
1534
- // var wrapping_div = $(this).closest (wrapping_div_class);
1535
- // if (typeof wrapping_div.data ("ai") != "undefined") {
1536
- // var data = JSON.parse (atob (wrapping_div.data ("ai")));
1537
- // if (typeof data !== "undefined" && data.constructor === Array) {
1538
- // data [1] = random_index + 1;
1539
- // wrapping_div.data ("ai", btoa (JSON.stringify (data)))
1540
- // }
1541
- // }
1542
- // });
1543
- // });
1544
- //';
1545
-
1546
- echo 'jQuery(function($){var wrapping_div_class=".', $block_class_name, '";$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);var d=new Date;var n=d.getMilliseconds();if(n%2)random_index=rotate_options.length-random_index-1;rotate_options.hide();$(rotate_options[random_index]).css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""});$(this).css({"position":""});var wrapping_div=$(this).closest(wrapping_div_class);
1547
- if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;wrapping_div.data("ai",btoa(JSON.stringify(data)))}}})});';
1548
  }
1549
 
1550
  if ($ai_wp_data [AI_STICKY_WIDGETS]) {
1551
-
1552
- // echo 'jQuery(document).ready(function($) {
1553
- // var sticky_widget_margin = ', get_sticky_widget_margin (), ';
1554
- // var document_width = $(document).width();
1555
-
1556
- // $(".ai-sticky").each (function () {
1557
- // var widget = $(this);
1558
- // var widget_width = widget.width();
1559
- //// console.log ("WIDGET:", widget.width (), widget.prop ("tagName"), widget.attr ("id"));
1560
- // var sidebar = widget.parent ();
1561
- // while (sidebar.prop ("tagName") != "BODY") {
1562
- //// console.log ("SIDEBAR:", sidebar.width (), sidebar.prop ("tagName"), sidebar.attr ("id"));
1563
- // var parent_element = sidebar.parent ();
1564
- // var parent_element_width = parent_element.width();
1565
- // if (parent_element_width > widget_width * 1.2 || parent_element_width > document_width / 2) break;
1566
- // sidebar = parent_element;
1567
- // }
1568
- // var new_sidebar_top = sidebar.offset ().top - widget.offset ().top + sticky_widget_margin;
1569
- //// console.log ("NEW SIDEBAR TOP:", new_sidebar_top);
1570
- // if (sidebar.css ("position") != "sticky" || isNaN (parseInt (sidebar.css ("top"))) || sidebar.css ("top") < new_sidebar_top) {
1571
- // sidebar.css ("position", "sticky").css ("top", new_sidebar_top);
1572
- //// console.log ("SET SIDEBAR TOP:", new_sidebar_top);
1573
- // }
1574
- // });
1575
- // });
1576
- //';
1577
-
1578
- echo 'jQuery(document).ready(function($){var sticky_widget_margin=', get_sticky_widget_margin (), ';var document_width=$(document).width();$(".ai-sticky").each(function(){var widget=$(this);var widget_width=widget.width();var sidebar=widget.parent();while(sidebar.prop("tagName")!="BODY"){var parent_element=sidebar.parent();var parent_element_width=parent_element.width();if(parent_element_width>widget_width*1.2||parent_element_width>document_width/2)break;sidebar=parent_element}var new_sidebar_top=sidebar.offset().top-widget.offset().top+
1579
- sticky_widget_margin;if(sidebar.css("position")!="sticky"||isNaN(parseInt(sidebar.css("top")))||sidebar.css("top")<new_sidebar_top)sidebar.css("position","sticky").css("top",new_sidebar_top)})});';
1580
-
1581
  }
1582
 
1583
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1584
  if ($ai_wp_data [AI_ADB_DETECTION]) {
1585
- if (!function_exists ('add_footer_inline_scripts_2')) echo ai_adb_replace_vars (ai_adb_code ());
1586
  }
1587
  }
1588
 
@@ -1594,7 +1367,7 @@ sticky_widget_margin;if(sidebar.css("position")!="sticky"||isNaN(parseInt(sideba
1594
  }
1595
 
1596
  function ai_admin_notice_hook () {
1597
- global $current_screen, $ai_db_options;
1598
 
1599
  // $sidebar_widgets = wp_get_sidebars_widgets();
1600
  // $sidebars_with_deprecated_widgets = array ();
@@ -1619,7 +1392,47 @@ function ai_admin_notice_hook () {
1619
  // ". Please replace them with the new 'Ad Inserter' code block widget. See <a href='https://wordpress.org/plugins/ad-inserter/faq/' target='_blank'>FAQ</a> for details.</p></div>";
1620
  // }
1621
 
1622
- if (function_exists ('ai_admin_notices')) ai_admin_notices ();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1623
  }
1624
 
1625
  function ai_plugin_action_links ($links) {
@@ -1698,7 +1511,7 @@ function ai_add_meta_box_hook() {
1698
  foreach ($screens as $screen) {
1699
  add_meta_box (
1700
  'adinserter_sectionid',
1701
- AD_INSERTER_NAME.' Exceptions',
1702
  'ai_meta_box_callback',
1703
  $screen
1704
  );
@@ -1723,6 +1536,8 @@ function ai_meta_box_callback ($post) {
1723
  $post_meta = get_post_meta ($post->ID, '_adinserter_block_exceptions', true);
1724
  $selected_blocks = explode (",", $post_meta);
1725
 
 
 
1726
  echo '<table>';
1727
  echo '<thead style="font-weight: bold;">';
1728
  echo ' <td>Block</td>';
@@ -1742,22 +1557,24 @@ function ai_meta_box_callback ($post) {
1742
 
1743
  if ($post_type == 'page') {
1744
  $page_name = 'pages';
1745
- $enabled_on_text = $obj->get_ad_enabled_on_which_pages ();
1746
  $general_enabled = $obj->get_display_settings_page();
1747
  } else {
1748
  $page_name = 'posts';
1749
- $enabled_on_text = $obj->get_ad_enabled_on_which_posts ();
1750
  $general_enabled = $obj->get_display_settings_post();
1751
  }
1752
 
1753
- $individual_option_enabled = $general_enabled && ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED || $enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED);
1754
- $individual_text_enabled = $enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED;
 
 
1755
 
1756
  if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF";
1757
  echo '<tr style="background: ', $background, ';">';
1758
  echo ' <td style="text-align: right;">', $obj->number, '</td>';
1759
  if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = "";
1760
- echo ' <td style="padding: 0 10px 0 10px;"><a href="', admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, '&tab=', $block, '" target="_blank">', $obj->get_ad_name(), '</a></td>';
1761
  echo ' <td style="padding: 0 10px 0 10px;">', $obj->get_automatic_insertion_text(), '</td>';
1762
  echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
1763
 
@@ -1789,9 +1606,17 @@ function ai_meta_box_callback ($post) {
1789
  echo '</tbody>';
1790
  echo '</table>';
1791
 
1792
- echo '<p>Default insertion for ', $page_name, ' for each code block can be configured on <a href="', admin_url ('options-general.php?page=ad-inserter.php'), '" target="_blank">', AD_INSERTER_NAME, ' Settings page</a>: enabled / disabled on all ', $page_name, ' (no exceptions) or enabled / disabled by default with exceptions set here.';
1793
- echo '<br /><strong>Enabled on all ', $page_name, '</strong> or <strong>Disabled on all ', $page_name, '</strong> means that exceptions are not enabled. Use <strong>On all except selected</strong> or <strong>Only on selected</strong> to enable exceptions on this page for each block.</p>';
1794
 
 
 
 
 
 
 
 
 
 
1795
  }
1796
 
1797
  function ai_save_meta_box_data_hook ($post_id) {
@@ -1831,7 +1656,7 @@ function ai_widgets_init_hook () {
1831
  register_widget ('ai_widget');
1832
  }
1833
 
1834
- function get_page_type_debug_info () {
1835
  global $ai_wp_data;
1836
 
1837
  switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
@@ -1865,7 +1690,23 @@ function get_page_type_debug_info () {
1865
  }
1866
  $style = AI_DEBUG_PAGE_TYPE_STYLE;
1867
 
1868
- return "<section style='$style'>".$page_type."</section>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1869
  }
1870
 
1871
 
@@ -1888,10 +1729,30 @@ function ai_wp_head_hook () {
1888
 
1889
  if ($obj->get_enable_manual ()) {
1890
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1891
- echo do_shortcode ($obj->ai_getCode ());
 
 
 
 
 
 
 
 
1892
  }
1893
 
1894
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
 
 
 
 
 
 
 
 
 
 
 
 
1895
  echo "<script>
1896
  jQuery(document).ready(function($) {
1897
  $('body').prepend (\"", get_page_type_debug_info () , "\");
@@ -1913,7 +1774,7 @@ function ai_wp_footer_hook () {
1913
  $start_time = microtime (true);
1914
  }
1915
 
1916
- if (!(defined ('DOING_AJAX') && DOING_AJAX)) {
1917
  add_footer_inline_scripts ();
1918
  }
1919
 
@@ -1926,7 +1787,15 @@ function ai_wp_footer_hook () {
1926
 
1927
  if ($obj->get_enable_manual ()) {
1928
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1929
- echo do_shortcode ($obj->ai_getCode ());
 
 
 
 
 
 
 
 
1930
  }
1931
 
1932
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
@@ -1945,9 +1814,21 @@ function ai_write_debug_info ($write_processing_log = false) {
1945
  echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
1946
  if (function_exists ('ai_debug_header')) ai_debug_header ();
1947
  echo "\n\n";
 
 
 
 
 
 
 
 
 
 
 
 
1948
  echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
1949
  echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
1950
- echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2, '.' , '') , " ms\n";
1951
  echo "USER CODE PROCESSING: ", number_format ($ai_total_php_time * 1000, 2, '.' , ''), " ms\n";
1952
  echo "TOTAL PROCESSING TIME: ", number_format ($ai_total_plugin_time * 1000, 2, '.' , ''), " ms\n";
1953
 
@@ -2018,8 +1899,27 @@ function ai_write_debug_info ($write_processing_log = false) {
2018
  }
2019
  echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
2020
  echo 'ID: ', get_the_ID(), "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2021
  }
2022
 
 
 
2023
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
2024
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_debug_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
2025
  if (function_exists ('ai_debug')) ai_debug ();
@@ -2069,38 +1969,40 @@ function ai_write_debug_info ($write_processing_log = false) {
2069
  echo 'HEADER CODE: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2070
  echo 'FOOTER CODE: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2071
 
2072
- echo 'AD BLOCKING DETECTION: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2073
- if ($block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual ()) {
2074
- echo 'ADB ACTION: ';
2075
- switch (get_adb_action ()) {
2076
- case AI_ACTION_NONE:
2077
- echo AI_TEXT_NONE;
2078
- break;
2079
- case AI_ACTION_WARNING_MESSAGE:
2080
- echo AI_TEXT_WARNING_MESSAGE;
2081
- break;
2082
- case AI_ACTION_REDIRECTION:
2083
- echo AI_TEXT_REDIRECTION;
2084
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
2085
  }
2086
- echo "\n";
2087
- echo 'ADB DELAY ACTION: ', get_delay_action (), "\n";
2088
- echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2089
- echo 'ADB SELECTORS: ', get_adb_selectors (), "\n";
2090
- $redirection_page = get_redirection_page ();
2091
- echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : $redirection_page, "\n";
2092
- echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
2093
- echo 'ADB MESSAGE: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode (), "\n";
2094
- echo 'ADB MESSAGE CSS: ', get_message_css (), "\n";
2095
- echo 'ADB OVERLAY CSS: ', get_overlay_css (), "\n";
2096
- echo 'ADB UNDISMISSIBLE: ', get_undismissible_message () ? 'ON' : 'OFF', "\n";
2097
  }
2098
 
2099
  echo "\n";
2100
 
2101
  $default = new ai_Block (1);
2102
 
2103
- echo "BLOCK SETTINGS Po Pa Hp Cp Ap Sp Aj Fe 404 Wi Sh PHP\n";
2104
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2105
  $obj = $block_object [$block];
2106
 
@@ -2120,6 +2022,8 @@ function ai_write_debug_info ($write_processing_log = false) {
2120
  case AI_OPTION_DISPLAY_ON_CATEGORY_PAGES:
2121
  case AI_OPTION_DISPLAY_ON_SEARCH_PAGES:
2122
  case AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES:
 
 
2123
  case AI_OPTION_ENABLE_FEED:
2124
  case AI_OPTION_ENABLE_404:
2125
  case AI_OPTION_ENABLE_MANUAL:
@@ -2128,7 +2032,7 @@ function ai_write_debug_info ($write_processing_log = false) {
2128
  if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false;
2129
  continue 2;
2130
  }
2131
- if ($obj->wp_options [$key] != $default->wp_options [$key]) {
2132
  $default_settings = false;
2133
  switch ($key) {
2134
  case AI_OPTION_AUTOMATIC_INSERTION:
@@ -2137,6 +2041,12 @@ function ai_write_debug_info ($write_processing_log = false) {
2137
  case AI_OPTION_ALIGNMENT_TYPE:
2138
  $alignment_settings = $obj->get_alignment_type_text ();
2139
  break;
 
 
 
 
 
 
2140
  case AI_OPTION_PARAGRAPH_TEXT:
2141
  case AI_OPTION_AVOID_TEXT_ABOVE:
2142
  case AI_OPTION_AVOID_TEXT_BELOW:
@@ -2172,6 +2082,7 @@ function ai_write_debug_info ($write_processing_log = false) {
2172
  echo $obj->get_display_settings_category() ? "o" : ".", " ";
2173
  echo $obj->get_display_settings_archive() ? "o" : ".", " ";
2174
  echo $obj->get_display_settings_search() ? "o" : ".", " ";
 
2175
  echo $obj->get_enable_ajax() ? "o" : ".", " ";
2176
  echo $obj->get_enable_feed() ? "o" : ".", " ";
2177
  echo $obj->get_enable_404() ? "o" : ".", " ";
@@ -2850,25 +2761,39 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
2850
  function filter_option_hf ($option, $value){
2851
  $value = str_replace (array ("\\\""), array ("\""), $value);
2852
 
2853
- if ($option == AI_OPTION_CODE ) {
2854
- } elseif ($option == AI_OPTION_ENABLE_MANUAL) {
2855
- } elseif ($option == AI_OPTION_PROCESS_PHP) {
2856
- } elseif ($option == AI_OPTION_ENABLE_404) {
2857
- } elseif ($option == AI_OPTION_DETECT_SERVER_SIDE) {
2858
- } elseif ($option == AI_OPTION_DISPLAY_FOR_DEVICES) {
2859
- }
2860
 
2861
  return $value;
2862
  }
2863
 
2864
- function ai_data () {
2865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2866
  check_admin_referer ("adinserter_data", "ai_check");
2867
 
2868
- if (isset ($_GET ["preview"])) {
2869
- $block = $_GET ["preview"];
2870
  if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
2871
- generate_code_preview ($block);
2872
  }
2873
  elseif ($block == 'adb') {
2874
  generate_code_preview_adb ($block);
@@ -2882,19 +2807,22 @@ function ai_data () {
2882
  }
2883
 
2884
  elseif (isset ($_GET ["rating"])) {
2885
- $cache_time = $_GET ["rating"] == 'update' ? 5 * 60 : AI_TRANSIENT_RATING_EXPIRATION;
2886
  if (!get_transient (AI_TRANSIENT_RATING) || !($transient_timeout = get_option ('_transient_timeout_' . AI_TRANSIENT_RATING)) || AI_TRANSIENT_RATING_EXPIRATION - ($transient_timeout - time ()) > $cache_time) {
2887
- if (preg_match_all ("#<span class=\"counter-count\">(.+?)</span>#", file_get_contents ('https://wordpress.org/plugins/ad-inserter/'), $ratings)) {
2888
- if (count ($ratings [1]) == 5) {
2889
- $total_rating = 0;
2890
- $total_count = 0;
2891
- foreach ($ratings [1] as $index => $count) {
2892
- $total_rating += (5 - $index) * $count;
2893
- $total_count += $count;
2894
- }
2895
- $rating = number_format ($total_rating / $total_count, 4);
2896
- set_transient (AI_TRANSIENT_RATING, $rating, AI_TRANSIENT_RATING_EXPIRATION);
 
2897
  }
 
 
2898
  }
2899
  }
2900
  if ($rating = get_transient (AI_TRANSIENT_RATING)) {
@@ -2902,8 +2830,13 @@ function ai_data () {
2902
  }
2903
  }
2904
 
2905
- elseif (function_exists ('ai_data_ajax')) {
2906
- ai_data_ajax ();
 
 
 
 
 
2907
  }
2908
 
2909
  wp_die ();
@@ -2932,7 +2865,33 @@ function ai_generate_extract (&$settings) {
2932
  $between_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2933
  $after_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2935
  // Generate extracted data
 
2936
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2937
 
2938
  if (!isset ($settings [$block])) continue;
@@ -2951,8 +2910,9 @@ function ai_generate_extract (&$settings) {
2951
  if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED;
2952
  if ($obj->get_enable_404()) $page_types []= AI_PT_404;
2953
 
 
2954
  if ($page_types) {
2955
- switch ($obj->get_automatic_insertion()) {
2956
  case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH:
2957
  case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH:
2958
  case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT:
@@ -2991,8 +2951,18 @@ function ai_generate_extract (&$settings) {
2991
  break;
2992
  }
2993
  }
 
 
 
 
 
 
 
 
2994
  }
2995
 
 
 
2996
  $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
2997
  $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
2998
  $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
@@ -3014,9 +2984,10 @@ function ai_load_settings () {
3014
 
3015
  if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) &&
3016
  isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
3017
- isset ($ai_db_options_extract [POST_HOOK_BLOCKS]) &&
3018
- isset ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
3019
- isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS]))
 
3020
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
3021
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
3022
 
@@ -3036,11 +3007,21 @@ function ai_load_settings () {
3036
  $block_object [AI_HEADER_OPTION_NAME] = $adH;
3037
  $block_object [AI_FOOTER_OPTION_NAME] = $adF;
3038
 
3039
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
3040
- $adA = new ai_AdA();
3041
- $adA->load_options (AI_ADB_MESSAGE_OPTION_NAME);
3042
- $block_object [AI_ADB_MESSAGE_OPTION_NAME] = $adA;
3043
- }
 
 
 
 
 
 
 
 
 
 
3044
 
3045
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS END");
3046
  }
@@ -3250,6 +3231,10 @@ function ai_settings () {
3250
 
3251
  $ai_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time ();
3252
 
 
 
 
 
3253
  update_option (AI_OPTION_NAME, $ai_options);
3254
 
3255
  // Multisite
@@ -3285,12 +3270,15 @@ function ai_settings () {
3285
  delete_option (AD_OPTIONS);
3286
 
3287
  delete_option (AI_OPTION_NAME);
3288
- delete_option (WP_AD_INSERTER_PRO_LICENSE);
3289
  if (is_multisite () && is_main_site ()) {
3290
  delete_site_option (AI_OPTION_NAME, $options);
3291
  }
3292
 
3293
- $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
 
 
 
3294
 
3295
  if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
3296
 
@@ -3581,6 +3569,9 @@ function ai_content_hook ($content = '') {
3581
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3582
  }
3583
 
 
 
 
3584
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
3585
  $style = AI_DEBUG_TAGS_STYLE;
3586
 
@@ -3604,7 +3595,7 @@ function ai_content_hook ($content = '') {
3604
  }
3605
 
3606
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
3607
- $style = AI_DEBUG_POSITIONS_STYLE;
3608
 
3609
  if (!$positions_inserted) {
3610
  $preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
@@ -3618,9 +3609,17 @@ function ai_content_hook ($content = '') {
3618
  $counter = $ad_inserter_globals [$globals_name];
3619
  if ($counter == 1) $counter = '';
3620
 
3621
- $content = "<section style='$style'><a style='float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0;'>".$content_words." words</a>BEFORE CONTENT ".$counter."<a style='float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0;'>".$content_words." words</a></section>". $content;
 
 
 
 
3622
 
3623
- $content = $content . "<section style='".AI_DEBUG_POSITIONS_STYLE."'>AFTER CONTENT ".$counter."</section>";
 
 
 
 
3624
  }
3625
 
3626
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
@@ -3737,8 +3736,11 @@ function ai_before_after_post ($query, $automatic_insertion) {
3737
 
3738
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
3739
 
3740
- if (!method_exists ($query, 'is_main_query')) return;
3741
- if (!$query->is_main_query()) return;
 
 
 
3742
 
3743
  $globals_name = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? AI_LOOP_BEFORE_COUNTER_NAME : AI_LOOP_AFTER_COUNTER_NAME;
3744
 
@@ -3755,7 +3757,9 @@ function ai_before_after_post ($query, $automatic_insertion) {
3755
 
3756
  $style = AI_DEBUG_POSITIONS_STYLE;
3757
 
 
3758
  echo "<section style='$style'>".($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
 
3759
  }
3760
 
3761
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
@@ -3845,7 +3849,10 @@ function ai_post_hook ($post) {
3845
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return;
3846
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return;
3847
 
3848
- if (!in_the_loop()) return;
 
 
 
3849
 
3850
  if (!isset ($ad_inserter_globals [AI_POST_COUNTER_NAME])) {
3851
  $ad_inserter_globals [AI_POST_COUNTER_NAME] = 0;
@@ -4167,12 +4174,28 @@ function ai_comment_end_callback ($comment, $args, $depth) {
4167
  function process_shortcode (&$block, $atts) {
4168
  global $block_object, $ai_last_check, $ai_wp_data;
4169
 
 
 
4170
  $parameters = shortcode_atts (array (
4171
  "block" => "",
4172
  "name" => "",
4173
  "ignore" => "",
 
 
 
 
 
 
 
 
4174
  ), $atts);
4175
 
 
 
 
 
 
 
4176
  $block = - 1;
4177
  if (is_numeric ($parameters ['block'])) {
4178
  $block = intval ($parameters ['block']);
@@ -4190,6 +4213,18 @@ function process_shortcode (&$block, $atts) {
4190
  }
4191
  }
4192
 
 
 
 
 
 
 
 
 
 
 
 
 
4193
  if ($block == 0) {
4194
  if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
4195
  ob_start ();
@@ -4240,8 +4275,7 @@ function process_shortcode (&$block, $atts) {
4240
  }
4241
  }
4242
 
4243
-
4244
- function process_shortcodes ($atts) {
4245
  global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
4246
 
4247
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
@@ -4249,9 +4283,11 @@ function process_shortcodes ($atts) {
4249
  $atts_string = '';
4250
  if (is_array ($atts))
4251
  foreach ($atts as $index => $att) {
4252
- $atts_string .= $index . '="'.$att.'" ';
 
 
4253
  }
4254
- ai_log ("PROCESS SHORTCODES [adinserter ".trim ($atts_string).']');
4255
  $start_time = microtime (true);
4256
  }
4257
  $ai_last_check = AI_CHECK_NONE;
@@ -4267,6 +4303,14 @@ function process_shortcodes ($atts) {
4267
  return $shortcode;
4268
  }
4269
 
 
 
 
 
 
 
 
 
4270
 
4271
  class ai_widget extends WP_Widget {
4272
 
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.2.0
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes into your website.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
12
 
13
  Change Log
14
 
15
+ Ad Inserter 2.2.0 - 2017-08-27
16
+ - Added support for ad blocking detection (experimental)
17
+ - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
18
+ - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
19
+ - Added syntax highlighting for shortcodes and separators
20
+ - Added style `clear: both;` to Default, Left, Right and Center alignments
21
+ - Bug fix for errors when loading tracking charts (Pro only)
22
+ - Many minor bug fixes, cosmetic changes and code improvements
23
+
24
  Ad Inserter 2.1.14 - 2017-08-07
25
  - Fix for error when using older PHP versions (prior to 5.5)
26
 
31
  - Added option to define tags inside which paragraphs are not counted
32
  - Added max insertions check when inserting for all paragraphs
33
  - Added support for inverted filter
34
+ - Added option to define minimum number of words in paragraphs above (experimental)
35
+ - Added support for %N filter item to filter every N-th insertion (experimental)
36
+ - Added filter support when inserting for all paragraphs (experimental)
37
  - Increased nonce lifespan to 48 hours when using tracking (Pro only)
38
  - Fixed wrong urls in debug menu when behind proxy
39
 
416
  */
417
 
418
 
419
+ global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options, $block_insertion_log;
420
+
421
  if (!defined ('AD_INSERTER_PLUGIN_DIR'))
422
  define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
423
 
424
+ define ('AI_WP_DEBUGGING_', 0);
425
+ define ('AI_DEBUG_PROCESSING_', 0x01);
426
+ define ('AI_URL_DEBUG_', 'ai-debug');
427
+ define ('AI_URL_DEBUG_PROCESSING_', 'ai-debug-processing');
428
+ define ('AI_URL_DEBUG_PHP_', 'ai-debug-php');
429
+
430
+ if (isset ($_GET [AI_URL_DEBUG_PHP_]) && $_GET [AI_URL_DEBUG_PHP_] != '') {
431
+ if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
432
+ ini_set ('display_errors', 1);
433
+ error_reporting (E_ALL);
434
+ }
435
+ }
436
+
437
+ $ai_wp_data [AI_WP_DEBUGGING_] = 0;
438
+
439
+ if (!is_admin()) {
440
+ if (!isset ($_GET [AI_URL_DEBUG_]))
441
+ if (isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || (isset ($_COOKIE ['AI_WP_DEBUGGING']) && ($_COOKIE ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING_) != 0)) {
442
+ if (!isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || $_GET [AI_URL_DEBUG_PROCESSING_] == 1) {
443
+ $ai_wp_data [AI_WP_DEBUGGING_] |= AI_DEBUG_PROCESSING_;
444
+
445
+ $ai_total_plugin_time = 0;
446
+ $start_time = microtime (true);
447
+ $ai_total_php_time = 0;
448
+ $ai_last_time = microtime (true);
449
+ $ai_processing_log = array ();
450
+ ai_log ("INITIALIZATION START");
451
+ }
452
+ }
453
+ }
454
+
455
+ // Version check
456
  global $wp_version, $version_string;
457
 
458
  if (version_compare ($wp_version, "4.0", "<")) {
459
  exit ('Ad Inserter requires WordPress 4.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>');
460
  }
461
 
 
 
462
  //include required files
463
  require_once AD_INSERTER_PLUGIN_DIR.'class.php';
464
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
466
  require_once AD_INSERTER_PLUGIN_DIR.'preview.php';
467
  require_once AD_INSERTER_PLUGIN_DIR.'preview-adb.php';
468
 
 
 
 
 
 
 
 
469
  $version_array = explode (".", AD_INSERTER_VERSION);
470
  $version_string = "";
471
  foreach ($version_array as $number) {
472
  $version_string .= sprintf ("%02d", $number);
473
  }
474
 
 
475
  $ai_wp_data [AI_WP_URL] = remove_debug_parameters_from_url ();
476
 
477
+ //$ai_wp_data [AI_WP_DEBUGGING] = 0;
 
 
 
 
478
 
479
+ //if (!is_admin()) {
480
+ // if (!isset ($_GET [AI_URL_DEBUG]))
481
+ // if (isset ($_GET [AI_URL_DEBUG_PROCESSING]) || (isset ($_COOKIE ['AI_WP_DEBUGGING']) && ($_COOKIE ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING) != 0)) {
482
+ // if (!isset ($_GET [AI_URL_DEBUG_PROCESSING]) || $_GET [AI_URL_DEBUG_PROCESSING] == 1) {
483
+ // $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_PROCESSING;
484
+
485
+ // $ai_total_plugin_time = 0;
486
+ // $start_time = microtime (true);
487
+ // $ai_total_php_time = 0;
488
+ // $ai_last_time = microtime (true);
489
+ // $ai_processing_log = array ();
490
+ // ai_log ("INITIALIZATION START");
491
+ // }
492
+ // }
493
+ //}
494
 
495
  $ad_inserter_globals = array ();
496
  $block_object = array ();
497
  $block_insertion_log = array ();
498
 
499
  ai_load_settings ();
500
+ $ai_wp_data [AI_JS_DEBUGGING] = get_javascript_debugging ();
501
 
502
  if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
503
  if (get_remote_debugging ()) {
510
  $ai_wp_data [AI_ADB_DETECTION] = $block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual ();
511
 
512
  if ($ai_wp_data [AI_ADB_DETECTION]) {
513
+ $adb_2_name = AI_ADB_2_DEFAULT_NAME;
514
  define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY.md5 (NONCE_KEY)))), 0, 8));
515
 
516
+ $script_path = AD_INSERTER_PLUGIN_DIR.'includes/js';
517
+ $script = $script_path.'/sponsors.js';
518
 
519
+ if (is_writable ($script_path) && is_writable ($script)) {
520
+ $adb_2_name = substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY).md5 (NONCE_KEY))), 0, 8);
521
+
522
+ $js_ok = false;
523
+ if (file_exists ($script)) {
524
+ if (strpos (file_get_contents ($script), $adb_2_name) !== false) $js_ok = true;
525
+ }
526
 
527
+ if (!$js_ok) {
528
+ file_put_contents ($script, 'window.' . $adb_2_name . '=true;');
529
+ define ('AI_ADB_2_FILE_RECREATED', true);
530
+ }
531
  }
532
 
533
+ define ('AI_ADB_2_NAME', $adb_2_name);
534
+
535
  if (function_exists ('ai_check_files')) ai_check_files ();
536
  }
537
  }
552
  }
553
  }
554
 
555
+
556
+
557
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
558
+ $ai_wp_data [AI_WP_AMP_PAGE] = false;
559
  $ai_wp_data [AI_WP_USER_SET] = false;
560
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
561
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
605
 
606
  add_action ('wp', 'ai_wp_hook');
607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
609
 
610
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
618
 
619
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
620
  add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
 
 
621
 
622
+ if (is_admin () === true) {
623
+ add_action ('wp_ajax_ai_ajax_backend', 'ai_ajax_backend');
624
+ add_action ('wp_ajax_ai_ajax', 'ai_ajax');
625
+ add_action ('wp_ajax_nopriv_ai_ajax', 'ai_ajax');
626
+ }
627
 
628
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
629
  $ai_total_plugin_time += microtime (true) - $start_time;
631
  }
632
 
633
 
 
634
  function ai_toolbar ($wp_admin_bar) {
635
  global $block_object, $ai_wp_data;
636
 
652
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING) == 0) $debug_ad_blocking = 1; else $debug_ad_blocking = 0;
653
  $debug_ad_blocking_class = $debug_ad_blocking == 0 ? ' on' : '';
654
 
655
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) == 0) $debug_ad_blocking_status = 1; else $debug_ad_blocking_status = 0;
656
+ $debug_ad_blocking_status_class = $debug_ad_blocking_status == 0 ? ' on' : '';
657
+
658
+ $debug_settings_on = $debug_blocks == 0 || $debug_positions === '' || $debug_tags == 0 || $debug_processing == 0 || $debug_no_insertion == 0 || $debug_ad_blocking == 0 || $debug_ad_blocking_status == 0;
659
 
660
  $debug_settings_class = $debug_settings_on ? ' on' : '';
661
  $top_menu_url = $debug_settings_on ? add_query_arg (AI_URL_DEBUG, '0', remove_debug_parameters_from_url ()) :
756
  'href' => set_url_parameter (AI_URL_DEBUG_NO_INSERTION, $debug_no_insertion),
757
  ));
758
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
759
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
760
+ $wp_admin_bar->add_node (array (
761
+ 'id' => 'ai-toolbar-adb-status',
762
+ 'parent' => 'ai-toolbar-settings',
763
+ 'title' => '<span class="ab-icon'.$debug_ad_blocking_status_class.'"></span>Ad Blocking Status',
764
+ 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING_STATUS, $debug_ad_blocking_status),
765
+ ));
766
+ $wp_admin_bar->add_node (array (
767
+ 'id' => 'ai-toolbar-adb',
768
+ 'parent' => 'ai-toolbar-settings',
769
+ 'title' => '<span class="ab-icon'.$debug_ad_blocking_class.'"></span>Simulate Ad Blocking',
770
+ 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING, $debug_ad_blocking),
771
+ ));
772
+ }
773
  }
774
  $wp_admin_bar->add_node (array (
775
  'id' => 'ai-toolbar-processing',
799
 
800
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
801
 
802
+ if (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
803
+ elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
804
+ elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
805
+ elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
806
+ elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
807
+ elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
808
+ elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
809
+ elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
810
+ elseif (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
811
+
812
+ if (function_exists ('is_amp_endpoint') && is_amp_endpoint ()) {
813
+ $ai_wp_data [AI_WP_AMP_PAGE] = true;
814
+ define ('AI_AMP_PAGE', true);
815
+ }
816
  }
817
 
818
  function ai_log_message ($message) {
849
  case AI_CHECK_PAGE_TYPE_FEED: $status .= "ENABLED ON FEED"; break;
850
  case AI_CHECK_PAGE_TYPE_404: $status .= "ENABLED ON 404"; break;
851
 
 
852
  case AI_CHECK_DESKTOP_DEVICES: $status .= "DESKTOP DEVICES"; break;
853
  case AI_CHECK_MOBILE_DEVICES: $status .= "MOBILE DEVICES"; break;
854
  case AI_CHECK_TABLET_DEVICES: $status .= "TABLET DEVICES"; break;
871
  case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break;
872
  case AI_CHECK_ADMINISTRATOR: $status .= "ADMINISTRATOR"; break;
873
 
874
+ case AI_CHECK_INDIVIDUALLY_DISABLED: $status .= "INDIVIDUALLY DISABLED"; break;
875
+ case AI_CHECK_INDIVIDUALLY_ENABLED: $status .= "INDIVIDUALLY ENABLED"; break;
876
  case AI_CHECK_DISABLED_MANUALLY: $status .= "DISABLED BY HTML COMMENT"; break;
877
 
878
  case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break;
928
 
929
  function remove_debug_parameters_from_url ($url = false) {
930
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
931
+ $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION, AI_URL_DEBUG_AD_BLOCKING, AI_URL_DEBUG_AD_BLOCKING_STATUS);
932
  } else
933
  $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION);
934
 
989
  if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION]))
990
  if ($_GET [AI_URL_DEBUG_NO_INSERTION] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_NO_INSERTION; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_NO_INSERTION;
991
 
992
+ if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING_STATUS]))
993
+ if ($_GET [AI_URL_DEBUG_AD_BLOCKING_STATUS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_AD_BLOCKING_STATUS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_AD_BLOCKING_STATUS;
994
+
995
  if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING]))
996
  if ($_GET [AI_URL_DEBUG_AD_BLOCKING] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_AD_BLOCKING; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_AD_BLOCKING;
997
 
1041
  $ai_walker = new ai_Walker_Comment;
1042
  }
1043
 
1044
+
1045
+ if ($ai_wp_data [AI_WP_AMP_PAGE] && has_action ('amp_post_template_head')) {
1046
+ add_action ('amp_post_template_head', 'ai_wp_head_hook');
1047
+ } else
1048
+ add_action ('wp_head', 'ai_wp_head_hook');
1049
+
1050
+ if ($ai_wp_data [AI_WP_AMP_PAGE] && has_action ('amp_post_template_head')) {
1051
+ add_action ('amp_post_template_footer', 'ai_wp_footer_hook');
1052
+ } else
1053
+ add_action ('wp_footer', 'ai_wp_footer_hook');
1054
+
1055
+
1056
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1057
+ // No scripts on AMP pages
1058
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1059
+ $ai_wp_data [AI_ADB_DETECTION] = false;
1060
+ $ai_wp_data [AI_TRACKING] = false;
1061
+ }
1062
+ }
1063
+
1064
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1065
  $ai_total_plugin_time += microtime (true) - $start_time;
1066
  ai_log ("WP HOOK END\n");
1075
  ai_wp_hook ();
1076
  }
1077
 
1078
+ add_shortcode ('adinserter', 'process_shortcodes_lc');
1079
+ add_shortcode ('ADINSERTER', 'process_shortcodes_uc');
1080
  }
1081
 
1082
  function ai_admin_menu_hook () {
1085
  if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return;
1086
 
1087
  $ai_settings_page = add_submenu_page ('options-general.php', AD_INSERTER_NAME.' Options', AD_INSERTER_NAME, 'manage_options', basename(__FILE__), 'ai_settings');
1088
+ add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
1089
+ add_action ('admin_head', 'ai_admin_head' );
1090
+ add_filter ('clean_url', 'ai_clean_url', 999999, 2);
1091
  }
1092
 
1093
+ function ai_admin_head () {
1094
+ if (wp_is_mobile()) {
1095
+ echo "<meta name='viewport' content='width=762'>\n";
1096
+ }
1097
+ }
1098
 
1099
  function ai_admin_enqueue_scripts ($hook_suffix) {
1100
  global $ai_settings_page;
1101
 
1102
  if ($hook_suffix == $ai_settings_page) {
1103
+ wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null);
 
 
 
 
 
 
 
 
 
1104
 
1105
  if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
1106
 
1107
+ wp_enqueue_style ('ai-image-picker', plugins_url ('css/image-picker.css', __FILE__), array (), AD_INSERTER_VERSION);
1108
  wp_add_inline_style ('ai-image-picker', '.thumbnail {border-radius: 6px;}');
1109
+ wp_enqueue_style ('ai-admin-css', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
1110
 
1111
+ wp_add_inline_style ('ai-admin-css', '.notice {margin: 5px 15px 15px 0;}');
1112
 
1113
  if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
1114
 
1115
+ // Located in the header to load datepicker js file to prevent error when async tags used
1116
+ wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (
1117
+ 'jquery',
1118
+ 'jquery-ui-datepicker',
1119
+
1120
+ ), AD_INSERTER_VERSION, false);
1121
 
1122
  if (AI_SYNTAX_HIGHLIGHTING) {
1123
+ wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1124
+ // wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1125
+ wp_enqueue_script ('ai-ace-html', plugins_url ('includes/ace/mode-html.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1126
+ wp_enqueue_script ('ai-ace-php', plugins_url ('includes/ace/mode-php.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1127
 
1128
  if (get_syntax_highlighter_theme () == AI_SYNTAX_HIGHLIGHTER_THEME || isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] == AI_SYNTAX_HIGHLIGHTER_THEME)
1129
+ wp_enqueue_script ('ai-ace-theme', plugins_url ('includes/ace/theme-ad_inserter.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1130
  }
1131
+
1132
+ wp_enqueue_script ('ai-admin-js', plugins_url ('js/ad-inserter.js', __FILE__), array (
1133
+ 'jquery',
1134
+ 'jquery-ui-tabs',
1135
+ 'jquery-ui-button',
1136
+ 'jquery-ui-tooltip',
1137
+ 'jquery-ui-datepicker',
1138
+ 'jquery-ui-dialog',
1139
+ ), AD_INSERTER_VERSION, true);
1140
  }
1141
+
1142
+ wp_enqueue_style ('ai-admin-css-gen', plugins_url ('css/ai-admin.css', __FILE__), array (), AD_INSERTER_VERSION);
1143
+ wp_enqueue_script ('ai-admin-js-gen', plugins_url ('includes/js/ai-admin.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1144
+ }
1145
+
1146
+ function ai_clean_url ( $url, $original_url){
1147
+ if (strpos ($url, 'async=') !== false && strpos ($url, '/plugins/ad-inserter') !== false) {
1148
+ // $url = $original_url;
1149
+ $url = str_replace ("' async='async", '', $url);
1150
+ }
1151
+ return $url;
1152
  }
1153
 
1154
  function add_head_inline_styles_and_scripts () {
1155
  global $ai_wp_data;
1156
 
1157
  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)) {
1158
+ // No scripts on AMP pages
1159
  echo "<style type='text/css'>\n";
1160
 
1161
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
 
1162
 
1163
+ if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
1164
+ echo "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
1165
  content: '\\f111';
1166
  top: 2px;
1167
  color: rgba(240,245,250,.6)!important;
1191
  #wp-admin-bar-ai-toolbar-no-insertion .ab-icon:before {
1192
  content: '\\f214';
1193
  }
1194
+ #wp-admin-bar-ai-toolbar-adb-status .ab-icon:before {
1195
+ content: '\\f223';
1196
+ }
1197
+ #wp-admin-bar-ai-toolbar-adb .ab-icon:before {
1198
  content: '\\f160';
1199
  }
1200
  #wp-admin-bar-ai-toolbar-processing .ab-icon:before {
1209
  ";
1210
 
1211
  echo "</style>\n";
1212
+ // No scripts on AMP pages
1213
  }
1214
  }
1215
 
1216
+ function ai_get_js ($js_name, $replace_js_data = true) {
1217
+ global $ai_wp_data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1218
 
1219
+ if ($ai_wp_data [AI_JS_DEBUGGING]) {
1220
+ $script = file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.js");
1221
+ } else $script = file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.min.js");
1222
+ if (!$replace_js_data) return $script;
1223
+ return ai_replace_js_data ($script, $js_name);
1224
  }
1225
 
1226
+ function ai_replace_js_data ($js) {
1227
+ global $block_object, $ai_wp_data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1228
 
1229
+ if (preg_match_all ('/AI_CONST_([_A-Z0-9]+)/', $js, $match)) {
1230
+ foreach ($match [1] as $index => $constant) {
1231
+ if (defined ($constant))
1232
+ $js = str_replace ($match [0][$index], constant ($constant), $js);
1233
  }
1234
  }
1235
 
1236
+ if (preg_match_all ('/AI_DATA_([_A-Z0-9]+)/', $js, $match)) {
1237
+ foreach ($match [1] as $index => $constant) {
1238
+ if (defined ($constant) && isset ($ai_wp_data [constant ($constant)]))
1239
+ $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)], $js);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1240
  }
1241
  }
1242
 
1243
+ if (preg_match_all ('/AI_DATAB_([_A-Z0-9]+)/', $js, $match)) {
1244
+ foreach ($match [1] as $index => $constant) {
1245
+ if (defined ($constant) && isset ($ai_wp_data [constant ($constant)]))
1246
+ $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)] ? 1 : 0, $js);
1247
+ }
 
1248
  }
1249
 
1250
+ if (preg_match_all ('/AI_DBG_([_A-Z0-9]+)/', $js, $match)) {
1251
+ foreach ($match [1] as $index => $constant) {
1252
+ if (defined ($constant))
1253
+ $js = str_replace ($match [0][$index], ($ai_wp_data [AI_WP_DEBUGGING] & constant ($constant)) != 0 ? 1 : 0, $js);
1254
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1255
  }
 
1256
 
1257
+ if (preg_match_all ('/AI_FUNC_([_A-Z0-9]+)/', $js, $match)) {
1258
+ foreach ($match [1] as $index => $function) {
1259
+ $function = strtolower ($function);
1260
+ if (function_exists ($function))
1261
+ $js = str_replace ($match [0][$index], call_user_func ($function), $js);
1262
+ }
1263
  }
1264
 
1265
+ if (preg_match_all ('/AI_FUNCB_([_A-Z0-9]+)/', $js, $match)) {
1266
+ foreach ($match [1] as $index => $function) {
1267
+ $function = strtolower ($function);
1268
+ if (function_exists ($function))
1269
+ $js = str_replace ($match [0][$index], call_user_func ($function) ? 1 : 0, $js);
1270
+ }
1271
  }
1272
 
1273
+ if (preg_match_all ('/AI_FUNCT_([_A-Z0-9]+)/', $js, $match)) {
1274
+ foreach ($match [1] as $index => $function) {
1275
+ $function = strtolower ($function);
1276
+ if (function_exists ($function))
1277
+ $js = str_replace ($match [0][$index], call_user_func ($function, true), $js);
1278
+ }
1279
  }
1280
 
1281
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1282
+ if (strpos ($js, 'AI_ADB_STATUS_MESSAGE') !== false) {
1283
+ $adb = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
1284
+
1285
+ $js = str_replace ('AI_ADB_OVERLAY_WINDOW', "jQuery ('<div>', {attr: {'style': '" . str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_OVERLAY_CSS) . get_overlay_css () . "'}})", $js);
1286
+ $js = str_replace ('AI_ADB_MESSAGE_WINDOW', "jQuery ('<div>', {attr: {'style': '" . str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_MESSAGE_CSS) . get_message_css () . "'}, html: '" .
1287
+ str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), do_shortcode ($adb->ai_getCode ())) . "'});", $js);
1288
+ $js = str_replace ('AI_ADB_SELECTORS', str_replace (' ', '', get_adb_selectors ()), $js);
1289
+
1290
+ $redirection_page = get_redirection_page ();
1291
+ if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ());
1292
+ $js = str_replace ('AI_ADB_REDIRECTION_PAGE', $url, $js);
1293
+
1294
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0) {
1295
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=1', '$("#ai-adb-status").text ("DETECTED, " + d1 + " PAGE VIEW" + (d1 == 1 ? "" : "S") + " - NO ACTION");', $js);
1296
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=2', '$("#ai-adb-status").text ("DETECTED, COOKIE DETECTED - NO ACTION");', $js);
1297
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=3', '$("#ai-adb-status").text ("DETECTED - ACTION");', $js);
1298
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=4', 'jQuery("#ai-adb-status").text ("NOT DETECTED");', $js);
1299
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=5', '$("#ai-adb-status").text ("COOKIES DELETED");', $js);
1300
+ } else {
1301
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=1', '', $js);
1302
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=2', '', $js);
1303
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=3', '', $js);
1304
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=4', '{}', $js);
1305
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=5', '', $js);
1306
+ }
1307
  }
 
 
 
 
 
 
 
 
1308
  }
1309
 
1310
+ $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1311
+ $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1312
+ if (defined ('AI_STATISTICS') && AI_STATISTICS) {
1313
+ $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1314
  }
1315
 
1316
+ if (function_exists ('ai_replace_js_data_2')) ai_replace_js_data_2 ($js);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1317
 
1318
+ return $js;
1319
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1320
 
1321
+ function ai_adb_code () {
1322
+ return ai_get_js ('ai-adb', false);
1323
  }
1324
 
1325
  function add_footer_inline_scripts () {
1342
  if ($inline_scripts) echo "<script type='text/javascript'>\n";
1343
 
1344
  if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
 
1345
  $block_class_name = get_block_class_name ();
1346
  if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1347
+ define ('AI_BLOCK_CLASS_NAME', $block_class_name);
1348
 
1349
+ echo ai_get_js ('ai-rotate');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1350
  }
1351
 
1352
  if ($ai_wp_data [AI_STICKY_WIDGETS]) {
1353
+ echo ai_get_js ('ai-sticky');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1354
  }
1355
 
1356
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1357
  if ($ai_wp_data [AI_ADB_DETECTION]) {
1358
+ if (!function_exists ('add_footer_inline_scripts_2')) echo ai_replace_js_data (ai_adb_code ());
1359
  }
1360
  }
1361
 
1367
  }
1368
 
1369
  function ai_admin_notice_hook () {
1370
+ global $current_screen, $ai_db_options, $ai_wp_data, $ai_db_options_extract;
1371
 
1372
  // $sidebar_widgets = wp_get_sidebars_widgets();
1373
  // $sidebars_with_deprecated_widgets = array ();
1392
  // ". Please replace them with the new 'Ad Inserter' code block widget. See <a href='https://wordpress.org/plugins/ad-inserter/faq/' target='_blank'>FAQ</a> for details.</p></div>";
1393
  // }
1394
 
1395
+ if (function_exists ('ai_admin_notices')) ai_admin_notices (); else {
1396
+ if (!wp_is_mobile () && is_super_admin ()) {
1397
+
1398
+ if ((get_option ('ai-notice-review') === false && $ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 6 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10) ||
1399
+
1400
+ (get_option ('ai-notice-review') == 'later' && ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 30 ||
1401
+ $ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 60))) {
1402
+
1403
+ if (get_option ('ai-notice-review') == 'later') {
1404
+ $message = "Hey, you are now using <strong>{$ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]} Ad Inserter</strong> code blocks.";
1405
+ $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
1406
+ } else {
1407
+ $message = "Hey, you've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.";
1408
+ $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="later">Not now, maybe later.</div>';
1409
+ }
1410
+ ?>
1411
+ <div class="notice notice-info ai-notice ai-no-phone" style="display: none;" data-notice="review" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" >
1412
+ <div class="ai-notice-element">
1413
+ <img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-50x50.jpg" style="width: 50px; margin: 5px 10px 0px 10px;" />
1414
+ </div>
1415
+ <div class="ai-notice-element" style="width: 100%; padding: 0 10px 0;">
1416
+ <p><?php echo $message; ?>
1417
+ I would really appreciate it if you could give the plugin a 5-star rating on WordPres.<br />
1418
+ Positive reviews are a great incentive to fix bugs and to add new features for better monetization of your website.
1419
+ Thank you! - Igor
1420
+ </p>
1421
+ </div>
1422
+ <div class="ai-notice-element ai-notice-buttons last">
1423
+ <button class="button-primary ai-notice-dismiss" data-notice="yes">
1424
+ <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" class="ai-notice-dismiss" target="_blank" data-notice="yes">Rate Ad Inserter</a>
1425
+ </button>
1426
+ <?php echo $option; ?>
1427
+ <div class="ai-notice-text-button ai-notice-dismiss" data-notice="already">I already did.</div>
1428
+ </div>
1429
+ </div>
1430
+
1431
+ <?php
1432
+ }
1433
+ }
1434
+ }
1435
+
1436
  }
1437
 
1438
  function ai_plugin_action_links ($links) {
1511
  foreach ($screens as $screen) {
1512
  add_meta_box (
1513
  'adinserter_sectionid',
1514
+ AD_INSERTER_NAME.' Individual Exceptions',
1515
  'ai_meta_box_callback',
1516
  $screen
1517
  );
1536
  $post_meta = get_post_meta ($post->ID, '_adinserter_block_exceptions', true);
1537
  $selected_blocks = explode (",", $post_meta);
1538
 
1539
+ ob_start ();
1540
+
1541
  echo '<table>';
1542
  echo '<thead style="font-weight: bold;">';
1543
  echo ' <td>Block</td>';
1557
 
1558
  if ($post_type == 'page') {
1559
  $page_name = 'pages';
1560
+ $enabled_on = $obj->get_ad_enabled_on_which_pages ();
1561
  $general_enabled = $obj->get_display_settings_page();
1562
  } else {
1563
  $page_name = 'posts';
1564
+ $enabled_on = $obj->get_ad_enabled_on_which_posts ();
1565
  $general_enabled = $obj->get_display_settings_post();
1566
  }
1567
 
1568
+ if (!$general_enabled || $enabled_on == AI_NO_INDIVIDUAL_EXCEPTIONS) continue;
1569
+
1570
+ $individual_option_enabled = $general_enabled && ($enabled_on == AI_INDIVIDUALLY_DISABLED || $enabled_on == AI_INDIVIDUALLY_ENABLED);
1571
+ $individual_text_enabled = $enabled_on == AI_INDIVIDUALLY_DISABLED;
1572
 
1573
  if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF";
1574
  echo '<tr style="background: ', $background, ';">';
1575
  echo ' <td style="text-align: right;">', $obj->number, '</td>';
1576
  if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = "";
1577
+ echo ' <td style="padding: 0 10px 0 10px;"><a href="', admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, '&tab=', $block, '" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">', $obj->get_ad_name(), '</a></td>';
1578
  echo ' <td style="padding: 0 10px 0 10px;">', $obj->get_automatic_insertion_text(), '</td>';
1579
  echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
1580
 
1606
  echo '</tbody>';
1607
  echo '</table>';
1608
 
1609
+ $exceptions_table = ob_get_clean ();
 
1610
 
1611
+ if ($rows == 0) {
1612
+ echo '<p><strong>No individual exceptions enabled for ', $page_name, '</strong>.</p>';
1613
+ } else echo $exceptions_table;
1614
+
1615
+ echo '<p>Default insertion for ', $page_name, ' for each code block can be configured on <a href="', admin_url ('options-general.php?page=ad-inserter.php'), '" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">',
1616
+ AD_INSERTER_NAME, ' Settings</a> page - selection next to <strong>Posts</strong> / <strong>Static pages</strong> checkbox.<br />',
1617
+ 'Default value is <strong>blank</strong> and means no individual exceptions (even if previously defined here).<br />',
1618
+ 'Set to <strong>Individually disabled</strong> or <strong>Individually enabled</strong> to enable individual exception settings on this page.<br />',
1619
+ 'For more information check <a href="https://adinserter.pro/exceptions" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">Ad Inserter Exceptions</a>.</p>';
1620
  }
1621
 
1622
  function ai_save_meta_box_data_hook ($post_id) {
1656
  register_widget ('ai_widget');
1657
  }
1658
 
1659
+ function get_page_type_debug_info ($text = '') {
1660
  global $ai_wp_data;
1661
 
1662
  switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
1690
  }
1691
  $style = AI_DEBUG_PAGE_TYPE_STYLE;
1692
 
1693
+ $page_type = "<section style='$style'>".$text.$page_type."</section>";;
1694
+
1695
+ return $page_type;
1696
+ }
1697
+
1698
+ function get_adb_status_debug_info () {
1699
+ global $ai_wp_data;
1700
+
1701
+ $page_type = '';
1702
+
1703
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1704
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
1705
+ $page_type = "<section id='ai-adb-bar' style='".AI_DEBUG_ADB_STYLE."' title='Click to delete ad blocking detection cokies'>AD BLOCKING <span id='ai-adb-status'>STATUS UNKNOWN</span></section>";
1706
+ }
1707
+ }
1708
+
1709
+ return $page_type;
1710
  }
1711
 
1712
 
1729
 
1730
  if ($obj->get_enable_manual ()) {
1731
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1732
+
1733
+ $processed_code = do_shortcode ($obj->ai_getCode ());
1734
+
1735
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1736
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1737
+ $processed_code = trim ($codes [$ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0]);
1738
+ }
1739
+
1740
+ echo $processed_code;
1741
  }
1742
 
1743
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1744
+ // No scripts on AMP pages
1745
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0 && $ai_wp_data [AI_ADB_DETECTION] && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1746
+ echo "<script>
1747
+ jQuery(document).ready(function($) {
1748
+ $('body').prepend (\"", get_adb_status_debug_info () , "\");
1749
+ });
1750
+ </script>\n";
1751
+ }
1752
+ }
1753
+
1754
+ // No scripts on AMP pages
1755
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 & !$ai_wp_data [AI_WP_AMP_PAGE]) {
1756
  echo "<script>
1757
  jQuery(document).ready(function($) {
1758
  $('body').prepend (\"", get_page_type_debug_info () , "\");
1774
  $start_time = microtime (true);
1775
  }
1776
 
1777
+ if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1778
  add_footer_inline_scripts ();
1779
  }
1780
 
1787
 
1788
  if ($obj->get_enable_manual ()) {
1789
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1790
+
1791
+ $processed_code = do_shortcode ($obj->ai_getCode ());
1792
+
1793
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1794
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1795
+ $processed_code = trim ($codes [$ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0]);
1796
+ }
1797
+
1798
+ echo $processed_code;
1799
  }
1800
 
1801
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1814
  echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
1815
  if (function_exists ('ai_debug_header')) ai_debug_header ();
1816
  echo "\n\n";
1817
+ if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
1818
+ echo "INSTALLED: ", date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600);
1819
+ if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) {
1820
+ printf (' (%04d-%02d-%02d %02d:%02d:%02d)', $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
1821
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
1822
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
1823
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
1824
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
1825
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s);
1826
+ }
1827
+ echo "\n";
1828
+ }
1829
  echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
1830
  echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
1831
+ echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2, '.' , ''), " ms\n";
1832
  echo "USER CODE PROCESSING: ", number_format ($ai_total_php_time * 1000, 2, '.' , ''), " ms\n";
1833
  echo "TOTAL PROCESSING TIME: ", number_format ($ai_total_plugin_time * 1000, 2, '.' , ''), " ms\n";
1834
 
1899
  }
1900
  echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
1901
  echo 'ID: ', get_the_ID(), "\n";
1902
+ break;
1903
+ case AI_PT_CATEGORY:
1904
+ $category_data = get_the_category();
1905
+ $categories = array ();
1906
+ foreach ($category_data as $category) {
1907
+ $categories []= $category->slug;
1908
+ }
1909
+ echo 'CATEGORY: ', implode (', ', $categories), "\n";
1910
+ break;
1911
+ case AI_PT_ARCHIVE:
1912
+ $tag_data = wp_get_post_tags (get_the_ID());
1913
+ $tags = array ();
1914
+ foreach ($tag_data as $tag) {
1915
+ $tags []= $tag->slug;
1916
+ }
1917
+ echo 'TAG: ', implode (', ', $tags), "\n";
1918
+ break;
1919
  }
1920
 
1921
+ echo 'AMP PAGE: ', ($ai_wp_data [AI_WP_AMP_PAGE] ? 'YES' : 'NO'), "\n";
1922
+
1923
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1924
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_debug_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
1925
  if (function_exists ('ai_debug')) ai_debug ();
1969
  echo 'HEADER CODE: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
1970
  echo 'FOOTER CODE: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
1971
 
1972
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1973
+ echo 'AD BLOCKING DETECTION: ', $ai_wp_data [AI_ADB_DETECTION] ? 'ENABLED' : 'DISABLED', "\n";
1974
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
1975
+ echo 'ADB ACTION: ';
1976
+ switch (get_adb_action ()) {
1977
+ case AI_ADB_ACTION_NONE:
1978
+ echo AI_TEXT_NONE;
1979
+ break;
1980
+ case AI_ADB_ACTION_MESSAGE:
1981
+ echo AI_TEXT_POPUP_MESSAGE;
1982
+ break;
1983
+ case AI_ADB_ACTION_REDIRECTION:
1984
+ echo AI_TEXT_REDIRECTION;
1985
+ break;
1986
+ }
1987
+ echo "\n";
1988
+ echo 'ADB DELAY ACTION: ', get_delay_action (), "\n";
1989
+ echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
1990
+ echo 'ADB SELECTORS: ', get_adb_selectors (), "\n";
1991
+ $redirection_page = get_redirection_page ();
1992
+ echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : $redirection_page, "\n";
1993
+ echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
1994
+ echo 'ADB MESSAGE: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode (), "\n";
1995
+ echo 'ADB MESSAGE CSS: ', get_message_css (), "\n";
1996
+ echo 'ADB OVERLAY CSS: ', get_overlay_css (), "\n";
1997
+ echo 'ADB UNDISMISSIBLE: ', get_undismissible_message () ? 'ON' : 'OFF', "\n";
1998
  }
 
 
 
 
 
 
 
 
 
 
 
1999
  }
2000
 
2001
  echo "\n";
2002
 
2003
  $default = new ai_Block (1);
2004
 
2005
+ echo "BLOCK SETTINGS Po Pa Hp Cp Ap Sp AM Aj Fe 404 Wi Sh PHP\n";
2006
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2007
  $obj = $block_object [$block];
2008
 
2022
  case AI_OPTION_DISPLAY_ON_CATEGORY_PAGES:
2023
  case AI_OPTION_DISPLAY_ON_SEARCH_PAGES:
2024
  case AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES:
2025
+ case AI_OPTION_ENABLE_AMP:
2026
+ case AI_OPTION_ENABLE_AJAX:
2027
  case AI_OPTION_ENABLE_FEED:
2028
  case AI_OPTION_ENABLE_404:
2029
  case AI_OPTION_ENABLE_MANUAL:
2032
  if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false;
2033
  continue 2;
2034
  }
2035
+ if ($obj->wp_options [$key] !== $default->wp_options [$key]) {
2036
  $default_settings = false;
2037
  switch ($key) {
2038
  case AI_OPTION_AUTOMATIC_INSERTION:
2041
  case AI_OPTION_ALIGNMENT_TYPE:
2042
  $alignment_settings = $obj->get_alignment_type_text ();
2043
  break;
2044
+ case AI_OPTION_ENABLED_ON_WHICH_PAGES:
2045
+ $settings = $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_pages_text () . ']';
2046
+ break;
2047
+ case AI_OPTION_ENABLED_ON_WHICH_POSTS:
2048
+ $settings = $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_posts_text () . ']';
2049
+ break;
2050
  case AI_OPTION_PARAGRAPH_TEXT:
2051
  case AI_OPTION_AVOID_TEXT_ABOVE:
2052
  case AI_OPTION_AVOID_TEXT_BELOW:
2082
  echo $obj->get_display_settings_category() ? "o" : ".", " ";
2083
  echo $obj->get_display_settings_archive() ? "o" : ".", " ";
2084
  echo $obj->get_display_settings_search() ? "o" : ".", " ";
2085
+ echo $obj->get_enable_amp() ? "o" : ".", " ";
2086
  echo $obj->get_enable_ajax() ? "o" : ".", " ";
2087
  echo $obj->get_enable_feed() ? "o" : ".", " ";
2088
  echo $obj->get_enable_404() ? "o" : ".", " ";
2761
  function filter_option_hf ($option, $value){
2762
  $value = str_replace (array ("\\\""), array ("\""), $value);
2763
 
2764
+ // if ($option == AI_OPTION_CODE ) {
2765
+ // } elseif ($option == AI_OPTION_ENABLE_MANUAL) {
2766
+ // } elseif ($option == AI_OPTION_PROCESS_PHP) {
2767
+ // } elseif ($option == AI_OPTION_ENABLE_404) {
2768
+ // } elseif ($option == AI_OPTION_DETECT_SERVER_SIDE) {
2769
+ // } elseif ($option == AI_OPTION_DISPLAY_FOR_DEVICES) {
2770
+ // }
2771
 
2772
  return $value;
2773
  }
2774
 
2775
+ function ai_ajax () {
2776
 
2777
+ // check_ajax_referer ("adinserter_data", "ai_check");
2778
+ // check_admin_referer ("adinserter_data", "ai_check");
2779
+
2780
+ if (function_exists ('ai_ajax_processing_2')) {
2781
+ ai_ajax_processing_2 ();
2782
+ }
2783
+
2784
+ wp_die ();
2785
+ }
2786
+
2787
+ function ai_ajax_backend () {
2788
+ global $preview_name, $preview_alignment, $preview_css;
2789
+
2790
+ // check_ajax_referer ("adinserter_data", "ai_check");
2791
  check_admin_referer ("adinserter_data", "ai_check");
2792
 
2793
+ if (isset ($_POST ["preview"])) {
2794
+ $block = urldecode ($_POST ["preview"]);
2795
  if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
2796
+ generate_code_preview ($block, urldecode ($_POST ["name"]), urldecode ($_POST ["alignment"]), urldecode ($_POST ["alignment_css"]), urldecode ($_POST ["custom_css"]));
2797
  }
2798
  elseif ($block == 'adb') {
2799
  generate_code_preview_adb ($block);
2807
  }
2808
 
2809
  elseif (isset ($_GET ["rating"])) {
2810
+ $cache_time = $_GET ["rating"] == 'update' ? 0 * 60 : AI_TRANSIENT_RATING_EXPIRATION;
2811
  if (!get_transient (AI_TRANSIENT_RATING) || !($transient_timeout = get_option ('_transient_timeout_' . AI_TRANSIENT_RATING)) || AI_TRANSIENT_RATING_EXPIRATION - ($transient_timeout - time ()) > $cache_time) {
2812
+ $args = (object) array ('slug' => 'ad-inserter');
2813
+ $request = array ('action' => 'plugin_information', 'timeout' => 5, 'request' => serialize ($args));
2814
+ $url = 'http://api.wordpress.org/plugins/info/1.0/';
2815
+ $response = wp_remote_post ($url, array ('body' => $request));
2816
+ $plugin_info = @unserialize ($response ['body']);
2817
+ if (isset ($plugin_info->ratings)) {
2818
+ $total_rating = 0;
2819
+ $total_count = 0;
2820
+ foreach ($plugin_info->ratings as $rating => $count) {
2821
+ $total_rating += $rating * $count;
2822
+ $total_count += $count;
2823
  }
2824
+ $rating = number_format ($total_rating / $total_count, 4);
2825
+ set_transient (AI_TRANSIENT_RATING, $rating, AI_TRANSIENT_RATING_EXPIRATION);
2826
  }
2827
  }
2828
  if ($rating = get_transient (AI_TRANSIENT_RATING)) {
2830
  }
2831
  }
2832
 
2833
+ elseif (isset ($_POST ["notice"])) {
2834
+ if (get_option ('ai-notice-review') == 'later') $_POST ["click"] = 'no';
2835
+ update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
2836
+ }
2837
+
2838
+ elseif (function_exists ('ai_ajax_backend_2')) {
2839
+ ai_ajax_backend_2 ();
2840
  }
2841
 
2842
  wp_die ();
2865
  $between_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2866
  $after_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2867
 
2868
+ // Get blocks used in sidebar widgets
2869
+ $sidebar_widgets = wp_get_sidebars_widgets();
2870
+ $widget_options = get_option ('widget_ai_widget');
2871
+
2872
+ $widget_blocks = array ();
2873
+ foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
2874
+ if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
2875
+ $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
2876
+ if ($sidebar_name != "") {
2877
+ foreach ($sidebar_widget as $widget) {
2878
+ if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
2879
+ if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
2880
+ $widget_option = $widget_options [$widget_id [1]];
2881
+ $widget_block = $widget_option ['block'];
2882
+ if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS) {
2883
+ $widget_blocks [] = $widget_block;
2884
+ }
2885
+ }
2886
+ }
2887
+ }
2888
+ }
2889
+ }
2890
+ }
2891
+ $widget_blocks = array_unique ($widget_blocks);
2892
+
2893
  // Generate extracted data
2894
+ $used_blocks = 0;
2895
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2896
 
2897
  if (!isset ($settings [$block])) continue;
2910
  if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED;
2911
  if ($obj->get_enable_404()) $page_types []= AI_PT_404;
2912
 
2913
+ $automatic_insertion = $obj->get_automatic_insertion();
2914
  if ($page_types) {
2915
+ switch ($automatic_insertion) {
2916
  case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH:
2917
  case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH:
2918
  case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT:
2951
  break;
2952
  }
2953
  }
2954
+
2955
+ $automatic = $automatic_insertion != AI_AUTOMATIC_INSERTION_DISABLED;
2956
+ $manual_widget = $obj->get_enable_widget() == AI_ENABLED;
2957
+ $manual_shortcode = $obj->get_enable_manual() == AI_ENABLED;
2958
+ $manual_php_function = $obj->get_enable_php_call() == AI_ENABLED;
2959
+ if ($automatic || ($manual_widget && in_array ($block, $widget_blocks)) || $manual_shortcode || $manual_php_function) {
2960
+ $used_blocks ++;
2961
+ }
2962
  }
2963
 
2964
+ $extract [AI_EXTRACT_USED_BLOCKS] = $used_blocks;
2965
+
2966
  $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
2967
  $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
2968
  $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
2984
 
2985
  if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) &&
2986
  isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
2987
+ isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][POST_HOOK_BLOCKS]) &&
2988
+ isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
2989
+ isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
2990
+ isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][AI_EXTRACT_USED_BLOCKS]))
2991
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
2992
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
2993
 
3007
  $block_object [AI_HEADER_OPTION_NAME] = $adH;
3008
  $block_object [AI_FOOTER_OPTION_NAME] = $adF;
3009
 
3010
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
3011
+ $adA = new ai_AdA();
3012
+ $adA->load_options (AI_ADB_MESSAGE_OPTION_NAME);
3013
+ $block_object [AI_ADB_MESSAGE_OPTION_NAME] = $adA;
3014
+ $ai_wp_data [AI_ADB_DETECTION] = $adA->get_enable_manual ();
3015
+ }
3016
+
3017
+ if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
3018
+ $install = new DateTime (date('Y-m-d H:i:s', $install_timestamp));
3019
+ $now = new DateTime (date('Y-m-d H:i:s', time()));
3020
+ if (method_exists ($install, 'diff')) {
3021
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] = $install->diff ($now);
3022
+ $ai_wp_data [AI_DAYS_SINCE_INSTAL] = $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d;
3023
+ }
3024
+ }
3025
 
3026
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS END");
3027
  }
3231
 
3232
  $ai_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time ();
3233
 
3234
+ if (get_option (AI_INSTALL_NAME) === false) {
3235
+ update_option (AI_INSTALL_NAME, time ());
3236
+ }
3237
+
3238
  update_option (AI_OPTION_NAME, $ai_options);
3239
 
3240
  // Multisite
3270
  delete_option (AD_OPTIONS);
3271
 
3272
  delete_option (AI_OPTION_NAME);
3273
+
3274
  if (is_multisite () && is_main_site ()) {
3275
  delete_site_option (AI_OPTION_NAME, $options);
3276
  }
3277
 
3278
+ if (function_exists ('ai_load_globals')) {
3279
+ delete_option (WP_AD_INSERTER_PRO_LICENSE);
3280
+ $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
3281
+ }
3282
 
3283
  if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
3284
 
3569
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3570
  }
3571
 
3572
+
3573
+ if (function_exists ('ai_content')) ai_content ($content);
3574
+
3575
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
3576
  $style = AI_DEBUG_TAGS_STYLE;
3577
 
3595
  }
3596
 
3597
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
3598
+ $style = AI_DEBUG_POSITIONS_STYLE;
3599
 
3600
  if (!$positions_inserted) {
3601
  $preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
3609
  $counter = $ad_inserter_globals [$globals_name];
3610
  if ($counter == 1) $counter = '';
3611
 
3612
+ $content = "<section style='$style'><a style='float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> BEFORE CONTENT ".$counter."<a style='float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0;'>".$content_words." words</a></section>". $content;
3613
+
3614
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
3615
+ $content = get_page_type_debug_info ('AMP ') . $content;
3616
+ }
3617
 
3618
+ $content = $content . "<section style='$style'>AFTER CONTENT ".$counter."</section>";
3619
+
3620
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
3621
+ $content = $content . get_page_type_debug_info ('AMP ');
3622
+ }
3623
  }
3624
 
3625
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
3736
 
3737
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
3738
 
3739
+ // Not used on AMP pages (yet)
3740
+ if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
3741
+ if (!method_exists ($query, 'is_main_query')) return;
3742
+ if (!$query->is_main_query()) return;
3743
+ }
3744
 
3745
  $globals_name = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? AI_LOOP_BEFORE_COUNTER_NAME : AI_LOOP_AFTER_COUNTER_NAME;
3746
 
3757
 
3758
  $style = AI_DEBUG_POSITIONS_STYLE;
3759
 
3760
+ if ($ai_wp_data [AI_WP_AMP_PAGE] && $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) echo get_page_type_debug_info ('AMP ');
3761
  echo "<section style='$style'>".($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
3762
+ if ($ai_wp_data [AI_WP_AMP_PAGE] && $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) echo get_page_type_debug_info ('AMP ');
3763
  }
3764
 
3765
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
3849
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return;
3850
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return;
3851
 
3852
+ // Not used on AMP pages (yet)
3853
+ if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
3854
+ if (!in_the_loop()) return;
3855
+ }
3856
 
3857
  if (!isset ($ad_inserter_globals [AI_POST_COUNTER_NAME])) {
3858
  $ad_inserter_globals [AI_POST_COUNTER_NAME] = 0;
4174
  function process_shortcode (&$block, $atts) {
4175
  global $block_object, $ai_last_check, $ai_wp_data;
4176
 
4177
+ if ($atts == '') return '';
4178
+
4179
  $parameters = shortcode_atts (array (
4180
  "block" => "",
4181
  "name" => "",
4182
  "ignore" => "",
4183
+ "debugger" => "",
4184
+ "adb" => "",
4185
+ "css" => "",
4186
+ "text" => "",
4187
+ "selectors" => "",
4188
+ "amp" => "",
4189
+ "rotate" => "",
4190
+ "count" => "",
4191
  ), $atts);
4192
 
4193
+ $output = "";
4194
+ if (function_exists ('ai_shortcode')) {
4195
+ $output = ai_shortcode ($parameters);
4196
+ if ($output != '') return $output;
4197
+ }
4198
+
4199
  $block = - 1;
4200
  if (is_numeric ($parameters ['block'])) {
4201
  $block = intval ($parameters ['block']);
4213
  }
4214
  }
4215
 
4216
+ if ($block == - 1) {
4217
+ if ($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts)) {
4218
+ return AD_ROTATE_SEPARATOR;
4219
+ }
4220
+ if ($parameters ['count'] != '' || in_array ('COUNT', $atts) || in_array ('count', $atts)) {
4221
+ return AD_COUNT_SEPARATOR;
4222
+ }
4223
+ if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
4224
+ return AD_AMP_SEPARATOR;
4225
+ }
4226
+ }
4227
+
4228
  if ($block == 0) {
4229
  if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
4230
  ob_start ();
4275
  }
4276
  }
4277
 
4278
+ function process_shortcodes ($atts, $ai_shortcode_name) {
 
4279
  global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
4280
 
4281
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
4283
  $atts_string = '';
4284
  if (is_array ($atts))
4285
  foreach ($atts as $index => $att) {
4286
+ if (is_numeric ($index))
4287
+ $atts_string .= $att.' '; else
4288
+ $atts_string .= $index.("='".$att."'").' ';
4289
  }
4290
+ ai_log ("PROCESS SHORTCODES [$ai_shortcode_name ".trim ($atts_string).']');
4291
  $start_time = microtime (true);
4292
  }
4293
  $ai_last_check = AI_CHECK_NONE;
4303
  return $shortcode;
4304
  }
4305
 
4306
+ function process_shortcodes_lc ($atts) {
4307
+ return process_shortcodes ($atts, 'adinserter');
4308
+ }
4309
+
4310
+ function process_shortcodes_uc ($atts) {
4311
+ return process_shortcodes ($atts, 'ADINSERTER');
4312
+ }
4313
+
4314
 
4315
  class ai_widget extends WP_Widget {
4316
 
class.php CHANGED
@@ -9,19 +9,24 @@ abstract class ai_BaseCodeBlock {
9
  var $w3tc_code;
10
  var $needs_class;
11
  var $code_version;
 
12
 
13
  function __construct () {
14
 
 
 
15
  $this->wp_options = array ();
16
  $this->fallback = 0;
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;
@@ -240,25 +245,49 @@ abstract class ai_BaseCodeBlock {
240
  unset ($this->wp_options ['']);
241
  }
242
 
 
 
 
 
 
243
  public function get_ad_data(){
244
  $ad_data = isset ($this->wp_options [AI_OPTION_CODE]) ? $this->wp_options [AI_OPTION_CODE] : '';
245
  return $ad_data;
246
  }
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
  }
@@ -310,7 +339,7 @@ abstract class ai_BaseCodeBlock {
310
  }
311
 
312
  public function ai_getCode (){
313
- global $block_object, $ai_total_php_time;
314
 
315
  $obj = $this;
316
  if ($this->fallback != 0) {
@@ -320,27 +349,30 @@ abstract class ai_BaseCodeBlock {
320
  $code = $obj->get_ad_data();
321
 
322
  if ($obj->get_process_php () && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
323
- $start_time = microtime (true);
324
 
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
 
@@ -360,8 +392,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
360
 
361
  function __construct () {
362
 
363
- $this->number = 0;
364
-
365
  parent::__construct();
366
 
367
  $this->wp_options [AI_OPTION_BLOCK_NAME] = AD_NAME;
@@ -394,6 +424,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
394
  $this->wp_options [AI_OPTION_START_DATE] = AD_EMPTY_DATA;
395
  $this->wp_options [AI_OPTION_END_DATE] = AD_EMPTY_DATA;
396
  $this->wp_options [AI_OPTION_FALLBACK] = AD_EMPTY_DATA;
 
 
397
  $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_EMPTY_DATA;
398
  $this->wp_options [AI_OPTION_ID_LIST] = AD_EMPTY_DATA;
399
  $this->wp_options [AI_OPTION_ID_LIST_TYPE] = AD_BLACK_LIST;
@@ -421,8 +453,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
421
  $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AI_DISABLED;
422
  $this->wp_options [AI_OPTION_ENABLE_AJAX] = AI_ENABLED;
423
  $this->wp_options [AI_OPTION_ENABLE_FEED] = AI_DISABLED;
424
- $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AD_ENABLED_ON_ALL;
425
- $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AD_ENABLED_ON_ALL;
426
  $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AI_DISABLED;
427
  $this->wp_options [AI_OPTION_ENABLE_WIDGET] = AI_ENABLED;
428
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT] = AD_EMPTY_DATA;
@@ -638,6 +670,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
638
 
639
  public function get_paragraph_number_minimum(){
640
  $option = isset ($this->wp_options [AI_OPTION_MIN_PARAGRAPHS]) ? $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] : "";
 
641
  return $option;
642
  }
643
 
@@ -648,6 +681,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
648
 
649
  public function get_minimum_words(){
650
  $option = isset ($this->wp_options [AI_OPTION_MIN_WORDS]) ? $this->wp_options [AI_OPTION_MIN_WORDS] : "";
 
651
  return $option;
652
  }
653
 
@@ -663,6 +697,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
663
 
664
  public function get_minimum_paragraph_words(){
665
  $option = isset ($this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS]) ? $this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS] : "";
 
666
  return $option;
667
  }
668
 
@@ -717,6 +752,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
717
 
718
  public function get_call_filter(){
719
  $option = isset ($this->wp_options [AI_OPTION_EXCERPT_NUMBER]) ? $this->wp_options [AI_OPTION_EXCERPT_NUMBER] : "";
 
720
  return $option;
721
  }
722
 
@@ -900,11 +936,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
900
  return $enable_ajax;
901
  }
902
 
 
903
  public function get_enable_manual (){
904
- $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : "";
905
- if ($option == '') {
906
- $option = AI_DISABLED;
907
- }
908
  return $option;
909
  }
910
 
@@ -1073,6 +1110,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1073
 
1074
  $code = $this->ai_getCode ();
1075
 
 
 
1076
  if (strpos ($code, AD_COUNT_SEPARATOR) !== false) {
1077
  $ads = explode (AD_COUNT_SEPARATOR, $code);
1078
 
@@ -1085,8 +1124,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1085
  } else $code = $ads [rand (0, count ($ads) - 1)];
1086
  }
1087
 
1088
- $processed_code = do_shortcode ($this->replace_ai_tags ($code));
1089
-
1090
  $dynamic_blocks = get_dynamic_blocks ();
1091
  if ($force_server_side_code || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
1092
 
@@ -1096,7 +1133,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1096
  switch ($dynamic_blocks) {
1097
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
1098
  $this->code_version = mt_rand (1, count ($ads));
1099
- $processed_code = $ads [$this->code_version - 1];
1100
  break;
1101
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1102
  $this->code_version = '""';
@@ -1122,6 +1159,23 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1122
  }
1123
  }
1124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1125
  if ($dynamic_blocks != AI_DYNAMIC_BLOCKS_SERVER_SIDE) {
1126
  $countries = trim (str_replace (' ', '', strtoupper ($this->get_ad_country_list (true))));
1127
  $country_list_type = $this->get_ad_country_list_type ();
@@ -1170,80 +1224,101 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1170
  }
1171
 
1172
 
1173
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1174
 
1175
- $adb_action = 2;
1176
- switch ($adb_action) {
1177
- case 1: // Replacement ad
1178
 
1179
- $globals_name = AI_ADB_FALLBACK_DEPTH_NAME;
1180
- if (!isset ($ad_inserter_globals [$globals_name])) {
1181
- $ad_inserter_globals [$globals_name] = 0;
1182
- }
 
 
 
 
 
 
 
 
 
 
 
1183
 
1184
- $fallback_block = 4;
1185
- if ($fallback_block != 0 && $fallback_block <= AD_INSERTER_BLOCKS && $fallback_block != $this->number && $ad_inserter_globals [$globals_name] < 2) {
1186
- $ad_inserter_globals [$globals_name] ++;
 
 
 
 
 
 
1187
 
1188
- $fallback_obj = $block_object [$fallback_block];
1189
 
1190
- $processed_code = "<div>\n" . $processed_code ."</div>\n";
 
1191
 
1192
- $fallback_code = $fallback_obj->ai_getProcessedCode (true);
 
 
1193
 
1194
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
 
1195
 
1196
- $color = '#e0e';
1197
 
1198
- $title = '';
1199
- $counters = $fallback_obj->ai_get_counters ($title);
 
 
 
 
 
 
 
1200
 
1201
- if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($fallback_obj->number); else $url_parameters = "";
1202
- $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $fallback_obj->number;
1203
 
1204
- $fallback_code = '<section style="border: 1px solid '.$color.';"><section style="padding: 1px 0 1px 5px; background: '.$color.'; color: white; font-size: 12px; text-align: left;"><a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'
1205
- . $url . '"><kbd style="display: none">[AI]</kbd>' . $fallback_obj->number . ' &nbsp; ' . $fallback_obj->get_ad_name () .'</a> &nbsp;&#8678;&nbsp; AD BLOCKING<a style="float: right; text-decoration: none; color: white; padding: 0px 10px 0 0;"><kbd title="'.$title.'">'.$counters.'</kbd><kbd style="display: none">[/AI]</kbd></a></section>' . $fallback_code . '</section>';
1206
- }
 
 
 
 
1207
 
1208
- $processed_code .= "<div class='ai-adb-show' style='visibility: hidden; display: none;' data='$this->number <= $fallback_obj->number'>\n" . $fallback_code ."</div>\n";
 
1209
 
1210
- $ad_inserter_globals [$globals_name] --;
1211
- }
 
 
 
 
 
 
1212
 
1213
- break;
1214
- case 2: // Show
1215
- $processed_code = "<div class='ai-adb-show' style='visibility: hidden; display: none;' data='$this->number'>\n" . $processed_code ."</div>\n";
1216
- break;
1217
- case 3: // Hide
1218
- $processed_code = "<div class='ai-adb-hide' data='$this->number'>\n" . $processed_code ."</div>\n";
1219
- break;
1220
  }
1221
 
1222
- }
1223
 
 
1224
 
1225
- $title = '';
1226
- $fallback_code = '';
1227
- $color = '#e00';
1228
- if ($this->fallback != 0) {
1229
- $color = '#e0e';
1230
- $fallback_block = $block_object [$this->fallback];
1231
- if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($fallback_block->number); else $url_parameters = "";
1232
- $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $fallback_block->number;
1233
- $fallback_code = ' &nbsp;&#8678;&nbsp; '.
1234
- '<a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'. $url . '"><kbd style="display: none">[AI]</kbd>' . $this->fallback . ' &nbsp; ' . $fallback_block->get_ad_name () .'</a>';
1235
- }
1236
- $counters = $this->ai_get_counters ($title);
1237
 
1238
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
1239
- if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
1240
- $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
1241
 
1242
- $processed_code = '<section style="border: 1px solid '.$color.';"><section style="padding: 1px 0 1px 5px; background: '.$color.'; color: white; font-size: 12px; text-align: left;"><a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'
1243
- . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' &nbsp; ' . $this->get_ad_name () .'</a>'.$fallback_code.'<a style="float: right; text-decoration: none; color: white; padding: 0px 10px 0 0;"><kbd title="'.$title.'">'.$counters.'</kbd><kbd style="display: none">[/AI]</kbd></a></section>' . $processed_code . '</section>';
1244
- }
1245
 
1246
- return $processed_code;
 
 
 
 
 
1247
  }
1248
 
1249
  public function get_ad_general_tag(){
@@ -1252,6 +1327,16 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1252
  return $option;
1253
  }
1254
 
 
 
 
 
 
 
 
 
 
 
1255
  public function get_scheduling(){
1256
  $option = isset ($this->wp_options [AI_OPTION_SCHEDULING]) ? $this->wp_options [AI_OPTION_SCHEDULING] : "";
1257
 
@@ -1266,6 +1351,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1266
  public function get_ad_after_day(){
1267
  $option = isset ($this->wp_options [AI_OPTION_AFTER_DAYS]) ? $this->wp_options [AI_OPTION_AFTER_DAYS] : "";
1268
  // if ($option == '') $option = AD_ZERO;
 
 
 
1269
  return $option;
1270
  }
1271
 
@@ -1286,6 +1374,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1286
 
1287
  public function get_maximum_insertions (){
1288
  $option = isset ($this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS]) ? $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] : "";
 
1289
  return $option;
1290
  }
1291
 
@@ -1356,7 +1445,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1356
  return $option;
1357
  }
1358
 
1359
- public function get_ad_name(){
1360
  $option = isset ($this->wp_options [AI_OPTION_BLOCK_NAME]) ? $this->wp_options [AI_OPTION_BLOCK_NAME] : "";
1361
  if ($option == '') $option = AD_NAME. " " . $this->number;
1362
  return $option;
@@ -1403,17 +1492,65 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1403
  }
1404
 
1405
  public function get_ad_enabled_on_which_pages (){
1406
- $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] : "";
1407
- if ($option == '') $option = AD_ENABLED_ON_ALL;
 
 
 
 
 
 
 
1408
  return $option;
1409
  }
1410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1411
  public function get_ad_enabled_on_which_posts (){
1412
- $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] : "";
1413
- if ($option == '') $option = AD_ENABLED_ON_ALL;
 
 
 
 
 
 
 
1414
  return $option;
1415
  }
1416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1417
  public function get_viewport_classes (){
1418
  $viewport_classes = "";
1419
  if ($this->get_detection_client_side ()) {
@@ -1430,77 +1567,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1430
  return ($viewport_classes);
1431
  }
1432
 
1433
- public function get_code_for_insertion ($include_viewport_classes = true, $hidden_widgets = false) {
1434
- global $ai_wp_data;
1435
-
1436
- if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1437
-
1438
- $hidden_blocks = '';
1439
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $this->get_detection_client_side()) {
1440
-
1441
- $title = '';
1442
- $counters = $this->ai_get_counters ($title);
1443
-
1444
- if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
1445
- $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
1446
-
1447
- $hidden_block_text = '<section style="text-align: center; font-weight: bold;">'.($hidden_widgets ? 'WIDGET':'BLOCK').' INSERTED BUT NOT VISIBLE</section>';
1448
-
1449
- $visible_blocks = '';
1450
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1451
- $viewport_name = get_viewport_name ($viewport);
1452
- if ($viewport_name != '') {
1453
- if ($this->get_detection_viewport ($viewport))
1454
- $visible_blocks .= '<section class="ai-viewport-' . $viewport .'" style=""><section style="padding: 1px 0 1px 5px; text-align: center; background: red; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">'.$viewport_name.'</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section><section>'; else
1455
- $hidden_blocks .= '<section class="ai-viewport-' . $viewport .'" style="' . $this->get_alignment_style() . '; border: 1px solid blue;"><section style="padding: 1px 0 1px 5px; text-align: center; background: blue; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">'.$viewport_name.'</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
1456
- }
1457
- }
1458
-
1459
- $code = "<div style='border: 1px solid red;'>".$visible_blocks.$this->ai_getProcessedCode (true).'</div>';
1460
- } else $code = $this->ai_getProcessedCode ();
1461
-
1462
- $block_class_name = get_block_class_name ();
1463
- if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1464
- $viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
1465
- if ($block_class_name != '' || $viewport_classes != '') {
1466
- if ($block_class_name == '') $viewport_classes = trim ($viewport_classes);
1467
- $class = " class='" . ($block_class_name != '' ? $block_class_name . " " . $block_class_name . "-" . $this->number : '') . $viewport_classes ."'";
1468
- } else $class = '';
1469
-
1470
- if ($hidden_widgets) return $hidden_blocks; else {
1471
- 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 = '';
1472
-
1473
- $tracking_code_pre = '';
1474
- $tracking_code_data = '';
1475
- $tracking_code_post = '';
1476
- $tracking_code = '';
1477
- if ($this->get_tracking ()) {
1478
- $tracking_code_pre = " data-ai='";
1479
- $tracking_code_data = "[{$this->number},{$this->code_version}]";
1480
- $tracking_code_post = "'";
1481
-
1482
- $tracking_code = $tracking_code_pre . base64_encode ($tracking_code_data) . $tracking_code_post;
1483
- }
1484
-
1485
- $wrapper_before = $hidden_blocks . "<div" . $class . $tracking_code . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1486
-
1487
- $wrapper_after = "</div>\n";
1488
-
1489
- if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
1490
-
1491
- if ($this->get_tracking ()) $tracking_code_data = '[#AI_DATA#]';
1492
-
1493
- $wrapper_before = $hidden_blocks . "<div" . $class . $tracking_code_pre . $tracking_code_data . $tracking_code_post . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1494
-
1495
- $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1496
- $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)).'\'));';
1497
- $code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1498
- return $code;
1499
- } else return $wrapper_before . $code . $wrapper_after;
1500
- }
1501
- }
1502
-
1503
-
1504
  public function before_paragraph ($content, $position_preview = false) {
1505
  global $ai_wp_data, $ai_last_check, $special_element_tags;
1506
 
@@ -2477,26 +2543,29 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2477
  }
2478
 
2479
  function check_category () {
 
2480
 
2481
  $categories = trim (strtolower ($this->get_ad_block_cat()));
2482
  $cat_type = $this->get_ad_block_cat_type();
2483
 
 
 
2484
  if ($cat_type == AD_BLACK_LIST) {
2485
 
2486
  if($categories == AD_EMPTY_DATA) return true;
2487
 
2488
  $cats_listed = explode (",", $categories);
2489
 
2490
- foreach (get_the_category() as $post_category) {
2491
 
2492
  foreach ($cats_listed as $cat_disabled){
2493
 
2494
  $cat_disabled = trim ($cat_disabled);
2495
 
2496
- $post_category_name = strtolower ($post_category->cat_name);
2497
- $post_category_slug = strtolower ($post_category->slug);
2498
 
2499
- if ($post_category_name == $cat_disabled || $post_category_slug == $cat_disabled) {
2500
  return false;
2501
  } else {
2502
  }
@@ -2510,16 +2579,16 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2510
 
2511
  $cats_listed = explode (",", $categories);
2512
 
2513
- foreach (get_the_category() as $post_category) {
2514
 
2515
  foreach ($cats_listed as $cat_enabled) {
2516
 
2517
  $cat_enabled = trim ($cat_enabled);
2518
 
2519
- $post_category_name = strtolower ($post_category->cat_name);
2520
- $post_category_slug = strtolower ($post_category->slug);
2521
 
2522
- if ($post_category_name == $cat_enabled || $post_category_slug == $cat_enabled) {
2523
  return true;
2524
  } else {
2525
  }
@@ -2760,7 +2829,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2760
  case AI_SCHEDULING_DELAY:
2761
  $after_days = trim ($this->get_ad_after_day());
2762
  if ($after_days == '') return true;
2763
- if (intval ($after_days) == AD_ZERO) return true;
 
2764
 
2765
  $post_date = get_the_date ('U');
2766
  if ($post_date === false) return true;
@@ -2937,26 +3007,26 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2937
  // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
2938
  // $selected_blocks = explode (",", $meta_value);
2939
 
2940
- $enabled_on_text = $this->get_ad_enabled_on_which_posts ();
2941
- if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
2942
- $ai_last_check = AI_CHECK_ENABLED_ON_ALL_EXCEPT_ON_SELECTED;
2943
  if (in_array ($this->number, $selected_blocks)) return false;
2944
  }
2945
- elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
2946
- $ai_last_check = AI_CHECK_ENABLED_ONLY_ON_SELECTED;
2947
  if (!in_array ($this->number, $selected_blocks)) return false;
2948
  }
2949
  } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
2950
  // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
2951
  // $selected_blocks = explode (",", $meta_value);
2952
 
2953
- $enabled_on_text = $this->get_ad_enabled_on_which_pages ();
2954
- if ($enabled_on_text == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) {
2955
- $ai_last_check = AI_CHECK_ENABLED_ON_ALL_EXCEPT_ON_SELECTED;
2956
  if (in_array ($this->number, $selected_blocks)) return false;
2957
  }
2958
- elseif ($enabled_on_text == AD_ENABLED_ONLY_ON_SELECTED) {
2959
- $ai_last_check = AI_CHECK_ENABLED_ONLY_ON_SELECTED;
2960
  if (!in_array ($this->number, $selected_blocks)) return false;
2961
  }
2962
  }
@@ -3259,6 +3329,8 @@ class ai_AdH extends ai_BaseCodeBlock {
3259
 
3260
  public function __construct () {
3261
  parent::__construct();
 
 
3262
  }
3263
  }
3264
 
@@ -3266,6 +3338,8 @@ class ai_AdF extends ai_BaseCodeBlock {
3266
 
3267
  public function __construct () {
3268
  parent::__construct();
 
 
3269
  }
3270
  }
3271
 
@@ -3274,6 +3348,7 @@ class ai_AdA extends ai_BaseCodeBlock {
3274
  public function __construct () {
3275
  parent::__construct();
3276
 
 
3277
  $this->wp_options [AI_OPTION_CODE] = AI_DEFAULT_ADB_MESSAGE;
3278
  }
3279
  }
9
  var $w3tc_code;
10
  var $needs_class;
11
  var $code_version;
12
+ var $debug_code;
13
 
14
  function __construct () {
15
 
16
+ $this->number = 0;
17
+
18
  $this->wp_options = array ();
19
  $this->fallback = 0;
20
  $this->client_side_ip_address_detection = false;
21
  $this->w3tc_code = '';
22
  $this->needs_class = false;
23
  $this->code_version = 0;
24
+ $this->color = '#e00';
25
 
26
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
27
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AI_DISABLED;
28
  $this->wp_options [AI_OPTION_ENABLE_MANUAL] = AI_DISABLED;
29
+ $this->wp_options [AI_OPTION_ENABLE_AMP] = AI_DISABLED;
30
  $this->wp_options [AI_OPTION_ENABLE_404] = AI_DISABLED;
31
  $this->wp_options [AI_OPTION_DETECT_SERVER_SIDE] = AI_DISABLED;
32
  $this->wp_options [AI_OPTION_DISPLAY_FOR_DEVICES] = AD_DISPLAY_DESKTOP_DEVICES;
245
  unset ($this->wp_options ['']);
246
  }
247
 
248
+ public function get_ad_name(){
249
+ $name = isset ($this->wp_options [AI_OPTION_BLOCK_NAME]) ? $this->wp_options [AI_OPTION_BLOCK_NAME] : "";
250
+ return $name;
251
+ }
252
+
253
  public function get_ad_data(){
254
  $ad_data = isset ($this->wp_options [AI_OPTION_CODE]) ? $this->wp_options [AI_OPTION_CODE] : '';
255
  return $ad_data;
256
  }
257
 
258
  public function get_enable_manual (){
259
+ $enable_manual = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : AI_DISABLED;
260
  if ($enable_manual == '') $enable_manual = AI_DISABLED;
261
  return $enable_manual;
262
  }
263
 
264
+ public function get_enable_amp ($return_saved_value = false){
265
+ $enable_amp = isset ($this->wp_options [AI_OPTION_ENABLE_AMP]) ? $this->wp_options [AI_OPTION_ENABLE_AMP] : AI_DISABLED;
266
+
267
+ if ($return_saved_value) return $enable_amp;
268
+
269
+ // Fix for AMP code blocks with url white-list */amp
270
+ $urls = $this->get_ad_url_list();
271
+ $url_type = $this->get_ad_url_list_type();
272
+ if ($url_type == AD_WHITE_LIST && strpos ($urls, '/amp') !== false) {
273
+ $enable_amp = true;
274
+ }
275
+ // Fix for code blocks using PHP function is_amp_endpoint
276
+ elseif ($this->get_process_php() && strpos ($this->get_ad_data (), 'is_amp_endpoint') !== false) {
277
+ $enable_amp = true;
278
+ }
279
+
280
+ return $enable_amp;
281
+ }
282
+
283
  public function get_process_php (){
284
+ $process_php = isset ($this->wp_options [AI_OPTION_PROCESS_PHP]) ? $this->wp_options [AI_OPTION_PROCESS_PHP] : AI_DISABLED;
285
  if ($process_php == '') $process_php = AI_DISABLED;
286
  return $process_php;
287
  }
288
 
289
  public function get_enable_404 (){
290
+ $enable_404 = isset ($this->wp_options [AI_OPTION_ENABLE_404]) ? $this->wp_options [AI_OPTION_ENABLE_404] : AI_DISABLED;
291
  if ($enable_404 == '') $enable_404 = AI_DISABLED;
292
  return $enable_404;
293
  }
339
  }
340
 
341
  public function ai_getCode (){
342
+ global $block_object, $ai_total_php_time, $ai_wp_data;
343
 
344
  $obj = $this;
345
  if ($this->fallback != 0) {
349
  $code = $obj->get_ad_data();
350
 
351
  if ($obj->get_process_php () && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
 
352
 
353
  $global_name = 'GENERATED_CODE';
354
  if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
355
 
356
+ $start_time = microtime (true);
357
+
358
  $php_error = "";
359
  ob_start ();
360
 
361
  try {
362
  eval ("?>". $code . "<?php ");
363
  } catch (Exception $e) {
364
+ $php_error = "PHP error in " . AD_INSERTER_NAME . " code block ". ($obj->number == 0 ? '' : $obj->number . " - ") . $obj->get_ad_name() . "<br />\n" . $e->getMessage();
365
  }
366
 
367
  $processed_code = ob_get_clean ();
368
 
369
  if (strpos ($processed_code, __FILE__) || $php_error != "") {
370
+
371
+ if (preg_match ("%(.+) in ".__FILE__."%", strip_tags($processed_code), $error_message))
372
+ $code = "PHP error in " . AD_INSERTER_NAME . " code block ". ($obj->number == 0 ? '' : $obj->number . " - ") . $obj->get_ad_name() . "<br />\n" . $error_message [1];
373
  elseif (preg_match ("%(.+) in ".__FILE__."%", $php_error, $error_message))
374
+ $code = "PHP error in " . AD_INSERTER_NAME . " code block ". ($obj->number == 0 ? '' : $obj->number . " - ") . $obj->get_ad_name() . "<br />\n" . $error_message [1];
375
+
376
  else $code = $processed_code;
377
  } else $code = $processed_code;
378
 
392
 
393
  function __construct () {
394
 
 
 
395
  parent::__construct();
396
 
397
  $this->wp_options [AI_OPTION_BLOCK_NAME] = AD_NAME;
424
  $this->wp_options [AI_OPTION_START_DATE] = AD_EMPTY_DATA;
425
  $this->wp_options [AI_OPTION_END_DATE] = AD_EMPTY_DATA;
426
  $this->wp_options [AI_OPTION_FALLBACK] = AD_EMPTY_DATA;
427
+ $this->wp_options [AI_OPTION_ADB_BLOCK_ACTION] = DEFAULT_ADB_BLOCK_ACTION;
428
+ $this->wp_options [AI_OPTION_ADB_BLOCK_REPLACEMENT] = AD_EMPTY_DATA;
429
  $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_EMPTY_DATA;
430
  $this->wp_options [AI_OPTION_ID_LIST] = AD_EMPTY_DATA;
431
  $this->wp_options [AI_OPTION_ID_LIST_TYPE] = AD_BLACK_LIST;
453
  $this->wp_options [AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES] = AI_DISABLED;
454
  $this->wp_options [AI_OPTION_ENABLE_AJAX] = AI_ENABLED;
455
  $this->wp_options [AI_OPTION_ENABLE_FEED] = AI_DISABLED;
456
+ $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] = AI_NO_INDIVIDUAL_EXCEPTIONS;
457
+ $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] = AI_NO_INDIVIDUAL_EXCEPTIONS;
458
  $this->wp_options [AI_OPTION_ENABLE_PHP_CALL] = AI_DISABLED;
459
  $this->wp_options [AI_OPTION_ENABLE_WIDGET] = AI_ENABLED;
460
  $this->wp_options [AI_OPTION_PARAGRAPH_TEXT] = AD_EMPTY_DATA;
670
 
671
  public function get_paragraph_number_minimum(){
672
  $option = isset ($this->wp_options [AI_OPTION_MIN_PARAGRAPHS]) ? $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] : "";
673
+ if ($option == '0') $option = '';
674
  return $option;
675
  }
676
 
681
 
682
  public function get_minimum_words(){
683
  $option = isset ($this->wp_options [AI_OPTION_MIN_WORDS]) ? $this->wp_options [AI_OPTION_MIN_WORDS] : "";
684
+ if ($option == '0') $option = '';
685
  return $option;
686
  }
687
 
697
 
698
  public function get_minimum_paragraph_words(){
699
  $option = isset ($this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS]) ? $this->wp_options [AI_OPTION_MIN_PARAGRAPH_WORDS] : "";
700
+ if ($option == '0') $option = '';
701
  return $option;
702
  }
703
 
752
 
753
  public function get_call_filter(){
754
  $option = isset ($this->wp_options [AI_OPTION_EXCERPT_NUMBER]) ? $this->wp_options [AI_OPTION_EXCERPT_NUMBER] : "";
755
+ if ($option == '0') $option = '';
756
  return $option;
757
  }
758
 
936
  return $enable_ajax;
937
  }
938
 
939
+ // Used for shortcodes
940
  public function get_enable_manual (){
941
+ $option = isset ($this->wp_options [AI_OPTION_ENABLE_MANUAL]) ? $this->wp_options [AI_OPTION_ENABLE_MANUAL] : AI_DISABLED;
942
+
943
+ if ($option == '') $option = AI_DISABLED;
944
+
945
  return $option;
946
  }
947
 
1110
 
1111
  $code = $this->ai_getCode ();
1112
 
1113
+ $processed_code = do_shortcode ($this->replace_ai_tags ($code));
1114
+
1115
  if (strpos ($code, AD_COUNT_SEPARATOR) !== false) {
1116
  $ads = explode (AD_COUNT_SEPARATOR, $code);
1117
 
1124
  } else $code = $ads [rand (0, count ($ads) - 1)];
1125
  }
1126
 
 
 
1127
  $dynamic_blocks = get_dynamic_blocks ();
1128
  if ($force_server_side_code || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
1129
 
1133
  switch ($dynamic_blocks) {
1134
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
1135
  $this->code_version = mt_rand (1, count ($ads));
1136
+ $processed_code = trim ($ads [$this->code_version - 1]);
1137
  break;
1138
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1139
  $this->code_version = '""';
1159
  }
1160
  }
1161
 
1162
+ $this->color = '#e00';
1163
+
1164
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1165
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1166
+ $code_index = $ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0;
1167
+ $this->color = $code_index ? '#0c0' : '#e00';
1168
+ $processed_code = trim ($codes [$code_index]);
1169
+ } else {
1170
+ // AMP page but No AMP separator - don't insert code unless enabled
1171
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1172
+ if (!$this->get_enable_amp ()) {
1173
+ $processed_code = '';
1174
+ $this->color = '#222';
1175
+ } else $this->color = '#0c0';
1176
+ }
1177
+ }
1178
+
1179
  if ($dynamic_blocks != AI_DYNAMIC_BLOCKS_SERVER_SIDE) {
1180
  $countries = trim (str_replace (' ', '', strtoupper ($this->get_ad_country_list (true))));
1181
  $country_list_type = $this->get_ad_country_list_type ();
1224
  }
1225
 
1226
 
 
1227
 
1228
+ if (function_exists ('ai_adb_block_actions')) $url_parameters = ai_adb_block_actions ($this, $processed_code);
 
 
1229
 
1230
+ $title = '';
1231
+ $fallback_code = '';
1232
+ if ($this->fallback != 0) {
1233
+ $this->color = '#a0f';
1234
+ $fallback_block = $block_object [$this->fallback];
1235
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($fallback_block->number); else $url_parameters = "";
1236
+ $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $fallback_block->number;
1237
+ $fallback_code = ' &nbsp;&#8678;&nbsp; '.
1238
+ '<a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'. $url . '"><kbd style="display: none">[AI]</kbd>' . $this->fallback . ' &nbsp; ' . $fallback_block->get_ad_name () .'</a>';
1239
+ }
1240
+ $counters = $this->ai_get_counters ($title);
1241
+
1242
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
1243
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
1244
+ $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
1245
 
1246
+ $processed_code = '<section style="border: 1px solid '.$this->color.';"><section style="padding: 1px 0 1px 5px; background: '.$this->color.'; color: white; font-size: 12px; text-align: left;"><a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'
1247
+ . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' &nbsp; ' . $this->get_ad_name () .'</a>&nbsp;'.$fallback_code.'<a style="float: right; text-decoration: none; color: white; padding: 0px 10px 0 0;"><kbd title="'.$title.'">'.$counters.'</kbd><kbd style="display: none">[/AI]</kbd></a></section>' . $processed_code . '</section>';
1248
+ }
1249
+
1250
+ return $processed_code;
1251
+ }
1252
+
1253
+ public function get_code_for_insertion ($include_viewport_classes = true, $hidden_widgets = false) {
1254
+ global $ai_wp_data;
1255
 
1256
+ if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1257
 
1258
+ $hidden_viewports = '';
1259
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $this->get_detection_client_side()) {
1260
 
1261
+ $processed_code = $this->ai_getProcessedCode (true);
1262
+ $title = '';
1263
+ $counters = $this->ai_get_counters ($title);
1264
 
1265
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
1266
+ $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
1267
 
1268
+ $hidden_block_text = '<section style="text-align: center; font-weight: bold;">&nbsp;'.($hidden_widgets ? 'WIDGET':'BLOCK').' INSERTED BUT NOT VISIBLE&nbsp;</section>';
1269
 
1270
+ $visible_viewports = '';
1271
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1272
+ $viewport_name = get_viewport_name ($viewport);
1273
+ if ($viewport_name != '') {
1274
+ if ($this->get_detection_viewport ($viewport))
1275
+ $visible_viewports .= '<section class="ai-viewport-' . $viewport .'" style=""><section style="padding: 1px 0 1px 5px; text-align: center; background: '.$this->color.'; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">&nbsp;'.$viewport_name.'&nbsp;</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section></section>'; else
1276
+ $hidden_viewports .= '<section class="ai-viewport-' . $viewport .'" style="' . $this->get_alignment_style() . '; border: 1px solid blue;"><section style="padding: 1px 0 1px 5px; text-align: center; background: blue; color: white; font-size: 12px;"><a style="float: left; text-decoration: none; color: white;" title="Click to go to block settings" href="' . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' ' . $this->get_ad_name () .'</a><a style="text-decoration: none; color: white;">&nbsp;'.$viewport_name.'&nbsp;</a><a style="float: right; text-decoration: none; color: white; padding-right: 5px;" title="'.$title.'">'.$counters.'<kbd style="display: none">[/AI]</kbd></a></section>' . $hidden_block_text . '</section>';
1277
+ }
1278
+ }
1279
 
1280
+ $code = "<div style='border: 1px solid " . $this->color . ";'>".$visible_viewports . $processed_code.'</div>';
1281
+ } else $code = $this->ai_getProcessedCode ();
1282
 
1283
+ $block_class_name = get_block_class_name ();
1284
+ if ($block_class_name == '' && $this->needs_class) $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1285
+ $viewport_classes = $include_viewport_classes ? $this->get_viewport_classes () : "";
1286
+ if ($block_class_name != '' || $viewport_classes != '') {
1287
+ if ($block_class_name == '') $viewport_classes = trim ($viewport_classes);
1288
+ $class = " class='" . ($block_class_name != '' ? $block_class_name . " " . $block_class_name . "-" . $this->number : '') . $viewport_classes ."'";
1289
+ } else $class = '';
1290
 
1291
+ if ($hidden_widgets) return $hidden_viewports; else {
1292
+ 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 = '';
1293
 
1294
+ $tracking_code_pre = '';
1295
+ $tracking_code_data = '';
1296
+ $tracking_code_post = '';
1297
+ $tracking_code = '';
1298
+ if ($this->get_tracking ()) {
1299
+ $tracking_code_pre = " data-ai='";
1300
+ $tracking_code_data = "[{$this->number},{$this->code_version}]";
1301
+ $tracking_code_post = "'";
1302
 
1303
+ $tracking_code = $tracking_code_pre . base64_encode ($tracking_code_data) . $tracking_code_post;
 
 
 
 
 
 
1304
  }
1305
 
1306
+ $wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1307
 
1308
+ $wrapper_after = "</div>\n";
1309
 
1310
+ if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
 
 
 
 
 
 
 
 
 
 
 
1311
 
1312
+ if ($this->get_tracking ()) $tracking_code_data = '[#AI_DATA#]';
 
 
1313
 
1314
+ $wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code_pre . $tracking_code_data . $tracking_code_post . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
 
 
1315
 
1316
+ $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1317
+ $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)).'\'));';
1318
+ $code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1319
+ return $code;
1320
+ } else return $wrapper_before . $code . $wrapper_after;
1321
+ }
1322
  }
1323
 
1324
  public function get_ad_general_tag(){
1327
  return $option;
1328
  }
1329
 
1330
+ public function get_adb_block_action (){
1331
+ $option = isset ($this->wp_options [AI_OPTION_ADB_BLOCK_ACTION]) ? $this->wp_options [AI_OPTION_ADB_BLOCK_ACTION] : DEFAULT_ADB_BLOCK_ACTION;
1332
+ return $option;
1333
+ }
1334
+
1335
+ public function get_adb_block_replacement (){
1336
+ $option = isset ($this->wp_options [AI_OPTION_ADB_BLOCK_REPLACEMENT]) ? $this->wp_options [AI_OPTION_ADB_BLOCK_REPLACEMENT] : AD_EMPTY_DATA;
1337
+ return $option;
1338
+ }
1339
+
1340
  public function get_scheduling(){
1341
  $option = isset ($this->wp_options [AI_OPTION_SCHEDULING]) ? $this->wp_options [AI_OPTION_SCHEDULING] : "";
1342
 
1351
  public function get_ad_after_day(){
1352
  $option = isset ($this->wp_options [AI_OPTION_AFTER_DAYS]) ? $this->wp_options [AI_OPTION_AFTER_DAYS] : "";
1353
  // if ($option == '') $option = AD_ZERO;
1354
+
1355
+ if ($option == '0') $option = '';
1356
+
1357
  return $option;
1358
  }
1359
 
1374
 
1375
  public function get_maximum_insertions (){
1376
  $option = isset ($this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS]) ? $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] : "";
1377
+ if ($option == '0') $option = '';
1378
  return $option;
1379
  }
1380
 
1445
  return $option;
1446
  }
1447
 
1448
+ public function get_ad_name(){
1449
  $option = isset ($this->wp_options [AI_OPTION_BLOCK_NAME]) ? $this->wp_options [AI_OPTION_BLOCK_NAME] : "";
1450
  if ($option == '') $option = AD_NAME. " " . $this->number;
1451
  return $option;
1492
  }
1493
 
1494
  public function get_ad_enabled_on_which_pages (){
1495
+ $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] : AI_NO_INDIVIDUAL_EXCEPTIONS;
1496
+
1497
+ if ($option == '') $option = AI_NO_INDIVIDUAL_EXCEPTIONS;
1498
+
1499
+ elseif ($option == AD_ENABLED_ON_ALL) $option = AI_NO_INDIVIDUAL_EXCEPTIONS;
1500
+ elseif ($option == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) $option = AI_INDIVIDUALLY_DISABLED;
1501
+ elseif ($option == AD_ENABLED_ONLY_ON_SELECTED) $option = AI_INDIVIDUALLY_ENABLED;
1502
+
1503
+ // return AI_INDIVIDUALLY_DISABLED;
1504
  return $option;
1505
  }
1506
 
1507
+ public function get_ad_enabled_on_which_pages_text (){
1508
+ switch ($this->get_ad_enabled_on_which_pages ()) {
1509
+ case AI_NO_INDIVIDUAL_EXCEPTIONS:
1510
+ return AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS;
1511
+ break;
1512
+ case AI_INDIVIDUALLY_DISABLED:
1513
+ return AI_TEXT_INDIVIDUALLY_DISABLED;
1514
+ break;
1515
+ case AI_INDIVIDUALLY_ENABLED:
1516
+ return AI_TEXT_INDIVIDUALLY_ENABLED;
1517
+ break;
1518
+ default:
1519
+ return '';
1520
+ break;
1521
+ }
1522
+ }
1523
+
1524
  public function get_ad_enabled_on_which_posts (){
1525
+ $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS] : AI_NO_INDIVIDUAL_EXCEPTIONS;
1526
+
1527
+ if ($option == '') $option = AI_NO_INDIVIDUAL_EXCEPTIONS;
1528
+
1529
+ elseif ($option == AD_ENABLED_ON_ALL) $option = AI_NO_INDIVIDUAL_EXCEPTIONS;
1530
+ elseif ($option == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) $option = AI_INDIVIDUALLY_DISABLED;
1531
+ elseif ($option == AD_ENABLED_ONLY_ON_SELECTED) $option = AI_INDIVIDUALLY_ENABLED;
1532
+
1533
+ // return AI_INDIVIDUALLY_DISABLED;
1534
  return $option;
1535
  }
1536
 
1537
+ public function get_ad_enabled_on_which_posts_text (){
1538
+ switch ($this->get_ad_enabled_on_which_posts ()) {
1539
+ case AI_NO_INDIVIDUAL_EXCEPTIONS:
1540
+ return AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS;
1541
+ break;
1542
+ case AI_INDIVIDUALLY_DISABLED:
1543
+ return AI_TEXT_INDIVIDUALLY_DISABLED;
1544
+ break;
1545
+ case AI_INDIVIDUALLY_ENABLED:
1546
+ return AI_TEXT_INDIVIDUALLY_ENABLED;
1547
+ break;
1548
+ default:
1549
+ return '';
1550
+ break;
1551
+ }
1552
+ }
1553
+
1554
  public function get_viewport_classes (){
1555
  $viewport_classes = "";
1556
  if ($this->get_detection_client_side ()) {
1567
  return ($viewport_classes);
1568
  }
1569
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1570
  public function before_paragraph ($content, $position_preview = false) {
1571
  global $ai_wp_data, $ai_last_check, $special_element_tags;
1572
 
2543
  }
2544
 
2545
  function check_category () {
2546
+ global $ai_wp_data;
2547
 
2548
  $categories = trim (strtolower ($this->get_ad_block_cat()));
2549
  $cat_type = $this->get_ad_block_cat_type();
2550
 
2551
+ $wp_categories = get_the_category ();
2552
+
2553
  if ($cat_type == AD_BLACK_LIST) {
2554
 
2555
  if($categories == AD_EMPTY_DATA) return true;
2556
 
2557
  $cats_listed = explode (",", $categories);
2558
 
2559
+ foreach ($wp_categories as $wp_category) {
2560
 
2561
  foreach ($cats_listed as $cat_disabled){
2562
 
2563
  $cat_disabled = trim ($cat_disabled);
2564
 
2565
+ $wp_category_name = strtolower ($wp_category->cat_name);
2566
+ $wp_category_slug = strtolower ($wp_category->slug);
2567
 
2568
+ if ($wp_category_name == $cat_disabled || $wp_category_slug == $cat_disabled) {
2569
  return false;
2570
  } else {
2571
  }
2579
 
2580
  $cats_listed = explode (",", $categories);
2581
 
2582
+ foreach ($wp_categories as $wp_category) {
2583
 
2584
  foreach ($cats_listed as $cat_enabled) {
2585
 
2586
  $cat_enabled = trim ($cat_enabled);
2587
 
2588
+ $wp_category_name = strtolower ($wp_category->cat_name);
2589
+ $wp_category_slug = strtolower ($wp_category->slug);
2590
 
2591
+ if ($wp_category_name == $cat_enabled || $wp_category_slug == $cat_enabled) {
2592
  return true;
2593
  } else {
2594
  }
2829
  case AI_SCHEDULING_DELAY:
2830
  $after_days = trim ($this->get_ad_after_day());
2831
  if ($after_days == '') return true;
2832
+ $after_days = intval ($after_days);
2833
+ if ($after_days == AD_ZERO) return true;
2834
 
2835
  $post_date = get_the_date ('U');
2836
  if ($post_date === false) return true;
3007
  // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
3008
  // $selected_blocks = explode (",", $meta_value);
3009
 
3010
+ $enabled_on = $this->get_ad_enabled_on_which_posts ();
3011
+ if ($enabled_on == AI_INDIVIDUALLY_DISABLED) {
3012
+ $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED;
3013
  if (in_array ($this->number, $selected_blocks)) return false;
3014
  }
3015
+ elseif ($enabled_on == AI_INDIVIDUALLY_ENABLED) {
3016
+ $ai_last_check = AI_CHECK_INDIVIDUALLY_ENABLED;
3017
  if (!in_array ($this->number, $selected_blocks)) return false;
3018
  }
3019
  } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
3020
  // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
3021
  // $selected_blocks = explode (",", $meta_value);
3022
 
3023
+ $enabled_on = $this->get_ad_enabled_on_which_pages ();
3024
+ if ($enabled_on == AI_INDIVIDUALLY_DISABLED) {
3025
+ $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED;
3026
  if (in_array ($this->number, $selected_blocks)) return false;
3027
  }
3028
+ elseif ($enabled_on == AI_INDIVIDUALLY_ENABLED) {
3029
+ $ai_last_check = AI_CHECK_INDIVIDUALLY_ENABLED;
3030
  if (!in_array ($this->number, $selected_blocks)) return false;
3031
  }
3032
  }
3329
 
3330
  public function __construct () {
3331
  parent::__construct();
3332
+
3333
+ $this->wp_options [AI_OPTION_BLOCK_NAME] = 'HEADER';
3334
  }
3335
  }
3336
 
3338
 
3339
  public function __construct () {
3340
  parent::__construct();
3341
+
3342
+ $this->wp_options [AI_OPTION_BLOCK_NAME] = 'FOOTER';
3343
  }
3344
  }
3345
 
3348
  public function __construct () {
3349
  parent::__construct();
3350
 
3351
+ $this->wp_options [AI_OPTION_BLOCK_NAME] = 'AD BLOCKING MESSAGE';
3352
  $this->wp_options [AI_OPTION_CODE] = AI_DEFAULT_ADB_MESSAGE;
3353
  }
3354
  }
constants.php CHANGED
@@ -4,6 +4,7 @@
4
  //error_reporting (E_ALL);
5
 
6
  define ('AI_OPTION_NAME', 'ad_inserter');
 
7
  define ('AI_OPTION_GLOBAL', 'global');
8
 
9
  if (!defined ('AD_INSERTER_PLUGIN_DIR'))
@@ -17,7 +18,7 @@ if (!defined( 'AD_INSERTER_NAME'))
17
  define ('AD_INSERTER_NAME', 'Ad Inserter');
18
 
19
  if (!defined( 'AD_INSERTER_VERSION'))
20
- define ('AD_INSERTER_VERSION', '2.1.14');
21
 
22
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
23
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -35,7 +36,7 @@ define ('AD_EMPTY_DATA', '');
35
  define ('AD_ZERO', '0');
36
  define ('AD_ONE', '1');
37
  define ('AD_TWO', '2');
38
- define ('AD_GENERAL_TAG', 'electronics');
39
  define ('AD_NAME', 'Block');
40
 
41
  // Old options
@@ -51,6 +52,7 @@ define ('AI_ADB_MESSAGE_OPTION_NAME', 'a');
51
 
52
  define ('AI_OPTION_CODE', 'code');
53
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
 
54
  define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
55
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
56
  define ('AI_OPTION_TRACKING', 'tracking');
@@ -122,6 +124,8 @@ define ('AI_OPTION_DISPLAY_FOR_DEVICES', 'display_for_devices');
122
  define ('AI_OPTION_DETECT_SERVER_SIDE', 'detect_server_side');
123
  define ('AI_OPTION_DETECT_CLIENT_SIDE', 'detect_client_side');
124
  define ('AI_OPTION_DETECT_VIEWPORT', 'detect_viewport');
 
 
125
 
126
  define ('AI_OPTION_DISABLED', 'disabled');
127
 
@@ -139,6 +143,7 @@ define ('AI_OPTION_ADB_MESSAGE_CSS', 'adb-message-css');
139
  define ('AI_OPTION_ADB_OVERLAY_CSS', 'adb-overlay-css');
140
  define ('AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE', 'adb-undismissible-message');
141
 
 
142
  //misc
143
  define('AD_EMPTY_VALUE','');
144
 
@@ -151,6 +156,7 @@ define('AI_FORM_CLEAR_STATISTICS','ai-clear-statistics');
151
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
152
  define('AD_ROTATE_SEPARATOR', '|rotate|');
153
  define('AD_COUNT_SEPARATOR', '|count|');
 
154
 
155
  //form select options
156
  define('AD_SELECT_SELECTED','selected');
@@ -217,10 +223,19 @@ define('AD_DIRECTION_FROM_TOP','From Top');
217
  define('AD_DIRECTION_FROM_BOTTOM','From Bottom');
218
 
219
  //Post-Page options
 
220
  define('AD_ENABLED_ON_ALL', 'On all');
221
  define('AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED', 'On all except selected');
222
  define('AD_ENABLED_ONLY_ON_SELECTED', 'Only on selected');
223
 
 
 
 
 
 
 
 
 
224
  //Alignment options - Deprecated
225
  define('AD_ALIGNMENT_NO_WRAPPING','No Wrapping');
226
  define('AD_ALIGNMENT_CUSTOM_CSS','Custom CSS');
@@ -257,10 +272,10 @@ define('AI_TEXT_STICKY_RIGHT', 'Sticky Right');
257
  define('AI_TEXT_STICKY_TOP', 'Sticky Top');
258
  define('AI_TEXT_STICKY_BOTTOM', 'Sticky Bottom');
259
 
260
- define('AI_ALIGNMENT_CSS_DEFAULT', 'margin: 8px 0;');
261
- define('AI_ALIGNMENT_CSS_LEFT', 'margin: 8px 0; text-align: left;||margin: 8px 0; text-align: left; display: flex; justify-content: flex-start;');
262
- define('AI_ALIGNMENT_CSS_RIGHT', 'margin: 8px 0; text-align: right;||margin: 8px 0; text-align: right; display: flex; justify-content: flex-end;');
263
- define('AI_ALIGNMENT_CSS_CENTER', 'margin: 8px auto; text-align: center;||margin: 8px 0; text-align: center; display: flex; justify-content: center;');
264
  define('AI_ALIGNMENT_CSS_FLOAT_LEFT', 'margin: 8px 8px 8px 0; float: left;');
265
  define('AI_ALIGNMENT_CSS_FLOAT_RIGHT', 'margin: 8px 0 8px 8px; float: right;');
266
  define('AI_ALIGNMENT_CSS_STICKY_LEFT', 'position: fixed; left: 0px; top: 100px; z-index: 9999;');
@@ -370,14 +385,24 @@ define('AI_TRACKING_INTERNAL', 1);
370
  define('AI_TRACKING_ENABLED', 1);
371
 
372
  // Ad Blocking
373
- define ('AI_ACTION_NONE', 0);
374
- define ('AI_ACTION_WARNING_MESSAGE', 1);
375
- define ('AI_ACTION_REDIRECTION', 2);
376
 
377
  define ('AI_TEXT_NONE', 'None');
378
- define ('AI_TEXT_WARNING_MESSAGE', 'Warning Message');
379
  define ('AI_TEXT_REDIRECTION', 'Redirection');
380
 
 
 
 
 
 
 
 
 
 
 
381
  // Click detection
382
  define ('AI_CLICK_DETECTION_STANDARD', 0);
383
  define ('AI_CLICK_DETECTION_ADVANCED', 1);
@@ -392,8 +417,16 @@ define ('AI_DISABLED', '0');
392
 
393
  define ('AI_COOKIE_TIME', 3600);
394
 
395
- define ('AI_TRANSIENT_RATING', 'ai-rating');
396
- define ('AI_TRANSIENT_RATING_EXPIRATION', 48 * 3600);
 
 
 
 
 
 
 
 
397
 
398
  define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
399
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
@@ -416,15 +449,23 @@ define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
416
  define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
417
  define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
418
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
 
419
 
420
- //define ('AI_ADBLOCKING_DETECTION', true);
421
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
 
 
 
 
 
 
 
422
  define ('AI_BASIC_ADB_OVERLAY_CSS', "position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99998; user-select: none;");
423
  define ('AI_DEFAULT_ADB_OVERLAY_CSS', "background: #000; opacity: 0.85;");
424
  define ('AI_BASIC_ADB_MESSAGE_CSS', "position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; background: #000; color: #fff; user-select: none;");
425
  define ('AI_DEFAULT_ADB_MESSAGE_CSS', "width: 300px; padding: 10px; border: 5px solid #f00; border-radius: 5px;");
426
  define ('AI_DEFAULT_ADB_MESSAGE', "<p><strong>Blocked because of Ad Blocker</strong></p>\n<p>It seems that you are using some ad blocking software which is preventing the page from fully loading. Please whitelist this website or disable ad blocking software.</p>");
427
- define ('AI_DEFAULT_ADB_ACTION', AI_ACTION_NONE);
428
  define ('AI_DEFAULT_ADB_NO_ACTION_PERIOD', 30);
429
  define ('AI_DEFAULT_ADB_REDIRECTION_PAGE', 0);
430
  define ('AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE', AI_DISABLED);
@@ -447,6 +488,7 @@ define ('POST_HOOK_BLOCKS', 'post_hook');
447
  define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
448
  define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
449
  define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
 
450
 
451
  define ('AI_CHECK_NONE', - 1);
452
  define ('AI_CHECK_INSERTED', 0);
@@ -477,8 +519,8 @@ define ('AI_CHECK_LOGGED_IN_USER', 21);
477
  define ('AI_CHECK_NOT_LOGGED_IN_USER', 22);
478
  define ('AI_CHECK_ADMINISTRATOR', 23);
479
 
480
- define ('AI_CHECK_ENABLED_ON_ALL_EXCEPT_ON_SELECTED', 24);
481
- define ('AI_CHECK_ENABLED_ONLY_ON_SELECTED', 25);
482
  define ('AI_CHECK_DISABLED_MANUALLY', 26);
483
  define ('AI_CHECK_MAX_INSERTIONS', 27);
484
  define ('AI_CHECK_FILTER', 28);
@@ -523,10 +565,10 @@ define ('AI_USER_NOT_LOGGED_IN', 0);
523
  define ('AI_USER_LOGGED_IN', 1);
524
  define ('AI_USER_ADMINISTRATOR', 2);
525
 
526
- define ('AI_WP_PAGE_TYPE', 0);
527
- define ('AI_WP_USER_SET', 1);
528
- define ('AI_WP_USER', 2);
529
- define ('AI_WP_DEBUGGING', 3);
530
  define ('AI_WP_DEBUG_BLOCK', 4);
531
  define ('AI_WP_URL', 5);
532
  define ('AI_SERVER_SIDE_DETECTION', 6);
@@ -538,6 +580,10 @@ define ('AI_NUMBER_OF_COMMENTS', 11);
538
  define ('AI_COMMENTS_SAVED_CALLBACK', 12);
539
  define ('AI_COMMENTS_SAVED_END_CALLBACK',13);
540
  define ('AI_ADB_DETECTION', 14);
 
 
 
 
541
 
542
  define ('AI_CONTEXT_NONE', 0);
543
  define ('AI_CONTEXT_CONTENT', 1);
@@ -554,23 +600,25 @@ define ('AI_CONTEXT_BEFORE_COMMENTS', 11);
554
  define ('AI_CONTEXT_BETWEEN_COMMENTS', 12);
555
  define ('AI_CONTEXT_AFTER_COMMENTS', 13);
556
 
557
- define ('AI_URL_DEBUG', 'ai-debug');
558
- define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing');
559
- define ('AI_URL_DEBUG_BLOCKS', 'ai-debug-blocks');
560
- define ('AI_URL_DEBUG_USER', 'ai-debug-user');
561
- define ('AI_URL_DEBUG_TAGS', 'ai-debug-tags');
562
- define ('AI_URL_DEBUG_POSITIONS', 'ai-debug-positions');
563
- define ('AI_URL_DEBUG_NO_INSERTION', 'ai-debug-no-insertion');
564
- define ('AI_URL_DEBUG_PHP', 'ai-debug-php');
565
- define ('AI_URL_DEBUG_COUNTRY', 'ai-debug-country');
566
- define ('AI_URL_DEBUG_AD_BLOCKING' , 'ai-debug-ad-blocking');
567
-
568
- define ('AI_DEBUG_PROCESSING', 0x01);
 
569
  define ('AI_DEBUG_BLOCKS', 0x02);
570
  define ('AI_DEBUG_TAGS', 0x04);
571
  define ('AI_DEBUG_POSITIONS', 0x08);
572
  define ('AI_DEBUG_NO_INSERTION', 0x10);
573
  define ('AI_DEBUG_AD_BLOCKING', 0x20);
 
574
 
575
  if (!defined ('AD_INSERTER_BLOCKS'))
576
  define ('AD_INSERTER_BLOCKS', 16);
@@ -581,6 +629,7 @@ if (!defined ('AD_INSERTER_VIEWPORTS'))
581
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
582
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
583
  define ('AI_DEBUG_PAGE_TYPE_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;');
 
584
  define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
585
 
586
 
4
  //error_reporting (E_ALL);
5
 
6
  define ('AI_OPTION_NAME', 'ad_inserter');
7
+ define ('AI_INSTALL_NAME', 'ai-install');
8
  define ('AI_OPTION_GLOBAL', 'global');
9
 
10
  if (!defined ('AD_INSERTER_PLUGIN_DIR'))
18
  define ('AD_INSERTER_NAME', 'Ad Inserter');
19
 
20
  if (!defined( 'AD_INSERTER_VERSION'))
21
+ define ('AD_INSERTER_VERSION', '2.2.0');
22
 
23
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
24
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
36
  define ('AD_ZERO', '0');
37
  define ('AD_ONE', '1');
38
  define ('AD_TWO', '2');
39
+ define ('AD_GENERAL_TAG', '');
40
  define ('AD_NAME', 'Block');
41
 
42
  // Old options
52
 
53
  define ('AI_OPTION_CODE', 'code');
54
  define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
55
+ define ('AI_OPTION_ENABLE_AMP', 'enable_amp');
56
  define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
57
  define ('AI_OPTION_PROCESS_PHP', 'process_php');
58
  define ('AI_OPTION_TRACKING', 'tracking');
124
  define ('AI_OPTION_DETECT_SERVER_SIDE', 'detect_server_side');
125
  define ('AI_OPTION_DETECT_CLIENT_SIDE', 'detect_client_side');
126
  define ('AI_OPTION_DETECT_VIEWPORT', 'detect_viewport');
127
+ define ('AI_OPTION_ADB_BLOCK_ACTION', 'adb-block-action');
128
+ define ('AI_OPTION_ADB_BLOCK_REPLACEMENT', 'adb-block-replacement');
129
 
130
  define ('AI_OPTION_DISABLED', 'disabled');
131
 
143
  define ('AI_OPTION_ADB_OVERLAY_CSS', 'adb-overlay-css');
144
  define ('AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE', 'adb-undismissible-message');
145
 
146
+
147
  //misc
148
  define('AD_EMPTY_VALUE','');
149
 
156
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
157
  define('AD_ROTATE_SEPARATOR', '|rotate|');
158
  define('AD_COUNT_SEPARATOR', '|count|');
159
+ define('AD_AMP_SEPARATOR', '|amp|');
160
 
161
  //form select options
162
  define('AD_SELECT_SELECTED','selected');
223
  define('AD_DIRECTION_FROM_BOTTOM','From Bottom');
224
 
225
  //Post-Page options
226
+ // Deprecated
227
  define('AD_ENABLED_ON_ALL', 'On all');
228
  define('AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED', 'On all except selected');
229
  define('AD_ENABLED_ONLY_ON_SELECTED', 'Only on selected');
230
 
231
+ define('AI_NO_INDIVIDUAL_EXCEPTIONS', 0);
232
+ define('AI_INDIVIDUALLY_DISABLED', 1);
233
+ define('AI_INDIVIDUALLY_ENABLED', 2);
234
+
235
+ define('AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS', '');
236
+ define('AI_TEXT_INDIVIDUALLY_DISABLED', 'Individually disabled');
237
+ define('AI_TEXT_INDIVIDUALLY_ENABLED', 'Individually enabled');
238
+
239
  //Alignment options - Deprecated
240
  define('AD_ALIGNMENT_NO_WRAPPING','No Wrapping');
241
  define('AD_ALIGNMENT_CUSTOM_CSS','Custom CSS');
272
  define('AI_TEXT_STICKY_TOP', 'Sticky Top');
273
  define('AI_TEXT_STICKY_BOTTOM', 'Sticky Bottom');
274
 
275
+ define('AI_ALIGNMENT_CSS_DEFAULT', 'margin: 8px 0; clear: both;');
276
+ define('AI_ALIGNMENT_CSS_LEFT', 'margin: 8px 0; text-align: left; clear: both;||margin: 8px 0; text-align: left; clear: both; display: flex; justify-content: flex-start;');
277
+ define('AI_ALIGNMENT_CSS_RIGHT', 'margin: 8px 0; text-align: right; clear: both;||margin: 8px 0; text-align: right; clear: both; display: flex; justify-content: flex-end;');
278
+ define('AI_ALIGNMENT_CSS_CENTER', 'margin: 8px auto; text-align: center; clear: both;||margin: 8px 0; text-align: center; clear: both; display: flex; justify-content: center;');
279
  define('AI_ALIGNMENT_CSS_FLOAT_LEFT', 'margin: 8px 8px 8px 0; float: left;');
280
  define('AI_ALIGNMENT_CSS_FLOAT_RIGHT', 'margin: 8px 0 8px 8px; float: right;');
281
  define('AI_ALIGNMENT_CSS_STICKY_LEFT', 'position: fixed; left: 0px; top: 100px; z-index: 9999;');
385
  define('AI_TRACKING_ENABLED', 1);
386
 
387
  // Ad Blocking
388
+ define ('AI_ADB_ACTION_NONE', 0);
389
+ define ('AI_ADB_ACTION_MESSAGE', 1);
390
+ define ('AI_ADB_ACTION_REDIRECTION', 2);
391
 
392
  define ('AI_TEXT_NONE', 'None');
393
+ define ('AI_TEXT_POPUP_MESSAGE', 'Popup Message');
394
  define ('AI_TEXT_REDIRECTION', 'Redirection');
395
 
396
+ define ('AI_ADB_BLOCK_ACTION_DO_NOTHING', 0);
397
+ define ('AI_ADB_BLOCK_ACTION_REPLACE', 1);
398
+ define ('AI_ADB_BLOCK_ACTION_SHOW', 2);
399
+ define ('AI_ADB_BLOCK_ACTION_HIDE', 3);
400
+
401
+ define ('AI_TEXT_DO_NOTHING', 'Do nothnig');
402
+ define ('AI_TEXT_REPLACE', 'Replace');
403
+ define ('AI_TEXT_SHOW', 'Show');
404
+ define ('AI_TEXT_HIDE', 'Hide');
405
+
406
  // Click detection
407
  define ('AI_CLICK_DETECTION_STANDARD', 0);
408
  define ('AI_CLICK_DETECTION_ADVANCED', 1);
417
 
418
  define ('AI_COOKIE_TIME', 3600);
419
 
420
+ define ('AI_TRANSIENT_RATING', 'ai-rating');
421
+ define ('AI_TRANSIENT_RATING_EXPIRATION', 48 * 3600);
422
+
423
+ define ('AI_TRANSIENT_ADB_CLASS_1', 'ai-adb-class-1');
424
+ define ('AI_TRANSIENT_ADB_CLASS_2', 'ai-adb-class-2');
425
+ define ('AI_TRANSIENT_ADB_CLASS_3', 'ai-adb-class-3');
426
+ define ('AI_TRANSIENT_ADB_CLASS_4', 'ai-adb-class-4');
427
+ define ('AI_TRANSIENT_ADB_CLASS_5', 'ai-adb-class-5');
428
+ define ('AI_TRANSIENT_ADB_CLASS_6', 'ai-adb-class-6');
429
+ define ('AI_TRANSIENT_ADB_CLASS_EXPIRATION', 48 * 3600);
430
 
431
  define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
432
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
449
  define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
450
  define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
451
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
452
+ define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
453
 
454
+ define ('AI_ADBLOCKING_DETECTION', true);
455
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
456
+ define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
457
+ define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
458
+ define ('AI_ADB_CONTENT_CSS_END', 'ai-adb-content-end');
459
+ define ('AI_ADB_CONTENT_DELETE_BEGIN', 'ai-adb-delete-begin');
460
+ define ('AI_ADB_CONTENT_DELETE_END', 'ai-adb-delete-end');
461
+ define ('AI_ADB_CONTENT_REPLACE_BEGIN', 'ai-adb-replace-begin');
462
+ define ('AI_ADB_CONTENT_REPLACE_END', 'ai-adb-replace-end');
463
  define ('AI_BASIC_ADB_OVERLAY_CSS', "position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99998; user-select: none;");
464
  define ('AI_DEFAULT_ADB_OVERLAY_CSS', "background: #000; opacity: 0.85;");
465
  define ('AI_BASIC_ADB_MESSAGE_CSS', "position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; background: #000; color: #fff; user-select: none;");
466
  define ('AI_DEFAULT_ADB_MESSAGE_CSS', "width: 300px; padding: 10px; border: 5px solid #f00; border-radius: 5px;");
467
  define ('AI_DEFAULT_ADB_MESSAGE', "<p><strong>Blocked because of Ad Blocker</strong></p>\n<p>It seems that you are using some ad blocking software which is preventing the page from fully loading. Please whitelist this website or disable ad blocking software.</p>");
468
+ define ('AI_DEFAULT_ADB_ACTION', AI_ADB_ACTION_NONE);
469
  define ('AI_DEFAULT_ADB_NO_ACTION_PERIOD', 30);
470
  define ('AI_DEFAULT_ADB_REDIRECTION_PAGE', 0);
471
  define ('AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE', AI_DISABLED);
488
  define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
489
  define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
490
  define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
491
+ define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
492
 
493
  define ('AI_CHECK_NONE', - 1);
494
  define ('AI_CHECK_INSERTED', 0);
519
  define ('AI_CHECK_NOT_LOGGED_IN_USER', 22);
520
  define ('AI_CHECK_ADMINISTRATOR', 23);
521
 
522
+ define ('AI_CHECK_INDIVIDUALLY_DISABLED', 24);
523
+ define ('AI_CHECK_INDIVIDUALLY_ENABLED', 25);
524
  define ('AI_CHECK_DISABLED_MANUALLY', 26);
525
  define ('AI_CHECK_MAX_INSERTIONS', 27);
526
  define ('AI_CHECK_FILTER', 28);
565
  define ('AI_USER_LOGGED_IN', 1);
566
  define ('AI_USER_ADMINISTRATOR', 2);
567
 
568
+ define ('AI_WP_DEBUGGING', 0); // AI_WP_DEBUGGING_
569
+ define ('AI_WP_PAGE_TYPE', 1);
570
+ define ('AI_WP_USER_SET', 2);
571
+ define ('AI_WP_USER', 3);
572
  define ('AI_WP_DEBUG_BLOCK', 4);
573
  define ('AI_WP_URL', 5);
574
  define ('AI_SERVER_SIDE_DETECTION', 6);
580
  define ('AI_COMMENTS_SAVED_CALLBACK', 12);
581
  define ('AI_COMMENTS_SAVED_END_CALLBACK',13);
582
  define ('AI_ADB_DETECTION', 14);
583
+ define ('AI_JS_DEBUGGING', 15);
584
+ define ('AI_WP_AMP_PAGE', 16);
585
+ define ('AI_INSTALL_TIME_DIFFERENCE', 17);
586
+ define ('AI_DAYS_SINCE_INSTAL', 18);
587
 
588
  define ('AI_CONTEXT_NONE', 0);
589
  define ('AI_CONTEXT_CONTENT', 1);
600
  define ('AI_CONTEXT_BETWEEN_COMMENTS', 12);
601
  define ('AI_CONTEXT_AFTER_COMMENTS', 13);
602
 
603
+ define ('AI_URL_DEBUG', 'ai-debug'); // AI_URL_DEBUG_
604
+ define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing'); // AI_URL_DEBUG_PROCESSING_
605
+ define ('AI_URL_DEBUG_PHP', 'ai-debug-php'); // AI_URL_DEBUG_PHP
606
+ define ('AI_URL_DEBUG_BLOCKS', 'ai-debug-blocks');
607
+ define ('AI_URL_DEBUG_USER', 'ai-debug-user');
608
+ define ('AI_URL_DEBUG_TAGS', 'ai-debug-tags');
609
+ define ('AI_URL_DEBUG_POSITIONS', 'ai-debug-positions');
610
+ define ('AI_URL_DEBUG_NO_INSERTION', 'ai-debug-no-insertion');
611
+ define ('AI_URL_DEBUG_COUNTRY', 'ai-debug-country');
612
+ define ('AI_URL_DEBUG_AD_BLOCKING' , 'ai-debug-adb');
613
+ define ('AI_URL_DEBUG_AD_BLOCKING_STATUS', 'ai-debug-adb-status');
614
+
615
+ define ('AI_DEBUG_PROCESSING', 0x01); // AI_DEBUG_PROCESSING_
616
  define ('AI_DEBUG_BLOCKS', 0x02);
617
  define ('AI_DEBUG_TAGS', 0x04);
618
  define ('AI_DEBUG_POSITIONS', 0x08);
619
  define ('AI_DEBUG_NO_INSERTION', 0x10);
620
  define ('AI_DEBUG_AD_BLOCKING', 0x20);
621
+ define ('AI_DEBUG_AD_BLOCKING_STATUS', 0x40);
622
 
623
  if (!defined ('AD_INSERTER_BLOCKS'))
624
  define ('AD_INSERTER_BLOCKS', 16);
629
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
630
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
631
  define ('AI_DEBUG_PAGE_TYPE_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;');
632
+ define ('AI_DEBUG_ADB_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid red; color: red; background: #fee; opacity: 0.85; cursor: pointer;');
633
  define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
634
 
635
 
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.1.14"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -268,28 +268,6 @@ textarea.simple-editor.small {
268
  height: 192px;
269
  }
270
 
271
- @media (min-width: 783px) and (max-width: 828px) {
272
- .auto-fold #wpcontent, .auto-fold #wpfooter {
273
- margin-left: 20px;
274
- }
275
- }
276
- @media (max-width: 782px) {
277
- .auto-fold #wpcontent {
278
- padding-left: 8px;
279
- }
280
- }
281
-
282
- @media screen and (max-width: 782px){
283
- #wpbody .small-select select {
284
- height: 32px;
285
- font-size: 14px;
286
- }
287
-
288
- #wpbody span.small-input-tags {
289
- width: 22%;
290
- }
291
- }
292
-
293
  .ms-container {
294
  width: 100%;
295
  font-size: 12px;
@@ -316,6 +294,14 @@ textarea.simple-editor.small {
316
  margin-top: 24px;
317
  }
318
 
 
 
 
 
 
 
 
 
319
  .country-flags .ms-container .ms-selectable li.ms-elem-selectable, .country-flags .ms-container .ms-selection li.ms-elem-selection {
320
  padding-left: 30px;
321
  }
@@ -490,6 +476,37 @@ div.automatic-insertion img {
490
  margin-top: 6px;
491
  }
492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
  @media(max-width: 768px) {
494
  .text .checkbox-button {
495
  padding: 2px 5px 2px 4px;
@@ -504,6 +521,13 @@ div.automatic-insertion img {
504
  font-family: sans-serif,Arial,Verdana;
505
  font-size: 16px;
506
  }
 
 
 
 
 
 
 
507
  }
508
 
509
  @media(min-width: 769px) {
@@ -513,4 +537,22 @@ div.automatic-insertion img {
513
  }
514
  }
515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
 
1
  #ai-data {
2
+ font-family: "2.2.0"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
268
  height: 192px;
269
  }
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  .ms-container {
272
  width: 100%;
273
  font-size: 12px;
294
  margin-top: 24px;
295
  }
296
 
297
+ div.custom-range-controls {
298
+ width: 696px;
299
+ }
300
+
301
+ div.custom-range-controls input.chart-date {
302
+ width: 85px;
303
+ }
304
+
305
  .country-flags .ms-container .ms-selectable li.ms-elem-selectable, .country-flags .ms-container .ms-selection li.ms-elem-selection {
306
  padding-left: 30px;
307
  }
476
  margin-top: 6px;
477
  }
478
 
479
+ #ai-sidebar .notice-dismiss {
480
+ position: absolute;
481
+ top: 0;
482
+ right: 1px;
483
+ border: none;
484
+ margin: 0;
485
+ padding: 9px;
486
+ background: 0 0;
487
+ color: #72777c;
488
+ cursor: pointer;
489
+ }
490
+
491
+ #ai-sidebar .notice-dismiss:focus {
492
+ outline: 0;
493
+ -webkit-box-shadow: none;
494
+ box-shadow: none;
495
+ }
496
+
497
+ #ai-sidebar .notice-dismiss.ui-state-active, #ai-sidebar .notice-dismiss.ui-widget-content .ui-state-active, #ai-sidebar .notice-dismiss.ui-widget-header .ui-state-active {
498
+ background: 0 0!important;
499
+ }
500
+
501
+ @media (max-width: 782px) {
502
+ .auto-fold #wpcontent {
503
+ padding-left: 4px;
504
+ }
505
+ #wpwrap {
506
+ width: 762px;
507
+ }
508
+ }
509
+
510
  @media(max-width: 768px) {
511
  .text .checkbox-button {
512
  padding: 2px 5px 2px 4px;
521
  font-family: sans-serif,Arial,Verdana;
522
  font-size: 16px;
523
  }
524
+ div.custom-range-controls {
525
+ width: 715px;
526
+ }
527
+ div.custom-range-controls input.chart-date {
528
+ width: 90px;
529
+ padding: 3px 3px;
530
+ }
531
  }
532
 
533
  @media(min-width: 769px) {
537
  }
538
  }
539
 
540
+ @media (min-width: 783px) and (max-width: 828px) {
541
+ .auto-fold #wpcontent, .auto-fold #wpfooter {
542
+ margin-left: 20px;
543
+ }
544
+ }
545
+
546
+ @media screen and (max-width: 782px){
547
+ #wpbody .small-select select {
548
+ height: 32px;
549
+ font-size: 14px;
550
+ }
551
+
552
+ #wpbody span.small-input-tags {
553
+ width: 22%;
554
+ }
555
+ }
556
+
557
+
558
 
css/ai-admin.css ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ai-notice {
2
+ vertical-align: middle;
3
+ padding: 0;
4
+ border-top: 1px solid #E5E5E5;
5
+ border-right: 1px solid #E5E5E5;
6
+ border-radius: 6px;
7
+ }
8
+ .ai-notice img {
9
+ }
10
+ .ai-notice-element {
11
+ display: table-cell;
12
+ vertical-align: middle;
13
+ color: #444;
14
+ font-size: 13px;
15
+ font-family: 'Open Sans', sans-serif;
16
+ }
17
+ .ai-notice-buttons {
18
+ border-left: 1px solid #E5E5E5;
19
+ padding: 0 15px;
20
+ background: #F8F8F8;
21
+ position: relative;
22
+ white-space: nowrap;
23
+ text-align: center;
24
+ }
25
+ .ai-notice-buttons.last {
26
+ border-top-right-radius: 6px;
27
+ border-bottom-right-radius: 6px;
28
+ }
29
+ .ai-notice-buttons button.button-primary {
30
+ margin: 10px;
31
+ }
32
+ .ai-notice-buttons a {
33
+ text-decoration: none;
34
+ box-shadow: 0 0 0;
35
+ color: #fff;
36
+ }
37
+ .ai-notice-text-button {
38
+ display: inline-block;
39
+ color: #bbb;
40
+ cursor: pointer;
41
+ margin: 2px 10px 10px;
42
+ }
43
+
44
+ @media (max-width: 1200px) {
45
+ .ai-notice-text-button {
46
+ display: block;
47
+ }
48
+ }
49
+
50
+ @media (max-width: 840px) {
51
+ .ai-no-phone {
52
+ display: none!important;
53
+ }
54
+ }
55
+
includes/ace/mode-ai-html.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ace.define ('ace/mode/ai-html', function (require, exports, module) {
2
+
3
+ var oop = require ("ace/lib/oop");
4
+ var HtmlMode = require ("ace/mode/html").Mode;
5
+ var AiHtmlHighlightRules = require ("ace/mode/ai_html_highlight_rules").AiHtmlHighlightRules;
6
+
7
+ var Mode = function() {
8
+ this.HighlightRules = AiHtmlHighlightRules;
9
+ };
10
+ oop.inherits (Mode, HtmlMode);
11
+
12
+ (function() {}).call(Mode.prototype);
13
+
14
+ exports.Mode = Mode;
15
+ });
16
+
17
+
18
+ ace.define ('ace/mode/ai_html_highlight_rules', function (require, exports, module) {
19
+
20
+ var oop = require("ace/lib/oop");
21
+ var HtmlHighlightRules = require ("ace/mode/html_highlight_rules").HtmlHighlightRules;
22
+
23
+ var AiHtmlHighlightRules = function() {
24
+ this.$rules = new HtmlHighlightRules().getRules();
25
+ this.$lang = require ("ace/lib/lang");
26
+ add_ai_highlighting_rules (this, HtmlHighlightRules);
27
+ }
28
+
29
+ oop.inherits (AiHtmlHighlightRules, HtmlHighlightRules);
30
+ exports.AiHtmlHighlightRules = AiHtmlHighlightRules;
31
+ });
32
+
33
+ function add_ai_highlighting_rules (highlighter, highlight_rules) {
34
+
35
+ highlighter.$ai_shortcodes = highlighter.$lang.arrayToMap ("adinserter".split ("|"));
36
+ highlighter.$ai_separators1 = highlighter.$lang.arrayToMap ("rotate".split ("|"));
37
+ highlighter.$ai_separators2 = highlighter.$lang.arrayToMap ("amp".split ("|"));
38
+ highlighter.$ai_attributes = highlighter.$lang.arrayToMap ("block|name|ignore|debugger|adb|css|text|selectors".split ("|"));
39
+
40
+ //WP shortcodes
41
+ highlighter.$rules ['start'].unshift (
42
+ {
43
+ token: function (shortcode_start, shortcode, shortcode_end) {
44
+ highlighter.$ai_shortcode = highlighter.$ai_shortcodes.hasOwnProperty (shortcode.toLowerCase());
45
+ return ["paren", highlighter.$ai_shortcode ? "shortcode.adinserter" : "shortcode"];
46
+ },
47
+ regex: "(\\[/?)([a-zA-Z][a-zA-Z0-9_]*)",
48
+ next: "ai-attributes"
49
+ },
50
+ {
51
+ token: "variable.language",
52
+ regex: "\\|rotate\\||\\|count\\||\\|amp\\|",
53
+ }
54
+ );
55
+
56
+ highlighter.embedRules (highlight_rules, "ai-", [
57
+ {
58
+ token: "paren",
59
+ regex: "\\]",
60
+ next: "start"
61
+ }
62
+ ]);
63
+
64
+ // Add ] to regexp for 'string.unquoted.attribute-value.html'
65
+ var arrayLength = highlighter.$rules ['ai-keyword.operator.attribute-equals.xml'].length;
66
+ for (var i = 0; i < arrayLength; i++) {
67
+ if (highlighter.$rules ['ai-keyword.operator.attribute-equals.xml'][i]['token'] == 'string.unquoted.attribute-value.html')
68
+ highlighter.$rules ['ai-keyword.operator.attribute-equals.xml'][i]['regex'] = "[^<>='\"`\\]\\s]+";
69
+ }
70
+
71
+ highlighter.$rules ['ai-attributes'].unshift (
72
+ {
73
+ token: function (attribute) {
74
+ return !highlighter.$ai_shortcode ? "entity.other.attribute-name.xml" :
75
+ highlighter.$ai_separators1.hasOwnProperty (attribute.toLowerCase()) ? "entity.other.attribute-name.xml" :
76
+ highlighter.$ai_separators2.hasOwnProperty (attribute.toLowerCase()) ? "identifier" :
77
+ highlighter.$ai_attributes.hasOwnProperty (attribute.toLowerCase()) ? "entity.other.attribute-name.xml" : "text";
78
+ },
79
+ regex: "[a-zA-Z][-a-zA-Z0-9]*"
80
+ },
81
+ );
82
+
83
+ // console.log (highlighter.$rules);
84
+ }
includes/ace/mode-ai-php.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ace.define ('ace/mode/ai-php', function (require, exports, module) {
2
+
3
+ var oop = require ("ace/lib/oop");
4
+ var PhpMode = require ("ace/mode/php").Mode;
5
+ var AiPhpHighlightRules = require ("ace/mode/ai_php_highlight_rules").AiPhpHighlightRules;
6
+
7
+ var Mode = function() {
8
+ this.HighlightRules = AiPhpHighlightRules;
9
+ };
10
+ oop.inherits (Mode, PhpMode);
11
+
12
+ (function() {}).call(Mode.prototype);
13
+
14
+ exports.Mode = Mode;
15
+ });
16
+
17
+
18
+ ace.define ('ace/mode/ai_php_highlight_rules', function (require, exports, module) {
19
+
20
+ var oop = require("ace/lib/oop");
21
+ var PhpHighlightRules = require ("ace/mode/php_highlight_rules").PhpHighlightRules;
22
+
23
+ var AiPhpHighlightRules = function() {
24
+ this.$rules = new PhpHighlightRules().getRules();
25
+ this.$lang = require ("ace/lib/lang");
26
+ add_ai_highlighting_rules (this, PhpHighlightRules);
27
+ }
28
+
29
+ oop.inherits (AiPhpHighlightRules, PhpHighlightRules);
30
+ exports.AiPhpHighlightRules = AiPhpHighlightRules;
31
+ });
includes/ace/theme-ad_inserter.js CHANGED
@@ -32,7 +32,7 @@ background: rgb(102, 82, 0)\
32
  margin: -1px 0 0 -1px;\
33
  border: 1px solid #FF00FF\
34
  }\
35
- .ace-tomorrow-night-bright .ace_stack {\
36
  background: rgb(66, 90, 44)\
37
  }\
38
  .ace-ad-inserter .ace_marker-layer .ace_active-line {\
@@ -55,8 +55,8 @@ color: #6A6A6A\
55
  color: #00FF00\
56
  }\
57
  .ace-ad-inserter .ace_paren,\
58
- .ace-ad-inserter .ace_punctuation.ace_operator,\
59
- .ace-ad-inserter .ace_keyword.ace_operator {\
60
  color: #FF4444\
61
  }\
62
  .ace-ad-inserter .ace_constant.ace_character,\
@@ -65,7 +65,7 @@ color: #FF4444\
65
  color: #FFFF00\
66
  }\
67
  .ace-ad-inserter .ace_constant.ace_language {\
68
- color: #00FF00\
69
  }\
70
  .ace-ad-inserter .ace_invalid {\
71
  color: #CDCDCD;\
@@ -108,7 +108,19 @@ color: #FF88FF\
108
  }\
109
  .ace-ad-inserter .ace_entity.ace_name.ace_tag,\
110
  .ace-ad-inserter .ace_entity.ace_other.ace_attribute-name {\
111
- color: #DDFF44\
 
 
 
 
 
 
 
 
 
 
 
 
112
  }\
113
  .ace-ad-inserter .ace_indent-guide {\
114
  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ09NrYAgMjP4PAAtGAwchHMyAAAAAAElFTkSuQmCC) right repeat-y\
@@ -117,3 +129,4 @@ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgb
117
  var dom = require("../lib/dom");
118
  dom.importCssString(exports.cssText, exports.cssClass);
119
  });
 
32
  margin: -1px 0 0 -1px;\
33
  border: 1px solid #FF00FF\
34
  }\
35
+ .ace-ad-inserter .ace_stack {\
36
  background: rgb(66, 90, 44)\
37
  }\
38
  .ace-ad-inserter .ace_marker-layer .ace_active-line {\
55
  color: #00FF00\
56
  }\
57
  .ace-ad-inserter .ace_paren,\
58
+ .ace-ad-inserter .ace_keyword.ace_operator,\
59
+ .ace-ad-inserter .ace_punctuation.ace_operator {\
60
  color: #FF4444\
61
  }\
62
  .ace-ad-inserter .ace_constant.ace_character,\
65
  color: #FFFF00\
66
  }\
67
  .ace-ad-inserter .ace_constant.ace_language {\
68
+ color: #00ff00\
69
  }\
70
  .ace-ad-inserter .ace_invalid {\
71
  color: #CDCDCD;\
108
  }\
109
  .ace-ad-inserter .ace_entity.ace_name.ace_tag,\
110
  .ace-ad-inserter .ace_entity.ace_other.ace_attribute-name {\
111
+ color: #fffF80\
112
+ }\
113
+ .ace-ad-inserter .ace_support.ace_php_tag {\
114
+ color: #ff8888\
115
+ }\
116
+ .ace-ad-inserter .ace_shortcode {\
117
+ color: #ff8888\
118
+ }\
119
+ .ace-ad-inserter .ace_shortcode.ace_adinserter {\
120
+ color: #ff88ff\
121
+ }\
122
+ .ace-ad-inserter .ace_shortcode.ace_ai-attribute {\
123
+ color: #80ff80\
124
  }\
125
  .ace-ad-inserter .ace_indent-guide {\
126
  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ09NrYAgMjP4PAAtGAwchHMyAAAAAAElFTkSuQmCC) right repeat-y\
129
  var dom = require("../lib/dom");
130
  dom.importCssString(exports.cssText, exports.cssClass);
131
  });
132
+
includes/js/ai-adb.js ADDED
@@ -0,0 +1,439 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var ai_adb_debugging = AI_DATAB_AI_JS_DEBUGGING;
2
+ var ai_adb_active = false;
3
+ var ai_adb_counter = 0;
4
+ var ai_adb_overlay = AI_ADB_OVERLAY_WINDOW;
5
+ var ai_adb_message_window = AI_ADB_MESSAGE_WINDOW;
6
+ var ai_adb_message_undismissible = AI_FUNCB_GET_UNDISMISSIBLE_MESSAGE;
7
+ var ai_adb_act_cookie_name = "aiADB";
8
+ var ai_adb_pgv_cookie_name = "aiADB_PV";
9
+ var ai_adb_page_redirection_cookie_name = "aiADB_PR";
10
+ var ai_adb_message_cookie_lifetime = AI_FUNCT_GET_NO_ACTION_PERIOD;
11
+ var ai_adb_action = AI_FUNCT_GET_ADB_ACTION;
12
+ var ai_adb_page_views = AI_FUNCT_GET_DELAY_ACTION;
13
+ var ai_adb_selectors = "AI_ADB_SELECTORS";
14
+ var ai_adb_redirection_url = "AI_ADB_REDIRECTION_PAGE";
15
+
16
+ function ai_adb_process_content () {
17
+ (function ($) {
18
+
19
+ if (ai_adb_debugging) console.log ("AI ad blocking CONTENT PROCESSING");
20
+
21
+ $(".AI_ADB_CONTENT_CSS_BEGIN_CLASS").each (function () {
22
+ var ai_adb_parent = $(this).parent ();
23
+
24
+ if (ai_adb_debugging) console.log ("AI ad blocking parent", ai_adb_parent.prop ("tagName"), "id=\""+ ai_adb_parent.attr ("id")+"\"", "class=\""+ ai_adb_parent.attr ("class")+"\"");
25
+
26
+ var ai_adb_css = $(this).data ("css");
27
+ if (typeof ai_adb_css == "undefined") ai_adb_css = "display: none !important;";
28
+
29
+ var ai_adb_selectors = $(this).data ("selectors");
30
+ if (typeof ai_adb_selectors == "undefined" || ai_adb_selectors == '') ai_adb_selectors = "p";
31
+
32
+ if (ai_adb_debugging) console.log ('AI ad blocking CSS, css=\'' + ai_adb_css +'\'', "selectors='" + ai_adb_selectors + "'");
33
+
34
+ var ai_adb_action = false;
35
+ $(ai_adb_parent).find ('.AI_ADB_CONTENT_CSS_BEGIN_CLASS, ' + ai_adb_selectors).each (function () {
36
+ if ($(this).hasClass ("AI_ADB_CONTENT_CSS_BEGIN_CLASS")) {$(this).remove (); ai_adb_action = true;}
37
+ else if ($(this).hasClass ("AI_ADB_CONTENT_CSS_END_CLASS")) {$(this).remove (); ai_adb_action = false;}
38
+ else if (ai_adb_action) {
39
+ var ai_adb_style = $(this).attr ("style");
40
+ if (typeof ai_adb_style == "undefined") ai_adb_style = "";
41
+ $(this).attr ("style", ai_adb_style + ";" + ai_adb_css);
42
+ }
43
+ });
44
+ });
45
+
46
+ $(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS").each (function () {
47
+ var ai_adb_parent = $(this).parent ();
48
+
49
+ if (ai_adb_debugging) console.log ("AI ad blocking DELETE, parent", ai_adb_parent.prop ("tagName"), "id=\""+ ai_adb_parent.attr ("id")+"\"", "class=\""+ ai_adb_parent.attr ("class")+"\"");
50
+
51
+ var ai_adb_selectors = $(this).data ("selectors");
52
+ if (typeof ai_adb_selectors == "undefined" || ai_adb_selectors == '') ai_adb_selectors = "p";
53
+
54
+ if (ai_adb_debugging) console.log ("AI ad blocking DELETE, selectors='" + ai_adb_selectors + "'");
55
+
56
+ var ai_adb_action = false;
57
+ $(ai_adb_parent).find ('.AI_ADB_CONTENT_DELETE_BEGIN_CLASS, ' + ai_adb_selectors).each (function () {
58
+ if ($(this).hasClass ("AI_ADB_CONTENT_DELETE_BEGIN_CLASS")) {$(this).remove (); ai_adb_action = true;}
59
+ else if ($(this).hasClass ("AI_ADB_CONTENT_DELETE_END_CLASS")) {$(this).remove (); ai_adb_action = false;}
60
+ else if (ai_adb_action) {
61
+ $(this).remove ();
62
+ }
63
+ });
64
+
65
+ });
66
+
67
+ $(".AI_ADB_CONTENT_REPLACE_BEGIN_CLASS").each (function () {
68
+ var ai_adb_parent = $(this).parent ();
69
+
70
+ if (ai_adb_debugging) console.log ("AI ad blocking REPLACE, parent", ai_adb_parent.prop ("tagName"), "id=\""+ ai_adb_parent.attr ("id")+"\"", "class=\""+ ai_adb_parent.attr ("class")+"\"");
71
+
72
+ var ai_adb_text = $(this).data ("text");
73
+ if (typeof ai_adb_text == "undefined") ai_adb_text = "";
74
+
75
+ var ai_adb_css = $(this).data ("css");
76
+ if (typeof ai_adb_css == "undefined") ai_adb_css = "";
77
+
78
+ var ai_adb_selectors = $(this).data ("selectors");
79
+ if (typeof ai_adb_selectors == "undefined" || ai_adb_selectors == '') ai_adb_selectors = "p";
80
+
81
+ if (ai_adb_debugging) console.log ("AI ad blocking REPLACE, text=\'" + ai_adb_text + '\'', 'css=\'' + ai_adb_css +'\'', "selectors='" + ai_adb_selectors + "'");
82
+
83
+ var ai_adb_action = false;
84
+ $(ai_adb_parent).find ('.AI_ADB_CONTENT_REPLACE_BEGIN_CLASS, ' + ai_adb_selectors).each (function () {
85
+ if ($(this).hasClass ("AI_ADB_CONTENT_REPLACE_BEGIN_CLASS")) {$(this).remove (); ai_adb_action = true;}
86
+ else if ($(this).hasClass ("AI_ADB_CONTENT_REPLACE_END_CLASS")) {$(this).remove (); ai_adb_action = false;}
87
+ else if (ai_adb_action) {
88
+ if (ai_adb_text.length != 0) {
89
+ var n = Math.round ($(this).text ().length / (ai_adb_text.length + 1));
90
+ $(this).text (Array(n + 1).join(ai_adb_text + ' '));
91
+ } else $(this).text ('');
92
+ var ai_adb_style = $(this).attr ("style");
93
+ if (typeof ai_adb_style == "undefined") ai_adb_style = "";
94
+ $(this).attr ("style", ai_adb_style + ";" + ai_adb_css);
95
+ }
96
+ });
97
+ });
98
+
99
+ }(jQuery));
100
+ }
101
+
102
+ var ai_adb_detected = function(n) {
103
+
104
+ if (ai_adb_debugging) console.log ("AI ad blocking DETECTED", n);
105
+
106
+ if (!ai_adb_active) {
107
+ ai_adb_active = true;
108
+
109
+ (function ($) {
110
+
111
+ $(window).ready(function () {
112
+ if (ai_adb_debugging) console.log ("AI ad blocking block actions");
113
+
114
+ $(".ai-adb-show").each (function () {
115
+ $(this).css ({"display": "block", "visibility": "visible"});
116
+ if (ai_adb_debugging) {
117
+ var debug_info = $(this).attr ("data");
118
+ console.log ("AI ad blocking SHOW", typeof debug_info != "undefined" ? debug_info : "");
119
+ }
120
+ });
121
+
122
+ $(".ai-adb-hide").each (function () {
123
+ $(this).css ({"display": "none", "visibility": "hidden"});
124
+ if (ai_adb_debugging) {
125
+ var debug_info = $(this).attr ("data");
126
+ console.log ("AI ad blocking HIDE", typeof debug_info != "undefined" ? debug_info : "");
127
+ }
128
+ });
129
+
130
+ // ai_adb_process_content ();
131
+
132
+ setTimeout (ai_adb_process_content, 10);
133
+ });
134
+
135
+ if (ai_adb_debugging) console.log ("AI ad blocking action check");
136
+ // $.removeCookie (ai_adb_pgv_cookie_name, {path: "/" });
137
+
138
+ if (ai_adb_page_views != 0) {
139
+ var ai_adb_page_view_counter = 1;
140
+ var cookie = $.cookie (ai_adb_pgv_cookie_name);
141
+ if (typeof cookie != "undefined") ai_adb_page_view_counter = parseInt (cookie) + 1;
142
+ if (ai_adb_debugging) console.log ("AI ad blocking page views cookie:", cookie, "- page view:", ai_adb_page_view_counter);
143
+ if (ai_adb_page_view_counter < ai_adb_page_views) {
144
+ if (ai_adb_debugging) console.log ("AI ad blocking", ai_adb_page_views, "page views not reached, no action");
145
+ var d1 = ai_adb_page_view_counter;
146
+ var AI_ADB_STATUS_MESSAGE=1;
147
+ $.cookie (ai_adb_pgv_cookie_name, ai_adb_page_view_counter, {expires: 365, path: "/"});
148
+ return;
149
+ }
150
+ }
151
+
152
+ if (ai_adb_message_cookie_lifetime != 0 && (ai_adb_action != 1 || !ai_adb_message_undismissible)) {
153
+ var cookie = $.cookie (ai_adb_act_cookie_name);
154
+ if (ai_adb_debugging) console.log ("AI ad blocking cookie:", cookie);
155
+ if (typeof cookie != "undefined" && cookie == "AI_CONST_AI_ADB_COOKIE_VALUE") {
156
+ if (ai_adb_debugging) console.log ("AI ad blocking valid cookie detected, no action");
157
+ var AI_ADB_STATUS_MESSAGE=2;
158
+ return;
159
+ }
160
+
161
+ else if (ai_adb_debugging) console.log ("AI ad blocking invalid cookie");
162
+ $.cookie (ai_adb_act_cookie_name, "AI_CONST_AI_ADB_COOKIE_VALUE", {expires: ai_adb_message_cookie_lifetime, path: "/"});
163
+ } else $.removeCookie (ai_adb_act_cookie_name, {path: "/" });
164
+
165
+ if (ai_adb_debugging) console.log ("AI ad blocking action", ai_adb_action);
166
+ var AI_ADB_STATUS_MESSAGE=3;
167
+
168
+ switch (ai_adb_action) {
169
+ case 1:
170
+ if (!ai_adb_message_undismissible) {
171
+ ai_adb_overlay.click (function () {
172
+ $(this).remove();
173
+ ai_adb_message_window.remove();
174
+ }).css ("cursor", "pointer");
175
+ ai_adb_message_window.click (function () {
176
+ $(this).remove();
177
+ ai_adb_overlay.remove();
178
+ }).css ("cursor", "pointer");
179
+ window.onkeydown = function( event ) {
180
+ if (event.keyCode === 27 ) {
181
+ ai_adb_overlay.click ();
182
+ ai_adb_message_window.click ();
183
+ }
184
+ }
185
+
186
+ if (ai_adb_debugging) console.log ("AI ad blocking MESSAGE click detection installed");
187
+
188
+ } else {
189
+ // $.removeCookie (ai_adb_act_cookie_name, {path: "/" });
190
+ }
191
+
192
+ if (ai_adb_debugging) console.log ("AI ad blocking MESSAGE");
193
+ $("body").prepend (ai_adb_overlay).prepend (ai_adb_message_window);
194
+ break;
195
+ case 2:
196
+ if (ai_adb_redirection_url != "") {
197
+ if (ai_adb_debugging) console.log ("AI ad blocking REDIRECTION to", ai_adb_redirection_url);
198
+
199
+ var redirect = true;
200
+ if (ai_adb_redirection_url.toLowerCase().substring (0, 4) == "http") {
201
+ if (window.location.href == ai_adb_redirection_url) var redirect = false;
202
+ } else {
203
+ if (window.location.pathname == ai_adb_redirection_url) var redirect = false;
204
+ }
205
+
206
+ if (redirect) {
207
+ var cookie = $.cookie (ai_adb_page_redirection_cookie_name);
208
+ if (typeof cookie == "undefined") {
209
+ var date = new Date();
210
+ date.setTime (date.getTime() + (10 * 1000));
211
+ $.cookie (ai_adb_page_redirection_cookie_name, window.location.href, {expires: date, path: "/" });
212
+
213
+ window.location.replace (ai_adb_redirection_url)
214
+ } else {
215
+ if (ai_adb_debugging) console.log ("AI ad blocking no redirection, cookie:", cookie);
216
+
217
+ }
218
+ } else {
219
+ if (ai_adb_debugging) console.log ("AI ad blocking already on page", window.location.href);
220
+ jQuery.removeCookie (ai_adb_page_redirection_cookie_name, {path: "/"});
221
+ }
222
+ }
223
+ break;
224
+ }
225
+
226
+ }(jQuery));
227
+
228
+ }
229
+ }
230
+
231
+
232
+ var ai_adb_undetected = function(n) {
233
+ ai_adb_counter ++;
234
+
235
+ if (ai_adb_debugging) console.log ("AI ad blocking not detected", n, "- counter:", ai_adb_counter);
236
+
237
+ if (!ai_adb_active && ai_adb_counter == 3) {
238
+ if (ai_adb_debugging) console.log ("AI ad blocking NOT DETECTED");
239
+
240
+ var AI_ADB_STATUS_MESSAGE=4;
241
+
242
+
243
+ // var redirected_page = false;
244
+ // if (ai_adb_redirection_url.toLowerCase().substring (0, 4) == "http") {
245
+ // if (window.location.href == ai_adb_redirection_url) var redirected_page = true;
246
+ // } else {
247
+ // if (window.location.pathname == ai_adb_redirection_url) var redirected_page = true;
248
+ // }
249
+
250
+ // if (redirected_page) {
251
+ // var cookie = jQuery.cookie (ai_adb_page_redirection_cookie_name);
252
+ // if (typeof cookie != "undefined" && cookie.toLowerCase().substring (0, 4) == "http") {
253
+ // if (ai_adb_debugging) console.log ("AI ad blocking returning to", cookie);
254
+ // jQuery.removeCookie (ai_adb_page_redirection_cookie_name, {path: "/"});
255
+ // window.location.replace (cookie);
256
+ // }
257
+ // }
258
+
259
+ }
260
+ }
261
+
262
+ if (AI_DBG_AI_DEBUG_AD_BLOCKING) jQuery (document).ready (function () {ai_adb_detected (0)});
263
+
264
+ if (!document.getElementById ("AI_CONST_AI_ADB_1_NAME")){
265
+ jQuery (document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (1)});
266
+ } else {
267
+ jQuery (document).ready (function () {ai_adb_undetected (1)});
268
+ }
269
+
270
+ if (typeof window.AI_CONST_AI_ADB_2_NAME == "undefined") {
271
+ jQuery (document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (2)});
272
+ } else {
273
+ jQuery (document).ready (function () {ai_adb_undetected (2)});
274
+ }
275
+
276
+ jQuery (document).ready (function ($) {
277
+ $(window).ready (function () {
278
+
279
+
280
+ $("#ai-adb-bar").click (function () {
281
+ $.removeCookie (ai_adb_act_cookie_name, {path: "/" });
282
+ $.removeCookie (ai_adb_pgv_cookie_name, {path: "/" });
283
+ var AI_ADB_STATUS_MESSAGE=5;
284
+ });
285
+
286
+ if ($("#banner-advert-container img").length > 0) {
287
+ if ($("#banner-advert-container img").outerHeight() === 0) {
288
+ $(document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (3)});
289
+ } else $(document).ready (function () {ai_adb_undetected (3)});
290
+ $("#banner-advert-container img").remove();
291
+ }
292
+
293
+ if ((!ai_adb_active || ai_adb_debugging) && ai_adb_selectors != "") {
294
+ var ai_adb_el_counter = 0;
295
+ var ai_adb_el_zero = 0;
296
+ var ai_adb_selector = ai_adb_selectors.split (",");
297
+ $.each (ai_adb_selector, function (i) {
298
+
299
+ if (ai_adb_debugging) console.log ("AI ad blocking selector", ai_adb_selector [i]);
300
+
301
+ if ($(ai_adb_selector [i]).length != 0) {
302
+ $(ai_adb_selector [i]).each (function (n) {
303
+
304
+ if (ai_adb_debugging) console.log ("AI ad blocking element id=\"" + $(this).attr ("id") + "\" class=\"" + $(this).attr ("class") + "\" heights:", $(this).outerHeight (), $(this).innerHeight (), $(this).height ());
305
+
306
+ ai_adb_el_counter ++;
307
+ if ($(this).outerHeight () === 0) {
308
+ $ (document).ready (function () {if (!ai_adb_active || ai_adb_debugging) ai_adb_detected (4)});
309
+ ai_adb_el_zero ++;
310
+ if (!ai_adb_debugging) return false;
311
+ }
312
+
313
+ });
314
+
315
+ }
316
+ });
317
+ if (ai_adb_el_counter != 0 && ai_adb_el_zero == 0) $(document).ready (function () {ai_adb_undetected (4)});
318
+ }
319
+ });
320
+ });
321
+
322
+ /*!
323
+ * jQuery Cookie Plugin v1.4.1
324
+ * https://github.com/carhartl/jquery-cookie
325
+ *
326
+ * Copyright 2013 Klaus Hartl
327
+ * Released under the MIT license
328
+ */
329
+ (function (factory) {
330
+ if (typeof define === "function" && define.amd) {
331
+ // AMD
332
+ define(["jquery"], factory);
333
+ } else if (typeof exports === "object") {
334
+ // CommonJS
335
+ factory(require("jquery"));
336
+ } else {
337
+ // Browser globals
338
+ factory(jQuery);
339
+ }
340
+ }(function ($) {
341
+
342
+ var pluses = /\+/g;
343
+
344
+ function encode(s) {
345
+ return config.raw ? s : encodeURIComponent(s);
346
+ }
347
+
348
+ function decode(s) {
349
+ return config.raw ? s : decodeURIComponent(s);
350
+ }
351
+
352
+ function stringifyCookieValue(value) {
353
+ return encode(config.json ? JSON.stringify(value) : String(value));
354
+ }
355
+
356
+ function parseCookieValue(s) {
357
+ if (s.indexOf('"') === 0) {
358
+ // This is a quoted cookie as according to RFC2068, unescape...
359
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
360
+ }
361
+
362
+ try {
363
+ // Replace server-side written pluses with spaces.
364
+ // If we can\'t decode the cookie, ignore it, it\'s unusable.
365
+ // If we can\'t parse the cookie, ignore it, it\'s unusable.
366
+ s = decodeURIComponent(s.replace(pluses, " "));
367
+ return config.json ? JSON.parse(s) : s;
368
+ } catch(e) {}
369
+ }
370
+
371
+ function read(s, converter) {
372
+ var value = config.raw ? s : parseCookieValue(s);
373
+ return $.isFunction(converter) ? converter(value) : value;
374
+ }
375
+
376
+ var config = $.cookie = function (key, value, options) {
377
+
378
+ // Write
379
+
380
+ if (value !== undefined && !$.isFunction(value)) {
381
+ options = $.extend({}, config.defaults, options);
382
+
383
+ if (typeof options.expires === "number") {
384
+ var days = options.expires, t = options.expires = new Date();
385
+ t.setTime(+t + days * 864e+5);
386
+ }
387
+
388
+ return (document.cookie = [
389
+ encode(key), "=", stringifyCookieValue(value),
390
+ options.expires ? "; expires=" + options.expires.toUTCString() : "", // use expires attribute, max-age is not supported by IE
391
+ options.path ? "; path=" + options.path : "",
392
+ options.domain ? "; domain=" + options.domain : "",
393
+ options.secure ? "; secure" : ""
394
+ ].join(""));
395
+ }
396
+
397
+ // Read
398
+
399
+ var result = key ? undefined : {};
400
+
401
+ // To prevent the for loop in the first place assign an empty array
402
+ // in case there are no cookies at all. Also prevents odd result when
403
+ // calling $.cookie().
404
+ var cookies = document.cookie ? document.cookie.split("; ") : [];
405
+
406
+ for (var i = 0, l = cookies.length; i < l; i++) {
407
+ var parts = cookies[i].split("=");
408
+ var name = decode(parts.shift());
409
+ var cookie = parts.join("=");
410
+
411
+ if (key && key === name) {
412
+ // If second argument (value) is a function it\'s a converter...
413
+ result = read(cookie, value);
414
+ break;
415
+ }
416
+
417
+ // Prevent storing a cookie that we couldn\'t decode.
418
+ if (!key && (cookie = read(cookie)) !== undefined) {
419
+ result[name] = cookie;
420
+ }
421
+ }
422
+
423
+ return result;
424
+ };
425
+
426
+ config.defaults = {};
427
+
428
+ $.removeCookie = function (key, options) {
429
+ if ($.cookie(key) === undefined) {
430
+ return false;
431
+ }
432
+
433
+ // Must not alter options, thus extending a fresh object...
434
+ $.cookie(key, "", $.extend({}, options, { expires: -1 }));
435
+ return !$.cookie(key);
436
+ };
437
+
438
+ }));
439
+
includes/js/ai-adb.min.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var ai_adb_debugging=AI_DATAB_AI_JS_DEBUGGING;var ai_adb_active=false;var ai_adb_counter=0;var ai_adb_overlay=AI_ADB_OVERLAY_WINDOW;var ai_adb_message_window=AI_ADB_MESSAGE_WINDOW;var ai_adb_message_undismissible=AI_FUNCB_GET_UNDISMISSIBLE_MESSAGE;var ai_adb_act_cookie_name="aiADB";var ai_adb_pgv_cookie_name="aiADB_PV";var ai_adb_page_redirection_cookie_name="aiADB_PR";var ai_adb_message_cookie_lifetime=AI_FUNCT_GET_NO_ACTION_PERIOD;var ai_adb_action=AI_FUNCT_GET_ADB_ACTION;
2
+ var ai_adb_page_views=AI_FUNCT_GET_DELAY_ACTION;var ai_adb_selectors="AI_ADB_SELECTORS";var ai_adb_redirection_url="AI_ADB_REDIRECTION_PAGE";
3
+ function ai_adb_process_content(){(function($){$(".AI_ADB_CONTENT_CSS_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_css=$(this).data("css");if(typeof ai_adb_css=="undefined")ai_adb_css="display: none !important;";var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_CSS_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_CSS_BEGIN_CLASS")){$(this).remove();
4
+ ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_CSS_END_CLASS")){$(this).remove();ai_adb_action=false}else if(ai_adb_action){var ai_adb_style=$(this).attr("style");if(typeof ai_adb_style=="undefined")ai_adb_style="";$(this).attr("style",ai_adb_style+";"+ai_adb_css)}})});$(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";
5
+ var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_DELETE_BEGIN_CLASS")){$(this).remove();ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_DELETE_END_CLASS")){$(this).remove();ai_adb_action=false}else if(ai_adb_action)$(this).remove()})});$(".AI_ADB_CONTENT_REPLACE_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_text=$(this).data("text");if(typeof ai_adb_text==
6
+ "undefined")ai_adb_text="";var ai_adb_css=$(this).data("css");if(typeof ai_adb_css=="undefined")ai_adb_css="";var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_REPLACE_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_REPLACE_BEGIN_CLASS")){$(this).remove();ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_REPLACE_END_CLASS")){$(this).remove();
7
+ ai_adb_action=false}else if(ai_adb_action){if(ai_adb_text.length!=0){var n=Math.round($(this).text().length/(ai_adb_text.length+1));$(this).text(Array(n+1).join(ai_adb_text+" "))}else $(this).text("");var ai_adb_style=$(this).attr("style");if(typeof ai_adb_style=="undefined")ai_adb_style="";$(this).attr("style",ai_adb_style+";"+ai_adb_css)}})})})(jQuery)}
8
+ var ai_adb_detected=function(n){if(!ai_adb_active){ai_adb_active=true;(function($){$(window).ready(function(){$(".ai-adb-show").each(function(){$(this).css({"display":"block","visibility":"visible"});if(ai_adb_debugging)var debug_info=$(this).attr("data")});$(".ai-adb-hide").each(function(){$(this).css({"display":"none","visibility":"hidden"});if(ai_adb_debugging)var debug_info=$(this).attr("data")});setTimeout(ai_adb_process_content,10)});if(ai_adb_page_views!=0){var ai_adb_page_view_counter=1;var cookie=
9
+ $.cookie(ai_adb_pgv_cookie_name);if(typeof cookie!="undefined")ai_adb_page_view_counter=parseInt(cookie)+1;if(ai_adb_page_view_counter<ai_adb_page_views){var d1=ai_adb_page_view_counter;var AI_ADB_STATUS_MESSAGE=1;$.cookie(ai_adb_pgv_cookie_name,ai_adb_page_view_counter,{expires:365,path:"/"});return}}if(ai_adb_message_cookie_lifetime!=0&&(ai_adb_action!=1||!ai_adb_message_undismissible)){var cookie=$.cookie(ai_adb_act_cookie_name);if(typeof cookie!="undefined"&&cookie=="AI_CONST_AI_ADB_COOKIE_VALUE"){var AI_ADB_STATUS_MESSAGE=
10
+ 2;return}$.cookie(ai_adb_act_cookie_name,"AI_CONST_AI_ADB_COOKIE_VALUE",{expires:ai_adb_message_cookie_lifetime,path:"/"})}else $.removeCookie(ai_adb_act_cookie_name,{path:"/"});var AI_ADB_STATUS_MESSAGE=3;switch(ai_adb_action){case 1:if(!ai_adb_message_undismissible){ai_adb_overlay.click(function(){$(this).remove();ai_adb_message_window.remove()}).css("cursor","pointer");ai_adb_message_window.click(function(){$(this).remove();ai_adb_overlay.remove()}).css("cursor","pointer");window.onkeydown=function(event){if(event.keyCode===
11
+ 27){ai_adb_overlay.click();ai_adb_message_window.click()}}}else;$("body").prepend(ai_adb_overlay).prepend(ai_adb_message_window);break;case 2:if(ai_adb_redirection_url!=""){var redirect=true;if(ai_adb_redirection_url.toLowerCase().substring(0,4)=="http"){if(window.location.href==ai_adb_redirection_url)var redirect=false}else if(window.location.pathname==ai_adb_redirection_url)var redirect=false;if(redirect){var cookie=$.cookie(ai_adb_page_redirection_cookie_name);if(typeof cookie=="undefined"){var date=
12
+ new Date;date.setTime(date.getTime()+10*1E3);$.cookie(ai_adb_page_redirection_cookie_name,window.location.href,{expires:date,path:"/"});window.location.replace(ai_adb_redirection_url)}else;}else jQuery.removeCookie(ai_adb_page_redirection_cookie_name,{path:"/"})}break}})(jQuery)}};var ai_adb_undetected=function(n){ai_adb_counter++;if(!ai_adb_active&&ai_adb_counter==3)var AI_ADB_STATUS_MESSAGE=4};if(AI_DBG_AI_DEBUG_AD_BLOCKING)jQuery(document).ready(function(){ai_adb_detected(0)});
13
+ if(!document.getElementById("AI_CONST_AI_ADB_1_NAME"))jQuery(document).ready(function(){if(!ai_adb_active||ai_adb_debugging)ai_adb_detected(1)});else jQuery(document).ready(function(){ai_adb_undetected(1)});if(typeof window.AI_CONST_AI_ADB_2_NAME=="undefined")jQuery(document).ready(function(){if(!ai_adb_active||ai_adb_debugging)ai_adb_detected(2)});else jQuery(document).ready(function(){ai_adb_undetected(2)});
14
+ jQuery(document).ready(function($){$(window).ready(function(){$("#ai-adb-bar").click(function(){$.removeCookie(ai_adb_act_cookie_name,{path:"/"});$.removeCookie(ai_adb_pgv_cookie_name,{path:"/"});var AI_ADB_STATUS_MESSAGE=5});if($("#banner-advert-container img").length>0){if($("#banner-advert-container img").outerHeight()===0)$(document).ready(function(){if(!ai_adb_active||ai_adb_debugging)ai_adb_detected(3)});else $(document).ready(function(){ai_adb_undetected(3)});$("#banner-advert-container img").remove()}if((!ai_adb_active||
15
+ ai_adb_debugging)&&ai_adb_selectors!=""){var ai_adb_el_counter=0;var ai_adb_el_zero=0;var ai_adb_selector=ai_adb_selectors.split(",");$.each(ai_adb_selector,function(i){if($(ai_adb_selector[i]).length!=0)$(ai_adb_selector[i]).each(function(n){ai_adb_el_counter++;if($(this).outerHeight()===0){$(document).ready(function(){if(!ai_adb_active||ai_adb_debugging)ai_adb_detected(4)});ai_adb_el_zero++;if(!ai_adb_debugging)return false}})});if(ai_adb_el_counter!=0&&ai_adb_el_zero==0)$(document).ready(function(){ai_adb_undetected(4)})}})});
16
+ (function(factory){if(typeof define==="function"&&define.amd)define(["jquery"],factory);else if(typeof exports==="object")factory(require("jquery"));else factory(jQuery)})(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){if(s.indexOf('"')===0)s=s.slice(1,-1).replace(/\\"/g,
17
+ '"').replace(/\\\\/g,"\\");try{s=decodeURIComponent(s.replace(pluses," "));return config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==="number"){var days=options.expires,t=options.expires=new Date;t.setTime(+t+days*864E5)}return document.cookie=
18
+ [encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}var result=key?undefined:{};var cookies=document.cookie?document.cookie.split("; "):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split("=");var name=decode(parts.shift());var cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}if(!key&&
19
+ (cookie=read(cookie))!==undefined)result[name]=cookie}return result};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined)return false;$.cookie(key,"",$.extend({},options,{expires:-1}));return!$.cookie(key)}});
includes/js/ai-admin.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery (function ($) {
2
+
3
+ $(document).ready(function($) {
4
+
5
+ function show_review_notice () {
6
+ $('.ai-notice').fadeIn ("fast", function() {
7
+ $(this).css ('display', 'table');
8
+ });
9
+ }
10
+
11
+ setTimeout (show_review_notice, 500);
12
+ });
13
+
14
+ $(document).on ('click', '.ai-notice .ai-notice-dismiss', function () {
15
+ var notice_div = $(this).closest ('.ai-notice');
16
+ var nonce = notice_div.attr ('nonce');
17
+ var notice = notice_div.data ('notice');
18
+ var action = $(this).data ('notice');
19
+ // console.log ('CLICK', notice, action);
20
+ notice_div.hide ();
21
+
22
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
23
+ $.ajax (ajaxurl, {
24
+ type: 'POST',
25
+ data: {
26
+ action: 'ai_ajax_backend',
27
+ ai_check: nonce,
28
+ notice: notice,
29
+ click: action,
30
+ }
31
+ });
32
+
33
+ });
34
+ });
includes/js/ai-rotate.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery (function ($) {
2
+ var wrapping_div_selector = ".AI_CONST_AI_BLOCK_CLASS_NAME";
3
+ $("div.ai-rotate").each (function () {
4
+ var rotate_options = $(".ai-rotate-option", this);
5
+ var random_index = Math.floor (Math.random () * rotate_options.length);
6
+
7
+ var d = new Date();
8
+ var n = d.getMilliseconds();
9
+ if (n % 2) random_index = rotate_options.length - random_index - 1;
10
+
11
+ rotate_options.hide ();
12
+ $(rotate_options [random_index]).css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
13
+ $(this).css ({"position": ""});
14
+
15
+ var wrapping_div = $(this).closest (wrapping_div_selector);
16
+ if (typeof wrapping_div.data ("ai") != "undefined") {
17
+ var data = JSON.parse (atob (wrapping_div.data ("ai")));
18
+ if (typeof data !== "undefined" && data.constructor === Array) {
19
+ data [1] = random_index + 1;
20
+ wrapping_div.data ("ai", btoa (JSON.stringify (data)))
21
+ }
22
+ }
23
+ });
24
+ });
25
+
includes/js/ai-rotate.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ jQuery(function($){var wrapping_div_selector=".AI_CONST_AI_BLOCK_CLASS_NAME";$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);var d=new Date;var n=d.getMilliseconds();if(n%2)random_index=rotate_options.length-random_index-1;rotate_options.hide();$(rotate_options[random_index]).css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""});$(this).css({"position":""});var wrapping_div=
2
+ $(this).closest(wrapping_div_selector);if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;wrapping_div.data("ai",btoa(JSON.stringify(data)))}}})});
includes/js/ai-sticky.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ var sticky_widget_margin = AI_FUNC_GET_STICKY_WIDGET_MARGIN;
3
+ var document_width = $(document).width();
4
+
5
+ $(".ai-sticky").each (function () {
6
+ var widget = $(this);
7
+ var widget_width = widget.width();
8
+ // console.log ("WIDGET:", widget.width (), widget.prop ("tagName"), widget.attr ("id"));
9
+ var sidebar = widget.parent ();
10
+ while (sidebar.prop ("tagName") != "BODY") {
11
+ // console.log ("SIDEBAR:", sidebar.width (), sidebar.prop ("tagName"), sidebar.attr ("id"));
12
+ var parent_element = sidebar.parent ();
13
+ var parent_element_width = parent_element.width();
14
+ if (parent_element_width > widget_width * 1.2 || parent_element_width > document_width / 2) break;
15
+ sidebar = parent_element;
16
+ }
17
+ var new_sidebar_top = sidebar.offset ().top - widget.offset ().top + sticky_widget_margin;
18
+ // console.log ("NEW SIDEBAR TOP:", new_sidebar_top);
19
+ if (sidebar.css ("position") != "sticky" || isNaN (parseInt (sidebar.css ("top"))) || sidebar.css ("top") < new_sidebar_top) {
20
+ sidebar.css ("position", "sticky").css ("top", new_sidebar_top);
21
+ // console.log ("SET SIDEBAR TOP:", new_sidebar_top);
22
+ }
23
+ });
24
+ });
includes/js/ai-sticky.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ jQuery(document).ready(function($){var sticky_widget_margin=AI_FUNC_GET_STICKY_WIDGET_MARGIN;var document_width=$(document).width();$(".ai-sticky").each(function(){var widget=$(this);var widget_width=widget.width();var sidebar=widget.parent();while(sidebar.prop("tagName")!="BODY"){var parent_element=sidebar.parent();var parent_element_width=parent_element.width();if(parent_element_width>widget_width*1.2||parent_element_width>document_width/2)break;sidebar=parent_element}var new_sidebar_top=sidebar.offset().top-
2
+ widget.offset().top+sticky_widget_margin;if(sidebar.css("position")!="sticky"||isNaN(parseInt(sidebar.css("top")))||sidebar.css("top")<new_sidebar_top)sidebar.css("position","sticky").css("top",new_sidebar_top)})});
includes/js/sponsors.js ADDED
@@ -0,0 +1 @@
 
1
+ window.ededdaeb=true;
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.1.14";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -38,9 +38,15 @@ var AI_ALIGNMENT_STICKY_RIGHT = 9;
38
  var AI_ALIGNMENT_STICKY_TOP = 10;
39
  var AI_ALIGNMENT_STICKY_BOTTOM = 11;
40
 
41
- var AI_ACTION_NONE = 0;
42
- var AI_ACTION_WARNING_MESSAGE = 1;
43
- var AI_ACTION_REDIRECTION = 2;
 
 
 
 
 
 
44
 
45
  var shSettings = {
46
  "tab_size":"4",
@@ -54,6 +60,8 @@ var shSettings = {
54
  function SyntaxHighlight (id, block, settings) {
55
  var textarea, editor, form, session, editDiv;
56
 
 
 
57
  this.textarea = textarea = jQuery(id);
58
  this.settings = settings || {};
59
 
@@ -89,7 +97,7 @@ function SyntaxHighlight (id, block, settings) {
89
  jQuery("#ai-active-tab").attr ("value", '[' + active_tab + ',' + active_tab_0 + ']');
90
  });
91
 
92
- session.setMode ("ace/mode/html");
93
 
94
  this.applySettings();
95
  }
@@ -144,6 +152,27 @@ function set_editor_text (block, text) {
144
  } else textarea.val (text);
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  jQuery(document).ready(function($) {
149
 
@@ -387,10 +416,6 @@ jQuery(document).ready(function($) {
387
  plotProps : {
388
  fill : "#e2f"
389
  }
390
- }, {
391
- plotProps : {
392
- fill : "gray"
393
- }
394
  }, {
395
  plotProps : {
396
  fill : "#ec6400"
@@ -457,7 +482,7 @@ jQuery(document).ready(function($) {
457
  syntax_highlighting = typeof shSettings ['theme'] != 'undefined' && shSettings ['theme'] != 'disabled';
458
 
459
  var header_id = 'name';
460
- var preview_top = (screen.height / 2) - (820 / 2);
461
 
462
  function remove_default_values (block) {
463
  $("#tab-" + block + " input:checkbox").each (function() {
@@ -558,8 +583,8 @@ jQuery(document).ready(function($) {
558
  var editor = ace.edit ("editor-" + block);
559
 
560
  if ($("input#process-php-"+block).is(":checked")) {
561
- editor.getSession ().setMode ("ace/mode/php");
562
- } else editor.getSession ().setMode ("ace/mode/html");
563
  }
564
 
565
  function disable_auto_refresh_statistics () {
@@ -752,9 +777,7 @@ jQuery(document).ready(function($) {
752
  $("#scheduling-delay-"+block).hide();
753
  $("#scheduling-between-dates-"+block).hide();
754
  $("#scheduling-delay-warning-"+block).hide();
755
-
756
  var scheduling = $("select#scheduling-"+block).val();
757
-
758
  if (scheduling == "1") {
759
  if (content_settings) {
760
  $("#scheduling-delay-"+block).show();
@@ -767,6 +790,13 @@ jQuery(document).ready(function($) {
767
  process_scheduling_dates (block);
768
  }
769
 
 
 
 
 
 
 
 
770
  if (syntax_highlighting) configure_editor_language (block);
771
  }
772
 
@@ -818,10 +848,10 @@ jQuery(document).ready(function($) {
818
 
819
  var adb_action = $("select#adb-action option:selected").attr('value');
820
 
821
- if (adb_action == AI_ACTION_WARNING_MESSAGE) {
822
  $("#adb-message").show();
823
  } else
824
- if (adb_action == AI_ACTION_REDIRECTION) {
825
  $("#adb-page-redirection").show();
826
  }
827
  }
@@ -848,8 +878,9 @@ jQuery(document).ready(function($) {
848
 
849
  if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
850
  var nonce = $(this).attr ('nonce');
851
- var site_url = $(this).attr ('site-url');
852
- $("#export_settings_0").load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&export=0&ai_check=" + nonce, function() {
 
853
  $("#export_settings_0").attr ("name", "export_settings_0");
854
  $("#export-switch-0").addClass ("loaded");
855
  });
@@ -904,12 +935,16 @@ jQuery(document).ready(function($) {
904
 
905
  var window_width = 820;
906
  var window_height = 870;
907
- var nonce = $(this).attr ('nonce');
908
- var site_url = $(this).attr ('site-url');
909
- var page = site_url+"/wp-admin/admin-ajax.php?action=ai_data&preview=adb&ai_check=" + nonce;
910
  var window_left = 120;
911
  var window_top = (screen.height / 2) - (870 / 2);
912
- var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
 
 
 
 
 
 
 
913
  });
914
  }
915
 
@@ -959,6 +994,11 @@ jQuery(document).ready(function($) {
959
  var block = $(this).attr('id').replace ("scheduling-", "");
960
  process_display_elements (block);
961
  });
 
 
 
 
 
962
 
963
  $("#display-homepage-"+tab).change (function() {
964
  var block = $(this).attr('id').replace ("display-homepage-", "");
@@ -1167,8 +1207,9 @@ jQuery(document).ready(function($) {
1167
 
1168
  if ($("#export-container-" + block).is(':visible') && !$(this).hasClass ("loaded")) {
1169
  var nonce = $(this).attr ('nonce');
1170
- var site_url = $(this).attr ('site-url');
1171
- $("#export_settings_" + block).load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&export=" + block + "&ai_check=" + nonce, function() {
 
1172
  $("#export_settings_" + block).attr ("name", "export_settings_" + block);
1173
  $("#export-switch-"+block).addClass ("loaded");
1174
  });
@@ -1205,7 +1246,7 @@ jQuery(document).ready(function($) {
1205
  label.addClass ('on');
1206
 
1207
  var nonce = $(this).attr ('nonce');
1208
- var site_url = $(this).attr ('site-url');
1209
  var start_date = $("input#chart-start-date-" + block).attr('value');
1210
  var end_date = $("input#chart-end-date-" + block).attr('value');
1211
  var container = $("div#statistics-elements-" + block);
@@ -1218,7 +1259,8 @@ jQuery(document).ready(function($) {
1218
  delete_range = '&delete=1';
1219
  }
1220
 
1221
- container.load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&statistics=" + block + "&start-date=" + start_date + "&end-date=" + end_date + delete_range + "&ai_check=" + nonce, function (response, status, xhr) {
 
1222
  label.removeClass ('on');
1223
  if ( status == "error" ) {
1224
  var message = "Error downloading data: " + xhr.status + " " + xhr.statusText ;
@@ -1371,53 +1413,58 @@ jQuery(document).ready(function($) {
1371
  $(this).blur ();
1372
 
1373
 
1374
- var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
 
1375
 
1376
- var css = "";
1377
  if (alignment == AI_ALIGNMENT_DEFAULT) {
1378
- css = $("#css-none-"+block).text ();
1379
  } else
1380
  if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
1381
- css = $("#custom-css-"+block).val();
1382
  } else
1383
  if (alignment == AI_ALIGNMENT_LEFT) {
1384
- css = $("#css-left-"+block).text ();
1385
  } else
1386
  if (alignment == AI_ALIGNMENT_RIGHT) {
1387
- css = $("#css-right-"+block).text ();
1388
  } else
1389
  if (alignment == AI_ALIGNMENT_CENTER) {
1390
- css = $("#css-center-"+block).text ();
1391
  } else
1392
  if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
1393
- css = $("#css-float-left-"+block).text ();
1394
  } else
1395
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
1396
- css = $("#css-float-right-"+block).text ();
1397
  } else
1398
  if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
1399
- css = $("#css-sticky-left-"+block).text ();
1400
  } else
1401
  if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
1402
- css = $("#css-sticky-right-"+block).text ();
1403
  }
1404
  if (alignment == AI_ALIGNMENT_STICKY_TOP) {
1405
- css = $("#css-sticky-top-"+block).text ();
1406
  } else
1407
  if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
1408
- css = $("#css-sticky-bottom-"+block).text ();
1409
  }
1410
 
1411
  var name = $("#name-label-"+block).text ();
1412
 
1413
  var window_width = 820;
1414
  var window_height = 820;
1415
- var nonce = $(this).attr ('nonce');
1416
- var site_url = $(this).attr ('site-url');
1417
- var page = site_url+"/wp-admin/admin-ajax.php?action=ai_data&preview=" + block + "&ai_check=" + nonce + "&alignment=" + alignment + "&css=" + encodeURI (css) + "&name=" + encodeURI (name);
1418
  var window_left = 120;
1419
  var window_top = (screen.height / 2) - (820 / 2);
1420
- var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
 
 
 
 
 
 
 
1421
  });
1422
 
1423
  generate_country_list ('country', tab);
@@ -1425,6 +1472,10 @@ jQuery(document).ready(function($) {
1425
  $('#tracking-' + tab).checkboxButton ();
1426
  $('#simple-editor-' + tab).checkboxButton ();
1427
  $('#process-php-' + tab).checkboxButton ();
 
 
 
 
1428
  }
1429
 
1430
  function generate_country_list (element_name_prefix, index) {
@@ -1591,8 +1642,9 @@ jQuery(document).ready(function($) {
1591
  function update_rating (parameter = '') {
1592
  var rating_bar = $('#ai-rating-bar');
1593
  var nonce = rating_bar.attr ('nonce');
1594
- var site_url = rating_bar.attr ('site-url');
1595
- $("#rating-value span").load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&rating=" + parameter + "&ai_check=" + nonce, function() {
 
1596
  var rating = $("#rating-value span").text ()
1597
  var rating_value = 0;
1598
  if (rating != '') var rating_value = parseFloat (rating);
@@ -1649,7 +1701,7 @@ jQuery(document).ready(function($) {
1649
 
1650
  setTimeout (configure_hidden_tab, 700);
1651
 
1652
- var plugin_version = $('#ai-data').attr ('version');
1653
  if (javascript_version != plugin_version) {
1654
 
1655
  // Check page HTML
@@ -1763,7 +1815,7 @@ jQuery(document).ready(function($) {
1763
  });
1764
 
1765
  $('#plugin_name').dblclick (function () {
1766
- $("#system-debugging").toggle();
1767
  });
1768
 
1769
  $('#ai-stars').click (function () {
1
+ var javascript_version = "2.2.0";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
38
  var AI_ALIGNMENT_STICKY_TOP = 10;
39
  var AI_ALIGNMENT_STICKY_BOTTOM = 11;
40
 
41
+ var AI_ADB_ACTION_NONE = 0;
42
+ var AI_ADB_ACTION_MESSAGE = 1;
43
+ var AI_ADB_ACTION_REDIRECTION = 2;
44
+
45
+ var AI_ADB_BLOCK_ACTION_DO_NOTHING = 0;
46
+ var AI_ADB_BLOCK_ACTION_REPLACE = 1;
47
+ var AI_ADB_BLOCK_ACTION_SHOW = 2;
48
+ var AI_ADB_BLOCK_ACTION_HIDE = 3;
49
+
50
 
51
  var shSettings = {
52
  "tab_size":"4",
60
  function SyntaxHighlight (id, block, settings) {
61
  var textarea, editor, form, session, editDiv;
62
 
63
+ settings ['tab_size'] = 2;
64
+
65
  this.textarea = textarea = jQuery(id);
66
  this.settings = settings || {};
67
 
97
  jQuery("#ai-active-tab").attr ("value", '[' + active_tab + ',' + active_tab_0 + ']');
98
  });
99
 
100
+ session.setMode ("ace/mode/ai-html");
101
 
102
  this.applySettings();
103
  }
152
  } else textarea.val (text);
153
  }
154
 
155
+ function window_open_post (url, windowoption, name, params) {
156
+ var form = document.createElement("form");
157
+ form.setAttribute("method", "post");
158
+ form.setAttribute("action", url);
159
+ form.setAttribute("target", name);
160
+ for (var i in params) {
161
+ if (params.hasOwnProperty(i)) {
162
+ var input = document.createElement('input');
163
+ input.type = 'hidden';
164
+ input.name = i;
165
+ input.value = encodeURI (params[i]);
166
+ form.appendChild(input);
167
+ }
168
+ }
169
+ document.body.appendChild(form);
170
+ //note I am using a post.htm page since I did not want to make double request to the page
171
+ //it might have some Page_Load call which might screw things up.
172
+ window.open("post.htm", name, windowoption);
173
+ form.submit();
174
+ document.body.removeChild(form);
175
+ }
176
 
177
  jQuery(document).ready(function($) {
178
 
416
  plotProps : {
417
  fill : "#e2f"
418
  }
 
 
 
 
419
  }, {
420
  plotProps : {
421
  fill : "#ec6400"
482
  syntax_highlighting = typeof shSettings ['theme'] != 'undefined' && shSettings ['theme'] != 'disabled';
483
 
484
  var header_id = 'name';
485
+ // var preview_top = (screen.height / 2) - (820 / 2);
486
 
487
  function remove_default_values (block) {
488
  $("#tab-" + block + " input:checkbox").each (function() {
583
  var editor = ace.edit ("editor-" + block);
584
 
585
  if ($("input#process-php-"+block).is(":checked")) {
586
+ editor.getSession ().setMode ("ace/mode/ai-php");
587
+ } else editor.getSession ().setMode ("ace/mode/ai-html");
588
  }
589
 
590
  function disable_auto_refresh_statistics () {
777
  $("#scheduling-delay-"+block).hide();
778
  $("#scheduling-between-dates-"+block).hide();
779
  $("#scheduling-delay-warning-"+block).hide();
 
780
  var scheduling = $("select#scheduling-"+block).val();
 
781
  if (scheduling == "1") {
782
  if (content_settings) {
783
  $("#scheduling-delay-"+block).show();
790
  process_scheduling_dates (block);
791
  }
792
 
793
+
794
+ $("#adb-block-replacement-"+block).hide();
795
+ var adb_block_action = $("select#adb-block-action-"+block).val();
796
+ if (adb_block_action == AI_ADB_BLOCK_ACTION_REPLACE) {
797
+ $("#adb-block-replacement-"+block).show();
798
+ }
799
+
800
  if (syntax_highlighting) configure_editor_language (block);
801
  }
802
 
848
 
849
  var adb_action = $("select#adb-action option:selected").attr('value');
850
 
851
+ if (adb_action == AI_ADB_ACTION_MESSAGE) {
852
  $("#adb-message").show();
853
  } else
854
+ if (adb_action == AI_ADB_ACTION_REDIRECTION) {
855
  $("#adb-page-redirection").show();
856
  }
857
  }
878
 
879
  if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
880
  var nonce = $(this).attr ('nonce');
881
+ // var site_url = $(this).attr ('site-url');
882
+ // $("#export_settings_0").load (site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&export=0&ai_check=" + nonce, function() {
883
+ $("#export_settings_0").load (ajaxurl+"?action=ai_ajax_backend&export=0&ai_check=" + nonce, function() {
884
  $("#export_settings_0").attr ("name", "export_settings_0");
885
  $("#export-switch-0").addClass ("loaded");
886
  });
935
 
936
  var window_width = 820;
937
  var window_height = 870;
 
 
 
938
  var window_left = 120;
939
  var window_top = (screen.height / 2) - (870 / 2);
940
+ var nonce = $(this).attr ('nonce');
941
+ // var site_url = $(this).attr ('site-url');
942
+ // var page = site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&preview=adb&ai_check=" + nonce;
943
+ // var page = ajaxurl+"?action=ai_ajax_backend&preview=adb&ai_check=" + nonce;
944
+ // var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
945
+
946
+ var param = {'action': 'ai_ajax_backend', 'preview': 'adb', 'ai_check': nonce};
947
+ window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
948
  });
949
  }
950
 
994
  var block = $(this).attr('id').replace ("scheduling-", "");
995
  process_display_elements (block);
996
  });
997
+ $("select#adb-block-action-"+tab).change (function() {
998
+ var block = $(this).attr('id').replace ("adb-block-action-", "");
999
+ process_display_elements (block);
1000
+ });
1001
+
1002
 
1003
  $("#display-homepage-"+tab).change (function() {
1004
  var block = $(this).attr('id').replace ("display-homepage-", "");
1207
 
1208
  if ($("#export-container-" + block).is(':visible') && !$(this).hasClass ("loaded")) {
1209
  var nonce = $(this).attr ('nonce');
1210
+ // var site_url = $(this).attr ('site-url');
1211
+ // $("#export_settings_" + block).load (site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&export=" + block + "&ai_check=" + nonce, function() {
1212
+ $("#export_settings_" + block).load (ajaxurl+"?action=ai_ajax_backend&export=" + block + "&ai_check=" + nonce, function() {
1213
  $("#export_settings_" + block).attr ("name", "export_settings_" + block);
1214
  $("#export-switch-"+block).addClass ("loaded");
1215
  });
1246
  label.addClass ('on');
1247
 
1248
  var nonce = $(this).attr ('nonce');
1249
+ // var site_url = $(this).attr ('site-url');
1250
  var start_date = $("input#chart-start-date-" + block).attr('value');
1251
  var end_date = $("input#chart-end-date-" + block).attr('value');
1252
  var container = $("div#statistics-elements-" + block);
1259
  delete_range = '&delete=1';
1260
  }
1261
 
1262
+ // container.load (site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&statistics=" + block + "&start-date=" + start_date + "&end-date=" + end_date + delete_range + "&ai_check=" + nonce, function (response, status, xhr) {
1263
+ container.load (ajaxurl+"?action=ai_ajax_backend&statistics=" + block + "&start-date=" + start_date + "&end-date=" + end_date + delete_range + "&ai_check=" + nonce, function (response, status, xhr) {
1264
  label.removeClass ('on');
1265
  if ( status == "error" ) {
1266
  var message = "Error downloading data: " + xhr.status + " " + xhr.statusText ;
1413
  $(this).blur ();
1414
 
1415
 
1416
+ var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1417
+ var custom_css = $("#custom-css-"+block).val ();
1418
 
1419
+ var alignment_css = "";
1420
  if (alignment == AI_ALIGNMENT_DEFAULT) {
1421
+ alignment_css = $("#css-none-"+block).text ();
1422
  } else
1423
  if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
1424
+ alignment_css = $("#custom-css-"+block).val();
1425
  } else
1426
  if (alignment == AI_ALIGNMENT_LEFT) {
1427
+ alignment_css = $("#css-left-"+block).text ();
1428
  } else
1429
  if (alignment == AI_ALIGNMENT_RIGHT) {
1430
+ alignment_css = $("#css-right-"+block).text ();
1431
  } else
1432
  if (alignment == AI_ALIGNMENT_CENTER) {
1433
+ alignment_css = $("#css-center-"+block).text ();
1434
  } else
1435
  if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
1436
+ alignment_css = $("#css-float-left-"+block).text ();
1437
  } else
1438
  if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
1439
+ alignment_css = $("#css-float-right-"+block).text ();
1440
  } else
1441
  if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
1442
+ alignment_css = $("#css-sticky-left-"+block).text ();
1443
  } else
1444
  if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
1445
+ alignment_css = $("#css-sticky-right-"+block).text ();
1446
  }
1447
  if (alignment == AI_ALIGNMENT_STICKY_TOP) {
1448
+ alignment_css = $("#css-sticky-top-"+block).text ();
1449
  } else
1450
  if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
1451
+ alignment_css = $("#css-sticky-bottom-"+block).text ();
1452
  }
1453
 
1454
  var name = $("#name-label-"+block).text ();
1455
 
1456
  var window_width = 820;
1457
  var window_height = 820;
 
 
 
1458
  var window_left = 120;
1459
  var window_top = (screen.height / 2) - (820 / 2);
1460
+ var nonce = $(this).attr ('nonce');
1461
+ // var site_url = $(this).attr ('site-url');
1462
+ // var page = site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&preview=" + block + "&ai_check=" + nonce + "&alignment=" + alignment + "&css=" + encodeURI (alignment_css) + "&name=" + encodeURI (name);
1463
+ // var page = ajaxurl+"?action=ai_ajax_backend&preview=" + block + "&ai_check=" + nonce + "&alignment=" + alignment + "&css=" + encodeURI (alignment_css) + "&name=" + encodeURI (name);
1464
+ // var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
1465
+
1466
+ var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'name': name, 'alignment': alignment, 'alignment_css': alignment_css, 'custom_css': custom_css};
1467
+ window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
1468
  });
1469
 
1470
  generate_country_list ('country', tab);
1472
  $('#tracking-' + tab).checkboxButton ();
1473
  $('#simple-editor-' + tab).checkboxButton ();
1474
  $('#process-php-' + tab).checkboxButton ();
1475
+
1476
+ $('#ai-misc-container-' + tab).tabs();
1477
+ $('#ai-misc-tabs-' + tab).show();
1478
+
1479
  }
1480
 
1481
  function generate_country_list (element_name_prefix, index) {
1642
  function update_rating (parameter = '') {
1643
  var rating_bar = $('#ai-rating-bar');
1644
  var nonce = rating_bar.attr ('nonce');
1645
+ // var site_url = rating_bar.attr ('site-url');
1646
+ // $("#rating-value span").load (site_url+"/wp-admin/admin-ajax.php?action=ai_ajax_backend&rating=" + parameter + "&ai_check=" + nonce, function() {
1647
+ $("#rating-value span").load (ajaxurl+"?action=ai_ajax_backend&rating=" + parameter + "&ai_check=" + nonce, function() {
1648
  var rating = $("#rating-value span").text ()
1649
  var rating_value = 0;
1650
  if (rating != '') var rating_value = parseFloat (rating);
1701
 
1702
  setTimeout (configure_hidden_tab, 700);
1703
 
1704
+ var plugin_version = $('#ai-data').attr ('version').split ('-') [0];
1705
  if (javascript_version != plugin_version) {
1706
 
1707
  // Check page HTML
1815
  });
1816
 
1817
  $('#plugin_name').dblclick (function () {
1818
+ $(".system-debugging").toggle();
1819
  });
1820
 
1821
  $('#ai-stars').click (function () {
preview-adb.php CHANGED
@@ -126,6 +126,7 @@ function generate_code_preview_adb () {
126
  }
127
 
128
  function update_message_preview (editor, e) {
 
129
  jQuery('#message').html (editor.getContent());
130
  }
131
 
@@ -243,6 +244,10 @@ input[type="button"] {
243
  width: initial;
244
  }
245
 
 
 
 
 
246
  .button {
247
  font-size: 14px!important;
248
  }
@@ -306,9 +311,9 @@ input[type="button"] {
306
  $error_reporting = error_reporting ();
307
  error_reporting ($error_reporting & ~E_NOTICE);
308
 
309
- // \_WP_Editors::enqueue_scripts();
310
- // print_footer_scripts ();
311
- // \_WP_Editors::editor_js();
312
 
313
  error_reporting ($error_reporting);
314
 
126
  }
127
 
128
  function update_message_preview (editor, e) {
129
+ if (e.type == 'keyup' && e.key == 'Escape') window.close();
130
  jQuery('#message').html (editor.getContent());
131
  }
132
 
244
  width: initial;
245
  }
246
 
247
+ input[type="text"] {
248
+ margin: 0;
249
+ }
250
+
251
  .button {
252
  font-size: 14px!important;
253
  }
311
  $error_reporting = error_reporting ();
312
  error_reporting ($error_reporting & ~E_NOTICE);
313
 
314
+ _WP_Editors::enqueue_scripts();
315
+ print_footer_scripts ();
316
+ _WP_Editors::editor_js();
317
 
318
  error_reporting ($error_reporting);
319
 
preview.php CHANGED
@@ -11,19 +11,32 @@ function alt_styles_data ($alt_styles_text) {
11
  }
12
  }
13
 
14
- function generate_code_preview ($block) {
15
  global $block_object, $ai_wp_data;
16
 
17
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
18
 
19
  $obj = $block_object [$block];
20
 
21
- $block_name = isset ($_GET ["name"]) ? $_GET ["name"] : $obj->get_ad_name();
22
- $custom_css = $obj->get_custom_css();
23
- $alignment_type = isset ($_GET ["alignment"]) ? $_GET ["alignment"] : $obj->get_alignment_type();
24
- $wrapper_css = isset ($_GET ["css"]) ? $_GET ["css"] : $obj->get_alignment_style ();
 
 
 
 
 
 
25
  $block_code = $obj->ai_getProcessedCode (true, true);
26
 
 
 
 
 
 
 
 
27
  ?><html>
28
  <head>
29
  <title><?php echo AD_INSERTER_NAME; ?> Code Preview</title>
@@ -517,8 +530,23 @@ function generate_code_preview ($block) {
517
  var last_bkg_div = "code-background-white";
518
  var invalid_tags = ['script', 'style'];
519
 
 
 
 
520
  code_blocks.each (function () {
521
  var element_tag = $(this).prop("tagName").toLowerCase();
 
 
 
 
 
 
 
 
 
 
 
 
522
 
523
  if (invalid_tags.indexOf (element_tag) < 0) {
524
  code_index ++;
@@ -639,6 +667,20 @@ function generate_code_preview ($block) {
639
 
640
  </script>
641
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
642
  .responsive-table td {
643
  white-space: nowrap;
644
  }
@@ -802,8 +844,7 @@ div.automatic-insertion img {
802
  width: 50px;
803
  }
804
  </style>
805
- <?php ai_wp_head_hook (); ?>
806
-
807
  </head>
808
  <body style='font-family: arial; text-align: justify; overflow-x: hidden;'>
809
  <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>"></div>
@@ -930,7 +971,7 @@ div.automatic-insertion img {
930
  <div id="css-code" style="margin: 20px 0;">
931
  <div style="margin: 20px 0 0 0;">
932
  Alignment and Style:&nbsp;&nbsp;&nbsp;
933
- <select style="border-radius: 5px; width:120px; height: 25px;" id="block-alignment">
934
  <option data-img-src="<?php echo plugins_url ('images/default.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
935
  <option data-img-src="<?php echo plugins_url ('images/align-left.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
936
  <option data-img-src="<?php echo plugins_url ('images/center.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
@@ -944,7 +985,7 @@ div.automatic-insertion img {
944
  <span id="css-index" style="margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
945
  </div>
946
 
947
- <div id="alignment-style" style="margin: 4px 0;"></div>
948
 
949
  <table class="responsive-table">
950
  <tr>
@@ -952,7 +993,7 @@ div.automatic-insertion img {
952
  <span id="css-label" style="vertical-align: middle; margin: 4px 0 0 0 0; width: 36px; font-size: 14px; font-weight: bold; display: none;">CSS</span>
953
  </td>
954
  <td style="width: 100%; height: 32px; padding:0;">
955
- <input id="custom-css" style="width: 100%; display: inline-block; padding: 5px 0 0 0; border-radius: 4px; display: none; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" value="<?php echo $custom_css; ?>" size="70" maxlength="160" title="Custom CSS code for wrapping div" />
956
  <span style="width: 100%; display: inline-block; padding: 5px 0 0 2px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
957
  <span id="css-no-wrapping" style="vertical-align: middle; display: none;"></span>
958
  <span id="css-<?php echo AI_ALIGNMENT_DEFAULT; ?>" class="css-code" style="vertical-align: middle; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
11
  }
12
  }
13
 
14
+ function generate_code_preview ($block, $name = null, $alignment = null, $alignment_css = null, $custom_css = null) {
15
  global $block_object, $ai_wp_data;
16
 
17
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
18
 
19
  $obj = $block_object [$block];
20
 
21
+ $block_name = $name != null ? $name : $obj->get_ad_name();
22
+ $alignment_type = $alignment != null ? $alignment : $obj->get_alignment_type();
23
+ $wrapper_css = $alignment_css != null ? $alignment_css : $obj->get_alignment_style ();
24
+ $custom_css_code = $custom_css != null ? $custom_css : $obj->get_custom_css();
25
+
26
+ // Head code must be called before ai_getProcessedCode (to process head PHP)
27
+ ob_start ();
28
+ ai_wp_head_hook ();
29
+ $head_code = ob_get_clean ();
30
+
31
  $block_code = $obj->ai_getProcessedCode (true, true);
32
 
33
+ // Fix for relative urls
34
+ $block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
35
+ $block_code = str_replace ("src='wp-content", "src='../wp-content", $block_code);
36
+ $block_code = str_replace ('href="wp-content', 'href="../wp-content', $block_code);
37
+ $block_code = str_replace ("href='wp-content", "href='../wp-content", $block_code);
38
+
39
+
40
  ?><html>
41
  <head>
42
  <title><?php echo AD_INSERTER_NAME; ?> Code Preview</title>
530
  var last_bkg_div = "code-background-white";
531
  var invalid_tags = ['script', 'style'];
532
 
533
+ // console.log ('code_blocks', code_blocks);
534
+
535
+ var filtered_code_blocks = $();
536
  code_blocks.each (function () {
537
  var element_tag = $(this).prop("tagName").toLowerCase();
538
+ if (element_tag == 'a') {
539
+ var a_children = $(this).children ();
540
+ if (a_children.length == 0)
541
+ filtered_code_blocks = filtered_code_blocks.add ($(this)); else
542
+ filtered_code_blocks = filtered_code_blocks.add (a_children);
543
+ } else filtered_code_blocks = filtered_code_blocks.add ($(this));
544
+ });
545
+
546
+ // code_blocks.each (function () {
547
+ filtered_code_blocks.each (function () {
548
+ var element_tag = $(this).prop("tagName");
549
+ if (typeof element_tag != 'undefined') element_tag = element_tag.toLowerCase();
550
 
551
  if (invalid_tags.indexOf (element_tag) < 0) {
552
  code_index ++;
667
 
668
  </script>
669
  <style>
670
+
671
+ /*html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {*/
672
+ a, img {
673
+ border: 0;
674
+ font: inherit;
675
+ font-size: 100%;
676
+ font-style: inherit;
677
+ font-weight: inherit;
678
+ margin: 0;
679
+ outline: 0;
680
+ padding: 0;
681
+ vertical-align: baseline;
682
+ }
683
+
684
  .responsive-table td {
685
  white-space: nowrap;
686
  }
844
  width: 50px;
845
  }
846
  </style>
847
+ <?php echo $head_code; ?>
 
848
  </head>
849
  <body style='font-family: arial; text-align: justify; overflow-x: hidden;'>
850
  <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>"></div>
971
  <div id="css-code" style="margin: 20px 0;">
972
  <div style="margin: 20px 0 0 0;">
973
  Alignment and Style:&nbsp;&nbsp;&nbsp;
974
+ <select id="block-alignment" style="border-radius: 5px; width:120px;">
975
  <option data-img-src="<?php echo plugins_url ('images/default.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
976
  <option data-img-src="<?php echo plugins_url ('images/align-left.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
977
  <option data-img-src="<?php echo plugins_url ('images/center.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
985
  <span id="css-index" style="margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
986
  </div>
987
 
988
+ <div id="alignment-style" style="margin: 4px 0; min-height: 74px;"></div>
989
 
990
  <table class="responsive-table">
991
  <tr>
993
  <span id="css-label" style="vertical-align: middle; margin: 4px 0 0 0 0; width: 36px; font-size: 14px; font-weight: bold; display: none;">CSS</span>
994
  </td>
995
  <td style="width: 100%; height: 32px; padding:0;">
996
+ <input id="custom-css" style="width: 100%; display: inline-block; padding: 5px 0 0 0; border-radius: 4px; display: none; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" value="<?php echo $custom_css_code; ?>" size="70" maxlength="160" title="Custom CSS code for wrapping div" />
997
  <span style="width: 100%; display: inline-block; padding: 5px 0 0 2px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
998
  <span id="css-no-wrapping" style="vertical-align: middle; display: none;"></span>
999
  <span id="css-<?php echo AI_ALIGNMENT_DEFAULT; ?>" class="css-code" style="vertical-align: middle; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
readme.txt CHANGED
@@ -2,13 +2,13 @@
2
 
3
  Contributors: spacetime
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
5
- Tags: ads, adsense, ad management, advertising manager, advanced contextual ads, ad rotation, adverts, widgets, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking, sticky, taxonomy, term, custom post
6
  Requires at least: 4.0
7
  Tested up to: 4.8
8
- Stable tag: 2.1.13
9
  License: GPLv3
10
 
11
- Ad management plugin: AdSense, Amazon ads, banners, ad rotation, sticky widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
12
 
13
  == Description ==
14
 
@@ -85,7 +85,7 @@ Ad Inserter Wordpress plugin is and advanced advertising manager - it has many f
85
 
86
  Ad Inserter is not just another plugin for WordPress ads. Do you enjoy finding the right plugin to solve a particular problem on your site? For example:
87
 
88
- * ad management
89
  * to insert ads between paragraphs
90
  * to insert ads between posts
91
  * to insert ads between comments
@@ -114,7 +114,7 @@ Few very important things you need to know in order to <a href="http://adinserte
114
  * Code block is any code (for example Google AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress
115
  * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
116
  * **Enable insertion on at least one <a href="https://adinserter.pro/page-types">Wordpress page type</a>** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
117
- * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
118
  * 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)
119
  * If you are using AdSense you may get blank (empty) ad blocks. This might be because there is some error in the code (wrong IDs), your Google AdSense account is not fully approved yet, your website was not accepted or your Google AdSense account is banned. Try <a href="http://bit.ly/2oF81Oh" target="_blank">Media net ads</a> - they seem to be a good alternative for contextual ads.
120
 
@@ -274,7 +274,7 @@ Caching on the frontend side (what visitors see) in some cases does speed up pag
274
  When you are using caching and visitor visits some page, Wordpress creates that page, Ad Inseter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later.
275
  The next time the page is visited **the visitor gets cached (saved) page**. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
276
 
277
- * Server-side block rotation with |rotate|
278
  * User check
279
  * Server-side device detection
280
  * Referer check
@@ -286,7 +286,7 @@ When you need the functions listed above you have to switch off caching (if poss
286
 
287
  However, Ad Inserter also supports some of the functions above even when caching is enabled:
288
 
289
- * Client-side ad rotation with |rotate|
290
  * Client-side device detection
291
  * Client-side GEO targeting (country detection, Pro only)
292
  * Client-side IP address detection (Pro only)
@@ -324,12 +324,12 @@ Please note also the following:
324
 
325
  To use client-side rotation you have to enable it first. Go to Ad Inserter plugin settings tab * / tab General and set Dynamic blocks to Client-side.
326
 
327
- Configure blocks normally and separate different versions with |rotate| tag. When the page will be created and Ad Inserter called, it will generate hidden code for all block versions. When the page will be loaded in the browser, one randomly chosen version of the code will be displayed. For example, to rotate 3 images:
328
 
329
  `<img style='height: 400px;' src="http://malsup.github.io/images/p1.jpg">
330
- |rotate|
331
  <img style='height: 400px;' src="http://malsup.github.io/images/p2.jpg">
332
- |rotate|
333
  <img style='height: 400px;' src="http://malsup.github.io/images/p3.jpg">`
334
 
335
  Please note the following:
@@ -405,7 +405,7 @@ You can also try <a href="http://bit.ly/2oF81Oh" target="_blank">Media net ads</
405
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
406
  * Optionally you can enable Sticky widget - this means that this widget (and widgets below) will stay fixed in the sidebar when the page is scrolled, but please note that this may not work with all themes
407
  * You can also make other widgets sticky even if you don't use Ad Inserter widgets - drag Ad Inserter widget to the sidebar ABOVE the top widget that needs to be sticky, select Dummy Widget for Block, check Sticky and save widget
408
- * In general plugin settings (tab *) you can also define Sticky Widget Top Margin to precisely define top position where first sticky widget will stop
409
 
410
  Additional note regarding *sticky widgets*:
411
 
@@ -581,7 +581,7 @@ Use Before paragraph automatic insertion and put `2, 0.5` as paragraph number. Y
581
 
582
  = 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? =
583
 
584
- Yes, simply create block with 4 ads separated with |rotate|: 3 times ad1 and 1 time ad2.
585
 
586
 
587
  = How can I show different ads to different visitors according to a url query parameter? =
@@ -628,27 +628,22 @@ For all options check <a href="http://adinserter.pro/documentation#code-block-op
628
 
629
  = How can I rotate few versions of the same ad? =
630
 
631
- Enter them into the ad box and separate them with |rotate| (vertical bars around text rotate). Ad Inserter will insert them randomly.
632
  Example:
633
 
634
  `ad_code_1
635
- |rotate|
636
  ad_code_2
637
- |rotate|
638
  ad_code_3`
639
 
640
 
641
  = What settings should I use for ads on AMP pages? =
642
 
643
- Asumming AMP urls end with `/amp/` use the following settings:
644
-
645
- * Automatic Insertion: set as needed
646
- * Select **No wrapping** style
647
- * Whitelist url `*/amp/`
648
- * Put AMP head script in the Header code block (tab * / tab Header) and enable it
649
- * For all other ads on standard (non AMP) pages blacklist url `*/amp/`
650
 
651
- If you have different url structure you'll have to adjust url pattern accordingly.
 
652
 
653
  For details check <a href="https://adinserter.pro/settings#amp" target="_blank">settings for ads on AMP pages</a>.
654
 
@@ -684,13 +679,13 @@ Try to use the following custom CSS:
684
 
685
  = How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left? =
686
 
687
- Set Block Alignment and Style to "No Wrapping" and create manual wrapping around both ads separated with |rotate|:
688
 
689
  `<div style="float: left; margin: 0 8px 8px 0;">
690
  AD CODE LEFT
691
  </div>
692
 
693
- |rotate|
694
 
695
  <div style="float: right; margin: 0 0 8px 8px;">
696
  AD CODE RIGHT
@@ -720,6 +715,18 @@ AD CODE RIGHT
720
 
721
  == Changelog ==
722
 
 
 
 
 
 
 
 
 
 
 
 
 
723
  = 2.1.14 =
724
  - Fix for error when using older PHP versions (prior to 5.5)
725
 
@@ -907,67 +914,19 @@ AD CODE RIGHT
907
  - Bug fix: Server-side detection checkbox was not saved properly
908
  - Many other minor bug fixes, code improvements and cosmetic changes
909
 
910
- = 1.7.0 =
911
- - Bug fix: Shortcodes did not ignore post/static page exceptions
912
- - Slightly redesigned user interface
913
- - Excerpt/Post number(s) renamed to Filter as it now works on all display positions
914
- - Widget setting removed from Automatic display to Manual display section
915
- - Added support to disable widgets (standalone checkbox in Manual display)
916
- - Added call counter/filter for widgets
917
- - Added support to edit CSS for predefined styles
918
- - Few other minor bug fixes, code improvements and cosmetic changes
919
-
920
- = 1.6.7 =
921
- - Bug fix: Block code textarea was not escaped
922
- - Added checks for page types for shortcodes
923
- - Added support for Before/After Post position call counter/filter
924
- - Few minor cosmetic changes
925
-
926
- = 1.6.6 =
927
- - Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
928
- - Few minor cosmetic changes
929
- - Requirements changed to WordPress 4.0 or newer
930
- - Added initial support for Pro version
931
-
932
- = 1.6.5 =
933
- - Fixed bug: Wrong counting of max insertions
934
- - Change: display position Before Title was renamed to Before Post
935
- - Added support for display position After Post
936
- - Added support for posts with no `<p>` tags (paragraphs separated with \r\n\r\n characters)
937
- - Added support for paragraph processing on homepage, category, archive and search pages
938
- - Added support for custom viewports
939
- - Added support for PHP function call counter
940
- - Added support to disable code block on error 404 pages
941
- - Added support to debug paragraph tags
942
-
943
- = 1.6.4 =
944
- - Fixed bug: For shortcodes in posts the url was not checked
945
- - Optimizations for device detection
946
-
947
- = 1.6.3 =
948
- - Removed deprecated code (fixes PHP 7 deprecated warnings)
949
- - Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
950
-
951
- = 1.6.2 =
952
- - Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type)
953
- - Added support to change plugin processing priority
954
-
955
- = 1.6.1 =
956
- * Fixed bug: For shortcodes in posts the date was not checked
957
- * Fixed error with some templates "Call to undefined method is_main_query()"
958
- * Added support for minumum number of page/post words for Before/After content display option
959
- * Added support for {author} and {author_name} tags
960
-
961
- = 1.6.0 =
962
- * Added support for client-side device detection
963
- * Many code improvements
964
- * Improved plugin processing speed
965
- * Removed support for deprecated tags for manual insertion {adinserter n}
966
- * Few minor bug fixes
967
-
968
 
969
  == Upgrade Notice ==
970
 
 
 
 
 
 
 
 
 
 
 
971
  = 2.1.14 =
972
  Fix for error when using older PHP versions (prior to 5.5)
973
 
2
 
3
  Contributors: spacetime
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
5
+ Tags: ads, adsense, ad management, advertising manager, advanced contextual ads, ad rotation, ad injection, adverts, sticky widgets, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking
6
  Requires at least: 4.0
7
  Tested up to: 4.8
8
+ Stable tag: 2.1.14
9
  License: GPLv3
10
 
11
+ Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
12
 
13
  == Description ==
14
 
85
 
86
  Ad Inserter is not just another plugin for WordPress ads. Do you enjoy finding the right plugin to solve a particular problem on your site? For example:
87
 
88
+ * ad management and ad injection
89
  * to insert ads between paragraphs
90
  * to insert ads between posts
91
  * to insert ads between comments
114
  * Code block is any code (for example Google AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress
115
  * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
116
  * **Enable insertion on at least one <a href="https://adinserter.pro/page-types">Wordpress page type</a>** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
117
+ * For Posts and Static pages **leave default BLANK selection value** after the checkbox unless you really know what are you doing (using individual exceptions)
118
  * 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)
119
  * If you are using AdSense you may get blank (empty) ad blocks. This might be because there is some error in the code (wrong IDs), your Google AdSense account is not fully approved yet, your website was not accepted or your Google AdSense account is banned. Try <a href="http://bit.ly/2oF81Oh" target="_blank">Media net ads</a> - they seem to be a good alternative for contextual ads.
120
 
274
  When you are using caching and visitor visits some page, Wordpress creates that page, Ad Inseter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later.
275
  The next time the page is visited **the visitor gets cached (saved) page**. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
276
 
277
+ * Server-side block rotation with [ADINSERTER ROTATE] (or old separator |rotate|)
278
  * User check
279
  * Server-side device detection
280
  * Referer check
286
 
287
  However, Ad Inserter also supports some of the functions above even when caching is enabled:
288
 
289
+ * Client-side ad rotation with [ADINSERTER ROTATE] (or old separator |rotate|)
290
  * Client-side device detection
291
  * Client-side GEO targeting (country detection, Pro only)
292
  * Client-side IP address detection (Pro only)
324
 
325
  To use client-side rotation you have to enable it first. Go to Ad Inserter plugin settings tab * / tab General and set Dynamic blocks to Client-side.
326
 
327
+ Configure blocks normally and separate different versions with [ADINSERTER ROTATE] shortcode. When the page will be created and Ad Inserter called, it will generate hidden code for all block versions. When the page will be loaded in the browser, one randomly chosen version of the code will be displayed. For example, to rotate 3 images:
328
 
329
  `<img style='height: 400px;' src="http://malsup.github.io/images/p1.jpg">
330
+ [ADINSERTER ROTATE]
331
  <img style='height: 400px;' src="http://malsup.github.io/images/p2.jpg">
332
+ [ADINSERTER ROTATE]
333
  <img style='height: 400px;' src="http://malsup.github.io/images/p3.jpg">`
334
 
335
  Please note the following:
405
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
406
  * Optionally you can enable Sticky widget - this means that this widget (and widgets below) will stay fixed in the sidebar when the page is scrolled, but please note that this may not work with all themes
407
  * You can also make other widgets sticky even if you don't use Ad Inserter widgets - drag Ad Inserter widget to the sidebar ABOVE the top widget that needs to be sticky, select Dummy Widget for Block, check Sticky and save widget
408
+ * In general plugin settings (tab *) you can also define Sticky Widget Top Margin to precisely define top position where the first sticky widget will stop
409
 
410
  Additional note regarding *sticky widgets*:
411
 
581
 
582
  = 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? =
583
 
584
+ Yes, simply create block with 4 ads separated with [ADINSERTER ROTATE]: 3 times ad1 and 1 time ad2.
585
 
586
 
587
  = How can I show different ads to different visitors according to a url query parameter? =
628
 
629
  = How can I rotate few versions of the same ad? =
630
 
631
+ Enter them into the ad box and separate them with `[ADINSERTER ROTATE]`. Ad Inserter will insert them randomly.
632
  Example:
633
 
634
  `ad_code_1
635
+ [ADINSERTER ROTATE]
636
  ad_code_2
637
+ [ADINSERTER ROTATE]
638
  ad_code_3`
639
 
640
 
641
  = What settings should I use for ads on AMP pages? =
642
 
643
+ Normally the code will not be inserted on AMP pages. There are two settings that can be used to insert code on AMP pages:
 
 
 
 
 
 
644
 
645
+ 1. **AMP pages** checkbox in **Misc / Insertion** section - If checked it enables insertion also on AMP pages. Use this approach only if you need to insert the same code on normal and AMP pages. To insert different codes on AMP pages use **[ADINSERTER AMP]** separator as described below.
646
+ 2. Separate the codes with **[ADINSERTER AMP]** separator - the code above the separator will be inserted on normal pages, the code below the separator will be inserted on AMP pages. This separator can be used also for **Header** and **Footer** code.
647
 
648
  For details check <a href="https://adinserter.pro/settings#amp" target="_blank">settings for ads on AMP pages</a>.
649
 
679
 
680
  = How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left? =
681
 
682
+ Set Block Alignment and Style to "No Wrapping" and create manual wrapping around both ads separated with [ADINSERTER ROTATE]:
683
 
684
  `<div style="float: left; margin: 0 8px 8px 0;">
685
  AD CODE LEFT
686
  </div>
687
 
688
+ [ADINSERTER ROTATE]
689
 
690
  <div style="float: right; margin: 0 0 8px 8px;">
691
  AD CODE RIGHT
715
 
716
  == Changelog ==
717
 
718
+ = 2.2.0 =
719
+ - Added support for ad blocking detection (experimental)
720
+ - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
721
+ - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
722
+ - Added syntax highlighting for shortcodes and separators
723
+ - Added option to define minimum number of words in paragraphs above
724
+ - Added support for %N filter item to filter every N-th insertion
725
+ - Added filter support when inserting for all paragraphs
726
+ - Added style `clear: both;` to Default, Left, Right and Center alignments
727
+ - Bug fix for errors when loading tracking charts (Pro only)
728
+ - Many minor bug fixes, cosmetic changes and code improvements
729
+
730
  = 2.1.14 =
731
  - Fix for error when using older PHP versions (prior to 5.5)
732
 
914
  - Bug fix: Server-side detection checkbox was not saved properly
915
  - Many other minor bug fixes, code improvements and cosmetic changes
916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
 
918
  == Upgrade Notice ==
919
 
920
+ = 2.2.0 =
921
+ Added support for ad blocking detection (experimental);
922
+ Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages;
923
+ Added syntax highlighting for shortcodes and separators
924
+ Added option to define minimum number of words in paragraphs above;
925
+ Added support for %N filter item to filter every N-th insertion;
926
+ Added style `clear: both;` to Default, Left, Right and Center alignments;
927
+ Added filter support when inserting for all paragraphs;
928
+ Bug fix for errors when loading tracking charts (Pro only);
929
+
930
  = 2.1.14 =
931
  Fix for error when using older PHP versions (prior to 5.5)
932
 
settings.php CHANGED
@@ -3,7 +3,8 @@
3
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
 
5
  function generate_settings_form (){
6
- global $ai_db_options, $block_object;
 
7
 
8
  $save_url = $_SERVER ['REQUEST_URI'];
9
  if (isset ($_GET ['tab'])) {
@@ -99,7 +100,7 @@ function generate_settings_form (){
99
 
100
  ?>
101
 
102
- <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>
103
  <?php
104
  if (function_exists ('ai_data_2')) ai_data_2 ();
105
  ?>
@@ -121,8 +122,8 @@ function generate_settings_form (){
121
  <a style="text-decoration: none;" href="http://adinserter.pro/documentation" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button></a>
122
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 68px;" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button></a>
123
  <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button></a>
124
- <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter please write a nice review" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
125
- <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" title="Upgrade to Ad Inserter Pro" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
126
  </div>
127
 
128
  <div style="clear: both;"></div>
@@ -134,7 +135,7 @@ function generate_settings_form (){
134
  <div id="javascript-warning" class="ai-form rounded" style="display: none;">
135
  <h2 id="javascript-version" style="float: left; color: red;" title="Loaded plugin javascript version">&nbsp;</h2>
136
  <div style="float: right; text-align: right; margin: 8px 5px 0px 0;">
137
- <span id="javascript-version-parameter" style="display: none;">Wrong version parameter for the javscript file, probably due to inappropriate caching.<br /></span>
138
  <span id="javascript-version-parameter-missing" style="display: none;">Missing version parameter for the javscript file, probably due to inappropriate caching.<br /></span>
139
  Incompatible (old) javscript file loaded, probably due to inappropriate caching.<br />
140
  Please delete browser's cache and all other caches used and then reload this page.
@@ -155,9 +156,9 @@ function generate_settings_form (){
155
 
156
  <div id="blocked-warning" class="ai-form warning-enabled rounded">
157
  <h2 class="blocked-warning-text" style="float: left; color: red;" title="Error loading page">PAGE BLOCKED</h2>
158
- <div style="float: right; text-align: right; margin: 8px 5px 0px 0;">
159
- This page was not loaded properly. Please check browser and plugins that may block CSS/javascript<br />
160
- files or images for this page. For <strong>Ad Blocker</strong> select "Disable on this page" or "Don't run on this page".
161
  </div>
162
  <div style="clear: both;"></div>
163
  </div>
@@ -213,50 +214,54 @@ function generate_settings_form (){
213
  for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
214
  $obj = $block_object [$ad_number];
215
 
 
 
216
  $manual_widget [$ad_number] = $obj->get_enable_widget() == AI_ENABLED;
217
  $manual_shortcode [$ad_number] = $obj->get_enable_manual() == AI_ENABLED;
218
  $manual_php_function [$ad_number] = $obj->get_enable_php_call() == AI_ENABLED;
219
  $manual [$ad_number] = ($manual_widget [$ad_number] && !empty ($sidebars_with_widget [$ad_number])) || $manual_shortcode [$ad_number] || $manual_php_function [$ad_number];
220
 
221
- $ad_name = $obj->get_ad_name();
222
- $automatic = $obj->get_automatic_insertion() != AI_AUTOMATIC_INSERTION_DISABLED;
223
-
224
- $ad_name_functions = false;
225
- if ($automatic) {
226
- $ad_name .= ": ".$obj->get_automatic_insertion_text ();
227
- $ad_name_functions = true;
228
- }
229
-
230
  $style = "";
231
-
 
232
  if ($automatic && $manual [$ad_number]) $style = "font-weight: bold; color: #c4f;";
233
- elseif ($automatic) $style = "font-weight: bold; color: #e44;";
234
- elseif ($manual [$ad_number]) $style = "font-weight: bold; color: #66f;";
235
 
236
- if (!empty ($sidebars_with_widget [$ad_number])) $sidebars [$ad_number] = implode (", ", $sidebars_with_widget [$ad_number]); else $sidebars [$ad_number] = "";
237
- if ($manual_widget [$ad_number]) {
238
- if ($sidebars [$ad_number] != "") {
239
- $ad_name .= $ad_name_functions ? ", " : ": ";
240
- $ad_name .= "Widget used in: [".$sidebars [$ad_number]."]";
 
241
  $ad_name_functions = true;
242
  }
243
- } else {
244
- if (!empty ($sidebars_with_widget [$ad_number])) {
 
 
245
  $ad_name .= $ad_name_functions ? ", " : ": ";
246
- $ad_name .= "Widget DISABLED but used in: [".$sidebars [$ad_number]."]";
247
  $ad_name_functions = true;
248
  }
249
- }
 
 
 
 
 
 
250
 
251
- if ($manual_shortcode [$ad_number]) {
252
- $ad_name .= $ad_name_functions ? ", " : ": ";
253
- $ad_name .= "Shortcode";
254
- $ad_name_functions = true;
255
- }
256
- if ($manual_php_function [$ad_number]) {
257
- $ad_name .= $ad_name_functions ? ", " : ": ";
258
- $ad_name .= "PHP function";
259
- $ad_name_functions = true;
 
260
  }
261
 
262
  echo "
@@ -264,22 +269,22 @@ function generate_settings_form (){
264
 
265
  }
266
 
267
- $title_hf = "";
268
- if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $title_hf .= ", Header code";
269
- if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $title_hf .= ", Footer code";
270
 
271
  $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
272
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
273
- if ($enabled_h || $enabled_f) $class_hf = " on"; else $class_hf = "";
274
 
275
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
276
- $enabled_a = $adA->get_enable_manual ();
277
- if ($enabled_a) $title_hf .= ", Ad blocking detection code";
278
- if ($enabled_a) $class_hf = " on";
279
  }
280
 
281
  ?>
282
- <li id="ai-tab0" class="ai-tab" title="<?php echo AD_INSERTER_NAME ?> General Settings<?php echo $title_hf ?>" style=" margin: 1px 0 0 0;"><a href="#tab-0" style="padding: 5px 14px 6px 12px;"><div class="ai-icon-gear<?php echo $class_hf ?>"></div></a></li>
283
  </ul>
284
 
285
  <?php
@@ -309,15 +314,44 @@ function generate_settings_form (){
309
  $show_manual = $manual [$ad_number];
310
  if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$ad_number] || empty ($sidebars_with_widget [$ad_number]) ? "#66f;" : "#e44;"); else $manual_style = "";
311
 
 
 
 
 
 
 
 
 
312
  $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
313
 
314
- $show_misc = $scheduling_active || !$obj->get_maximum_insertions () || !$obj->get_call_filter() || $obj->get_inverted_filter() || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS || $obj->get_enable_404 () == AI_ENABLED || $obj->get_enable_feed () == AI_ENABLED;
 
 
 
 
 
 
 
 
 
315
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
316
 
 
 
 
 
 
317
  $automatic_insertion = $obj->get_automatic_insertion();
318
 
319
- $paragraph_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH;
320
- $content_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT;
 
 
 
 
 
 
 
321
 
322
  $paragraph_counting =
323
  $obj->get_direction_type() != $default->get_direction_type() ||
@@ -368,10 +402,10 @@ function generate_settings_form (){
368
 
369
  <div style="padding: 0; min-height: 28px;">
370
  <div style="float: left;">
371
- <button id="misc-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Limit / Filter / Delay insertions, general tag, check for users, insert on error 404 page or in feeds"><span style="<?php echo $misc_style; ?>">Misc</span></button>
372
- <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
373
  <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url, Referer (domain) or Country"><span style="<?php echo $lists_style; ?>">Lists</span></button>
374
  <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
 
 
375
  <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">Preview</button>
376
  </div>
377
  <div style="float: right;">
@@ -444,14 +478,14 @@ function generate_settings_form (){
444
  <div class="responsive-table small-button rounded">
445
  <table>
446
  <tr>
447
- <td style="width: 70%">
448
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
449
  <input 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 '; ?> />
450
 
451
- <select style="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">
452
- <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>
453
- <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
454
- <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
455
  </select>
456
  &nbsp;
457
  <label for="display-posts-<?php echo $ad_number; ?>">Posts</label>
@@ -459,7 +493,7 @@ function generate_settings_form (){
459
  <?php
460
  if (!empty ($block_exceptions [$ad_number])) {
461
  ?>
462
- <button id="exceptions-button-<?php echo $ad_number; ?>" type="button" style="display: none; width: 15px; height: 15px; margin-left: 20px;" title="Toggle Exceptions"></button>
463
  <?php
464
  }
465
  ?>
@@ -469,12 +503,12 @@ function generate_settings_form (){
469
  </td>
470
  <td style="padding-left: 8px;">
471
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
472
- <input id= "display-homepage-<?php echo $ad_number; ?>" style="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 '; ?> />
473
  <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>
474
  </td>
475
  <td style="padding-left: 8px;">
476
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
477
- <input id= "display-category-<?php echo $ad_number; ?>" style="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 '; ?> />
478
  <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)">Category pages</label>
479
  </td>
480
  </tr>
@@ -484,10 +518,10 @@ function generate_settings_form (){
484
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
485
  <input 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 '; ?> />
486
 
487
- <select style="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">
488
- <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>
489
- <option value="<?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED; ?></option>
490
- <option value="<?php echo AD_ENABLED_ONLY_ON_SELECTED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AD_ENABLED_ONLY_ON_SELECTED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ENABLED_ONLY_ON_SELECTED; ?></option>
491
  </select>
492
  &nbsp;
493
  <label for="display-pages-<?php echo $ad_number; ?>">Static pages</label>
@@ -496,12 +530,12 @@ function generate_settings_form (){
496
  </td>
497
  <td style="padding-left: 8px;">
498
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
499
- <input id= "display-search-<?php echo $ad_number; ?>" style="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 '; ?> />
500
  <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable insertion on search blog pages">Search pages</label>
501
  </td>
502
  <td style="padding-left: 8px;">
503
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
504
- <input id= "display-archive-<?php echo $ad_number; ?>" style="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 '; ?> />
505
  <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable insertion on tag or archive blog pages">Tag / Archive pages</label>
506
  </td>
507
  </tr>
@@ -546,7 +580,7 @@ function generate_settings_form (){
546
  </div>
547
 
548
  <div id="paragraph-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php echo $paragraph_settings ? "" : " display: none;" ?>">
549
- <div style="height: 26px;">
550
  <div style="float: left; margin-top: 1px;">
551
  Paragraph number(s)
552
  <input
@@ -563,7 +597,9 @@ function generate_settings_form (){
563
  <button id="counting-button-<?php echo $ad_number; ?>" type="button" style="min-width: 85px; margin-right: 8px; display: none;">Counting</button>
564
  <button id="clearance-button-<?php echo $ad_number; ?>" type="button" style="min-width: 85px; margin-right: 0px; display: none;">Clearance</button>
565
  </div>
566
- </div>
 
 
567
  </div>
568
 
569
  <div id="paragraph-counting-<?php echo $ad_number; ?>" class="rounded" style="<?php echo $paragraph_counting ? "" : "display: none;" ?>">
@@ -884,7 +920,7 @@ function generate_settings_form (){
884
  </label>
885
  </td>
886
  <td>
887
- <pre style= "margin: 0; display: inline; color: blue;" title="Sidebars (or widget positions) where this widged is used"><?php echo $sidebars [$ad_number], !empty ($sidebars [$ad_number]) ? " &nbsp;" : ""; ?></pre>
888
  <button id="widgets-button-<?php echo $ad_number; ?>" type="button" style="display: none; width: 15px; height: 15px;" title="Manage Widgets"></button>
889
  </td>
890
  </tr>
@@ -897,8 +933,8 @@ function generate_settings_form (){
897
  </label>
898
  </td>
899
  <td>
900
- <pre class="select" style="margin: 0; display: inline; color: blue; font-size: 11px;">[adinserter block="<?php echo $ad_number; ?>"]</pre>
901
- or <pre class="select" style="margin: 0; display: inline; color: blue;">[adinserter name="<?php echo $obj->get_ad_name(); ?>"]</pre>
902
  </td>
903
  </tr>
904
  <tr>
@@ -910,103 +946,12 @@ function generate_settings_form (){
910
  </label>
911
  </td>
912
  <td class="select">
913
- <pre style="margin: 0; display: inline; color: blue; font-size: 11px;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $ad_number; ?>); ?&gt;</pre>
914
  </td>
915
  </tr>
916
  </table>
917
  </div>
918
 
919
- <div id="misc-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php if (!$show_misc) echo 'display: none;'; ?>">
920
- <div class="max-input" style="margin: 0 0 8px 0;">
921
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
922
- Insert for
923
- <select style="margin-bottom: 3px;" id="display-for-users-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_display_for_users(); ?>" style="width:160px">
924
- <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
925
- <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
926
- <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
927
- <option value="<?php echo AD_DISPLAY_ADMINISTRATORS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ADMINISTRATORS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ADMINISTRATORS; ?></option>
928
- </select>
929
- </span>
930
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
931
- &nbsp;&nbsp;
932
- Max <input type="text" style="width: 32px;" name="<?php echo AI_OPTION_MAXIMUM_INSERTIONS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_maximum_insertions (); ?>" value="<?php echo $obj->get_maximum_insertions (); ?>" size="1" maxlength="3" title="Empty or 0 means no limit" /> insertions
933
- </span>
934
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
935
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
936
- <input style="margin-left: 20px;" 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 '; ?> />
937
- <label for="enable-ajax-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion in Ajax requests">Ajax</label>
938
- </span>
939
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
940
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
941
- <input style="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 '; ?> />
942
- <label for="enable-feed-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion in feeds">Feed</label>
943
- </span>
944
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
945
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
946
- <input style="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 '; ?> />
947
- <label for="enable-404-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion on page for Error 404: Page not found">404</label>
948
- </span>
949
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
950
- &nbsp;&nbsp;
951
- General tag
952
- &nbsp;
953
- </span>
954
- <span style="display: table-cell;">
955
- <input style="width: 100%;" type="text" name="<?php echo AI_OPTION_GENERAL_TAG, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_general_tag(); ?>" value="<?php echo $obj->get_ad_general_tag(); ?>" size="8" maxlength="40" title="Used for {tags} when no page data is found" />
956
- </span>
957
- </div>
958
-
959
- <div style="margin: 8px 0;">
960
- <div class="max-input" style="margin: 8px 0;">
961
- <span style="display: table-cell;">
962
- Filter insertions
963
- </span>
964
- <span style="display: table-cell;">
965
- <input style="width: 100%; padding-right: 10px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_call_filter(); ?>" value="<?php echo $obj->get_call_filter(); ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, empty means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="12" maxlength="24" />
966
- </span>
967
- <span style="display: table-cell;">
968
- &nbsp;&nbsp;&nbsp;using
969
- <select style="margin-bottom: 3px;" id="filter-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_FILTER_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_filter_type(); ?>" style="width:160px">
970
- <option value="<?php echo AI_FILTER_AUTO; ?>" <?php echo ($filter_type == AI_FILTER_AUTO) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AUTO; ?></option>
971
- <option value="<?php echo AI_FILTER_PHP_FUNCTION_CALLS; ?>" <?php echo ($filter_type == AI_FILTER_PHP_FUNCTION_CALLS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_PHP_FUNCTION_CALLS; ?></option>
972
- <option value="<?php echo AI_FILTER_CONTENT_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_CONTENT_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CONTENT_PROCESSING; ?></option>
973
- <option value="<?php echo AI_FILTER_EXCERPT_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_EXCERPT_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_EXCERPT_PROCESSING; ?></option>
974
- <option value="<?php echo AI_FILTER_BEFORE_POST_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_BEFORE_POST_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST_PROCESSING; ?></option>
975
- <option value="<?php echo AI_FILTER_AFTER_POST_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_AFTER_POST_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_POST_PROCESSING; ?></option>
976
- <option value="<?php echo AI_FILTER_WIDGET_DRAWING; ?>" <?php echo ($filter_type == AI_FILTER_WIDGET_DRAWING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_WIDGET_DRAWING; ?></option>
977
- <option value="<?php echo AI_FILTER_SUBPAGES; ?>" <?php echo ($filter_type == AI_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SUBPAGES; ?></option>
978
- <option value="<?php echo AI_FILTER_POSTS; ?>" <?php echo ($filter_type == AI_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_POSTS; ?></option>
979
- <option value="<?php echo AI_FILTER_PARAGRAPHS; ?>" <?php echo ($filter_type == AI_FILTER_PARAGRAPHS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_PARAGRAPHS; ?></option>
980
- <option value="<?php echo AI_FILTER_COMMENTS; ?>" <?php echo ($filter_type == AI_FILTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_COMMENTS; ?></option>
981
- </select>
982
- counter
983
- </span>
984
- <span style="display: table-cell;">
985
- <input type="hidden" name="<?php echo AI_OPTION_INVERTED_FILTER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
986
- <input style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_INVERTED_FILTER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_inverted_filter(); ?>" <?php if ($obj->get_inverted_filter () == AI_ENABLED) echo 'checked '; ?> />
987
- <label for="enable-ajax-<?php echo $ad_number; ?>" style="vertical-align: top;" title="If checked specified calls are unwanted">Invert filter</label>
988
- </span>
989
- </div>
990
- </div>
991
-
992
- <div style="margin: 8px 0 0 0;">
993
- <select style="margin-bottom: 0px;" id="scheduling-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_SCHEDULING, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_scheduling(); ?>">
994
- <option value="<?php echo AI_SCHEDULING_OFF; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_OFF) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_OFF; ?></option>
995
- <option value="<?php echo AI_SCHEDULING_DELAY; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_DELAY) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DELAY_INSERTION; ?></option>
996
- <?php if (function_exists ('ai_scheduling_options')) ai_scheduling_options ($obj); ?>
997
- </select>
998
-
999
- <span id="scheduling-delay-<?php echo $ad_number; ?>">
1000
- for <input type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_after_day(); ?>" value="<?php echo $obj->get_ad_after_day(); ?>" size="2" maxlength="3" /> days after publishing
1001
- </span>
1002
- <span id="scheduling-delay-warning-<?php echo $ad_number; ?>" style="color: #d00; display: none;">&nbsp;&nbsp; Not available</span>
1003
-
1004
- <?php if (function_exists ('ai_scheduling_data')) ai_scheduling_data ($ad_number, $obj, $default); ?>
1005
- </div>
1006
-
1007
- <?php if (function_exists ('ai_adb_action')) ai_adb_action ($ad_number, $obj, $default); ?>
1008
- </div>
1009
-
1010
  <div id="device-detection-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php if (!$show_devices) echo 'display: none;'; ?>">
1011
  <table>
1012
  <tr>
@@ -1055,6 +1000,121 @@ function generate_settings_form (){
1055
  </table>
1056
  </div>
1057
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1058
  <div id="no-wrapping-warning-<?php echo $ad_number; ?>" class="rounded" style="display: none;">
1059
  <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>
1060
  </div>
@@ -1093,7 +1153,7 @@ function generate_settings_form (){
1093
  if ($enabled_f) $style_f = "font-weight: bold; color: #66f;"; else $style_f = "";
1094
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1095
  $adb_action = get_adb_action();
1096
- if ($enabled_a) $style_a = "font-weight: bold; color: " . ($adb_action == AI_ACTION_NONE ? "#66f;" : "#f00;"); else $style_a = "";
1097
  }
1098
  if (false) $style_d = "font-weight: bold; color: #e44;"; else $style_d = "";
1099
  ?>
@@ -1116,7 +1176,7 @@ function generate_settings_form (){
1116
  <table class="ai-settings-table" style="width: 100%;">
1117
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
1118
  <tr>
1119
- <td style="width: 36%;">
1120
  Syntax Highlighter Theme
1121
  </td>
1122
  <td>
@@ -1177,7 +1237,7 @@ function generate_settings_form (){
1177
  </tr>
1178
  <tr>
1179
  <td>
1180
- Minimum User Role for Exceptions Editing
1181
  </td>
1182
  <td>
1183
  <select style="margin-bottom: 3px;" id="minimum-user-role" name="minimum-user-role" selected-value="1" data="<?php echo get_minimum_user_role (); ?>" default="<?php echo DEFAULT_MINIMUM_USER_ROLE; ?>" style="width:300px">
@@ -1393,9 +1453,9 @@ function generate_settings_form (){
1393
  </td>
1394
  <td>
1395
  <select id="adb-action" name="<?php echo AI_OPTION_ADB_ACTION; ?>" title="Global action when ad blocking is detected" default="<?php echo AI_DEFAULT_ADB_ACTION; ?>" >
1396
- <option value="<?php echo AI_ACTION_NONE; ?>" <?php echo ($adb_action == AI_ACTION_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NONE; ?></option>
1397
- <option value="<?php echo AI_ACTION_WARNING_MESSAGE; ?>" <?php echo ($adb_action == AI_ACTION_WARNING_MESSAGE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_WARNING_MESSAGE; ?></option>
1398
- <option value="<?php echo AI_ACTION_REDIRECTION; ?>" <?php echo ($adb_action == AI_ACTION_REDIRECTION) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_REDIRECTION; ?></option>
1399
  </select>
1400
  </td>
1401
  </tr>
@@ -1504,7 +1564,7 @@ function generate_settings_form (){
1504
  Overlay CSS
1505
  </td>
1506
  <td>
1507
- <input id="overlay-css" style="width: 100%;" type="text" name="<?php echo AI_OPTION_ADB_OVERLAY_CSS; ?>" value="<?php echo get_overlay_css (); ?>" default="<?php echo AI_ADB_DEFAULT_OVERLAY_CSS; ?>" size="50" maxlength="200" />
1508
  </td>
1509
  </tr>
1510
  <tr>
@@ -1513,7 +1573,7 @@ function generate_settings_form (){
1513
  </td>
1514
  <td>
1515
  <input type="hidden" name="<?php echo AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE; ?>" value="0" />
1516
- <input style="margin-left: 1px;" type="checkbox" name="<?php echo AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE; ?>" id="undismissible-message" value="1" default="<?php echo AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE; ?>" <?php if (get_undismissible_message () == AI_ENABLED) echo 'checked '; ?> />
1517
  </td>
1518
  </tr>
1519
  </table>
@@ -1524,27 +1584,66 @@ function generate_settings_form (){
1524
  <?php } ?>
1525
 
1526
  <div id="tab-debugging" class="rounded">
1527
- <div style="margin: 0 0 8px 0;">
1528
- <input type="hidden" name="admin_toolbar_debugging" value="0" />
1529
- <input 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 '; ?> />
1530
- <label for="admin-toolbar-debugging" title="Enable or disable debugging functions in admin toolbar">Debugging functions in admin toolbar</label>
1531
- </div>
1532
-
1533
- <div style="margin: 8px 0 0 0;">
1534
- <input type="hidden" name="remote_debugging" value="0" />
1535
- <input 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 '; ?> />
1536
- <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>
1537
- </div>
1538
-
1539
- <div id="system-debugging" style="display: none;">
1540
- <div style="margin: 8px 0 0 0;">
1541
- <input type="hidden" name="javascript_debugging" value="0" />
1542
- <input 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 '; ?> />
1543
- <label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
1544
- </div>
1545
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1546
  <?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
1547
- </div>
1548
  </div>
1549
 
1550
  </div>
@@ -1552,27 +1651,42 @@ function generate_settings_form (){
1552
 
1553
  </div>
1554
 
1555
- <?php if (!function_exists ('ai_settings_side')) { ?>
1556
 
1557
- <div class="ai-form header rounded">
1558
- <div style="float: left;">
1559
- <h2 style="display: inline-block; margin: 5px 0;">Blank Ad Blocks? Looking for AdSense alternative?</h2>
1560
- </div>
1561
- <div style="clear: both;"></div>
1562
- </div>
1563
 
1564
- <div class="ai-form rounded" style="height: 90px; padding: 8px 4px 8px 12px;">
1565
- <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img id="ai-media-1" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>contextual-1.gif" /></a>
1566
- </div>
1567
 
1568
- <!--<div class="ai-form header rounded">-->
1569
- <!-- <div style="float: left;">-->
1570
- <!-- <h2 style="display: inline-block; margin: 5px 0;">WordPress [Great Content] + Ad Inserter [AdSense, Amazon, media.net] = ?</h2>-->
1571
- <!-- </div>-->
1572
- <!-- <div style="clear: both;"></div>-->
1573
- <!--</div>-->
1574
 
1575
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1576
 
1577
  <input id="ai-active-tab" type="hidden" name="ai-active-tab" value="[<?php echo $active_tab, ',', $active_tab_0; ?>]" />
1578
  <?php wp_nonce_field ('save_adinserter_settings'); ?>
@@ -1585,106 +1699,32 @@ function generate_settings_form (){
1585
 
1586
  <?php
1587
  if ($subpage == 'main') {
1588
- if (function_exists ('ai_settings_side')) ai_settings_side (); else { ?>
 
1589
  <div id="ai-sidebar" style="float: left;">
1590
- <div class="ai-form header rounded no-select">
1591
- <div style="float: left;">
1592
- <h2 style="display: inline-block; margin: 7px 0;">Support plugin development</h2>
1593
- </div>
1594
- <div style="float: right;">
1595
- <a href="https://twitter.com/AdInserter" class="clear-link" target="_blank"><img id="ai-tw" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>twitter.png" style="vertical-align: middle; margin: 0 0 0 20px;" title="Ad Inserter on Twitter" alt="Ad Inserter on Twitter" /></a>
1596
- <a href="https://www.facebook.com/AdInserter/" class="clear-link" target="_blank"><img id="ai-fb" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>facebook.png" style="vertical-align: middle; margin: 0 0 0 10px;" title="Ad Inserter on Facebook" alt="Ad Inserter on Facebook" /></a>
1597
- </div>
1598
- <div style="float: right; margin-top: 2px;">
1599
- <h2 style="display: inline-block; margin: 5px 0;">Follow Ad Inserter</h2>
1600
- </div>
1601
-
1602
- <div style="clear: both;"></div>
1603
- </div>
1604
-
1605
- <div class="ai-form header no-select rounded">
1606
- <ul style="margin: 0;">
1607
- <li><strong>&squf;</strong>
1608
- If you like Ad Inserter please do me a big favor and give plugin a 5 star rating on the <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">review page</a>.
1609
-
1610
- <div id="ai-stars" style="float: right; margin: 0 0 -3px 0; cursor: pointer;"><span><?php echo $rating_value; ?></span><img id="ai-stars-img" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>stars.png" style="margin: 0 0 -3px 10px;"/></div>
1611
-
1612
-
1613
- <div id="ai-rating-bar" class="header" style="float: right; cursor: pointer; margin: 4px 0 0 0; width: 148px; display: none;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">
1614
- <div class="header" style="background: #ccc;" title="Average rating of the plugin - Thank you!">
1615
- <div id="rating-value" style="text-align: center; font-size: 11px; line-height: 12px; border-radius: 2px; background: #fddf87; height: 100%; <?php echo $rating_css; ?>"><span style=""><?php echo $rating_string; ?></span></div>
1616
- </div>
1617
- </div>
1618
- </li>
1619
- <li><strong>&squf;</strong>
1620
- If you're not happy then please open a thread on the <a href="https://wordpress.org/support/plugin/ad-inserter/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">support forum</a> and <a href="https://wordpress.org/support/topic/please-read-how-to-ask-for-help-2/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">describe the problem</a>.
1621
- </li>
1622
- <li><strong>&squf;</strong>
1623
- Ads are not showing? Check <a href="https://adinserter.pro/documentation#ads-not-displayed" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">troubleshooting guide</a> to find out how to fix the problem.
1624
- </li>
1625
- </ul>
1626
-
1627
- <p style="text-align: justify;">Positive reviews are a great way to show your appreciation for my work. Besides being an incredible boost to my morale,<br />
1628
- they are also a great incentive to fix bugs and to add new features for better monetization of your website.
1629
- Thank you! Igor <img draggable="false" class="emoji" alt="happy" src="https://s.w.org/images/core/emoji/2.3/svg/1f642.svg" style="margin-left: 5px!important;"></p>
1630
- </div>
1631
-
1632
- <div class="ai-form rounded no-select" style="background: #fff;">
1633
- <div style="float: right;" >
1634
- <div>
1635
- <a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" title="Automate ad placement on posts and pages" target="_blank"><img id="ai-pro-1" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="margin-top: 10px;" /></a>
1636
- </div>
1637
- <div>
1638
- <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img id="ai-media-2" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>contextual-2.jpg" style="margin-top: 10px;" /></a>
1639
 
1640
- </div>
1641
- </div>
1642
-
1643
- <h3 style="text-align: justify;">Looking for Pro Ad Management plugin?</h3>
1644
- <h4 style="text-align: justify;">To Optimally Monetize your WordPress website?</h4>
1645
-
1646
- <ul>
1647
- <li><strong>&squf;</strong> 64 code (ad) blocks</li>
1648
- <li><strong>&squf;</strong> Syntax highlighting editor</li>
1649
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#code-preview" class="simple-link" target="_blank">Code preview</a> with visual CSS editor</li>
1650
- <li><strong>&squf;</strong> Automatic insertion before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1651
- <li><strong>&squf;</strong> Automatic insertion between posts on blog pages</li>
1652
- <li><strong>&squf;</strong> Automatic insertion before, between and after comments</li>
1653
- <li><strong>&squf;</strong> Insertion exceptions for posts and pages</li>
1654
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#manual" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1655
- <li><strong>&squf;</strong> Sticky positions (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
1656
- <li><strong>&squf;</strong> Sticky (fixed) widgets (sidebar does not move when the page scrolls)</li>
1657
- <li><strong>&squf;</strong> Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
1658
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options to avoid insertion near images or headers (AdSense TOS)</li>
1659
- <li><strong>&squf;</strong> Options to disable insertion on Ajax calls, 404 error pages or in feeds</li>
1660
- <li><strong>&squf;</strong> Ad rotation (works also with caching)</li>
1661
- <li><strong>&squf;</strong> Ad impression and click <a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">tracking</a> (works also with Javascript ads like AdSense)</li>
1662
- <li><strong>&squf;</strong> Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
1663
- <li><strong>&squf;</strong> Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
1664
- <li><strong>&squf;</strong> Support for contextual <a href="https://adinserter.pro/settings#amazon" class="simple-link" target="_blank">Amazon Native Shopping Ads</a> (responsive)</li>
1665
- <li><strong>&squf;</strong> Custom CSS class name for wrapping divs to avoid ad blockers</li>
1666
- <li><strong>&squf;</strong> PHP code processing</li>
1667
- <li><strong>&squf;</strong> Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
1668
- <li><strong>&squf;</strong> Support for Google Analytics, Piwik or any other web analytics code</li>
1669
- <li><strong>&squf;</strong> Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1670
- <li><strong>&squf;</strong> Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a> (works with caching, 6 custom viewports)</li>
1671
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> categories, tags, taxonomies, post IDs, urls, referers</li>
1672
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> IP addresses or countries (works also with caching)</li>
1673
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1674
- <li><strong>&squf;</strong> Import/Export block or plugin settings</li>
1675
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a> with fallback option</li>
1676
- <li><strong>&squf;</strong> Country-level <a href="http://adinserter.pro/documentation#geo-targeting" class="simple-link" target="_blank">GEO targeting</a> (works also with caching)</li>
1677
- <li><strong>&squf;</strong> Simple troubleshooting with many <a href="http://adinserter.pro/documentation#debugging" class="simple-link" target="_blank">debugging functions</a></li>
1678
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
1679
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
1680
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of HTML tags for easier ad placement between paragraphs</li>
1681
- <li><strong>&squf;</strong> Support via email</li>
1682
- </ul>
1683
-
1684
- <p style="text-align: justify;">Ad Inserter Pro is a complete all-in-one ad management plugin for WordPress website with many advertising features to automatically insert adverts on posts and pages.
1685
- With Ad Inserter Pro you also get <strong>one year of free updates and support via email</strong>. If you find Ad Inserter useful and need more code blocks, GEO targeting,
1686
- impression and click tracking or multisite support 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>
1687
- </div>
1688
 
1689
  </div>
1690
  <?php
@@ -1704,7 +1744,8 @@ function generate_settings_form (){
1704
  if (!jQuery(image_selector + ":visible").length) {
1705
  var image = jQuery(image_selector);
1706
  image.hide ().after (image.clone ().attr ('class', '').attr ("id", image_id + '-ajax').
1707
- attr ('src', '<?php echo wp_make_link_relative (get_site_url()); ?>/wp-admin/admin-ajax.php?action=ai_data&image=' + image_src + '&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').
 
1708
  css ('display', css_display));
1709
  }
1710
  }
@@ -1728,3 +1769,142 @@ function generate_settings_form (){
1728
 
1729
  <?php
1730
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
 
5
  function generate_settings_form (){
6
+ global $ai_db_options, $block_object, $ai_wp_data, $ai_db_options_extract;
7
+ global $rating_value, $rating_string, $rating_css;
8
 
9
  $save_url = $_SERVER ['REQUEST_URI'];
10
  if (isset ($_GET ['tab'])) {
100
 
101
  ?>
102
 
103
+ <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo $ai_wp_data [AI_JS_DEBUGGING] ? '1' : '0'; ?>" ></div>
104
  <?php
105
  if (function_exists ('ai_data_2')) ai_data_2 ();
106
  ?>
122
  <a style="text-decoration: none;" href="http://adinserter.pro/documentation" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button></a>
123
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 68px;" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button></a>
124
  <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button></a>
125
+ <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
126
+ <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
127
  </div>
128
 
129
  <div style="clear: both;"></div>
135
  <div id="javascript-warning" class="ai-form rounded" style="display: none;">
136
  <h2 id="javascript-version" style="float: left; color: red;" title="Loaded plugin javascript version">&nbsp;</h2>
137
  <div style="float: right; text-align: right; margin: 8px 5px 0px 0;">
138
+ <span id="javascript-version-parameter" style="display: none;">Wrong or <a href="https://adinserter.pro/documentation#missing-version-parameter" class="simple-link" target="_blank">missing version parameter</a> for the javscript file, probably due to inappropriate caching.<br /></span>
139
  <span id="javascript-version-parameter-missing" style="display: none;">Missing version parameter for the javscript file, probably due to inappropriate caching.<br /></span>
140
  Incompatible (old) javscript file loaded, probably due to inappropriate caching.<br />
141
  Please delete browser's cache and all other caches used and then reload this page.
156
 
157
  <div id="blocked-warning" class="ai-form warning-enabled rounded">
158
  <h2 class="blocked-warning-text" style="float: left; color: red;" title="Error loading page">PAGE BLOCKED</h2>
159
+ <div style="float: right; text-align: right; width: 600px; margin: 8px 5px 0px 0;">
160
+ This page was <a href="https://adinserter.pro/documentation#page-blocked" class="simple-link" target="_blank">not loaded properly</a>. Make sure your theme doesn't add async or defer tags to javascript files.
161
+ Check also browser and ad blocking plugins that may block CSS/js files or images for this page.
162
  </div>
163
  <div style="clear: both;"></div>
164
  </div>
214
  for ($ad_number = $start; $ad_number <= $end; $ad_number ++){
215
  $obj = $block_object [$ad_number];
216
 
217
+ $automatic = $obj->get_automatic_insertion() != AI_AUTOMATIC_INSERTION_DISABLED;
218
+
219
  $manual_widget [$ad_number] = $obj->get_enable_widget() == AI_ENABLED;
220
  $manual_shortcode [$ad_number] = $obj->get_enable_manual() == AI_ENABLED;
221
  $manual_php_function [$ad_number] = $obj->get_enable_php_call() == AI_ENABLED;
222
  $manual [$ad_number] = ($manual_widget [$ad_number] && !empty ($sidebars_with_widget [$ad_number])) || $manual_shortcode [$ad_number] || $manual_php_function [$ad_number];
223
 
 
 
 
 
 
 
 
 
 
224
  $style = "";
225
+ $ad_name = "";
226
+ $sidebars [$ad_number] = "";
227
  if ($automatic && $manual [$ad_number]) $style = "font-weight: bold; color: #c4f;";
228
+ elseif ($automatic) $style = "font-weight: bold; color: #e44;";
229
+ elseif ($manual [$ad_number]) $style = "font-weight: bold; color: #66f;";
230
 
231
+ if (!wp_is_mobile () && false) {
232
+ $ad_name = $obj->get_ad_name();
233
+
234
+ $ad_name_functions = false;
235
+ if ($automatic) {
236
+ $ad_name .= ": ".$obj->get_automatic_insertion_text ();
237
  $ad_name_functions = true;
238
  }
239
+
240
+ if (!empty ($sidebars_with_widget [$ad_number])) $sidebars [$ad_number] = implode (", ", $sidebars_with_widget [$ad_number]);
241
+ if ($manual_widget [$ad_number]) {
242
+ if ($sidebars [$ad_number] != "") {
243
  $ad_name .= $ad_name_functions ? ", " : ": ";
244
+ $ad_name .= "Widget used in: [".$sidebars [$ad_number]."]";
245
  $ad_name_functions = true;
246
  }
247
+ } else {
248
+ if (!empty ($sidebars_with_widget [$ad_number])) {
249
+ $ad_name .= $ad_name_functions ? ", " : ": ";
250
+ $ad_name .= "Widget DISABLED but used in: [".$sidebars [$ad_number]."]";
251
+ $ad_name_functions = true;
252
+ }
253
+ }
254
 
255
+ if ($manual_shortcode [$ad_number]) {
256
+ $ad_name .= $ad_name_functions ? ", " : ": ";
257
+ $ad_name .= "Shortcode";
258
+ $ad_name_functions = true;
259
+ }
260
+ if ($manual_php_function [$ad_number]) {
261
+ $ad_name .= $ad_name_functions ? ", " : ": ";
262
+ $ad_name .= "PHP function";
263
+ $ad_name_functions = true;
264
+ }
265
  }
266
 
267
  echo "
269
 
270
  }
271
 
272
+ $title_hfa = "";
273
+ if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $title_hfa .= ", Header code";
274
+ if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $title_hfa .= ", Footer code";
275
 
276
  $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
277
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
278
+ if ($enabled_h || $enabled_f) $class_hfa = " on"; else $class_hfa = "";
279
 
280
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
281
+ $enabled_a = $ai_wp_data [AI_ADB_DETECTION];
282
+ if ($enabled_a) $title_hfa .= ", Ad blocking detection code";
283
+ if ($enabled_a) $class_hfa = " on";
284
  }
285
 
286
  ?>
287
+ <li id="ai-tab0" class="ai-tab" title="<?php echo AD_INSERTER_NAME ?> General Settings<?php echo $title_hfa ?>" style=" margin: 1px 0 0 0;"><a href="#tab-0" style="padding: 5px 14px 6px 12px;"><div class="ai-icon-gear<?php echo $class_hfa ?>"></div></a></li>
288
  </ul>
289
 
290
  <?php
314
  $show_manual = $manual [$ad_number];
315
  if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$ad_number] || empty ($sidebars_with_widget [$ad_number]) ? "#66f;" : "#e44;"); else $manual_style = "";
316
 
317
+ $insertion_options =
318
+ $obj->get_maximum_insertions () ||
319
+ $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS ||
320
+ $obj->get_enable_amp () == AI_ENABLED ||
321
+ $obj->get_enable_ajax () != AI_ENABLED ||
322
+ $obj->get_enable_404 () == AI_ENABLED ||
323
+ $obj->get_enable_feed () == AI_ENABLED;
324
+
325
  $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
326
 
327
+ $filter_active = $obj->get_call_filter() && $obj->get_inverted_filter() != 0;
328
+
329
+ $adb_block_action_active = $obj->get_adb_block_action () != AI_ADB_BLOCK_ACTION_DO_NOTHING;
330
+
331
+ $show_misc =
332
+ $insertion_options ||
333
+ $scheduling_active ||
334
+ $filter_active ||
335
+ $adb_block_action_active;
336
+
337
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
338
 
339
+ if ($insertion_options) $insertion_style = "font-weight: bold; color: #66f;"; else $insertion_style = "";
340
+ if ($scheduling_active) $scheduling_style = "font-weight: bold; color: #66f;"; else $scheduling_style = "";
341
+ if ($filter_active) $filter_style = "font-weight: bold; color: #66f;"; else $filter_style = "";
342
+ if ($adb_block_action_active) $adb_style = "font-weight: bold; color: #66f;"; else $adb_style = "";
343
+
344
  $automatic_insertion = $obj->get_automatic_insertion();
345
 
346
+ $paragraph_settings =
347
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH ||
348
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH;
349
+
350
+ $content_settings =
351
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH ||
352
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH ||
353
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT ||
354
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT;
355
 
356
  $paragraph_counting =
357
  $obj->get_direction_type() != $default->get_direction_type() ||
402
 
403
  <div style="padding: 0; min-height: 28px;">
404
  <div style="float: left;">
 
 
405
  <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url, Referer (domain) or Country"><span style="<?php echo $lists_style; ?>">Lists</span></button>
406
  <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
407
+ <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
408
+ <button id="misc-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Check for user status, Limit insertions, [error 404 page, Ajax requests, RSS feeds], Filter, Scheduling, General tag"><span style="<?php echo $misc_style; ?>">Misc</span></button>
409
  <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">Preview</button>
410
  </div>
411
  <div style="float: right;">
478
  <div class="responsive-table small-button rounded">
479
  <table>
480
  <tr>
481
+ <td style="width: 70%; padding-bottom: 5px;">
482
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
483
  <input 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 '; ?> />
484
 
485
+ <select style="margin: 0 0 0 10px;" title="Individual post exceptions (if enabled here) can be configured in post editor. Leave blank for no individual post exceptions." 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">
486
+ <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
487
+ <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
488
+ <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
489
  </select>
490
  &nbsp;
491
  <label for="display-posts-<?php echo $ad_number; ?>">Posts</label>
493
  <?php
494
  if (!empty ($block_exceptions [$ad_number])) {
495
  ?>
496
+ <button id="exceptions-button-<?php echo $ad_number; ?>" type="button" style="display: none; width: 15px; height: 15px; margin-left: 20px;" title="Toggle list of individual exceptions"></button>
497
  <?php
498
  }
499
  ?>
503
  </td>
504
  <td style="padding-left: 8px;">
505
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
506
+ <input id= "display-homepage-<?php echo $ad_number; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable insertion on homepage: latest posts (including sub-pages), static page or theme homepage" value="1" default="<?php echo $default->get_display_settings_home(); ?>" <?php if ($obj->get_display_settings_home()==AI_ENABLED) echo 'checked '; ?> />
507
  <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>
508
  </td>
509
  <td style="padding-left: 8px;">
510
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
511
+ <input id= "display-category-<?php echo $ad_number; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)" value="1" default="<?php echo $default->get_display_settings_category(); ?>" <?php if ($obj->get_display_settings_category()==AI_ENABLED) echo 'checked '; ?> />
512
  <label for="display-category-<?php echo $ad_number; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)">Category pages</label>
513
  </td>
514
  </tr>
518
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
519
  <input 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 '; ?> />
520
 
521
+ <select style="margin: 0 0 0 10px;" title="Individual static page exceptions (if enabled here) can be configured in page editor. Leave blank for no individual page exceptions." 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">
522
+ <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
523
+ <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
524
+ <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
525
  </select>
526
  &nbsp;
527
  <label for="display-pages-<?php echo $ad_number; ?>">Static pages</label>
530
  </td>
531
  <td style="padding-left: 8px;">
532
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
533
+ <input id= "display-search-<?php echo $ad_number; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable insertion on search blog pages" value="1" default="<?php echo $default->get_display_settings_search(); ?>" <?php if ($obj->get_display_settings_search()==AI_ENABLED) echo 'checked '; ?> />
534
  <label for="display-search-<?php echo $ad_number; ?>" title="Enable or disable insertion on search blog pages">Search pages</label>
535
  </td>
536
  <td style="padding-left: 8px;">
537
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
538
+ <input id= "display-archive-<?php echo $ad_number; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Enable or disable insertion on tag or archive blog pages" value="1" default="<?php echo $default->get_display_settings_archive(); ?>" <?php if ($obj->get_display_settings_archive()==AI_ENABLED) echo 'checked '; ?> />
539
  <label for="display-archive-<?php echo $ad_number; ?>" title="Enable or disable insertion on tag or archive blog pages">Tag / Archive pages</label>
540
  </td>
541
  </tr>
580
  </div>
581
 
582
  <div id="paragraph-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php echo $paragraph_settings ? "" : " display: none;" ?>">
583
+ <!-- <div>-->
584
  <div style="float: left; margin-top: 1px;">
585
  Paragraph number(s)
586
  <input
597
  <button id="counting-button-<?php echo $ad_number; ?>" type="button" style="min-width: 85px; margin-right: 8px; display: none;">Counting</button>
598
  <button id="clearance-button-<?php echo $ad_number; ?>" type="button" style="min-width: 85px; margin-right: 0px; display: none;">Clearance</button>
599
  </div>
600
+
601
+ <div style="clear: both;"></div>
602
+ <!-- </div>-->
603
  </div>
604
 
605
  <div id="paragraph-counting-<?php echo $ad_number; ?>" class="rounded" style="<?php echo $paragraph_counting ? "" : "display: none;" ?>">
920
  </label>
921
  </td>
922
  <td>
923
+ <pre style= "margin: 0; display: inline; color: blue; white-space: pre-wrap; word-wrap: break-word;" title="Sidebars (or widget positions) where this widged is used"><?php echo $sidebars [$ad_number], !empty ($sidebars [$ad_number]) ? " &nbsp;" : ""; ?></pre>
924
  <button id="widgets-button-<?php echo $ad_number; ?>" type="button" style="display: none; width: 15px; height: 15px;" title="Manage Widgets"></button>
925
  </td>
926
  </tr>
933
  </label>
934
  </td>
935
  <td>
936
+ <pre class="select" style="margin: 0; display: inline; color: blue; font-size: 11px; white-space: pre-wrap; word-wrap: break-word;">[adinserter block="<?php echo $ad_number; ?>"]</pre>
937
+ or <pre class="select" style="margin: 0; display: inline; color: blue; white-space: pre-wrap; word-wrap: break-word;">[adinserter name="<?php echo $obj->get_ad_name(); ?>"]</pre>
938
  </td>
939
  </tr>
940
  <tr>
946
  </label>
947
  </td>
948
  <td class="select">
949
+ <pre style="margin: 0; display: inline; color: blue; font-size: 11px; white-space: pre-wrap; word-wrap: break-word;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $ad_number; ?>); ?&gt;</pre>
950
  </td>
951
  </tr>
952
  </table>
953
  </div>
954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
955
  <div id="device-detection-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php if (!$show_devices) echo 'display: none;'; ?>">
956
  <table>
957
  <tr>
1000
  </table>
1001
  </div>
1002
 
1003
+ <div id="misc-settings-<?php echo $ad_number; ?>" style="<?php if (!$show_misc) echo 'display: none;'; ?>">
1004
+ <div id="ai-misc-container-<?php echo $ad_number; ?>" style="padding: 0; margin 8px 0 0 0; border: 0;">
1005
+ <ul id="ai-misc-tabs-<?php echo $ad_number; ?>" style="display: none;">
1006
+ <li id="ai-misc-insertion-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-insertion-<?php echo $ad_number; ?>"><span style="<?php echo $insertion_style; ?>">Insertion</span></a></li>
1007
+ <li id="ai-misc-filter-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-filter-<?php echo $ad_number; ?>"><span style="<?php echo $filter_style; ?>">Filter</span></a></li>
1008
+ <li id="ai-misc-scheduling-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-scheduling-<?php echo $ad_number; ?>"><span style="<?php echo $scheduling_style; ?>">Scheduling</span></a></li>
1009
+ <?php if (function_exists ('ai_adb_action_0')) ai_adb_action_0 ($ad_number, $adb_style); ?>
1010
+ <li id="ai-misc-general-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-general-<?php echo $ad_number; ?>">General</a></li>
1011
+ </ul>
1012
+
1013
+ <div id="tab-insertion-<?php echo $ad_number; ?>" class="rounded">
1014
+ <div class="max-input">
1015
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1016
+ Insert for
1017
+ <select id="display-for-users-<?php echo $ad_number; ?>" style="margin: 0 1px;" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_display_for_users(); ?>" style="width:160px">
1018
+ <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
1019
+ <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
1020
+ <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
1021
+ <option value="<?php echo AD_DISPLAY_ADMINISTRATORS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ADMINISTRATORS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ADMINISTRATORS; ?></option>
1022
+ </select>
1023
+ </span>
1024
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1025
+ &nbsp;&nbsp;
1026
+ Max <input type="text" style="width: 32px;" name="<?php echo AI_OPTION_MAXIMUM_INSERTIONS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_maximum_insertions (); ?>" value="<?php echo $obj->get_maximum_insertions (); ?>" size="1" maxlength="3" title="Empty or 0 means no limit" /> insertions
1027
+ </span>
1028
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1029
+ <input type="hidden" name="<?php echo AI_OPTION_ENABLE_AMP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
1030
+ <input style="margin-left: 10px;" id="enable-amp-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_AMP, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_enable_amp(true); ?>" <?php if ($obj->get_enable_amp (true) == AI_ENABLED) echo 'checked '; ?> />
1031
+ <label for="enable-amp-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion on AMP pages. To insert different codes on normal and AMP pages separate them with [ADINSERTER AMP] separator.">AMP pages</label>
1032
+ </span>
1033
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1034
+ <input type="hidden" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
1035
+ <input style="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 '; ?> />
1036
+ <label for="enable-ajax-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion for Ajax requests">Ajax</label>
1037
+ </span>
1038
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1039
+ <input type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
1040
+ <input style="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 '; ?> />
1041
+ <label for="enable-feed-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion in RSS feeds">RSS Feed</label>
1042
+ </span>
1043
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1044
+ <input type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
1045
+ <input style="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 '; ?> />
1046
+ <label for="enable-404-<?php echo $ad_number; ?>" style="vertical-align: top;" title="Enable or disable insertion on page for Error 404: Page not found">Error page</label>
1047
+ </span>
1048
+ </div>
1049
+ </div>
1050
+
1051
+ <div id="tab-filter-<?php echo $ad_number; ?>" class="rounded">
1052
+ <div class="max-input">
1053
+ <span style="display: table-cell;">
1054
+ Filter insertions
1055
+ </span>
1056
+ <span style="display: table-cell;">
1057
+ <input style="width: 100%; padding-right: 10px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_call_filter(); ?>" value="<?php echo $obj->get_call_filter(); ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, empty means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="12" maxlength="24" />
1058
+ </span>
1059
+ <span style="display: table-cell;">
1060
+ &nbsp;&nbsp;&nbsp;using
1061
+ <select id="filter-type-<?php echo $ad_number; ?>" style="margin: 0 1px;" name="<?php echo AI_OPTION_FILTER_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_filter_type(); ?>" style="width:160px">
1062
+ <option value="<?php echo AI_FILTER_AUTO; ?>" <?php echo ($filter_type == AI_FILTER_AUTO) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AUTO; ?></option>
1063
+ <option value="<?php echo AI_FILTER_PHP_FUNCTION_CALLS; ?>" <?php echo ($filter_type == AI_FILTER_PHP_FUNCTION_CALLS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_PHP_FUNCTION_CALLS; ?></option>
1064
+ <option value="<?php echo AI_FILTER_CONTENT_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_CONTENT_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CONTENT_PROCESSING; ?></option>
1065
+ <option value="<?php echo AI_FILTER_EXCERPT_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_EXCERPT_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_EXCERPT_PROCESSING; ?></option>
1066
+ <option value="<?php echo AI_FILTER_BEFORE_POST_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_BEFORE_POST_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST_PROCESSING; ?></option>
1067
+ <option value="<?php echo AI_FILTER_AFTER_POST_PROCESSING; ?>" <?php echo ($filter_type == AI_FILTER_AFTER_POST_PROCESSING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_POST_PROCESSING; ?></option>
1068
+ <option value="<?php echo AI_FILTER_WIDGET_DRAWING; ?>" <?php echo ($filter_type == AI_FILTER_WIDGET_DRAWING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_WIDGET_DRAWING; ?></option>
1069
+ <option value="<?php echo AI_FILTER_SUBPAGES; ?>" <?php echo ($filter_type == AI_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SUBPAGES; ?></option>
1070
+ <option value="<?php echo AI_FILTER_POSTS; ?>" <?php echo ($filter_type == AI_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_POSTS; ?></option>
1071
+ <option value="<?php echo AI_FILTER_PARAGRAPHS; ?>" <?php echo ($filter_type == AI_FILTER_PARAGRAPHS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_PARAGRAPHS; ?></option>
1072
+ <option value="<?php echo AI_FILTER_COMMENTS; ?>" <?php echo ($filter_type == AI_FILTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_COMMENTS; ?></option>
1073
+ </select>
1074
+ counter
1075
+ </span>
1076
+ <span style="display: table-cell;">
1077
+ <input type="hidden" name="<?php echo AI_OPTION_INVERTED_FILTER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
1078
+ <input style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_INVERTED_FILTER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_inverted_filter(); ?>" <?php if ($obj->get_inverted_filter () == AI_ENABLED) echo 'checked '; ?> />
1079
+ <label for="enable-ajax-<?php echo $ad_number; ?>" style="vertical-align: top;" title="If checked specified calls are unwanted">Invert filter</label>
1080
+ </span>
1081
+ </div>
1082
+ </div>
1083
+
1084
+ <div id="tab-scheduling-<?php echo $ad_number; ?>" class="rounded" style="min-height: 24px;">
1085
+ <select id="scheduling-<?php echo $ad_number; ?>" style="margin: 0 1px;" name="<?php echo AI_OPTION_SCHEDULING, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_scheduling(); ?>">
1086
+ <option value="<?php echo AI_SCHEDULING_OFF; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_OFF) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_OFF; ?></option>
1087
+ <option value="<?php echo AI_SCHEDULING_DELAY; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_DELAY) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DELAY_INSERTION; ?></option>
1088
+ <?php if (function_exists ('ai_scheduling_options')) ai_scheduling_options ($obj); ?>
1089
+ </select>
1090
+
1091
+ <span id="scheduling-delay-<?php echo $ad_number; ?>">
1092
+ for <input type="text" name="<?php echo AI_OPTION_AFTER_DAYS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_after_day(); ?>" value="<?php echo $obj->get_ad_after_day(); ?>" size="2" maxlength="3" /> days after publishing
1093
+ </span>
1094
+ <span id="scheduling-delay-warning-<?php echo $ad_number; ?>" style="color: #d00; display: none;">&nbsp;&nbsp; Not available</span>
1095
+
1096
+ <?php if (function_exists ('ai_scheduling_data')) ai_scheduling_data ($ad_number, $obj, $default); ?>
1097
+ </div>
1098
+
1099
+ <?php if (function_exists ('ai_adb_action')) ai_adb_action ($ad_number, $obj, $default); ?>
1100
+
1101
+ <div id="tab-general-<?php echo $ad_number; ?>" class="rounded">
1102
+ <div class="max-input">
1103
+ <span style="display: table-cell; width: 1px; white-space: nowrap;">
1104
+ General tag
1105
+ &nbsp;
1106
+ </span>
1107
+ <span style="display: table-cell;">
1108
+ <input style="width: 100%;" type="text" name="<?php echo AI_OPTION_GENERAL_TAG, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_general_tag(); ?>" value="<?php echo $obj->get_ad_general_tag(); ?>" size="8" maxlength="40" title="Used for {tags} when no page data is found" />
1109
+ </span>
1110
+ <span style="display: table-cell; width: 400px; white-space: nowrap;">
1111
+ </span>
1112
+ </div>
1113
+ </div>
1114
+
1115
+ </div>
1116
+ </div>
1117
+
1118
  <div id="no-wrapping-warning-<?php echo $ad_number; ?>" class="rounded" style="display: none;">
1119
  <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>
1120
  </div>
1153
  if ($enabled_f) $style_f = "font-weight: bold; color: #66f;"; else $style_f = "";
1154
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1155
  $adb_action = get_adb_action();
1156
+ if ($enabled_a) $style_a = "font-weight: bold; color: " . ($adb_action == AI_ADB_ACTION_NONE ? "#66f;" : "#f00;"); else $style_a = "";
1157
  }
1158
  if (false) $style_d = "font-weight: bold; color: #e44;"; else $style_d = "";
1159
  ?>
1176
  <table class="ai-settings-table" style="width: 100%;">
1177
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
1178
  <tr>
1179
+ <td style="width: 34%;">
1180
  Syntax Highlighter Theme
1181
  </td>
1182
  <td>
1237
  </tr>
1238
  <tr>
1239
  <td>
1240
+ Min. User Role for Ind. Exceptions Editing
1241
  </td>
1242
  <td>
1243
  <select style="margin-bottom: 3px;" id="minimum-user-role" name="minimum-user-role" selected-value="1" data="<?php echo get_minimum_user_role (); ?>" default="<?php echo DEFAULT_MINIMUM_USER_ROLE; ?>" style="width:300px">
1453
  </td>
1454
  <td>
1455
  <select id="adb-action" name="<?php echo AI_OPTION_ADB_ACTION; ?>" title="Global action when ad blocking is detected" default="<?php echo AI_DEFAULT_ADB_ACTION; ?>" >
1456
+ <option value="<?php echo AI_ADB_ACTION_NONE; ?>" <?php echo ($adb_action == AI_ADB_ACTION_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NONE; ?></option>
1457
+ <option value="<?php echo AI_ADB_ACTION_MESSAGE; ?>" <?php echo ($adb_action == AI_ADB_ACTION_MESSAGE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_POPUP_MESSAGE; ?></option>
1458
+ <option value="<?php echo AI_ADB_ACTION_REDIRECTION; ?>" <?php echo ($adb_action == AI_ADB_ACTION_REDIRECTION) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_REDIRECTION; ?></option>
1459
  </select>
1460
  </td>
1461
  </tr>
1564
  Overlay CSS
1565
  </td>
1566
  <td>
1567
+ <input id="overlay-css" style="width: 100%;" type="text" name="<?php echo AI_OPTION_ADB_OVERLAY_CSS; ?>" value="<?php echo get_overlay_css (); ?>" default="<?php echo AI_DEFAULT_ADB_OVERLAY_CSS; ?>" size="50" maxlength="200" />
1568
  </td>
1569
  </tr>
1570
  <tr>
1573
  </td>
1574
  <td>
1575
  <input type="hidden" name="<?php echo AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE; ?>" value="0" />
1576
+ <input type="checkbox" name="<?php echo AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE; ?>" id="undismissible-message" value="1" default="<?php echo AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE; ?>" <?php if (get_undismissible_message () == AI_ENABLED) echo 'checked '; ?> />
1577
  </td>
1578
  </tr>
1579
  </table>
1584
  <?php } ?>
1585
 
1586
  <div id="tab-debugging" class="rounded">
1587
+ <table class="ai-settings-table" style="width: 100%;">
1588
+ <tr>
1589
+ <td style="width: 30%;">
1590
+ <label for="admin-toolbar-debugging" title="Enable or disable debugging functions in admin toolbar">Debugging functions in admin toolbar</label>
1591
+ </td>
1592
+ <td>
1593
+ <input type="hidden" name="admin_toolbar_debugging" value="0" />
1594
+ <input 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 '; ?> />
1595
+ </td>
1596
+ </tr>
1597
+ <tr>
1598
+ <td>
1599
+ <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>
1600
+ </td>
1601
+ <td>
1602
+ <input type="hidden" name="remote_debugging" value="0" />
1603
+ <input 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 '; ?> />
1604
+ </td>
1605
+ </tr>
1606
+ <tr class="system-debugging" style="display: none;">
1607
+ <td>
1608
+ <label for="javascript-debugging" title="Enable Javascript console output">Javascript debugging</label>
1609
+ </td>
1610
+ <td>
1611
+ <input type="hidden" name="javascript_debugging" value="0" />
1612
+ <input 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 '; ?> />
1613
+ </td>
1614
+ </tr>
1615
+ <tr class="system-debugging" style="display: none;">
1616
+ <td>
1617
+ Installation
1618
+ </td>
1619
+ <td>
1620
+ <?php echo ($install_timestamp = get_option (AI_INSTALL_NAME)) !== false ? date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600) : ""; ?>
1621
+ </td>
1622
+ </tr>
1623
+ <tr class="system-debugging" style="display: none;">
1624
+ <td>
1625
+ Age
1626
+ </td>
1627
+ <td>
1628
+ <?php if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) printf ('%04d-%02d-%02d %02d:%02d:%02d',
1629
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
1630
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
1631
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
1632
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
1633
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
1634
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s); ?>
1635
+ </td>
1636
+ </tr>
1637
+ <tr class="system-debugging" style="display: none;">
1638
+ <td>
1639
+ Used blocks
1640
+ </td>
1641
+ <td>
1642
+ <?php if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) echo $ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]; ?>
1643
+ </td>
1644
+ </tr>
1645
  <?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
1646
+ </table>
1647
  </div>
1648
 
1649
  </div>
1651
 
1652
  </div>
1653
 
1654
+ <?php
1655
 
1656
+ $sidebar = 0;
1657
+ if (isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
1658
+ if ( $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 5) $sidebar = 1;
 
 
 
1659
 
1660
+ if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20) $sidebar = 2;
 
 
1661
 
1662
+ if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 25) $sidebar = 3;
1663
+ if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 25 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 35) $sidebar = 3;
 
 
 
 
1664
 
1665
+ if ( $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 40) $sidebar = 4;
1666
+ }
1667
+
1668
+ // $sidebar = 4;
1669
+
1670
+
1671
+ if (!function_exists ('ai_settings_side') && $sidebar >= 2) {
1672
+
1673
+ switch ($sidebar) {
1674
+ case 0:
1675
+ break;
1676
+ case 1:
1677
+ break;
1678
+ case 2:
1679
+ break;
1680
+ case 3:
1681
+ sidebar_ratings ();
1682
+ break;
1683
+ case 4:
1684
+ sidebar_addense_alternative ();
1685
+ break;
1686
+ }
1687
+
1688
+ }
1689
+ ?>
1690
 
1691
  <input id="ai-active-tab" type="hidden" name="ai-active-tab" value="[<?php echo $active_tab, ',', $active_tab_0; ?>]" />
1692
  <?php wp_nonce_field ('save_adinserter_settings'); ?>
1699
 
1700
  <?php
1701
  if ($subpage == 'main') {
1702
+ if (function_exists ('ai_settings_side')) ai_settings_side (); else {
1703
+ ?>
1704
  <div id="ai-sidebar" style="float: left;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1705
 
1706
+ <?php
1707
+ switch ($sidebar) {
1708
+ case 0:
1709
+ break;
1710
+ case 1:
1711
+ sidebar_support ();
1712
+ break;
1713
+ case 2:
1714
+ sidebar_support ();
1715
+ sidebar_addense_alternative ();
1716
+ break;
1717
+ case 3:
1718
+ sidebar_support ();
1719
+ sidebar_addense_alternative ();
1720
+ break;
1721
+ case 4:
1722
+ sidebar_support ();
1723
+ sidebar_ratings ();
1724
+ sidebar_pro ();
1725
+ break;
1726
+ }
1727
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1728
 
1729
  </div>
1730
  <?php
1744
  if (!jQuery(image_selector + ":visible").length) {
1745
  var image = jQuery(image_selector);
1746
  image.hide ().after (image.clone ().attr ('class', '').attr ("id", image_id + '-ajax').
1747
+ // attr ('src', '<?php echo wp_make_link_relative (get_site_url()); ?>/wp-admin/admin-ajax.php?action=ai_ajax_backend&image=' + image_src + '&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').
1748
+ attr ('src', ajaxurl+'?action=ai_ajax_backend&image=' + image_src + '&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').
1749
  css ('display', css_display));
1750
  }
1751
  }
1769
 
1770
  <?php
1771
  }
1772
+
1773
+ function sidebar_addense_alternative () { ?>
1774
+
1775
+ <div class="ai-form header rounded">
1776
+ <div style="float: left;">
1777
+ <h2 style="display: inline-block; margin: 5px 0;">Blank Ad Blocks? Looking for AdSense alternative?</h2>
1778
+ </div>
1779
+ <div style="clear: both;"></div>
1780
+ </div>
1781
+
1782
+ <div class="ai-form rounded" style="height: 90px; padding: 8px 4px 8px 12px;">
1783
+ <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img id="ai-media-1" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>contextual-1.gif" /></a>
1784
+ </div>
1785
+
1786
+ <?php
1787
+ }
1788
+
1789
+ function sidebar_ratings () {
1790
+ if (!wp_is_mobile () && is_super_admin ()) {
1791
+ ?>
1792
+
1793
+ <div class="ai-form header no-select rounded" style="position: relative;">
1794
+ <ul style="margin: 0;">
1795
+ <li>
1796
+ Ads are not showing? Check <a href="https://adinserter.pro/documentation#ads-not-displayed" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">troubleshooting guide</a> to find out how to fix the problem.
1797
+ </li>
1798
+ <li>
1799
+ If you need any kind of help or support, please do not hesitate to open a thread on the <a href="https://wordpress.org/support/plugin/ad-inserter/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">support forum</a>.
1800
+ </li>
1801
+ </ul>
1802
+
1803
+ <p style="text-align: justify;">
1804
+ You've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.
1805
+ Positive <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">reviews</a> are a great way to show your appreciation for my work.
1806
+ Besides being an incredible boost to my morale, they are also a great incentive to fix bugs and to add new features for better monetization of your website.
1807
+ Thank you! Igor <img draggable="false" class="emoji" alt="happy" src="https://s.w.org/images/core/emoji/2.3/svg/1f642.svg" style="margin-left: 5px!important;"></p>
1808
+ </div>
1809
+
1810
+ <?php
1811
+ }
1812
+ }
1813
+
1814
+ function sidebar_support () {
1815
+ global $rating_value, $rating_string, $rating_css;
1816
+ ?>
1817
+
1818
+ <div class="ai-form header rounded no-select">
1819
+ <div style="float: left;">
1820
+ <h2 style="display: inline-block; margin: 7px 0;">Support plugin development</h2>
1821
+ </div>
1822
+
1823
+ <div style="float: right;">
1824
+ <a href="https://twitter.com/AdInserter" class="clear-link" target="_blank"><img id="ai-tw" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>twitter.png" style="vertical-align: middle; margin: 0 0 0 20px;" title="Ad Inserter on Twitter" alt="Ad Inserter on Twitter" /></a>
1825
+ <a href="https://www.facebook.com/AdInserter/" class="clear-link" target="_blank"><img id="ai-fb" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>facebook.png" style="vertical-align: middle; margin: 0 0 0 10px;" title="Ad Inserter on Facebook" alt="Ad Inserter on Facebook" /></a>
1826
+ </div>
1827
+ <div style="float: right; margin-top: 2px;">
1828
+ <h2 style="display: inline-block; margin: 5px 0;">Follow Ad Inserter</h2>
1829
+ </div>
1830
+
1831
+ <div style="float: right; margin: 8px 20px 0 0;">
1832
+ <div id="ai-stars" style="float: right; margin: 0 0 -3px 0; cursor: pointer; font-size: 11px;"><span><?php //echo $rating_value; ?></span><img id="ai-stars-img" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>stars.png" style="margin: 0 0 -3px 10px;"/></div>
1833
+
1834
+ <div id="ai-rating-bar" class="header" style="float: right; cursor: pointer; margin: 3px 0 0 0; width: 148px; display: none;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">
1835
+ <div class="header" style="background: #ccc;" title="Average rating of the plugin - Thank you!">
1836
+ <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">
1837
+ <div id="rating-value" style="text-align: center; font-size: 11px; line-height: 12px; border-radius: 2px; background: #fddf87; height: 100%; <?php echo $rating_css; ?>"><span style=""><?php echo $rating_string; ?></span></div>
1838
+ </a>
1839
+ </div>
1840
+ </div>
1841
+ </div>
1842
+
1843
+ <div style="clear: both;"></div>
1844
+ </div>
1845
+
1846
+ <?php
1847
+ }
1848
+
1849
+ function sidebar_pro () { ?>
1850
+
1851
+ <div class="ai-form rounded no-select" style="background: #fff;">
1852
+ <div style="float: right;" >
1853
+ <div>
1854
+ <a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" title="Automate ad placement on posts and pages" target="_blank"><img id="ai-pro-1" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="margin-top: 10px;" /></a>
1855
+ </div>
1856
+ <div>
1857
+ <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img id="ai-media-2" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>contextual-2.jpg" style="margin-top: 10px;" /></a>
1858
+ </div>
1859
+ </div>
1860
+
1861
+ <h3 style="text-align: justify;">Looking for Pro Ad Management plugin?</h3>
1862
+ <h4 style="text-align: justify;">To Optimally Monetize your WordPress website?</h4>
1863
+
1864
+ <ul>
1865
+ <li>64 code (ad) blocks</li>
1866
+ <li>Syntax highlighting editor</li>
1867
+ <li><a href="http://adinserter.pro/documentation#code-preview" class="simple-link" target="_blank">Code preview</a> with visual CSS editor</li>
1868
+ <li>Automatic insertion before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1869
+ <li>Automatic insertion between posts on blog pages</li>
1870
+ <li>Automatic insertion before, between and after comments</li>
1871
+ <li>Insertion exceptions for posts and pages</li>
1872
+ <li><a href="http://adinserter.pro/documentation#manual" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1873
+ <li>Sticky positions (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
1874
+ <li>Sticky (fixed) widgets (sidebar does not move when the page scrolls)</li>
1875
+ <li>Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
1876
+ <li><a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options to avoid insertion near images or headers (AdSense TOS)</li>
1877
+ <li>Options to disable insertion on Ajax calls, 404 error pages or in feeds</li>
1878
+ <li>Ad rotation (works also with caching)</li>
1879
+ <li>Ad impression and click <a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">tracking</a> (works also with Javascript ads like AdSense)</li>
1880
+ <li>Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
1881
+ <li>Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
1882
+ <li>Support for contextual <a href="https://adinserter.pro/settings#amazon" class="simple-link" target="_blank">Amazon Native Shopping Ads</a> (responsive)</li>
1883
+ <li>Custom CSS class name for wrapping divs to avoid ad blockers</li>
1884
+ <li>PHP code processing</li>
1885
+ <li>Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
1886
+ <li>Support for Google Analytics, Piwik or any other web analytics code</li>
1887
+ <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1888
+ <li>Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a> (works with caching, 6 custom viewports)</li>
1889
+ <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> categories, tags, taxonomies, post IDs, urls, referers</li>
1890
+ <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> IP addresses or countries (works also with caching)</li>
1891
+ <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1892
+ <li>Import/Export block or plugin settings</li>
1893
+ <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a> with fallback option</li>
1894
+ <li>Country-level <a href="http://adinserter.pro/documentation#geo-targeting" class="simple-link" target="_blank">GEO targeting</a> (works also with caching)</li>
1895
+ <li>Simple troubleshooting with many <a href="http://adinserter.pro/documentation#debugging" class="simple-link" target="_blank">debugging functions</a></li>
1896
+ <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
1897
+ <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
1898
+ <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of HTML tags for easier ad placement between paragraphs</li>
1899
+ <li>Support via email</li>
1900
+ </ul>
1901
+
1902
+ <p style="text-align: justify;">Ad Inserter Pro is a complete all-in-one ad management plugin for WordPress website with many advertising features to automatically insert adverts on posts and pages.
1903
+ With Ad Inserter Pro you also get <strong>one year of free updates and support via email</strong>. If you find Ad Inserter useful and need more code blocks, GEO targeting,
1904
+ impression and click tracking or multisite support 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>
1905
+ </div>
1906
+
1907
+ <?php
1908
+ }
1909
+
1910
+