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

Version Description

  • Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
  • Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
  • Added support for post-type:POST_TYPE taxonomy list items
  • Added support for JavaScript based sticky widgets
  • Added support for ad blocking statistics (Pro only)
  • Added support for WP AMP and WP AMP Ninja plugins
  • Post/Page Word Count moved to Misc section (now works also on widgets)
  • Few 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.3
Comparing to
See all releases

Code changes from version 2.2.2 to 2.2.3

ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.2.2
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,16 @@ Plugin URI: http://adinserter.pro/documentation
12
 
13
  Change Log
14
 
 
 
 
 
 
 
 
 
 
 
15
  Ad Inserter 2.2.2 - 2017-08-28
16
  - Fix for mobile admin layout
17
  - Few other minor bug fixes
@@ -560,7 +570,6 @@ if (get_dynamic_blocks ()) {
560
  }
561
 
562
 
563
-
564
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
565
  $ai_wp_data [AI_WP_AMP_PAGE] = false;
566
  $ai_wp_data [AI_WP_USER_SET] = false;
@@ -809,14 +818,23 @@ function set_page_type () {
809
  if (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
810
  elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
811
  elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
 
812
  elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
813
  elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
814
  elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
815
- elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
816
  elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
817
  elseif (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
818
 
819
- if (function_exists ('is_amp_endpoint') && is_amp_endpoint ()) {
 
 
 
 
 
 
 
 
 
820
  $ai_wp_data [AI_WP_AMP_PAGE] = true;
821
  define ('AI_AMP_PAGE', true);
822
  }
@@ -913,6 +931,8 @@ function ai_block_insertion_status ($block, $ai_last_check) {
913
  function ai_log_block_status ($block, $ai_last_check) {
914
  global $block_insertion_log, $ad_inserter_globals;
915
 
 
 
916
  $global_name = AI_BLOCK_COUNTER_NAME . $block;
917
 
918
  $block_status = ai_block_insertion_status ($block, $ai_last_check);
@@ -951,6 +971,7 @@ function number_of_words (&$content) {
951
  $text = str_replace (array ("\n", " "), " ", $text);
952
  $text = str_replace (" ", " ", $text);
953
  $text = strip_tags ($text);
 
954
  return count (explode (" ", $text));
955
  }
956
 
@@ -1049,15 +1070,32 @@ function ai_wp_hook () {
1049
  }
1050
 
1051
 
1052
- if ($ai_wp_data [AI_WP_AMP_PAGE] && has_action ('amp_post_template_head')) {
 
1053
  add_action ('amp_post_template_head', 'ai_amp_head_hook');
 
 
 
 
 
 
1054
  } else
1055
- add_action ('wp_head', 'ai_wp_head_hook');
 
1056
 
1057
- if ($ai_wp_data [AI_WP_AMP_PAGE] && has_action ('amp_post_template_head')) {
 
1058
  add_action ('amp_post_template_footer', 'ai_amp_footer_hook');
 
 
 
 
 
 
 
1059
  } else
1060
- add_action ('wp_footer', 'ai_wp_footer_hook');
 
1061
 
1062
 
1063
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
@@ -1125,7 +1163,6 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
1125
  wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (
1126
  'jquery',
1127
  'jquery-ui-datepicker',
1128
-
1129
  ), AD_INSERTER_VERSION, false);
1130
 
1131
  if (AI_SYNTAX_HIGHLIGHTING) {
@@ -1319,8 +1356,21 @@ function ai_replace_js_data ($js) {
1319
  $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1320
  $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1321
  if (defined ('AI_STATISTICS') && AI_STATISTICS) {
 
1322
  $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
 
 
 
 
 
 
 
 
 
 
 
1323
  }
 
1324
 
1325
  if (function_exists ('ai_replace_js_data_2')) ai_replace_js_data_2 ($js);
1326
 
@@ -1338,9 +1388,9 @@ function add_footer_inline_scripts () {
1338
 
1339
  if ($ai_wp_data [AI_ADB_DETECTION]) {
1340
  if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1341
- echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: - 1;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>';
1342
- echo "<script type='text/javascript' src='", plugins_url ('includes/js/ads.js?', __FILE__ ), "'></script>\n";
1343
- echo "<script type='text/javascript' src='", plugins_url ('includes/js/sponsors.js?', __FILE__ ), "'></script>\n";
1344
  }
1345
  }
1346
 
@@ -1348,13 +1398,14 @@ function add_footer_inline_scripts () {
1348
 
1349
  $inline_scripts = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE || $ai_wp_data [AI_TRACKING] || $ai_wp_data [AI_STICKY_WIDGETS] || (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
1350
 
 
 
 
 
 
1351
  if ($inline_scripts) echo "<script type='text/javascript'>\n";
1352
 
1353
  if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1354
- $block_class_name = get_block_class_name ();
1355
- if ($block_class_name == '') $block_class_name = DEFAULT_BLOCK_CLASS_NAME;
1356
- define ('AI_BLOCK_CLASS_NAME', $block_class_name);
1357
-
1358
  echo ai_get_js ('ai-rotate');
1359
  }
1360
 
@@ -1742,8 +1793,7 @@ function ai_wp_head_hook () {
1742
 
1743
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1744
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1745
- // $processed_code = trim ($codes [$ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0]);
1746
- $processed_code = trim ($codes [0]);
1747
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
1748
 
1749
  echo $processed_code;
@@ -1752,7 +1802,8 @@ function ai_wp_head_hook () {
1752
 
1753
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1754
  // No scripts on AMP pages
1755
- 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]) {
 
1756
  echo "<script>
1757
  jQuery(document).ready(function($) {
1758
  $('body').prepend (\"", get_adb_status_debug_info () , "\");
@@ -1762,7 +1813,8 @@ function ai_wp_head_hook () {
1762
  }
1763
 
1764
  // No scripts on AMP pages
1765
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 & !$ai_wp_data [AI_WP_AMP_PAGE]) {
 
1766
  echo "<script>
1767
  jQuery(document).ready(function($) {
1768
  $('body').prepend (\"", get_page_type_debug_info () , "\");
@@ -1779,10 +1831,10 @@ function ai_wp_head_hook () {
1779
  function ai_amp_head_hook () {
1780
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1781
 
1782
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1783
- // ai_log ("HEAD HOOK START");
1784
- // $start_time = microtime (true);
1785
- // }
1786
 
1787
  // add_head_inline_styles_and_scripts ();
1788
 
@@ -1799,7 +1851,7 @@ function ai_amp_head_hook () {
1799
 
1800
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1801
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1802
- $processed_code = trim ($codes [1]);
1803
  echo $processed_code;
1804
  }
1805
  }
@@ -1825,10 +1877,10 @@ function ai_amp_head_hook () {
1825
  //</script>\n";
1826
  // }
1827
 
1828
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1829
- // $ai_total_plugin_time += microtime (true) - $start_time;
1830
- // ai_log ("HEAD HOOK END\n");
1831
- // }
1832
  }
1833
 
1834
 
@@ -1840,7 +1892,8 @@ function ai_wp_footer_hook () {
1840
  $start_time = microtime (true);
1841
  }
1842
 
1843
- if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
 
1844
  add_footer_inline_scripts ();
1845
  }
1846
 
@@ -1857,8 +1910,7 @@ function ai_wp_footer_hook () {
1857
 
1858
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1859
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1860
- // $processed_code = trim ($codes [$ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0]);
1861
- $processed_code = trim ($codes [0]);
1862
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
1863
 
1864
  echo $processed_code;
@@ -1878,10 +1930,10 @@ function ai_wp_footer_hook () {
1878
  function ai_amp_footer_hook () {
1879
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1880
 
1881
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1882
- // ai_log ("FOOTER HOOK START");
1883
- // $start_time = microtime (true);
1884
- // }
1885
 
1886
  // if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1887
  // add_footer_inline_scripts ();
@@ -1900,7 +1952,7 @@ function ai_amp_footer_hook () {
1900
 
1901
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1902
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1903
- $processed_code = trim ($codes [1]);
1904
  echo $processed_code;
1905
  }
1906
  }
@@ -1910,10 +1962,10 @@ function ai_amp_footer_hook () {
1910
  // echo get_page_type_debug_info () , "\n";
1911
  // }
1912
 
1913
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1914
- // $ai_total_plugin_time += microtime (true) - $start_time;
1915
- // ai_log ("FOOTER HOOK END\n");
1916
- // }
1917
  }
1918
 
1919
  function ai_write_debug_info ($write_processing_log = false) {
@@ -1925,12 +1977,13 @@ function ai_write_debug_info ($write_processing_log = false) {
1925
  if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
1926
  echo "INSTALLED: ", date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600);
1927
  if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) {
1928
- printf (' (%04d-%02d-%02d %02d:%02d:%02d)', $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
1929
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
1930
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
1931
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
1932
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
1933
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s);
 
1934
  }
1935
  echo "\n";
1936
  }
@@ -1959,6 +2012,7 @@ function ai_write_debug_info ($write_processing_log = false) {
1959
  if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) == AI_USER_ADMINISTRATOR) echo "ADMINISTRATOR";
1960
  $current_user = wp_get_current_user();
1961
  echo "\n";
 
1962
  echo 'USER ROLES: ', implode (', ', $current_user->roles), "\n";
1963
  echo 'MIN.USER FOR EXCEPTIONS: ', get_minimum_user_role (), "\n";
1964
  echo "PAGE TYPE: ";
@@ -1982,17 +2036,18 @@ function ai_write_debug_info ($write_processing_log = false) {
1982
  switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
1983
  case AI_PT_STATIC:
1984
  case AI_PT_POST:
 
1985
  echo 'POST TYPE: ', get_post_type (), "\n";
1986
  $category_data = get_the_category();
1987
  $categories = array ();
1988
  foreach ($category_data as $category) {
1989
- $categories []= $category->slug;
1990
  }
1991
  echo 'CATEGORIES: ', implode (', ', $categories), "\n";
1992
  $tag_data = wp_get_post_tags (get_the_ID());
1993
  $tags = array ();
1994
  foreach ($tag_data as $tag) {
1995
- $tags []= $tag->slug;
1996
  }
1997
  echo 'TAGS: ', implode (', ', $tags), "\n";
1998
  $taxonomies = array ();
@@ -2006,7 +2061,16 @@ function ai_write_debug_info ($write_processing_log = false) {
2006
  }
2007
  }
2008
  echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
2009
- echo 'ID: ', get_the_ID(), "\n";
 
 
 
 
 
 
 
 
 
2010
  break;
2011
  case AI_PT_CATEGORY:
2012
  $category_data = get_the_category();
@@ -2140,7 +2204,16 @@ function ai_write_debug_info ($write_processing_log = false) {
2140
  if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false;
2141
  continue 2;
2142
  }
2143
- if ($obj->wp_options [$key] !== $default->wp_options [$key]) {
 
 
 
 
 
 
 
 
 
2144
  $default_settings = false;
2145
  switch ($key) {
2146
  case AI_OPTION_AUTOMATIC_INSERTION:
@@ -2169,6 +2242,9 @@ function ai_write_debug_info ($write_processing_log = false) {
2169
  $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
2170
  break;
2171
  }
 
 
 
2172
  } else
2173
  switch ($key) {
2174
  case AI_OPTION_AUTOMATIC_INSERTION:
@@ -2368,6 +2444,8 @@ function ai_check_plugin_options ($plugin_options = array ()) {
2368
 
2369
  if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
2370
 
 
 
2371
  if (!isset ($plugin_options ['STICKY_WIDGET_MARGIN'])) $plugin_options ['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN;
2372
  $sticky_widget_margin = $plugin_options ['STICKY_WIDGET_MARGIN'];
2373
  if (!is_numeric ($sticky_widget_margin)) {
@@ -2533,6 +2611,14 @@ function get_minimum_user_role () {
2533
  return ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE']);
2534
  }
2535
 
 
 
 
 
 
 
 
 
2536
  function get_sticky_widget_margin () {
2537
  global $ai_db_options;
2538
 
@@ -3129,7 +3215,7 @@ function ai_load_settings () {
3129
  $now = new DateTime (date('Y-m-d H:i:s', time()));
3130
  if (method_exists ($install, 'diff')) {
3131
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] = $install->diff ($now);
3132
- $ai_wp_data [AI_DAYS_SINCE_INSTAL] = $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d;
3133
  }
3134
  }
3135
 
@@ -3302,6 +3388,7 @@ function ai_settings () {
3302
  if (isset ($_POST ['syntax-highlighter-theme'])) $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
3303
  if (isset ($_POST ['block-class-name'])) $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
3304
  if (isset ($_POST ['minimum-user-role'])) $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
 
3305
  if (isset ($_POST ['sticky-widget-margin'])) $options ['STICKY_WIDGET_MARGIN'] = filter_option ('STICKY_WIDGET_MARGIN', $_POST ['sticky-widget-margin']);
3306
  if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']);
3307
  if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']);
@@ -3526,8 +3613,9 @@ function ai_adinserter ($ad_number = '', $ignore = ''){
3526
  $ai_last_check = AI_CHECK_ENABLED;
3527
  if (!$obj->get_enable_php_call ()) return "";
3528
  if (!$obj->check_server_side_detection ()) return "";
3529
- if (!$obj->check_page_types_lists_users (in_array ("page_type", $ignore_array))) return "";
3530
  if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return "";
 
3531
 
3532
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
3533
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
@@ -3901,6 +3989,7 @@ function ai_before_after_post ($query, $automatic_insertion) {
3901
  if (!$obj->check_page_types_lists_users ()) continue;
3902
  if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
3903
  if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
 
3904
 
3905
  // Last check before counter check before insertion
3906
  $ai_last_check = AI_CHECK_CODE;
@@ -4300,6 +4389,8 @@ function process_shortcode (&$block, $atts) {
4300
  "amp" => "",
4301
  "rotate" => "",
4302
  "count" => "",
 
 
4303
  ), $atts);
4304
 
4305
  $output = "";
@@ -4335,6 +4426,17 @@ function process_shortcode (&$block, $atts) {
4335
  if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
4336
  return AD_AMP_SEPARATOR;
4337
  }
 
 
 
 
 
 
 
 
 
 
 
4338
  }
4339
 
4340
  if ($block == 0) {
@@ -4371,7 +4473,7 @@ function process_shortcode (&$block, $atts) {
4371
  if (!$obj->get_enable_manual ()) return "";
4372
 
4373
  if (!$obj->check_server_side_detection ()) return "";
4374
- if (!$obj->check_page_types_lists_users (in_array ("page_type", $ignore_array))) return "";
4375
 
4376
  // Last check before counter check before insertion
4377
  $ai_last_check = AI_CHECK_CODE;
@@ -4408,7 +4510,11 @@ function process_shortcodes ($atts, $ai_shortcode_name) {
4408
 
4409
  if ($debug_processing) {
4410
  $ai_total_plugin_time += microtime (true) - $start_time;
4411
- if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
 
 
 
 
4412
  ai_log ("SHORTCODE END\n");
4413
  }
4414
 
@@ -4584,6 +4690,7 @@ function ai_widget_draw ($args, $instance, &$block) {
4584
  if (!$obj->check_server_side_detection ()) return;
4585
  if (!$obj->check_page_types_lists_users ()) return;
4586
  if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return;
 
4587
 
4588
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
4589
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.2.3
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.3 - 2017-09-26
16
+ - Added support to insert custom fields via shortcut [adinserter custom-field='CUSTOM_FIELD_NAME']
17
+ - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
18
+ - Added support for post-type:POST_TYPE taxonomy list items
19
+ - Added support for JavaScript based sticky widgets
20
+ - Added support for ad blocking statistics
21
+ - Added support for WP AMP and WP AMP Ninja plugins
22
+ - Post/Page Word Count moved to Misc section (now works also on widgets)
23
+ - Few minor bug fixes, cosmetic changes and code improvements
24
+
25
  Ad Inserter 2.2.2 - 2017-08-28
26
  - Fix for mobile admin layout
27
  - Few other minor bug fixes
570
  }
571
 
572
 
 
573
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
574
  $ai_wp_data [AI_WP_AMP_PAGE] = false;
575
  $ai_wp_data [AI_WP_USER_SET] = false;
818
  if (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
819
  elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
820
  elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
821
+ elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
822
  elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
823
  elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
824
  elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
 
825
  elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
826
  elseif (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
827
 
828
+ if (
829
+ // AMP, Accelerated Mobile Pages
830
+ function_exists ('is_amp_endpoint') && is_amp_endpoint () ||
831
+
832
+ // WP AMP Ninja
833
+ isset ($_GET ['wpamp']) ||
834
+
835
+ // WP AMP - Accelerated Mobile Pages for WordPress
836
+ function_exists ('is_wp_amp') && is_wp_amp ()
837
+ ) {
838
  $ai_wp_data [AI_WP_AMP_PAGE] = true;
839
  define ('AI_AMP_PAGE', true);
840
  }
931
  function ai_log_block_status ($block, $ai_last_check) {
932
  global $block_insertion_log, $ad_inserter_globals;
933
 
934
+ if ($block < 1) return 'NO BLOCK SHORTCODE';
935
+
936
  $global_name = AI_BLOCK_COUNTER_NAME . $block;
937
 
938
  $block_status = ai_block_insertion_status ($block, $ai_last_check);
971
  $text = str_replace (array ("\n", " "), " ", $text);
972
  $text = str_replace (" ", " ", $text);
973
  $text = strip_tags ($text);
974
+ if ($text == '') return 0;
975
  return count (explode (" ", $text));
976
  }
977
 
1070
  }
1071
 
1072
 
1073
+ if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1074
+ // AMP, Accelerated Mobile Pages
1075
  add_action ('amp_post_template_head', 'ai_amp_head_hook');
1076
+
1077
+ // WP AMP Ninja
1078
+ add_action ('wpamp_custom_script', 'ai_amp_head_hook');
1079
+
1080
+ // WP AMP - Accelerated Mobile Pages for WordPress
1081
+ add_action ('amphtml_template_head', 'ai_amp_head_hook');
1082
  } else
1083
+ // WP
1084
+ add_action ('wp_head', 'ai_wp_head_hook');
1085
 
1086
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1087
+ // AMP, Accelerated Mobile Pages
1088
  add_action ('amp_post_template_footer', 'ai_amp_footer_hook');
1089
+
1090
+ // WP AMP Ninja
1091
+ add_action ('wpamp_google_analytics_code', 'ai_amp_footer_hook');
1092
+
1093
+ // WP AMP - Accelerated Mobile Pages for WordPress
1094
+ // add_action ('amphtml_template_footer', 'ai_amp_footer_hook');
1095
+ add_action ('amphtml_after_footer', 'ai_amp_footer_hook');
1096
  } else
1097
+ // WP
1098
+ add_action ('wp_footer', 'ai_wp_footer_hook');
1099
 
1100
 
1101
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1163
  wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (
1164
  'jquery',
1165
  'jquery-ui-datepicker',
 
1166
  ), AD_INSERTER_VERSION, false);
1167
 
1168
  if (AI_SYNTAX_HIGHLIGHTING) {
1356
  $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1357
  $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1358
  if (defined ('AI_STATISTICS') && AI_STATISTICS) {
1359
+ $js = str_replace ('AI_TRACK_PAGEVIEWS', get_track_pageviews () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1360
  $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1361
+
1362
+ if (!isset ($ai_wp_data [AI_VIEWPORTS])) {
1363
+ $viewports = array ();
1364
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1365
+ $viewport_name = get_viewport_name ($viewport);
1366
+ $viewport_width = get_viewport_width ($viewport);
1367
+ if ($viewport_name != '') $viewports [$viewport] = $viewport_width;
1368
+ }
1369
+ $ai_wp_data [AI_VIEWPORTS] = $viewports;
1370
+ }
1371
+ $js = str_replace ('AI_VIEWPORTS', '[' . implode (',', $ai_wp_data [AI_VIEWPORTS]) . ']', $js);
1372
  }
1373
+ $js = str_replace ('AI_BLOCK_CLASS_NAME', get_block_class_name () != '' ? get_block_class_name () : DEFAULT_BLOCK_CLASS_NAME, $js);
1374
 
1375
  if (function_exists ('ai_replace_js_data_2')) ai_replace_js_data_2 ($js);
1376
 
1388
 
1389
  if ($ai_wp_data [AI_ADB_DETECTION]) {
1390
  if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1391
+ echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: - 1;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
1392
+ echo "<script type='text/javascript' src='", plugins_url ('includes/js/ads.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1393
+ echo "<script type='text/javascript' src='", plugins_url ('includes/js/sponsors.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1394
  }
1395
  }
1396
 
1398
 
1399
  $inline_scripts = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE || $ai_wp_data [AI_TRACKING] || $ai_wp_data [AI_STICKY_WIDGETS] || (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
1400
 
1401
+ if ($ai_wp_data [AI_STICKY_WIDGETS] && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_JS) {
1402
+ // echo "<script type='text/javascript' src='", plugins_url ('includes/js/ResizeSensor.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1403
+ echo "<script type='text/javascript' src='", plugins_url ('includes/js/theia-sticky-sidebar.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1404
+ }
1405
+
1406
  if ($inline_scripts) echo "<script type='text/javascript'>\n";
1407
 
1408
  if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
 
 
 
 
1409
  echo ai_get_js ('ai-rotate');
1410
  }
1411
 
1793
 
1794
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1795
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1796
+ $processed_code = $codes [0];
 
1797
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
1798
 
1799
  echo $processed_code;
1802
 
1803
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1804
  // No scripts on AMP pages
1805
+ // 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]) {
1806
+ 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]*/) {
1807
  echo "<script>
1808
  jQuery(document).ready(function($) {
1809
  $('body').prepend (\"", get_adb_status_debug_info () , "\");
1813
  }
1814
 
1815
  // No scripts on AMP pages
1816
+ // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1817
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 /*&& !$ai_wp_data [AI_WP_AMP_PAGE]*/) {
1818
  echo "<script>
1819
  jQuery(document).ready(function($) {
1820
  $('body').prepend (\"", get_page_type_debug_info () , "\");
1831
  function ai_amp_head_hook () {
1832
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1833
 
1834
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1835
+ ai_log ("HEAD HOOK START");
1836
+ $start_time = microtime (true);
1837
+ }
1838
 
1839
  // add_head_inline_styles_and_scripts ();
1840
 
1851
 
1852
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1853
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1854
+ $processed_code = ltrim ($codes [1]);
1855
  echo $processed_code;
1856
  }
1857
  }
1877
  //</script>\n";
1878
  // }
1879
 
1880
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1881
+ $ai_total_plugin_time += microtime (true) - $start_time;
1882
+ ai_log ("HEAD HOOK END\n");
1883
+ }
1884
  }
1885
 
1886
 
1892
  $start_time = microtime (true);
1893
  }
1894
 
1895
+ // if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1896
+ if (!(defined ('DOING_AJAX') && DOING_AJAX) /*&& !$ai_wp_data [AI_WP_AMP_PAGE]*/) {
1897
  add_footer_inline_scripts ();
1898
  }
1899
 
1910
 
1911
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1912
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1913
+ $processed_code = $codes [0];
 
1914
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
1915
 
1916
  echo $processed_code;
1930
  function ai_amp_footer_hook () {
1931
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1932
 
1933
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1934
+ ai_log ("FOOTER HOOK START");
1935
+ $start_time = microtime (true);
1936
+ }
1937
 
1938
  // if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1939
  // add_footer_inline_scripts ();
1952
 
1953
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1954
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1955
+ $processed_code = ltrim ($codes [1]);
1956
  echo $processed_code;
1957
  }
1958
  }
1962
  // echo get_page_type_debug_info () , "\n";
1963
  // }
1964
 
1965
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1966
+ $ai_total_plugin_time += microtime (true) - $start_time;
1967
+ ai_log ("FOOTER HOOK END\n");
1968
+ }
1969
  }
1970
 
1971
  function ai_write_debug_info ($write_processing_log = false) {
1977
  if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
1978
  echo "INSTALLED: ", date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600);
1979
  if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) {
1980
+ printf (' (%04d-%02d-%02d %02d:%02d:%02d, %d days)', $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
1981
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
1982
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
1983
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
1984
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
1985
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s,
1986
+ isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) ? $ai_wp_data [AI_DAYS_SINCE_INSTAL] : null);
1987
  }
1988
  echo "\n";
1989
  }
2012
  if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) == AI_USER_ADMINISTRATOR) echo "ADMINISTRATOR";
2013
  $current_user = wp_get_current_user();
2014
  echo "\n";
2015
+ echo "USERNAME: ", $current_user->user_login, "\n";
2016
  echo 'USER ROLES: ', implode (', ', $current_user->roles), "\n";
2017
  echo 'MIN.USER FOR EXCEPTIONS: ', get_minimum_user_role (), "\n";
2018
  echo "PAGE TYPE: ";
2036
  switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2037
  case AI_PT_STATIC:
2038
  case AI_PT_POST:
2039
+ echo 'ID: ', get_the_ID(), "\n";
2040
  echo 'POST TYPE: ', get_post_type (), "\n";
2041
  $category_data = get_the_category();
2042
  $categories = array ();
2043
  foreach ($category_data as $category) {
2044
+ $categories []= $category->name . ' ('.$category->slug.')';
2045
  }
2046
  echo 'CATEGORIES: ', implode (', ', $categories), "\n";
2047
  $tag_data = wp_get_post_tags (get_the_ID());
2048
  $tags = array ();
2049
  foreach ($tag_data as $tag) {
2050
+ $tags []= $tag->name . ' ('.$tag->slug.')';
2051
  }
2052
  echo 'TAGS: ', implode (', ', $tags), "\n";
2053
  $taxonomies = array ();
2061
  }
2062
  }
2063
  echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
2064
+
2065
+ $post_meta = get_post_meta (get_the_ID());
2066
+ $meta_string = array ();
2067
+ foreach ($post_meta as $key => $post_meta_field) {
2068
+ foreach ($post_meta_field as $post_meta_field_item) {
2069
+ $meta_string []= $key . ':' . $post_meta_field_item;
2070
+ }
2071
+ }
2072
+ echo 'POST META: ', implode (', ', $meta_string), "\n";
2073
+
2074
  break;
2075
  case AI_PT_CATEGORY:
2076
  $category_data = get_the_category();
2204
  if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false;
2205
  continue 2;
2206
  }
2207
+
2208
+ // if (gettype ($obj->wp_options [$key]) == 'string' && gettype ($default->wp_options [$key]) == 'integer') {
2209
+ // $default->wp_options [$key] = strval ($default->wp_options [$key]);
2210
+ // }
2211
+ // elseif (gettype ($obj->wp_options [$key]) == 'integer' && gettype ($default->wp_options [$key]) == 'string') {
2212
+ // $default->wp_options [$key] = intval ($default->wp_options [$key]);
2213
+ // }
2214
+
2215
+ // if ($obj->wp_options [$key] !== $default->wp_options [$key]) {
2216
+ if ($obj->wp_options [$key] != $default->wp_options [$key]) {
2217
  $default_settings = false;
2218
  switch ($key) {
2219
  case AI_OPTION_AUTOMATIC_INSERTION:
2242
  $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
2243
  break;
2244
  }
2245
+
2246
+ // $settings .= ' ['.gettype ($obj->wp_options [$key]).':'.$obj->wp_options [$key].'#'.gettype ($default->wp_options [$key]).':'.$default->wp_options [$key].'] ';
2247
+
2248
  } else
2249
  switch ($key) {
2250
  case AI_OPTION_AUTOMATIC_INSERTION:
2444
 
2445
  if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
2446
 
2447
+ if (!isset ($plugin_options ['STICKY_WIDGET_MODE'])) $plugin_options ['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE;
2448
+
2449
  if (!isset ($plugin_options ['STICKY_WIDGET_MARGIN'])) $plugin_options ['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN;
2450
  $sticky_widget_margin = $plugin_options ['STICKY_WIDGET_MARGIN'];
2451
  if (!is_numeric ($sticky_widget_margin)) {
2611
  return ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE']);
2612
  }
2613
 
2614
+ function get_sticky_widget_mode () {
2615
+ global $ai_db_options;
2616
+
2617
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE;
2618
+
2619
+ return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE']);
2620
+ }
2621
+
2622
  function get_sticky_widget_margin () {
2623
  global $ai_db_options;
2624
 
3215
  $now = new DateTime (date('Y-m-d H:i:s', time()));
3216
  if (method_exists ($install, 'diff')) {
3217
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] = $install->diff ($now);
3218
+ $ai_wp_data [AI_DAYS_SINCE_INSTAL] = $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->days;
3219
  }
3220
  }
3221
 
3388
  if (isset ($_POST ['syntax-highlighter-theme'])) $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
3389
  if (isset ($_POST ['block-class-name'])) $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
3390
  if (isset ($_POST ['minimum-user-role'])) $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
3391
+ if (isset ($_POST ['sticky-widget-mode'])) $options ['STICKY_WIDGET_MODE'] = filter_option ('STICKY_WIDGET_MODE', $_POST ['sticky-widget-mode']);
3392
  if (isset ($_POST ['sticky-widget-margin'])) $options ['STICKY_WIDGET_MARGIN'] = filter_option ('STICKY_WIDGET_MARGIN', $_POST ['sticky-widget-margin']);
3393
  if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']);
3394
  if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']);
3613
  $ai_last_check = AI_CHECK_ENABLED;
3614
  if (!$obj->get_enable_php_call ()) return "";
3615
  if (!$obj->check_server_side_detection ()) return "";
3616
+ if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
3617
  if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return "";
3618
+ if (!$obj->check_number_of_words ()) return "";
3619
 
3620
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
3621
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
3989
  if (!$obj->check_page_types_lists_users ()) continue;
3990
  if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
3991
  if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
3992
+ if (!$obj->check_number_of_words ()) continue;
3993
 
3994
  // Last check before counter check before insertion
3995
  $ai_last_check = AI_CHECK_CODE;
4389
  "amp" => "",
4390
  "rotate" => "",
4391
  "count" => "",
4392
+ "custom-field" => "",
4393
+ "data" => "",
4394
  ), $atts);
4395
 
4396
  $output = "";
4426
  if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
4427
  return AD_AMP_SEPARATOR;
4428
  }
4429
+ if ($parameters ['custom-field'] != '') {
4430
+ $post_meta = get_post_meta (get_the_ID(), $parameters ['custom-field']);
4431
+ if (is_array ($post_meta)) {
4432
+ $post_meta = implode (', ', $post_meta);
4433
+ }
4434
+ return $post_meta;
4435
+ }
4436
+ if ($parameters ['data'] != '') {
4437
+ return '{'.$parameters ['data'].'}';
4438
+ }
4439
+
4440
  }
4441
 
4442
  if ($block == 0) {
4473
  if (!$obj->get_enable_manual ()) return "";
4474
 
4475
  if (!$obj->check_server_side_detection ()) return "";
4476
+ if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
4477
 
4478
  // Last check before counter check before insertion
4479
  $ai_last_check = AI_CHECK_CODE;
4510
 
4511
  if ($debug_processing) {
4512
  $ai_total_plugin_time += microtime (true) - $start_time;
4513
+ if ($block == - 1) {
4514
+ if (strlen ($shortcode) < 100) ai_log ('SHORTCODE TEXT: "' . ai_log_filter_content ($shortcode) . '"'); else
4515
+ ai_log ('SHORTCODE TEXT: "' . ai_log_filter_content (html_entity_decode (substr ($shortcode, 0, 60))) . ' ... ' . ai_log_filter_content (html_entity_decode (substr ($shortcode, - 60))) . '"');
4516
+ }
4517
+ elseif ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
4518
  ai_log ("SHORTCODE END\n");
4519
  }
4520
 
4690
  if (!$obj->check_server_side_detection ()) return;
4691
  if (!$obj->check_page_types_lists_users ()) return;
4692
  if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return;
4693
+ if (!$obj->check_number_of_words ()) return;
4694
 
4695
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
4696
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
class.php CHANGED
@@ -341,11 +341,9 @@ abstract class ai_BaseCodeBlock {
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) {
346
- $obj = $block_object [$this->fallback];
347
- }
348
 
 
349
  $code = $obj->get_ad_data();
350
 
351
  if ($obj->get_process_php () && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
@@ -1110,7 +1108,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
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);
@@ -1223,9 +1221,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1223
  }
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 = '';
@@ -1251,7 +1251,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
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
 
@@ -1298,13 +1298,24 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1298
  $tracking_code_data = '';
1299
  $tracking_code_post = '';
1300
  $tracking_code = '';
1301
- if ($this->get_tracking ()) {
1302
- $tracking_code_pre = " data-ai='";
1303
- $tracking_code_data = "[{$this->number},{$this->code_version}]";
1304
- $tracking_code_post = "'";
1305
 
1306
- $tracking_code = $tracking_code_pre . base64_encode ($tracking_code_data) . $tracking_code_post;
1307
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1308
 
1309
  $wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1310
 
@@ -2606,7 +2617,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2606
  $tags = $this->get_ad_block_tag();
2607
  $tag_type = $this->get_ad_block_tag_type();
2608
 
2609
- $tags = trim (strtolower ($tags));
 
2610
  $tags_listed = explode (",", $tags);
2611
  foreach ($tags_listed as $index => $tag_listed) {
2612
  $tags_listed [$index] = trim ($tag_listed);
@@ -2651,17 +2663,33 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2651
  if ($taxonomies == AD_EMPTY_DATA) return true;
2652
 
2653
  $taxonomies_listed = explode (",", $taxonomies);
2654
-
2655
  $taxonomy_names = get_post_taxonomies ();
2656
- foreach ($taxonomy_names as $taxonomy_name) {
2657
- $terms = get_the_terms (0, $taxonomy_name);
2658
- if (is_array ($terms)) {
2659
- foreach ($terms as $term) {
2660
 
2661
- foreach ($taxonomies_listed as $taxonomy_disabled){
 
2662
 
2663
- $taxonomy_disabled = trim ($taxonomy_disabled);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2664
 
 
 
 
 
2665
  $post_term_name = strtolower ($term->name);
2666
  $post_term_slug = strtolower ($term->slug);
2667
  $post_taxonomy = strtolower ($term->taxonomy);
@@ -2676,6 +2704,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2676
  }
2677
  }
2678
  }
 
2679
  return true;
2680
 
2681
  } else {
@@ -2683,19 +2712,36 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2683
  if ($taxonomies == AD_EMPTY_DATA) return false;
2684
 
2685
  $taxonomies_listed = explode (",", $taxonomies);
2686
-
2687
  $taxonomy_names = get_post_taxonomies ();
2688
- foreach ($taxonomy_names as $taxonomy_name) {
2689
- $terms = get_the_terms (0, $taxonomy_name);
2690
- if (is_array ($terms)) {
2691
- foreach ($terms as $term) {
2692
 
2693
- foreach ($taxonomies_listed as $taxonomy_enabled) {
 
2694
 
2695
- $taxonomy_enabled = trim ($taxonomy_enabled);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2696
 
 
 
 
 
2697
  $post_term_name = strtolower ($term->name);
2698
  $post_term_slug = strtolower ($term->slug);
 
2699
 
2700
  if ($post_term_name == $taxonomy_enabled || $post_term_slug == $taxonomy_enabled) return true;
2701
 
@@ -2707,6 +2753,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2707
  }
2708
  }
2709
  }
 
2710
  return false;
2711
  }
2712
  }
@@ -2892,17 +2939,32 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2892
  return !$return;
2893
  }
2894
 
2895
- function check_number_of_words (&$content, $number_of_words = 0) {
2896
- global $ai_last_check;
2897
 
2898
- if ($number_of_words == 0) {
2899
- $number_of_words = number_of_words ($content);
2900
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2901
 
2902
  $ai_last_check = AI_CHECK_MIN_NUMBER_OF_WORDS;
2903
- if ($number_of_words < intval ($this->get_minimum_words())) return false;
2904
 
2905
- $maximum_words = intval ($this->get_maximum_words());
2906
  if ($maximum_words <= 0) $maximum_words = 1000000;
2907
 
2908
  $ai_last_check = AI_CHECK_MAX_NUMBER_OF_WORDS;
@@ -2988,9 +3050,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2988
  $ai_last_check = AI_CHECK_SCHEDULING;
2989
  if (!$this->check_scheduling ()) return false;
2990
 
2991
- // $ai_last_check = AI_CHECK_CODE;
2992
- // if ($this->ai_getCode () == '') return false;
2993
-
2994
  $display_for_users = $this->get_display_for_users ();
2995
 
2996
  $ai_last_check = AI_CHECK_LOGGED_IN_USER;
@@ -3150,166 +3209,184 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3150
  function replace_ai_tags ($content){
3151
  global $ai_wp_data;
3152
 
3153
- $general_tag = str_replace ("&amp;", " and ", $this->get_ad_general_tag());
3154
- $title = $general_tag;
3155
- $short_title = $general_tag;
3156
- $category = $general_tag;
3157
- $short_category = $general_tag;
3158
- $tag = $general_tag;
3159
- $smart_tag = $general_tag;
3160
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY) {
3161
- $categories = get_the_category();
3162
- if (!empty ($categories)) {
3163
- $first_category = reset ($categories);
3164
- $category = str_replace ("&amp;", "and", $first_category->name);
3165
- if ($category == "Uncategorized") $category = $general_tag;
3166
- } else {
3167
- $category = $general_tag;
3168
- }
3169
- if (strpos ($category, ",") !== false) {
3170
- $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3171
- } else $short_category = $category;
3172
- if (strpos ($short_category, "and") !== false) {
3173
- $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3174
- }
3175
-
3176
- $title = $category;
3177
- $title = str_replace ("&amp;", "and", $title);
3178
- $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3179
- $tag = $short_title;
3180
- $smart_tag = $short_title;
3181
- } elseif (is_tag ()) {
3182
- $title = single_tag_title('', false);
3183
- $title = str_replace (array ("&amp;", "#"), array ("and", ""), $title);
3184
- $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3185
- $category = $short_title;
3186
- if (strpos ($category, ",") !== false) {
3187
- $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3188
- } else $short_category = $category;
3189
- if (strpos ($short_category, "and") !== false) {
3190
- $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3191
- }
3192
- $tag = $short_title;
3193
- $smart_tag = $short_title;
3194
- } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH) {
3195
- $title = get_search_query();
3196
- $title = str_replace ("&amp;", "and", $title);
3197
- $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3198
- $category = $short_title;
3199
- if (strpos ($category, ",") !== false) {
3200
- $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3201
- } else $short_category = $category;
3202
- if (strpos ($short_category, "and") !== false) {
3203
- $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3204
- }
3205
- $tag = $short_title;
3206
- $smart_tag = $short_title;
3207
- } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) {
3208
- $title = get_the_title();
3209
- $title = str_replace ("&amp;", "and", $title);
3210
-
3211
- $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3212
-
3213
- $categories = get_the_category();
3214
- if (!empty ($categories)) {
3215
- $first_category = reset ($categories);
3216
- $category = str_replace ("&amp;", "and", $first_category->name);
3217
- if ($category == "Uncategorized") $category = $general_tag;
3218
- } else {
3219
- $category = $short_title;
3220
- }
3221
- if (strpos ($category, ",") !== false) {
3222
- $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3223
- } else $short_category = $category;
3224
- if (strpos ($short_category, "and") !== false) {
3225
- $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3226
- }
3227
-
3228
- $tags = get_the_tags();
3229
- if (!empty ($tags)) {
3230
-
3231
- $first_tag = reset ($tags);
3232
- $tag = str_replace (array ("&amp;", "#"), array ("and", ""), isset ($first_tag->name) ? $first_tag->name : '');
3233
 
3234
- $tag_array = array ();
3235
- foreach ($tags as $tag_data) {
3236
- if (isset ($tag_data->name))
3237
- $tag_array [] = explode (" ", $tag_data->name);
 
 
 
 
 
 
 
 
 
 
 
3238
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3239
 
3240
- $selected_tag = '';
 
3241
 
3242
- if (count ($tag_array [0]) == 2) $selected_tag = $tag_array [0];
3243
- elseif (count ($tag_array) > 1 && count ($tag_array [1]) == 2) $selected_tag = $tag_array [1];
3244
- elseif (count ($tag_array) > 2 && count ($tag_array [2]) == 2) $selected_tag = $tag_array [2];
3245
- elseif (count ($tag_array) > 3 && count ($tag_array [3]) == 2) $selected_tag = $tag_array [3];
3246
- elseif (count ($tag_array) > 4 && count ($tag_array [4]) == 2) $selected_tag = $tag_array [4];
3247
 
 
3248
 
3249
- if ($selected_tag == '' && count ($tag_array) >= 2 && count ($tag_array [0]) == 1 && count ($tag_array [1]) == 1) {
 
 
 
 
3250
 
3251
- if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) {
3252
- if (strpos ($tag_array [0][0], $tag_array [1][0]) !== false) $tag_array = array_slice ($tag_array, 1, count ($tag_array) - 1);
3253
- }
3254
 
3255
- if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) {
3256
- if (strpos ($tag_array [1][0], $tag_array [0][0]) !== false) $tag_array = array_slice ($tag_array, 1, count ($tag_array) - 1);
3257
- }
3258
 
3259
- if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) {
3260
- if (count ($tag_array) >= 2 && count ($tag_array [0]) == 1 && count ($tag_array [1]) == 1) {
3261
- $selected_tag = array ($tag_array [0][0], $tag_array [1][0]);
3262
  }
3263
- }
3264
- }
3265
 
3266
- if ($selected_tag == '') {
3267
- $first_tag = reset ($tags);
3268
- $smart_tag = implode (" ", array_slice (explode (" ", isset ($first_tag->name) ? $first_tag->name : ''), 0, 3));
3269
- } else $smart_tag = implode (" ", $selected_tag);
3270
 
3271
- $smart_tag = str_replace (array ("&amp;", "#"), array ("and", ""), $smart_tag);
 
 
 
 
 
3272
 
3273
- } else {
3274
- $tag = $category;
3275
- $smart_tag = $category;
3276
- }
3277
- }
3278
 
3279
- $title = str_replace (array ("'", '"'), array ("&#8217;", "&#8221;"), $title);
3280
- $title = html_entity_decode ($title, ENT_QUOTES, "utf-8");
3281
 
3282
- $short_title = str_replace (array ("'", '"'), array ("&#8217;", "&#8221;"), $short_title);
3283
- $short_title = html_entity_decode ($short_title, ENT_QUOTES, "utf-8");
 
 
 
3284
 
3285
- $search_query = "";
3286
- if (isset ($_SERVER['HTTP_REFERER'])) {
3287
- $referrer = $_SERVER['HTTP_REFERER'];
3288
- } else $referrer = '';
3289
- if (preg_match ("/[\.\/](google|yahoo|bing|ask)\.[a-z\.]{2,5}[\/]/i", $referrer, $search_engine)){
3290
- $referrer_query = parse_url ($referrer);
3291
- $referrer_query = isset ($referrer_query ["query"]) ? $referrer_query ["query"] : "";
3292
- parse_str ($referrer_query, $value);
3293
- $search_query = isset ($value ["q"]) ? $value ["q"] : "";
3294
- if ($search_query == "") {
3295
- $search_query = isset ($value ["p"]) ? $value ["p"] : "";
3296
- }
3297
- }
3298
- if ($search_query == "") $search_query = $smart_tag;
3299
-
3300
- $author = get_the_author_meta ('display_name');
3301
- $author_name = get_the_author_meta ('first_name') . " " . get_the_author_meta ('last_name');
3302
- if ($author_name == '') $author_name = $author;
3303
-
3304
- $ad_data = preg_replace ("/{title}/i", $title, $content);
3305
- $ad_data = preg_replace ("/{short_title}/i", $short_title, $ad_data);
3306
- $ad_data = preg_replace ("/{category}/i", $category, $ad_data);
3307
- $ad_data = preg_replace ("/{short_category}/i", $short_category, $ad_data);
3308
- $ad_data = preg_replace ("/{tag}/i", $tag, $ad_data);
3309
- $ad_data = preg_replace ("/{smart_tag}/i", $smart_tag, $ad_data);
3310
- $ad_data = preg_replace ("/{search_query}/i", $search_query, $ad_data);
3311
- $ad_data = preg_replace ("/{author}/i", $author, $ad_data);
3312
- $ad_data = preg_replace ("/{author_name}/i", $author_name, $ad_data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3313
 
3314
  if (function_exists ('ai_tags')) ai_tags ($ad_data);
3315
 
341
  public function ai_getCode (){
342
  global $block_object, $ai_total_php_time, $ai_wp_data;
343
 
344
+ if ($this->fallback != 0) return $block_object [$this->fallback]->ai_getCode ();
 
 
 
345
 
346
+ $obj = $this;
347
  $code = $obj->get_ad_data();
348
 
349
  if ($obj->get_process_php () && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
1108
 
1109
  $code = $this->ai_getCode ();
1110
 
1111
+ $processed_code = $this->replace_ai_tags (do_shortcode ($code));
1112
 
1113
  if (strpos ($code, AD_COUNT_SEPARATOR) !== false) {
1114
  $ads = explode (AD_COUNT_SEPARATOR, $code);
1221
  }
1222
  }
1223
 
1224
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
1225
+ $processed_code = "<div class='ai-code'>\n" . $processed_code ."</div>\n";
1226
+ }
1227
 
1228
+ if (function_exists ('ai_adb_block_actions')) ai_adb_block_actions ($this, $processed_code, $hide_label);
 
1229
 
1230
  $title = '';
1231
  $fallback_code = '';
1251
  }
1252
 
1253
  public function get_code_for_insertion ($include_viewport_classes = true, $hidden_widgets = false) {
1254
+ global $ai_wp_data, $block_object;
1255
 
1256
  if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) return $this->ai_getProcessedCode ();
1257
 
1298
  $tracking_code_data = '';
1299
  $tracking_code_post = '';
1300
  $tracking_code = '';
 
 
 
 
1301
 
1302
+ if ($this->fallback != 0) {
1303
+ if ($block_object [$this->fallback]->get_tracking ()) {
1304
+ $tracking_code_pre = " data-ai='";
1305
+ $tracking_code_data = "[{$this->fallback},{$this->code_version}]";
1306
+ $tracking_code_post = "'";
1307
+
1308
+ $tracking_code = $tracking_code_pre . base64_encode ($tracking_code_data) . $tracking_code_post;
1309
+ }
1310
+ } else {
1311
+ if ($this->get_tracking ()) {
1312
+ $tracking_code_pre = " data-ai='";
1313
+ $tracking_code_data = "[{$this->number},{$this->code_version}]";
1314
+ $tracking_code_post = "'";
1315
+
1316
+ $tracking_code = $tracking_code_pre . base64_encode ($tracking_code_data) . $tracking_code_post;
1317
+ }
1318
+ }
1319
 
1320
  $wrapper_before = $hidden_viewports . "<div" . $class . $tracking_code . " style='" . $additional_block_style . $this->get_alignment_style() . "'>\n";
1321
 
2617
  $tags = $this->get_ad_block_tag();
2618
  $tag_type = $this->get_ad_block_tag_type();
2619
 
2620
+ // $tags = trim (strtolower ($tags));
2621
+ $tags = trim ($tags);
2622
  $tags_listed = explode (",", $tags);
2623
  foreach ($tags_listed as $index => $tag_listed) {
2624
  $tags_listed [$index] = trim ($tag_listed);
2663
  if ($taxonomies == AD_EMPTY_DATA) return true;
2664
 
2665
  $taxonomies_listed = explode (",", $taxonomies);
 
2666
  $taxonomy_names = get_post_taxonomies ();
 
 
 
 
2667
 
2668
+ foreach ($taxonomies_listed as $taxonomy_disabled) {
2669
+ $taxonomy_disabled = trim ($taxonomy_disabled);
2670
 
2671
+ if (strpos ($taxonomy_disabled, 'user:') === 0) {
2672
+ $current_user = wp_get_current_user();
2673
+ $terms = explode (':', $taxonomy_disabled);
2674
+ if ($terms [1] == $current_user->user_login) return false;
2675
+ }
2676
+ elseif (strpos ($taxonomy_disabled, 'user-role:') === 0) {
2677
+ $current_user = wp_get_current_user();
2678
+ $terms = explode (':', $taxonomy_disabled);
2679
+ foreach (wp_get_current_user()->roles as $role) {
2680
+ if ($terms [1] == $role) return false;
2681
+ }
2682
+ }
2683
+ elseif (strpos ($taxonomy_disabled, 'post-type:') === 0) {
2684
+ $post_type = get_post_type ();
2685
+ $terms = explode (':', $taxonomy_disabled);
2686
+ if ($terms [1] == $post_type) return false;
2687
+ }
2688
 
2689
+ foreach ($taxonomy_names as $taxonomy_name) {
2690
+ $terms = get_the_terms (0, $taxonomy_name);
2691
+ if (is_array ($terms)) {
2692
+ foreach ($terms as $term) {
2693
  $post_term_name = strtolower ($term->name);
2694
  $post_term_slug = strtolower ($term->slug);
2695
  $post_taxonomy = strtolower ($term->taxonomy);
2704
  }
2705
  }
2706
  }
2707
+
2708
  return true;
2709
 
2710
  } else {
2712
  if ($taxonomies == AD_EMPTY_DATA) return false;
2713
 
2714
  $taxonomies_listed = explode (",", $taxonomies);
 
2715
  $taxonomy_names = get_post_taxonomies ();
 
 
 
 
2716
 
2717
+ foreach ($taxonomies_listed as $taxonomy_enabled) {
2718
+ $taxonomy_enabled = trim ($taxonomy_enabled);
2719
 
2720
+ if (strpos ($taxonomy_enabled, 'user:') === 0) {
2721
+ $current_user = wp_get_current_user();
2722
+ $terms = explode (':', $taxonomy_enabled);
2723
+ if ($terms [1] == $current_user->user_login) return true;
2724
+ }
2725
+ elseif (strpos ($taxonomy_enabled, 'user-role:') === 0) {
2726
+ $current_user = wp_get_current_user();
2727
+ $terms = explode (':', $taxonomy_enabled);
2728
+ foreach (wp_get_current_user()->roles as $role) {
2729
+ if ($terms [1] == $role) return true;
2730
+ }
2731
+ }
2732
+ elseif (strpos ($taxonomy_enabled, 'post-type:') === 0) {
2733
+ $post_type = get_post_type ();
2734
+ $terms = explode (':', $taxonomy_enabled);
2735
+ if ($terms [1] == $post_type) return true;
2736
+ }
2737
 
2738
+ foreach ($taxonomy_names as $taxonomy_name) {
2739
+ $terms = get_the_terms (0, $taxonomy_name);
2740
+ if (is_array ($terms)) {
2741
+ foreach ($terms as $term) {
2742
  $post_term_name = strtolower ($term->name);
2743
  $post_term_slug = strtolower ($term->slug);
2744
+ $post_taxonomy = strtolower ($term->taxonomy);
2745
 
2746
  if ($post_term_name == $taxonomy_enabled || $post_term_slug == $taxonomy_enabled) return true;
2747
 
2753
  }
2754
  }
2755
  }
2756
+
2757
  return false;
2758
  }
2759
  }
2939
  return !$return;
2940
  }
2941
 
2942
+ function check_number_of_words (&$content = null, $number_of_words = 0) {
2943
+ global $ai_last_check, $ai_wp_data;
2944
 
2945
+ $minimum_words = intval ($this->get_minimum_words());
2946
+ $maximum_words = intval ($this->get_maximum_words());
2947
+
2948
+ if ($minimum_words == 0 && $maximum_words == 0) return true;
2949
+
2950
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
2951
+ if ($number_of_words == 0) {
2952
+ if (!isset ($ai_wp_data [AI_WORD_COUNT])) {
2953
+ if ($content === null) {
2954
+ $content = '';
2955
+ $content_post = get_post ();
2956
+ if (isset ($content_post->post_content)) $content = $content_post->post_content;
2957
+ }
2958
+
2959
+ $number_of_words = number_of_words ($content);
2960
+ } else $number_of_words = $ai_wp_data [AI_WORD_COUNT];
2961
+ }
2962
+ } else $number_of_words = 0;
2963
+ $ai_wp_data [AI_WORD_COUNT] = $number_of_words;
2964
 
2965
  $ai_last_check = AI_CHECK_MIN_NUMBER_OF_WORDS;
2966
+ if ($number_of_words < $minimum_words) return false;
2967
 
 
2968
  if ($maximum_words <= 0) $maximum_words = 1000000;
2969
 
2970
  $ai_last_check = AI_CHECK_MAX_NUMBER_OF_WORDS;
3050
  $ai_last_check = AI_CHECK_SCHEDULING;
3051
  if (!$this->check_scheduling ()) return false;
3052
 
 
 
 
3053
  $display_for_users = $this->get_display_for_users ();
3054
 
3055
  $ai_last_check = AI_CHECK_LOGGED_IN_USER;
3209
  function replace_ai_tags ($content){
3210
  global $ai_wp_data;
3211
 
3212
+ if (!isset ($ai_wp_data [AI_TAGS])) {
3213
+ $general_tag = str_replace ("&amp;", " and ", $this->get_ad_general_tag());
3214
+ $title = $general_tag;
3215
+ $short_title = $general_tag;
3216
+ $category = $general_tag;
3217
+ $short_category = $general_tag;
3218
+ $tag = $general_tag;
3219
+ $smart_tag = $general_tag;
3220
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY) {
3221
+ $categories = get_the_category();
3222
+ if (!empty ($categories)) {
3223
+ $first_category = reset ($categories);
3224
+ $category = str_replace ("&amp;", "and", $first_category->name);
3225
+ if ($category == "Uncategorized") $category = $general_tag;
3226
+ } else {
3227
+ $category = $general_tag;
3228
+ }
3229
+ if (strpos ($category, ",") !== false) {
3230
+ $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3231
+ } else $short_category = $category;
3232
+ if (strpos ($short_category, "and") !== false) {
3233
+ $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3234
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3235
 
3236
+ $title = $category;
3237
+ $title = str_replace ("&amp;", "and", $title);
3238
+ $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3239
+ $tag = $short_title;
3240
+ $smart_tag = $short_title;
3241
+ } elseif (is_tag ()) {
3242
+ $title = single_tag_title('', false);
3243
+ $title = str_replace (array ("&amp;", "#"), array ("and", ""), $title);
3244
+ $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3245
+ $category = $short_title;
3246
+ if (strpos ($category, ",") !== false) {
3247
+ $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3248
+ } else $short_category = $category;
3249
+ if (strpos ($short_category, "and") !== false) {
3250
+ $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3251
  }
3252
+ $tag = $short_title;
3253
+ $smart_tag = $short_title;
3254
+ } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH) {
3255
+ $title = get_search_query();
3256
+ $title = str_replace ("&amp;", "and", $title);
3257
+ $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3258
+ $category = $short_title;
3259
+ if (strpos ($category, ",") !== false) {
3260
+ $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3261
+ } else $short_category = $category;
3262
+ if (strpos ($short_category, "and") !== false) {
3263
+ $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3264
+ }
3265
+ $tag = $short_title;
3266
+ $smart_tag = $short_title;
3267
+ } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) {
3268
+ $title = get_the_title();
3269
+ $title = str_replace ("&amp;", "and", $title);
3270
+
3271
+ $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3));
3272
+
3273
+ $categories = get_the_category();
3274
+ if (!empty ($categories)) {
3275
+ $first_category = reset ($categories);
3276
+ $category = str_replace ("&amp;", "and", $first_category->name);
3277
+ if ($category == "Uncategorized") $category = $general_tag;
3278
+ } else {
3279
+ $category = $short_title;
3280
+ }
3281
+ if (strpos ($category, ",") !== false) {
3282
+ $short_category = trim (substr ($category, 0, strpos ($category, ",")));
3283
+ } else $short_category = $category;
3284
+ if (strpos ($short_category, "and") !== false) {
3285
+ $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and")));
3286
+ }
3287
+
3288
+ $tags = get_the_tags();
3289
+ if (!empty ($tags)) {
3290
 
3291
+ $first_tag = reset ($tags);
3292
+ $tag = str_replace (array ("&amp;", "#"), array ("and", ""), isset ($first_tag->name) ? $first_tag->name : '');
3293
 
3294
+ $tag_array = array ();
3295
+ foreach ($tags as $tag_data) {
3296
+ if (isset ($tag_data->name))
3297
+ $tag_array [] = explode (" ", $tag_data->name);
3298
+ }
3299
 
3300
+ $selected_tag = '';
3301
 
3302
+ if (count ($tag_array [0]) == 2) $selected_tag = $tag_array [0];
3303
+ elseif (count ($tag_array) > 1 && count ($tag_array [1]) == 2) $selected_tag = $tag_array [1];
3304
+ elseif (count ($tag_array) > 2 && count ($tag_array [2]) == 2) $selected_tag = $tag_array [2];
3305
+ elseif (count ($tag_array) > 3 && count ($tag_array [3]) == 2) $selected_tag = $tag_array [3];
3306
+ elseif (count ($tag_array) > 4 && count ($tag_array [4]) == 2) $selected_tag = $tag_array [4];
3307
 
 
 
 
3308
 
3309
+ if ($selected_tag == '' && count ($tag_array) >= 2 && count ($tag_array [0]) == 1 && count ($tag_array [1]) == 1) {
 
 
3310
 
3311
+ if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) {
3312
+ if (strpos ($tag_array [0][0], $tag_array [1][0]) !== false) $tag_array = array_slice ($tag_array, 1, count ($tag_array) - 1);
 
3313
  }
 
 
3314
 
3315
+ if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) {
3316
+ if (strpos ($tag_array [1][0], $tag_array [0][0]) !== false) $tag_array = array_slice ($tag_array, 1, count ($tag_array) - 1);
3317
+ }
 
3318
 
3319
+ if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) {
3320
+ if (count ($tag_array) >= 2 && count ($tag_array [0]) == 1 && count ($tag_array [1]) == 1) {
3321
+ $selected_tag = array ($tag_array [0][0], $tag_array [1][0]);
3322
+ }
3323
+ }
3324
+ }
3325
 
3326
+ if ($selected_tag == '') {
3327
+ $first_tag = reset ($tags);
3328
+ $smart_tag = implode (" ", array_slice (explode (" ", isset ($first_tag->name) ? $first_tag->name : ''), 0, 3));
3329
+ } else $smart_tag = implode (" ", $selected_tag);
 
3330
 
3331
+ $smart_tag = str_replace (array ("&amp;", "#"), array ("and", ""), $smart_tag);
 
3332
 
3333
+ } else {
3334
+ $tag = $category;
3335
+ $smart_tag = $category;
3336
+ }
3337
+ }
3338
 
3339
+ $title = str_replace (array ("'", '"'), array ("&#8217;", "&#8221;"), $title);
3340
+ $title = html_entity_decode ($title, ENT_QUOTES, "utf-8");
3341
+
3342
+ $short_title = str_replace (array ("'", '"'), array ("&#8217;", "&#8221;"), $short_title);
3343
+ $short_title = html_entity_decode ($short_title, ENT_QUOTES, "utf-8");
3344
+
3345
+ $search_query = "";
3346
+ if (isset ($_SERVER['HTTP_REFERER'])) {
3347
+ $referrer = $_SERVER['HTTP_REFERER'];
3348
+ } else $referrer = '';
3349
+ if (preg_match ("/[\.\/](google|yahoo|bing|ask)\.[a-z\.]{2,5}[\/]/i", $referrer, $search_engine)){
3350
+ $referrer_query = parse_url ($referrer);
3351
+ $referrer_query = isset ($referrer_query ["query"]) ? $referrer_query ["query"] : "";
3352
+ parse_str ($referrer_query, $value);
3353
+ $search_query = isset ($value ["q"]) ? $value ["q"] : "";
3354
+ if ($search_query == "") {
3355
+ $search_query = isset ($value ["p"]) ? $value ["p"] : "";
3356
+ }
3357
+ }
3358
+ if ($search_query == "") $search_query = $smart_tag;
3359
+
3360
+ $author = get_the_author_meta ('display_name');
3361
+ $author_name = get_the_author_meta ('first_name') . " " . get_the_author_meta ('last_name');
3362
+ if ($author_name == '') $author_name = $author;
3363
+
3364
+ $ai_wp_data [AI_TAGS]['TITLE'] = $title;
3365
+ $ai_wp_data [AI_TAGS]['SHORT_TITLE'] = $short_title;
3366
+ $ai_wp_data [AI_TAGS]['CATEGORY'] = $category;
3367
+ $ai_wp_data [AI_TAGS]['SHORT_CATEGORY'] = $short_category;
3368
+ $ai_wp_data [AI_TAGS]['TAG'] = $tag;
3369
+ $ai_wp_data [AI_TAGS]['SMART_TAG'] = $smart_tag;
3370
+ $ai_wp_data [AI_TAGS]['SEARCH_QUERY'] = $search_query;
3371
+ $ai_wp_data [AI_TAGS]['AUTHOR'] = $author;
3372
+ $ai_wp_data [AI_TAGS]['AUTHOR_NAME'] = $author_name;
3373
+ }
3374
+
3375
+ $ad_data = preg_replace ("/{title}/i", $ai_wp_data [AI_TAGS]['TITLE'], $content);
3376
+ $ad_data = preg_replace ("/{short-title}/i", $ai_wp_data [AI_TAGS]['SHORT_TITLE'], $ad_data);
3377
+ $ad_data = preg_replace ("/{category}/i", $ai_wp_data [AI_TAGS]['CATEGORY'], $ad_data);
3378
+ $ad_data = preg_replace ("/{short-category}/i", $ai_wp_data [AI_TAGS]['SHORT_CATEGORY'], $ad_data);
3379
+ $ad_data = preg_replace ("/{tag}/i", $ai_wp_data [AI_TAGS]['TAG'], $ad_data);
3380
+ $ad_data = preg_replace ("/{smart-tag}/i", $ai_wp_data [AI_TAGS]['SMART_TAG'], $ad_data);
3381
+ $ad_data = preg_replace ("/{search-query}/i", $ai_wp_data [AI_TAGS]['SEARCH_QUERY'], $ad_data);
3382
+ $ad_data = preg_replace ("/{author}/i", $ai_wp_data [AI_TAGS]['AUTHOR'], $ad_data);
3383
+ $ad_data = preg_replace ("/{author-name}/i", $ai_wp_data [AI_TAGS]['AUTHOR_NAME'], $ad_data);
3384
+
3385
+ $ad_data = preg_replace ("/{short_title}/i", $ai_wp_data [AI_TAGS]['SHORT_TITLE'], $ad_data);
3386
+ $ad_data = preg_replace ("/{short_category}/i", $ai_wp_data [AI_TAGS]['SHORT_CATEGORY'], $ad_data);
3387
+ $ad_data = preg_replace ("/{smart_tag}/i", $ai_wp_data [AI_TAGS]['SMART_TAG'], $ad_data);
3388
+ $ad_data = preg_replace ("/{search_query}/i", $ai_wp_data [AI_TAGS]['SEARCH_QUERY'], $ad_data);
3389
+ $ad_data = preg_replace ("/{author_name}/i", $ai_wp_data [AI_TAGS]['AUTHOR_NAME'], $ad_data);
3390
 
3391
  if (function_exists ('ai_tags')) ai_tags ($ad_data);
3392
 
constants.php CHANGED
@@ -18,7 +18,7 @@ if (!defined( 'AD_INSERTER_NAME'))
18
  define ('AD_INSERTER_NAME', 'Ad Inserter');
19
 
20
  if (!defined( 'AD_INSERTER_VERSION'))
21
- define ('AD_INSERTER_VERSION', '2.2.2');
22
 
23
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
24
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -380,10 +380,10 @@ define('AI_TEXT_MULTIBYTE', 'Multibyte');
380
 
381
  // Tracking
382
  define('AI_TRACKING_DISABLED', 0);
383
- define('AI_TRACKING_INTERNAL', 1);
384
-
385
  define('AI_TRACKING_ENABLED', 1);
386
 
 
 
387
  // Ad Blocking
388
  define ('AI_ADB_ACTION_NONE', 0);
389
  define ('AI_ADB_ACTION_MESSAGE', 1);
@@ -411,6 +411,13 @@ define ('AI_TEXT_INTERNAL', 'Internal');
411
  define ('AI_TEXT_ADVANCED', 'Advanced');
412
  define ('AI_TEXT_ENABLED', 'Enabled');
413
 
 
 
 
 
 
 
 
414
  //Settings
415
  define ('AI_ENABLED', '1');
416
  define ('AI_DISABLED', '0');
@@ -432,6 +439,7 @@ define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
432
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
433
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
434
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
 
435
  define ('DEFAULT_STICKY_WIDGET_MARGIN', 15);
436
  define ('DEFAULT_PLUGIN_PRIORITY', 99999);
437
  define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
@@ -447,7 +455,9 @@ define ('DEFAULT_MULTISITE_PHP_PROCESSING', AI_ENABLED);
447
  define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
448
  define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
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
 
@@ -469,6 +479,8 @@ 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);
 
 
472
 
473
  define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
474
  define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
@@ -584,6 +596,9 @@ 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);
18
  define ('AD_INSERTER_NAME', 'Ad Inserter');
19
 
20
  if (!defined( 'AD_INSERTER_VERSION'))
21
+ define ('AD_INSERTER_VERSION', '2.2.3');
22
 
23
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
24
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
380
 
381
  // Tracking
382
  define('AI_TRACKING_DISABLED', 0);
 
 
383
  define('AI_TRACKING_ENABLED', 1);
384
 
385
+ define('AI_TRACKING_INTERNAL', 0);
386
+
387
  // Ad Blocking
388
  define ('AI_ADB_ACTION_NONE', 0);
389
  define ('AI_ADB_ACTION_MESSAGE', 1);
411
  define ('AI_TEXT_ADVANCED', 'Advanced');
412
  define ('AI_TEXT_ENABLED', 'Enabled');
413
 
414
+ // Sticky widget mode
415
+ define ('AI_STICKY_WIDGET_MODE_CSS', 0);
416
+ define ('AI_STICKY_WIDGET_MODE_JS', 1);
417
+
418
+ define ('AI_TEXT_CSS', 'CSS');
419
+ define ('AI_TEXT_JS', 'JavaScript ');
420
+
421
  //Settings
422
  define ('AI_ENABLED', '1');
423
  define ('AI_DISABLED', '0');
439
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
440
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
441
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
442
+ define ('DEFAULT_STICKY_WIDGET_MODE', AI_STICKY_WIDGET_MODE_CSS);
443
  define ('DEFAULT_STICKY_WIDGET_MARGIN', 15);
444
  define ('DEFAULT_PLUGIN_PRIORITY', 99999);
445
  define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
455
  define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
456
  define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
457
  define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
458
+ define ('DEFAULT_TRACKING_MODE', AI_TRACKING_INTERNAL);
459
  define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
460
+ define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
461
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
462
  define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
463
 
479
  define ('AI_DEFAULT_ADB_NO_ACTION_PERIOD', 30);
480
  define ('AI_DEFAULT_ADB_REDIRECTION_PAGE', 0);
481
  define ('AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE', AI_DISABLED);
482
+ define ('AI_ADB_VERSION_MASK', 0x7F);
483
+ define ('AI_ADB_FLAG_BLOCKED', 0x80);
484
 
485
  define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
486
  define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
596
  define ('AI_WP_AMP_PAGE', 16);
597
  define ('AI_INSTALL_TIME_DIFFERENCE', 17);
598
  define ('AI_DAYS_SINCE_INSTAL', 18);
599
+ define ('AI_TAGS', 19);
600
+ define ('AI_VIEWPORTS', 20);
601
+ define ('AI_WORD_COUNT', 21);
602
 
603
  define ('AI_CONTEXT_NONE', 0);
604
  define ('AI_CONTEXT_CONTENT', 1);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.2.2"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -20,6 +20,11 @@
20
  font-size: 12px;
21
  }
22
 
 
 
 
 
 
23
  .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {
24
  background: #fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x!important;
25
  }
@@ -282,9 +287,15 @@ textarea.simple-editor.small {
282
  font-size: 12px;
283
  }
284
 
285
- .ms-container dd, li {
 
286
  margin-bottom: 4px;
287
  }
 
 
 
 
 
288
  .ms-container .search-input {
289
  width: 100%;
290
  border-radius: 4px;
@@ -298,7 +309,7 @@ div.custom-range-controls {
298
  width: 696px;
299
  }
300
 
301
- div.custom-range-controls input.chart-date {
302
  width: 85px;
303
  }
304
 
@@ -448,6 +459,15 @@ div.automatic-insertion img {
448
  background: url('images/icons.png') -60px 0;
449
  }
450
 
 
 
 
 
 
 
 
 
 
451
  .checkbox-icon.icon-loading {
452
  width: 12px;
453
  height: 12px;
@@ -522,9 +542,9 @@ div.automatic-insertion img {
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
  }
1
  #ai-data {
2
+ font-family: "2.2.3"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
20
  font-size: 12px;
21
  }
22
 
23
+ .ui-widget-header {
24
+ border: 1px solid #aaa;
25
+ background: #ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;
26
+ }
27
+
28
  .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {
29
  background: #fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x!important;
30
  }
287
  font-size: 12px;
288
  }
289
 
290
+ .ms-container dd, .ms-container li {
291
+ /*.ms-container dd, li {*/
292
  margin-bottom: 4px;
293
  }
294
+
295
+ .feature-list li {
296
+ margin-bottom: 2px;
297
+ }
298
+
299
  .ms-container .search-input {
300
  width: 100%;
301
  border-radius: 4px;
309
  width: 696px;
310
  }
311
 
312
+ input.ai-date-input {
313
  width: 85px;
314
  }
315
 
459
  background: url('images/icons.png') -60px 0;
460
  }
461
 
462
+ .checkbox-icon.icon-adb {
463
+ background: url('images/icons.png') -120px -20px;
464
+ }
465
+
466
+ .checkbox-icon.icon-adb.on {
467
+ background: url('images/icons.png') -120px 0;
468
+ }
469
+
470
+
471
  .checkbox-icon.icon-loading {
472
  width: 12px;
473
  height: 12px;
542
  font-size: 16px;
543
  }
544
  div.custom-range-controls {
545
+ width: 720px;
546
  }
547
+ input.ai-date-input {
548
  width: 90px;
549
  padding: 3px 3px;
550
  }
css/images/icons.png CHANGED
Binary file
images/ai-charts-250.png ADDED
Binary file
includes/Mobile_Detect.php CHANGED
@@ -22,7 +22,7 @@
22
  * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
23
  * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
24
  *
25
- * @version 2.8.25
26
  */
27
 
28
  class ai_Mobile_Detect
@@ -66,7 +66,7 @@ class ai_Mobile_Detect
66
  /**
67
  * Stores the version number of the current release.
68
  */
69
- const VERSION = '2.8.25';
70
 
71
  /**
72
  * A type for the version() method indicating a string return value.
@@ -220,7 +220,7 @@ class ai_Mobile_Detect
220
  // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
221
  // @see #442
222
  'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
223
- 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone.
224
  // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
225
  'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)',
226
  // Only the Surface tablets with Windows RT are considered mobile.
@@ -230,7 +230,7 @@ class ai_Mobile_Detect
230
  'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
231
  // Watch out for PadFone, see #132.
232
  // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
233
- 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z',
234
  'BlackBerryTablet' => 'PlayBook|RIM Tablet',
235
  'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
236
  'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
@@ -252,7 +252,7 @@ class ai_Mobile_Detect
252
  // Prestigio Tablets http://www.prestigio.com/support
253
  'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
254
  // http://support.lenovo.com/en_GB/downloads/default.page?#
255
- 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
256
  // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
257
  'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
258
  // http://www.yarvik.com/en/matrix/tablets/
@@ -451,6 +451,7 @@ class ai_Mobile_Detect
451
  // http://www.nbru.cn/index.html
452
  'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
453
  // http://navroad.com/products/produkty/tablety/
 
454
  'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
455
  // http://leader-online.com/new_site/product-category/tablets/
456
  // http://www.leader-online.net.au/List/Tablet
@@ -467,7 +468,7 @@ class ai_Mobile_Detect
467
  'Hudl' => 'Hudl HT7S3|Hudl 2',
468
  // http://www.telstra.com.au/home-phone/thub-2/
469
  'TelstraTablet' => 'T-Hub2',
470
- 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b'
471
  );
472
 
473
  /**
22
  * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
23
  * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
24
  *
25
+ * @version 2.8.26
26
  */
27
 
28
  class ai_Mobile_Detect
66
  /**
67
  * Stores the version number of the current release.
68
  */
69
+ const VERSION = '2.8.26';
70
 
71
  /**
72
  * A type for the version() method indicating a string return value.
220
  // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
221
  // @see #442
222
  'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
223
+ 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone.
224
  // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
225
  'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)',
226
  // Only the Surface tablets with Windows RT are considered mobile.
230
  'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
231
  // Watch out for PadFone, see #132.
232
  // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
233
+ 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\bP027\b',
234
  'BlackBerryTablet' => 'PlayBook|RIM Tablet',
235
  'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
236
  'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
252
  // Prestigio Tablets http://www.prestigio.com/support
253
  'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
254
  // http://support.lenovo.com/en_GB/downloads/default.page?#
255
+ 'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
256
  // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
257
  'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
258
  // http://www.yarvik.com/en/matrix/tablets/
451
  // http://www.nbru.cn/index.html
452
  'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
453
  // http://navroad.com/products/produkty/tablety/
454
+ // http://navroad.com/products/produkty/tablety/
455
  'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
456
  // http://leader-online.com/new_site/product-category/tablets/
457
  // http://www.leader-online.net.au/List/Tablet
468
  'Hudl' => 'Hudl HT7S3|Hudl 2',
469
  // http://www.telstra.com.au/home-phone/thub-2/
470
  'TelstraTablet' => 'T-Hub2',
471
+ 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b|\bQTAQZ3\b'
472
  );
473
 
474
  /**
includes/ace/mode-ai-html.js CHANGED
@@ -33,9 +33,9 @@ exports.AiHtmlHighlightRules = AiHtmlHighlightRules;
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 (
@@ -44,7 +44,7 @@ function add_ai_highlighting_rules (highlighter, highlight_rules) {
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
  {
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|count".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|custom-field|data".split ("|"));
39
 
40
  //WP shortcodes
41
  highlighter.$rules ['start'].unshift (
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
  {
includes/ace/theme-ad_inserter.js CHANGED
@@ -113,14 +113,25 @@ color: #fffF80\
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\
113
  .ace-ad-inserter .ace_support.ace_php_tag {\
114
  color: #ff8888\
115
  }\
116
+ //.ace-ad-inserter .ace_paren.ace_adinserter {\
117
+ //color: #FF4444;\
118
+ //border-left: 1px solid #BBBBFF;\
119
+ //border-top: 1px solid #BBBBFF;\
120
+ //border-bottom: 1px solid #BBBBFF;\
121
+ //border-radius: 3px;\
122
+ //}\
123
  .ace-ad-inserter .ace_shortcode {\
124
  color: #ff8888\
125
  }\
126
  .ace-ad-inserter .ace_shortcode.ace_adinserter {\
127
+ color: #ff88ff;\
128
+ //border-top: 1px solid #BBBBFF;\
129
+ //border-bottom: 1px solid #BBBBFF;\
130
  }\
131
  .ace-ad-inserter .ace_shortcode.ace_ai-attribute {\
132
+ color: #80ff80;\
133
+ //border: 1px solid #FFBBBB;\
134
+ //border-radius: 3px;\
135
  }\
136
  .ace-ad-inserter .ace_indent-guide {\
137
  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ09NrYAgMjP4PAAtGAwchHMyAAAAAAElFTkSuQmCC) right repeat-y\
includes/js/ResizeSensor.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright Marc J. Schmidt. See the LICENSE file at the top-level
3
+ * directory of this distribution and at
4
+ * https://github.com/marcj/css-element-queries/blob/master/LICENSE.
5
+ */
6
+ ;
7
+ (function() {
8
+
9
+ /**
10
+ * Class for dimension change detection.
11
+ *
12
+ * @param {Element|Element[]|Elements|jQuery} element
13
+ * @param {Function} callback
14
+ *
15
+ * @constructor
16
+ */
17
+ var ResizeSensor = function(element, callback) {
18
+ /**
19
+ *
20
+ * @constructor
21
+ */
22
+ function EventQueue() {
23
+ this.q = [];
24
+ this.add = function(ev) {
25
+ this.q.push(ev);
26
+ };
27
+
28
+ var i, j;
29
+ this.call = function() {
30
+ for (i = 0, j = this.q.length; i < j; i++) {
31
+ this.q[i].call();
32
+ }
33
+ };
34
+ }
35
+
36
+ /**
37
+ * @param {HTMLElement} element
38
+ * @param {String} prop
39
+ * @returns {String|Number}
40
+ */
41
+ function getComputedStyle(element, prop) {
42
+ if (element.currentStyle) {
43
+ return element.currentStyle[prop];
44
+ } else if (window.getComputedStyle) {
45
+ return window.getComputedStyle(element, null).getPropertyValue(prop);
46
+ } else {
47
+ return element.style[prop];
48
+ }
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @param {HTMLElement} element
54
+ * @param {Function} resized
55
+ */
56
+ function attachResizeEvent(element, resized) {
57
+ if (!element.resizedAttached) {
58
+ element.resizedAttached = new EventQueue();
59
+ element.resizedAttached.add(resized);
60
+ } else if (element.resizedAttached) {
61
+ element.resizedAttached.add(resized);
62
+ return;
63
+ }
64
+
65
+ element.resizeSensor = document.createElement('div');
66
+ element.resizeSensor.className = 'resize-sensor';
67
+ var style = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';
68
+ var styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
69
+
70
+ element.resizeSensor.style.cssText = style;
71
+ element.resizeSensor.innerHTML =
72
+ '<div class="resize-sensor-expand" style="' + style + '">' +
73
+ '<div style="' + styleChild + '"></div>' +
74
+ '</div>' +
75
+ '<div class="resize-sensor-shrink" style="' + style + '">' +
76
+ '<div style="' + styleChild + ' width: 200%; height: 200%"></div>' +
77
+ '</div>';
78
+ element.appendChild(element.resizeSensor);
79
+
80
+ if (!{fixed: 1, absolute: 1}[getComputedStyle(element, 'position')]) {
81
+ element.style.position = 'relative';
82
+ }
83
+
84
+ var expand = element.resizeSensor.childNodes[0];
85
+ var expandChild = expand.childNodes[0];
86
+ var shrink = element.resizeSensor.childNodes[1];
87
+ var shrinkChild = shrink.childNodes[0];
88
+
89
+ var lastWidth, lastHeight;
90
+
91
+ var reset = function() {
92
+ expandChild.style.width = expand.offsetWidth + 10 + 'px';
93
+ expandChild.style.height = expand.offsetHeight + 10 + 'px';
94
+ expand.scrollLeft = expand.scrollWidth;
95
+ expand.scrollTop = expand.scrollHeight;
96
+ shrink.scrollLeft = shrink.scrollWidth;
97
+ shrink.scrollTop = shrink.scrollHeight;
98
+ lastWidth = element.offsetWidth;
99
+ lastHeight = element.offsetHeight;
100
+ };
101
+
102
+ reset();
103
+
104
+ var changed = function() {
105
+ if (element.resizedAttached) {
106
+ element.resizedAttached.call();
107
+ }
108
+ };
109
+
110
+ var addEvent = function(el, name, cb) {
111
+ if (el.attachEvent) {
112
+ el.attachEvent('on' + name, cb);
113
+ } else {
114
+ el.addEventListener(name, cb);
115
+ }
116
+ };
117
+
118
+ var onScroll = function() {
119
+ if (element.offsetWidth != lastWidth || element.offsetHeight != lastHeight) {
120
+ changed();
121
+ }
122
+ reset();
123
+ };
124
+
125
+ addEvent(expand, 'scroll', onScroll);
126
+ addEvent(shrink, 'scroll', onScroll);
127
+ }
128
+
129
+ var elementType = Object.prototype.toString.call(element);
130
+ var isCollectionTyped = ('[object Array]' === elementType
131
+ || ('[object NodeList]' === elementType)
132
+ || ('[object HTMLCollection]' === elementType)
133
+ || ('undefined' !== typeof jQuery && element instanceof jQuery) //jquery
134
+ || ('undefined' !== typeof Elements && element instanceof Elements) //mootools
135
+ );
136
+
137
+ if (isCollectionTyped) {
138
+ var i = 0, j = element.length;
139
+ for (; i < j; i++) {
140
+ attachResizeEvent(element[i], callback);
141
+ }
142
+ } else {
143
+ attachResizeEvent(element, callback);
144
+ }
145
+
146
+ this.detach = function() {
147
+ if (isCollectionTyped) {
148
+ var i = 0, j = element.length;
149
+ for (; i < j; i++) {
150
+ ResizeSensor.detach(element[i]);
151
+ }
152
+ } else {
153
+ ResizeSensor.detach(element);
154
+ }
155
+ };
156
+ };
157
+
158
+ ResizeSensor.detach = function(element) {
159
+ if (element.resizeSensor) {
160
+ element.removeChild(element.resizeSensor);
161
+ delete element.resizeSensor;
162
+ delete element.resizedAttached;
163
+ }
164
+ };
165
+
166
+ // make available to common module loader
167
+ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
168
+ module.exports = ResizeSensor;
169
+ }
170
+ else {
171
+ window.ResizeSensor = ResizeSensor;
172
+ }
173
+
174
+ })();
175
+
176
+ //# sourceMappingURL=maps/ResizeSensor.js.map
includes/js/ResizeSensor.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ !function(){var e=function(t,i){function s(){this.q=[],this.add=function(e){this.q.push(e)};var e,t;this.call=function(){for(e=0,t=this.q.length;e<t;e++)this.q[e].call()}}function o(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null).getPropertyValue(t):e.style[t]}function n(e,t){if(e.resizedAttached){if(e.resizedAttached)return void e.resizedAttached.add(t)}else e.resizedAttached=new s,e.resizedAttached.add(t);e.resizeSensor=document.createElement("div"),e.resizeSensor.className="resize-sensor";var i="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;",n="position: absolute; left: 0; top: 0; transition: 0s;";e.resizeSensor.style.cssText=i,e.resizeSensor.innerHTML='<div class="resize-sensor-expand" style="'+i+'"><div style="'+n+'"></div></div><div class="resize-sensor-shrink" style="'+i+'"><div style="'+n+' width: 200%; height: 200%"></div></div>',e.appendChild(e.resizeSensor),{fixed:1,absolute:1}[o(e,"position")]||(e.style.position="relative");var d,r,l=e.resizeSensor.childNodes[0],c=l.childNodes[0],h=e.resizeSensor.childNodes[1],a=(h.childNodes[0],function(){c.style.width=l.offsetWidth+10+"px",c.style.height=l.offsetHeight+10+"px",l.scrollLeft=l.scrollWidth,l.scrollTop=l.scrollHeight,h.scrollLeft=h.scrollWidth,h.scrollTop=h.scrollHeight,d=e.offsetWidth,r=e.offsetHeight});a();var f=function(){e.resizedAttached&&e.resizedAttached.call()},u=function(e,t,i){e.attachEvent?e.attachEvent("on"+t,i):e.addEventListener(t,i)},p=function(){e.offsetWidth==d&&e.offsetHeight==r||f(),a()};u(l,"scroll",p),u(h,"scroll",p)}var d=Object.prototype.toString.call(t),r="[object Array]"===d||"[object NodeList]"===d||"[object HTMLCollection]"===d||"undefined"!=typeof jQuery&&t instanceof jQuery||"undefined"!=typeof Elements&&t instanceof Elements;if(r)for(var l=0,c=t.length;l<c;l++)n(t[l],i);else n(t,i);this.detach=function(){if(r)for(var i=0,s=t.length;i<s;i++)e.detach(t[i]);else e.detach(t)}};e.detach=function(e){e.resizeSensor&&(e.removeChild(e.resizeSensor),delete e.resizeSensor,delete e.resizedAttached)},"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=e:window.ResizeSensor=e}();
2
+ //# sourceMappingURL=maps/ResizeSensor.min.js.map
includes/js/ai-adb.js CHANGED
@@ -1,3 +1,5 @@
 
 
1
  var ai_adb_debugging = AI_DATAB_AI_JS_DEBUGGING;
2
  var ai_adb_active = false;
3
  var ai_adb_counter = 0;
@@ -113,8 +115,26 @@ var ai_adb_detected = function(n) {
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
  });
@@ -122,7 +142,7 @@ var ai_adb_detected = function(n) {
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
  });
@@ -225,6 +245,7 @@ var ai_adb_detected = function(n) {
225
 
226
  }(jQuery));
227
 
 
228
  }
229
  }
230
 
@@ -237,8 +258,7 @@ var ai_adb_undetected = function(n) {
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") {
1
+ var ai_adb = false;
2
+ var ai_adb_wrapping_div_selector = ".AI_BLOCK_CLASS_NAME";
3
  var ai_adb_debugging = AI_DATAB_AI_JS_DEBUGGING;
4
  var ai_adb_active = false;
5
  var ai_adb_counter = 0;
115
 
116
  $(".ai-adb-show").each (function () {
117
  $(this).css ({"display": "block", "visibility": "visible"});
118
+
119
+ var tracking_data = $(this).data ('ai-tracking');
120
+ if (typeof tracking_data != 'undefined') {
121
+ var wrapping_div = $(this).closest (ai_adb_wrapping_div_selector);
122
+ if (typeof wrapping_div.data ("ai") != "undefined") {
123
+
124
+ if ($(this).hasClass ('ai-no-tracking')) {
125
+ var data = JSON.parse (atob (wrapping_div.data ("ai")));
126
+ if (typeof data !== "undefined" && data.constructor === Array) {
127
+ data [1] = "";
128
+ tracking_data = btoa (JSON.stringify (data));
129
+ }
130
+ }
131
+
132
+ wrapping_div.data ("ai", tracking_data);
133
+ }
134
+ }
135
+
136
  if (ai_adb_debugging) {
137
+ var debug_info = $(this).data ("ai-debug");
138
  console.log ("AI ad blocking SHOW", typeof debug_info != "undefined" ? debug_info : "");
139
  }
140
  });
142
  $(".ai-adb-hide").each (function () {
143
  $(this).css ({"display": "none", "visibility": "hidden"});
144
  if (ai_adb_debugging) {
145
+ var debug_info = $(this).data ("ai-debug");
146
  console.log ("AI ad blocking HIDE", typeof debug_info != "undefined" ? debug_info : "");
147
  }
148
  });
245
 
246
  }(jQuery));
247
 
248
+ ai_adb = true;
249
  }
250
  }
251
 
258
  if (!ai_adb_active && ai_adb_counter == 3) {
259
  if (ai_adb_debugging) console.log ("AI ad blocking NOT DETECTED");
260
 
261
+ var AI_ADB_STATUS_MESSAGE=4; // Check replacement code {}
 
262
 
263
  // var redirected_page = false;
264
  // if (ai_adb_redirection_url.toLowerCase().substring (0, 4) == "http") {
includes/js/ai-adb.min.js CHANGED
@@ -1,19 +1,20 @@
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)}});
 
1
+ var ai_adb=false;var ai_adb_wrapping_div_selector=".AI_BLOCK_CLASS_NAME";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;
2
+ var ai_adb_action=AI_FUNCT_GET_ADB_ACTION;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"});var tracking_data=$(this).data("ai-tracking");if(typeof tracking_data!="undefined"){var wrapping_div=$(this).closest(ai_adb_wrapping_div_selector);if(typeof wrapping_div.data("ai")!="undefined"){if($(this).hasClass("ai-no-tracking")){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!==
9
+ "undefined"&&data.constructor===Array){data[1]="";tracking_data=btoa(JSON.stringify(data))}}wrapping_div.data("ai",tracking_data)}}});$(".ai-adb-hide").each(function(){$(this).css({"display":"none","visibility":"hidden"})});setTimeout(ai_adb_process_content,10)});if(ai_adb_page_views!=0){var ai_adb_page_view_counter=1;var cookie=$.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;
10
+ 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=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,
11
+ {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===27){ai_adb_overlay.click();ai_adb_message_window.click()}}}else;$("body").prepend(ai_adb_overlay).prepend(ai_adb_message_window);break;
12
+ 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=new Date;date.setTime(date.getTime()+10*1E3);$.cookie(ai_adb_page_redirection_cookie_name,window.location.href,{expires:date,path:"/"});
13
+ window.location.replace(ai_adb_redirection_url)}else;}else jQuery.removeCookie(ai_adb_page_redirection_cookie_name,{path:"/"})}break}})(jQuery);ai_adb=true}};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)});
14
+ 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)});
15
+ 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||
16
+ 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)})}})});
17
+ (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,
18
+ '"').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=
19
+ [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&&
20
+ (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-rotate.js CHANGED
@@ -1,5 +1,5 @@
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);
@@ -12,12 +12,27 @@ jQuery (function ($) {
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
  });
1
  jQuery (function ($) {
2
+ var wrapping_div_selector = ".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);
12
  $(rotate_options [random_index]).css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
13
  $(this).css ({"position": ""});
14
 
15
+ var tracking_updated = false;
16
+ var adb_show_wrapping_div = $(this).closest ('.ai-adb-show');
17
+ if (typeof adb_show_wrapping_div != "undefined") {
18
+ if (typeof adb_show_wrapping_div.data ("ai-tracking") != "undefined") {
19
+ var data = JSON.parse (atob (adb_show_wrapping_div.data ("ai-tracking")));
20
+ if (typeof data !== "undefined" && data.constructor === Array) {
21
+ data [1] = random_index + 1;
22
+ adb_show_wrapping_div.data ("ai-tracking", btoa (JSON.stringify (data)))
23
+ tracking_updated = true;
24
+ }
25
+ }
26
+ }
27
+
28
+ if (!tracking_updated) {
29
+ var wrapping_div = $(this).closest (wrapping_div_selector);
30
+ if (typeof wrapping_div.data ("ai") != "undefined") {
31
+ var data = JSON.parse (atob (wrapping_div.data ("ai")));
32
+ if (typeof data !== "undefined" && data.constructor === Array) {
33
+ data [1] = random_index + 1;
34
+ wrapping_div.data ("ai", btoa (JSON.stringify (data)))
35
+ }
36
  }
37
  }
38
  });
includes/js/ai-rotate.min.js CHANGED
@@ -1,2 +1,3 @@
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)))}}})});
 
1
+ jQuery(function($){var wrapping_div_selector=".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 tracking_updated=
2
+ false;var adb_show_wrapping_div=$(this).closest(".ai-adb-show");if(typeof adb_show_wrapping_div!="undefined")if(typeof adb_show_wrapping_div.data("ai-tracking")!="undefined"){var data=JSON.parse(atob(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;adb_show_wrapping_div.data("ai-tracking",btoa(JSON.stringify(data)));tracking_updated=true}}if(!tracking_updated){var wrapping_div=$(this).closest(wrapping_div_selector);if(typeof wrapping_div.data("ai")!=
3
+ "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 CHANGED
@@ -1,24 +1,56 @@
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
  });
 
1
  jQuery(document).ready(function($) {
2
+ var sticky_widget_mode = AI_FUNC_GET_STICKY_WIDGET_MODE;
3
  var sticky_widget_margin = AI_FUNC_GET_STICKY_WIDGET_MARGIN;
4
  var document_width = $(document).width();
5
 
6
  $(".ai-sticky").each (function () {
7
  var widget = $(this);
8
  var widget_width = widget.width();
9
+
10
+ console.log ("WIDGET:", widget.width (), widget.prop ("tagName"), widget.attr ("id"));
11
+
12
+ var already_sticky_js = false;
13
  var sidebar = widget.parent ();
14
  while (sidebar.prop ("tagName") != "BODY") {
15
+
16
+ if (sidebar.hasClass ('theiaStickySidebar')) {
17
+ already_sticky_js = true;
18
+ break;
19
+ }
20
+
21
+ console.log ("SIDEBAR:", sidebar.width (), sidebar.prop ("tagName"), sidebar.attr ("id"));
22
+
23
  var parent_element = sidebar.parent ();
24
  var parent_element_width = parent_element.width();
25
  if (parent_element_width > widget_width * 1.2 || parent_element_width > document_width / 2) break;
26
  sidebar = parent_element;
27
  }
28
+ if (already_sticky_js) {
29
+ console.log ("JS STICKY SIDEBAR ALREADY SET");
30
+ return;
 
 
31
  }
32
+
33
+ var new_sidebar_top = sidebar.offset ().top - widget.offset ().top + sticky_widget_margin;
34
+
35
+ console.log ("NEW SIDEBAR TOP:", new_sidebar_top);
36
+
37
+ if (sticky_widget_mode == 0) {
38
+ // CSS
39
+ if (sidebar.css ("position") != "sticky" || isNaN (parseInt (sidebar.css ("top"))) || sidebar.css ("top") < new_sidebar_top) {
40
+ sidebar.css ("position", "sticky").css ("top", new_sidebar_top);
41
+
42
+ console.log ("CSS STICKY SIDEBAR, TOP:", new_sidebar_top);
43
+ }
44
+ else console.log ("CSS STICKY SIDEBAR ALREADY SET");
45
+ } else {
46
+ // Javascript
47
+ sidebar.theiaStickySidebar({
48
+ additionalMarginTop: new_sidebar_top,
49
+ sidebarBehavior: 'stick-to-top',
50
+ });
51
+
52
+ console.log ("JS STICKY SIDEBAR, TOP:", new_sidebar_top);
53
+ }
54
  });
55
  });
56
+
includes/js/ai-sticky.min.js CHANGED
@@ -1,2 +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)})});
1
+ jQuery(document).ready(function($){var sticky_widget_mode=AI_FUNC_GET_STICKY_WIDGET_MODE;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 already_sticky_js=false;var sidebar=widget.parent();while(sidebar.prop("tagName")!="BODY"){if(sidebar.hasClass("theiaStickySidebar")){already_sticky_js=true;break}var parent_element=sidebar.parent();var parent_element_width=parent_element.width();
2
+ if(parent_element_width>widget_width*1.2||parent_element_width>document_width/2)break;sidebar=parent_element}if(already_sticky_js)return;var new_sidebar_top=sidebar.offset().top-widget.offset().top+sticky_widget_margin;if(sticky_widget_mode==0){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)}else sidebar.theiaStickySidebar({additionalMarginTop:new_sidebar_top,sidebarBehavior:"stick-to-top"})})});
includes/js/theia-sticky-sidebar.js ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * Theia Sticky Sidebar v1.7.0
3
+ * https://github.com/WeCodePixels/theia-sticky-sidebar
4
+ *
5
+ * Glues your website's sidebars, making them permanently visible while scrolling.
6
+ *
7
+ * Copyright 2013-2016 WeCodePixels and other contributors
8
+ * Released under the MIT license
9
+ */
10
+
11
+ (function ($) {
12
+ $.fn.theiaStickySidebar = function (options) {
13
+ var defaults = {
14
+ 'containerSelector': '',
15
+ 'additionalMarginTop': 0,
16
+ 'additionalMarginBottom': 0,
17
+ 'updateSidebarHeight': true,
18
+ 'minWidth': 0,
19
+ 'disableOnResponsiveLayouts': true,
20
+ 'sidebarBehavior': 'modern',
21
+ 'defaultPosition': 'relative',
22
+ 'namespace': 'TSS'
23
+ };
24
+ options = $.extend(defaults, options);
25
+
26
+ // Validate options
27
+ options.additionalMarginTop = parseInt(options.additionalMarginTop) || 0;
28
+ options.additionalMarginBottom = parseInt(options.additionalMarginBottom) || 0;
29
+
30
+ tryInitOrHookIntoEvents(options, this);
31
+
32
+ // Try doing init, otherwise hook into window.resize and document.scroll and try again then.
33
+ function tryInitOrHookIntoEvents(options, $that) {
34
+ var success = tryInit(options, $that);
35
+
36
+ if (!success) {
37
+ console.log('TSS: Body width smaller than options.minWidth. Init is delayed.');
38
+
39
+ $(document).on('scroll.' + options.namespace, function (options, $that) {
40
+ return function (evt) {
41
+ var success = tryInit(options, $that);
42
+
43
+ if (success) {
44
+ $(this).unbind(evt);
45
+ }
46
+ };
47
+ }(options, $that));
48
+ $(window).on('resize.' + options.namespace, function (options, $that) {
49
+ return function (evt) {
50
+ var success = tryInit(options, $that);
51
+
52
+ if (success) {
53
+ $(this).unbind(evt);
54
+ }
55
+ };
56
+ }(options, $that))
57
+ }
58
+ }
59
+
60
+ // Try doing init if proper conditions are met.
61
+ function tryInit(options, $that) {
62
+ if (options.initialized === true) {
63
+ return true;
64
+ }
65
+
66
+ if ($('body').width() < options.minWidth) {
67
+ return false;
68
+ }
69
+
70
+ init(options, $that);
71
+
72
+ return true;
73
+ }
74
+
75
+ // Init the sticky sidebar(s).
76
+ function init(options, $that) {
77
+ options.initialized = true;
78
+
79
+ // Add CSS
80
+ var existingStylesheet = $('#theia-sticky-sidebar-stylesheet-' + options.namespace);
81
+ if (existingStylesheet.length === 0) {
82
+ $('head').append($('<style id="theia-sticky-sidebar-stylesheet-' + options.namespace + '">.theiaStickySidebar:after {content: ""; display: table; clear: both;}</style>'));
83
+ }
84
+
85
+ $that.each(function () {
86
+ var o = {};
87
+
88
+ o.sidebar = $(this);
89
+
90
+ // Save options
91
+ o.options = options || {};
92
+
93
+ // Get container
94
+ o.container = $(o.options.containerSelector);
95
+ if (o.container.length == 0) {
96
+ o.container = o.sidebar.parent();
97
+ }
98
+
99
+ // Create sticky sidebar
100
+ o.sidebar.parents().css('-webkit-transform', 'none'); // Fix for WebKit bug - https://code.google.com/p/chromium/issues/detail?id=20574
101
+ o.sidebar.css({
102
+ 'position': o.options.defaultPosition,
103
+ 'overflow': 'visible',
104
+ // The "box-sizing" must be set to "content-box" because we set a fixed height to this element when the sticky sidebar has a fixed position.
105
+ '-webkit-box-sizing': 'border-box',
106
+ '-moz-box-sizing': 'border-box',
107
+ 'box-sizing': 'border-box'
108
+ });
109
+
110
+ // Get the sticky sidebar element. If none has been found, then create one.
111
+ o.stickySidebar = o.sidebar.find('.theiaStickySidebar');
112
+ if (o.stickySidebar.length == 0) {
113
+ // Remove <script> tags, otherwise they will be run again when added to the stickySidebar.
114
+ var javaScriptMIMETypes = /(?:text|application)\/(?:x-)?(?:javascript|ecmascript)/i;
115
+ o.sidebar.find('script').filter(function (index, script) {
116
+ return script.type.length === 0 || script.type.match(javaScriptMIMETypes);
117
+ }).remove();
118
+
119
+ o.stickySidebar = $('<div>').addClass('theiaStickySidebar').append(o.sidebar.children());
120
+ o.sidebar.append(o.stickySidebar);
121
+ }
122
+
123
+ // Get existing top and bottom margins and paddings
124
+ o.marginBottom = parseInt(o.sidebar.css('margin-bottom'));
125
+ o.paddingTop = parseInt(o.sidebar.css('padding-top'));
126
+ o.paddingBottom = parseInt(o.sidebar.css('padding-bottom'));
127
+
128
+ // Add a temporary padding rule to check for collapsable margins.
129
+ var collapsedTopHeight = o.stickySidebar.offset().top;
130
+ var collapsedBottomHeight = o.stickySidebar.outerHeight();
131
+ o.stickySidebar.css('padding-top', 1);
132
+ o.stickySidebar.css('padding-bottom', 1);
133
+ collapsedTopHeight -= o.stickySidebar.offset().top;
134
+ collapsedBottomHeight = o.stickySidebar.outerHeight() - collapsedBottomHeight - collapsedTopHeight;
135
+ if (collapsedTopHeight == 0) {
136
+ o.stickySidebar.css('padding-top', 0);
137
+ o.stickySidebarPaddingTop = 0;
138
+ }
139
+ else {
140
+ o.stickySidebarPaddingTop = 1;
141
+ }
142
+
143
+ if (collapsedBottomHeight == 0) {
144
+ o.stickySidebar.css('padding-bottom', 0);
145
+ o.stickySidebarPaddingBottom = 0;
146
+ }
147
+ else {
148
+ o.stickySidebarPaddingBottom = 1;
149
+ }
150
+
151
+ // We use this to know whether the user is scrolling up or down.
152
+ o.previousScrollTop = null;
153
+
154
+ // Scroll top (value) when the sidebar has fixed position.
155
+ o.fixedScrollTop = 0;
156
+
157
+ // Set sidebar to default values.
158
+ resetSidebar();
159
+
160
+ o.onScroll = function (o) {
161
+ // Stop if the sidebar isn't visible.
162
+ if (!o.stickySidebar.is(":visible")) {
163
+ return;
164
+ }
165
+
166
+ // Stop if the window is too small.
167
+ if ($('body').width() < o.options.minWidth) {
168
+ resetSidebar();
169
+ return;
170
+ }
171
+
172
+ // Stop if the sidebar width is larger than the container width (e.g. the theme is responsive and the sidebar is now below the content)
173
+ if (o.options.disableOnResponsiveLayouts) {
174
+ var sidebarWidth = o.sidebar.outerWidth(o.sidebar.css('float') == 'none');
175
+
176
+ if (sidebarWidth + 50 > o.container.width()) {
177
+ resetSidebar();
178
+ return;
179
+ }
180
+ }
181
+
182
+ var scrollTop = $(document).scrollTop();
183
+ var position = 'static';
184
+
185
+ // If the user has scrolled down enough for the sidebar to be clipped at the top, then we can consider changing its position.
186
+ if (scrollTop >= o.sidebar.offset().top + (o.paddingTop - o.options.additionalMarginTop)) {
187
+ // The top and bottom offsets, used in various calculations.
188
+ var offsetTop = o.paddingTop + options.additionalMarginTop;
189
+ var offsetBottom = o.paddingBottom + o.marginBottom + options.additionalMarginBottom;
190
+
191
+ // All top and bottom positions are relative to the window, not to the parent elemnts.
192
+ var containerTop = o.sidebar.offset().top;
193
+ var containerBottom = o.sidebar.offset().top + getClearedHeight(o.container);
194
+
195
+ // The top and bottom offsets relative to the window screen top (zero) and bottom (window height).
196
+ var windowOffsetTop = 0 + options.additionalMarginTop;
197
+ var windowOffsetBottom;
198
+
199
+ var sidebarSmallerThanWindow = (o.stickySidebar.outerHeight() + offsetTop + offsetBottom) < $(window).height();
200
+ if (sidebarSmallerThanWindow) {
201
+ windowOffsetBottom = windowOffsetTop + o.stickySidebar.outerHeight();
202
+ }
203
+ else {
204
+ windowOffsetBottom = $(window).height() - o.marginBottom - o.paddingBottom - options.additionalMarginBottom;
205
+ }
206
+
207
+ var staticLimitTop = containerTop - scrollTop + o.paddingTop;
208
+ var staticLimitBottom = containerBottom - scrollTop - o.paddingBottom - o.marginBottom;
209
+
210
+ var top = o.stickySidebar.offset().top - scrollTop;
211
+ var scrollTopDiff = o.previousScrollTop - scrollTop;
212
+
213
+ // If the sidebar position is fixed, then it won't move up or down by itself. So, we manually adjust the top coordinate.
214
+ if (o.stickySidebar.css('position') == 'fixed') {
215
+ if (o.options.sidebarBehavior == 'modern') {
216
+ top += scrollTopDiff;
217
+ }
218
+ }
219
+
220
+ if (o.options.sidebarBehavior == 'stick-to-top') {
221
+ top = options.additionalMarginTop;
222
+ }
223
+
224
+ if (o.options.sidebarBehavior == 'stick-to-bottom') {
225
+ top = windowOffsetBottom - o.stickySidebar.outerHeight();
226
+ }
227
+
228
+ if (scrollTopDiff > 0) { // If the user is scrolling up.
229
+ top = Math.min(top, windowOffsetTop);
230
+ }
231
+ else { // If the user is scrolling down.
232
+ top = Math.max(top, windowOffsetBottom - o.stickySidebar.outerHeight());
233
+ }
234
+
235
+ top = Math.max(top, staticLimitTop);
236
+
237
+ top = Math.min(top, staticLimitBottom - o.stickySidebar.outerHeight());
238
+
239
+ // If the sidebar is the same height as the container, we won't use fixed positioning.
240
+ var sidebarSameHeightAsContainer = o.container.height() == o.stickySidebar.outerHeight();
241
+
242
+ if (!sidebarSameHeightAsContainer && top == windowOffsetTop) {
243
+ position = 'fixed';
244
+ }
245
+ else if (!sidebarSameHeightAsContainer && top == windowOffsetBottom - o.stickySidebar.outerHeight()) {
246
+ position = 'fixed';
247
+ }
248
+ else if (scrollTop + top - o.sidebar.offset().top - o.paddingTop <= options.additionalMarginTop) {
249
+ // Stuck to the top of the page. No special behavior.
250
+ position = 'static';
251
+ }
252
+ else {
253
+ // Stuck to the bottom of the page.
254
+ position = 'absolute';
255
+ }
256
+ }
257
+
258
+ /*
259
+ * Performance notice: It's OK to set these CSS values at each resize/scroll, even if they don't change.
260
+ * It's way slower to first check if the values have changed.
261
+ */
262
+ if (position == 'fixed') {
263
+ var scrollLeft = $(document).scrollLeft();
264
+
265
+ o.stickySidebar.css({
266
+ 'position': 'fixed',
267
+ 'width': getWidthForObject(o.stickySidebar) + 'px',
268
+ 'transform': 'translateY(' + top + 'px)',
269
+ 'left': (o.sidebar.offset().left + parseInt(o.sidebar.css('padding-left')) - scrollLeft) + 'px',
270
+ 'top': '0px'
271
+ });
272
+ }
273
+ else if (position == 'absolute') {
274
+ var css = {};
275
+
276
+ if (o.stickySidebar.css('position') != 'absolute') {
277
+ css.position = 'absolute';
278
+ css.transform = 'translateY(' + (scrollTop + top - o.sidebar.offset().top - o.stickySidebarPaddingTop - o.stickySidebarPaddingBottom) + 'px)';
279
+ css.top = '0px';
280
+ }
281
+
282
+ css.width = getWidthForObject(o.stickySidebar) + 'px';
283
+ css.left = '';
284
+
285
+ o.stickySidebar.css(css);
286
+ }
287
+ else if (position == 'static') {
288
+ resetSidebar();
289
+ }
290
+
291
+ if (position != 'static') {
292
+ if (o.options.updateSidebarHeight == true) {
293
+ o.sidebar.css({
294
+ 'min-height': o.stickySidebar.outerHeight() + o.stickySidebar.offset().top - o.sidebar.offset().top + o.paddingBottom
295
+ });
296
+ }
297
+ }
298
+
299
+ o.previousScrollTop = scrollTop;
300
+ };
301
+
302
+ // Initialize the sidebar's position.
303
+ o.onScroll(o);
304
+
305
+ // Recalculate the sidebar's position on every scroll and resize.
306
+ $(document).on('scroll.' + o.options.namespace, function (o) {
307
+ return function () {
308
+ o.onScroll(o);
309
+ };
310
+ }(o));
311
+ $(window).on('resize.' + o.options.namespace, function (o) {
312
+ return function () {
313
+ o.stickySidebar.css({'position': 'static'});
314
+ o.onScroll(o);
315
+ };
316
+ }(o));
317
+
318
+ // Recalculate the sidebar's position every time the sidebar changes its size.
319
+ if (typeof ResizeSensor !== 'undefined') {
320
+ new ResizeSensor(o.stickySidebar[0], function (o) {
321
+ return function () {
322
+ o.onScroll(o);
323
+ };
324
+ }(o));
325
+ }
326
+
327
+ // Reset the sidebar to its default state
328
+ function resetSidebar() {
329
+ o.fixedScrollTop = 0;
330
+ o.sidebar.css({
331
+ 'min-height': '1px'
332
+ });
333
+ o.stickySidebar.css({
334
+ 'position': 'static',
335
+ 'width': '',
336
+ 'transform': 'none'
337
+ });
338
+ }
339
+
340
+ // Get the height of a div as if its floated children were cleared. Note that this function fails if the floats are more than one level deep.
341
+ function getClearedHeight(e) {
342
+ var height = e.height();
343
+
344
+ e.children().each(function () {
345
+ height = Math.max(height, $(this).height());
346
+ });
347
+
348
+ return height;
349
+ }
350
+ });
351
+ }
352
+
353
+ function getWidthForObject(object) {
354
+ var width;
355
+
356
+ try {
357
+ width = object[0].getBoundingClientRect().width;
358
+ }
359
+ catch (err) {
360
+ }
361
+
362
+ if (typeof width === "undefined") {
363
+ width = object.width();
364
+ }
365
+
366
+ return width;
367
+ }
368
+
369
+ return this;
370
+ }
371
+ })(jQuery);
372
+
373
+ //# sourceMappingURL=maps/theia-sticky-sidebar.js.map
includes/js/theia-sticky-sidebar.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ !function(i){i.fn.theiaStickySidebar=function(t){function e(t,e){var a=o(t,e);a||(console.log("TSS: Body width smaller than options.minWidth. Init is delayed."),i(document).on("scroll."+t.namespace,function(t,e){return function(a){var n=o(t,e);n&&i(this).unbind(a)}}(t,e)),i(window).on("resize."+t.namespace,function(t,e){return function(a){var n=o(t,e);n&&i(this).unbind(a)}}(t,e)))}function o(t,e){return t.initialized===!0||!(i("body").width()<t.minWidth)&&(a(t,e),!0)}function a(t,e){t.initialized=!0;var o=i("#theia-sticky-sidebar-stylesheet-"+t.namespace);0===o.length&&i("head").append(i('<style id="theia-sticky-sidebar-stylesheet-'+t.namespace+'">.theiaStickySidebar:after {content: ""; display: table; clear: both;}</style>')),e.each(function(){function e(){a.fixedScrollTop=0,a.sidebar.css({"min-height":"1px"}),a.stickySidebar.css({position:"static",width:"",transform:"none"})}function o(t){var e=t.height();return t.children().each(function(){e=Math.max(e,i(this).height())}),e}var a={};if(a.sidebar=i(this),a.options=t||{},a.container=i(a.options.containerSelector),0==a.container.length&&(a.container=a.sidebar.parent()),a.sidebar.parents().css("-webkit-transform","none"),a.sidebar.css({position:a.options.defaultPosition,overflow:"visible","-webkit-box-sizing":"border-box","-moz-box-sizing":"border-box","box-sizing":"border-box"}),a.stickySidebar=a.sidebar.find(".theiaStickySidebar"),0==a.stickySidebar.length){var s=/(?:text|application)\/(?:x-)?(?:javascript|ecmascript)/i;a.sidebar.find("script").filter(function(i,t){return 0===t.type.length||t.type.match(s)}).remove(),a.stickySidebar=i("<div>").addClass("theiaStickySidebar").append(a.sidebar.children()),a.sidebar.append(a.stickySidebar)}a.marginBottom=parseInt(a.sidebar.css("margin-bottom")),a.paddingTop=parseInt(a.sidebar.css("padding-top")),a.paddingBottom=parseInt(a.sidebar.css("padding-bottom"));var r=a.stickySidebar.offset().top,d=a.stickySidebar.outerHeight();a.stickySidebar.css("padding-top",1),a.stickySidebar.css("padding-bottom",1),r-=a.stickySidebar.offset().top,d=a.stickySidebar.outerHeight()-d-r,0==r?(a.stickySidebar.css("padding-top",0),a.stickySidebarPaddingTop=0):a.stickySidebarPaddingTop=1,0==d?(a.stickySidebar.css("padding-bottom",0),a.stickySidebarPaddingBottom=0):a.stickySidebarPaddingBottom=1,a.previousScrollTop=null,a.fixedScrollTop=0,e(),a.onScroll=function(a){if(a.stickySidebar.is(":visible")){if(i("body").width()<a.options.minWidth)return void e();if(a.options.disableOnResponsiveLayouts){var s=a.sidebar.outerWidth("none"==a.sidebar.css("float"));if(s+50>a.container.width())return void e()}var r=i(document).scrollTop(),d="static";if(r>=a.sidebar.offset().top+(a.paddingTop-a.options.additionalMarginTop)){var c,p=a.paddingTop+t.additionalMarginTop,b=a.paddingBottom+a.marginBottom+t.additionalMarginBottom,l=a.sidebar.offset().top,f=a.sidebar.offset().top+o(a.container),h=0+t.additionalMarginTop,g=a.stickySidebar.outerHeight()+p+b<i(window).height();c=g?h+a.stickySidebar.outerHeight():i(window).height()-a.marginBottom-a.paddingBottom-t.additionalMarginBottom;var u=l-r+a.paddingTop,S=f-r-a.paddingBottom-a.marginBottom,y=a.stickySidebar.offset().top-r,m=a.previousScrollTop-r;"fixed"==a.stickySidebar.css("position")&&"modern"==a.options.sidebarBehavior&&(y+=m),"stick-to-top"==a.options.sidebarBehavior&&(y=t.additionalMarginTop),"stick-to-bottom"==a.options.sidebarBehavior&&(y=c-a.stickySidebar.outerHeight()),y=m>0?Math.min(y,h):Math.max(y,c-a.stickySidebar.outerHeight()),y=Math.max(y,u),y=Math.min(y,S-a.stickySidebar.outerHeight());var k=a.container.height()==a.stickySidebar.outerHeight();d=(k||y!=h)&&(k||y!=c-a.stickySidebar.outerHeight())?r+y-a.sidebar.offset().top-a.paddingTop<=t.additionalMarginTop?"static":"absolute":"fixed"}if("fixed"==d){var v=i(document).scrollLeft();a.stickySidebar.css({position:"fixed",width:n(a.stickySidebar)+"px",transform:"translateY("+y+"px)",left:a.sidebar.offset().left+parseInt(a.sidebar.css("padding-left"))-v+"px",top:"0px"})}else if("absolute"==d){var x={};"absolute"!=a.stickySidebar.css("position")&&(x.position="absolute",x.transform="translateY("+(r+y-a.sidebar.offset().top-a.stickySidebarPaddingTop-a.stickySidebarPaddingBottom)+"px)",x.top="0px"),x.width=n(a.stickySidebar)+"px",x.left="",a.stickySidebar.css(x)}else"static"==d&&e();"static"!=d&&1==a.options.updateSidebarHeight&&a.sidebar.css({"min-height":a.stickySidebar.outerHeight()+a.stickySidebar.offset().top-a.sidebar.offset().top+a.paddingBottom}),a.previousScrollTop=r}},a.onScroll(a),i(document).on("scroll."+a.options.namespace,function(i){return function(){i.onScroll(i)}}(a)),i(window).on("resize."+a.options.namespace,function(i){return function(){i.stickySidebar.css({position:"static"}),i.onScroll(i)}}(a)),"undefined"!=typeof ResizeSensor&&new ResizeSensor(a.stickySidebar[0],function(i){return function(){i.onScroll(i)}}(a))})}function n(i){var t;try{t=i[0].getBoundingClientRect().width}catch(i){}return"undefined"==typeof t&&(t=i.width()),t}var s={containerSelector:"",additionalMarginTop:0,additionalMarginBottom:0,updateSidebarHeight:!0,minWidth:0,disableOnResponsiveLayouts:!0,sidebarBehavior:"modern",defaultPosition:"relative",namespace:"TSS"};return t=i.extend(s,t),t.additionalMarginTop=parseInt(t.additionalMarginTop)||0,t.additionalMarginBottom=parseInt(t.additionalMarginBottom)||0,e(t,this),this}}(jQuery);
2
+ //# sourceMappingURL=maps/theia-sticky-sidebar.min.js.map
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.2.2";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -312,6 +312,9 @@ jQuery(document).ready(function($) {
312
  serie9 : {
313
  color : "#000",
314
  },
 
 
 
315
  },
316
  defaultAxis : {
317
  labels : true,
@@ -432,6 +435,10 @@ jQuery(document).ready(function($) {
432
  plotProps : {
433
  fill : "#000"
434
  }
 
 
 
 
435
  }]
436
  }
437
  }
@@ -681,7 +688,7 @@ jQuery(document).ready(function($) {
681
  function process_display_elements (block) {
682
 
683
  $("#paragraph-settings-"+block).hide();
684
- $("#content-settings-"+block).hide();
685
 
686
  var automatic_insertion = $("select#display-type-"+block+" option:selected").attr('value');
687
 
@@ -693,9 +700,9 @@ jQuery(document).ready(function($) {
693
  }
694
 
695
  var content_settings = automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH || automatic_insertion == AI_BEFORE_CONTENT || automatic_insertion == AI_AFTER_CONTENT;
696
- if (content_settings) {
697
- $("#content-settings-"+block).show();
698
- }
699
 
700
  $("#css-label-"+block).css('display', 'table-cell');
701
  $("#edit-css-button-"+block).css('display', 'table-cell');
@@ -856,13 +863,153 @@ jQuery(document).ready(function($) {
856
  }
857
  }
858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
859
  function configure_tab_0 () {
860
 
861
  if (debug) console.log ("configure_tab_0");
862
 
863
  $('#tab-0').addClass ('configured');
864
 
865
- // $('#tab-0 input[type=submit], #tab-0 button').button().show ();
866
  $('#tab-0 input[type=submit]').button().show ();
867
 
868
  configure_editor ('h');
@@ -918,6 +1065,22 @@ jQuery(document).ready(function($) {
918
  $('#simple-editor-f').checkboxButton ();
919
  $('#process-php-f').checkboxButton ();
920
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
921
  $('#enable-adb-detection').checkboxButton ();
922
  $('#simple-editor-a').checkboxButton ();
923
  $('#process-php-a').checkboxButton ();
@@ -938,11 +1101,6 @@ jQuery(document).ready(function($) {
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
  });
@@ -1207,8 +1365,6 @@ jQuery(document).ready(function($) {
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");
@@ -1238,137 +1394,13 @@ jQuery(document).ready(function($) {
1238
  }
1239
  });
1240
 
1241
- $("input#load-custom-range-"+tab).click (function () {
1242
- var block = $(this).attr ("id");
1243
- block = block.replace ("load-custom-range-","");
1244
- var label = $(this).next ().find ('.checkbox-icon');
1245
-
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);
1253
-
1254
- var version_charts_container = $("div#ai-version-charts-" + block);
1255
- var version_charts_container_visible = version_charts_container.is (':visible');
1256
-
1257
- var delete_range = '';
1258
- if ($("input#clear-range-"+block).hasClass ('delete')) {
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 ;
1267
- $( "div#load-error-" + block).html (message);
1268
- if (debug) console.log (message);
1269
- } else {
1270
- $( "div#load-error-" + block).html ('');
1271
- if (debug) console.log ("Custom statistics loaded: " + block);
1272
- configure_charts (container);
1273
-
1274
- container.find ("label.ai-version-charts-button.not-configured").click (function () {
1275
- $(this).removeClass ('not-configured');
1276
- var version_charts_container = $(this).closest (".ai-charts").find ('div.ai-version-charts');
1277
- version_charts_container.toggle ();
1278
-
1279
- var not_configured_charts = version_charts_container.find ('.ai-chart.not-configured.hidden');
1280
- if (not_configured_charts.length) {
1281
- not_configured_charts.each (function() {
1282
- $(this).removeClass ('hidden');
1283
- });
1284
- setTimeout (function() {configure_charts (version_charts_container);}, 10);
1285
- }
1286
- });
1287
-
1288
- if (version_charts_container_visible) {
1289
- container.find ("label.ai-version-charts-button.not-configured").click ();
1290
- }
1291
-
1292
- $("input#chart-start-date-"+block).css ('color', '#32373c');
1293
- $("input#chart-end-date-"+block).css ('color', '#32373c');
1294
- }
1295
- });
1296
- });
1297
-
1298
- $("input#auto-refresh-"+tab).click (function () {
1299
- var block = $(this).attr ("id");
1300
- block = block.replace ("auto-refresh-","");
1301
- var label = $(this).next ().find ('.checkbox-icon');
1302
- label.toggleClass ('on');
1303
- if (label.hasClass ('on')) {
1304
- reload_statistics (block);
1305
- }
1306
- });
1307
-
1308
- $("input#clear-range-"+tab).click (function () {
1309
  var block = $(this).attr ("id");
1310
- block = block.replace ("clear-range-","");
1311
-
1312
- var delete_button = this;
1313
- var start_date = $("input#chart-start-date-" + block).attr('value');
1314
- var end_date = $("input#chart-end-date-" + block).attr('value');
1315
-
1316
- var message = '';
1317
- if (start_date == '' && end_date == '')
1318
- var message = 'Delete all statistics data?'; else
1319
- if (start_date != '' && end_date != '') var message = 'Delete statistics data between ' + start_date + ' and ' + end_date + '?';
1320
-
1321
- if (message != '')
1322
- $('<div />').html(message).attr ('title', 'Warning').dialog({
1323
- bgiframe: true,
1324
- draggable: false,
1325
- resizable: false,
1326
- modal: true,
1327
- height: "auto",
1328
- width: 400,
1329
- position: {my: 'center', at: 'center', of: '#ai-settings'},
1330
- buttons: {
1331
- "Delete": function() {
1332
- $(this).dialog ("close");
1333
-
1334
- $(delete_button).addClass ('delete');
1335
- $("input#load-custom-range-"+block).click ();
1336
- $(delete_button).removeClass ('delete');
1337
- },
1338
- Cancel: function() {
1339
- $(this).dialog ("close");
1340
- },
1341
- },
1342
- open: function() {$(this).parent ().find ('button:nth-child(2)').focus();}
1343
- });
1344
- });
1345
-
1346
- $("input#chart-start-date-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
1347
- $("input#chart-end-date-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
1348
-
1349
- $("input#chart-start-date-"+tab).change (function() {
1350
- disable_auto_refresh_statistics ();
1351
- var block = $(this).attr('id').replace ("chart-start-date-", "");
1352
- $(this).css ('color', 'red');
1353
- process_chart_dates (block);
1354
- });
1355
-
1356
- $("input#chart-end-date-"+tab).change (function() {
1357
- disable_auto_refresh_statistics ();
1358
- var block = $(this).attr('id').replace ("chart-end-date-", "");
1359
- $(this).css ('color', 'red');
1360
- process_chart_dates (block);
1361
- });
1362
-
1363
- $("div#custom-range-controls-"+tab+" span.data-range").click (function () {
1364
- disable_auto_refresh_statistics ();
1365
- var id = $(this).closest (".custom-range-controls").attr ("id");
1366
- block = id.replace ("custom-range-controls-","");
1367
- $("input#chart-start-date-"+block).attr ("value", $(this).data ("start-date"));
1368
- $("input#chart-end-date-"+block).attr ("value", $(this).data ("end-date"));
1369
- $("input#load-custom-range-"+block).click ();
1370
  });
1371
 
 
1372
 
1373
  $("#device-detection-button-"+tab).button ({
1374
  }).show ().click (function () {
@@ -1476,6 +1508,8 @@ jQuery(document).ready(function($) {
1476
  $('#ai-misc-container-' + tab).tabs();
1477
  $('#ai-misc-tabs-' + tab).show();
1478
 
 
 
1479
  }
1480
 
1481
  function generate_country_list (element_name_prefix, index) {
@@ -1584,6 +1618,8 @@ jQuery(document).ready(function($) {
1584
  }
1585
 
1586
  function configure_chart (container) {
 
 
1587
  if (!$(container).hasClass ('not-configured')) return;
1588
  var template = $(container).data ('template');
1589
 
@@ -1593,7 +1629,9 @@ jQuery(document).ready(function($) {
1593
  if (typeof color_indexes != 'undefined') {
1594
  var colors = $.elycharts.templates['ai-pie'].defaultSeries.values;
1595
  color_indexes.forEach (function (element) {
1596
- new_colors.push (colors [element]);
 
 
1597
  });
1598
  }
1599
 
@@ -1607,6 +1645,17 @@ jQuery(document).ready(function($) {
1607
  if (values == null) values = $(container).data ('values-8');
1608
  if (values == null) values = $(container).data ('values-9');
1609
 
 
 
 
 
 
 
 
 
 
 
 
1610
  $(container).chart({
1611
  template: template,
1612
  labels: $(container).data ('labels'),
@@ -1620,10 +1669,11 @@ jQuery(document).ready(function($) {
1620
  serie7: $(container).data ('values-7'),
1621
  serie8: $(container).data ('values-8'),
1622
  serie9: $(container).data ('values-9'),
 
1623
  },
1624
- legend: $(container).data ('legend'),
1625
  tooltips: {serie1: $(container).data ('tooltips')},
1626
- defaultSeries: {values: new_colors},
1627
  defaultAxis : {
1628
  max: $(container).data ('max'),
1629
  },
@@ -1642,10 +1692,8 @@ jQuery(document).ready(function($) {
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);
1651
  $("#rating-value").css ('width', rating_value * 20 + '%');
@@ -1660,6 +1708,7 @@ jQuery(document).ready(function($) {
1660
  function configure_charts (container) {
1661
  $(container).find ('.ai-chart.not-configured').each (function() {
1662
  if (!$(this).hasClass ('hidden')) {
 
1663
  configure_chart (this);
1664
  }
1665
  });
1
+ var javascript_version = "2.2.3";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
312
  serie9 : {
313
  color : "#000",
314
  },
315
+ serie10 : {
316
+ color : "#000", // Used also for BLOCKED
317
+ },
318
  },
319
  defaultAxis : {
320
  labels : true,
435
  plotProps : {
436
  fill : "#000"
437
  }
438
+ }, {
439
+ plotProps : {
440
+ fill : "#000" // Used also for BLOCKED
441
+ }
442
  }]
443
  }
444
  }
688
  function process_display_elements (block) {
689
 
690
  $("#paragraph-settings-"+block).hide();
691
+ // $("#content-settings-"+block).hide();
692
 
693
  var automatic_insertion = $("select#display-type-"+block+" option:selected").attr('value');
694
 
700
  }
701
 
702
  var content_settings = automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH || automatic_insertion == AI_BEFORE_CONTENT || automatic_insertion == AI_AFTER_CONTENT;
703
+ // if (content_settings) {
704
+ // $("#content-settings-"+block).show();
705
+ // }
706
 
707
  $("#css-label-"+block).css('display', 'table-cell');
708
  $("#edit-css-button-"+block).css('display', 'table-cell');
863
  }
864
  }
865
 
866
+
867
+ function configure_statistics_toolbar (tab) {
868
+ $("input#load-custom-range-"+tab).click (function () {
869
+ var block = $(this).attr ("id");
870
+ block = block.replace ("load-custom-range-","");
871
+
872
+ var label = $(this).next ().find ('.checkbox-icon');
873
+ label.addClass ('on');
874
+
875
+ var nonce = $(this).attr ('nonce');
876
+ var start_date = $("input#chart-start-date-" + block).attr('value');
877
+ var end_date = $("input#chart-end-date-" + block).attr('value');
878
+ var container = $("div#statistics-elements-" + block);
879
+
880
+ var version_charts_container = $("div#ai-version-charts-" + block);
881
+ var version_charts_container_visible = version_charts_container.is (':visible');
882
+
883
+ var delete_range = '';
884
+ if ($("input#clear-range-"+block).hasClass ('delete')) {
885
+ delete_range = '&delete=1';
886
+ }
887
+
888
+ var adb = '';
889
+ if ($("input#adb-statistics-button-"+block).next ().find ('.icon-adb').hasClass ('on')) {
890
+ adb = '&adb=1';
891
+ }
892
+
893
+ container.load (ajaxurl+"?action=ai_ajax_backend&statistics=" + block + "&start-date=" + start_date + "&end-date=" + end_date + delete_range + adb + "&ai_check=" + nonce, function (response, status, xhr) {
894
+ label.removeClass ('on');
895
+ if ( status == "error" ) {
896
+ var message = "Error downloading data: " + xhr.status + " " + xhr.statusText ;
897
+ $( "div#load-error-" + block).html (message);
898
+ if (debug) console.log (message);
899
+ } else {
900
+ $( "div#load-error-" + block).html ('');
901
+ if (debug) console.log ("Custom statistics loaded: " + block);
902
+ configure_charts (container);
903
+
904
+ container.find ("label.ai-version-charts-button.not-configured").click (function () {
905
+ var no_delay_version_charts = $(this).hasClass ('no-version-charts-delay');
906
+
907
+ $(this).removeClass ('not-configured');
908
+ var version_charts_container = $(this).closest (".ai-charts").find ('div.ai-version-charts');
909
+ version_charts_container.toggle ();
910
+
911
+ var not_configured_charts = version_charts_container.find ('.ai-chart.not-configured.hidden');
912
+ if (not_configured_charts.length) {
913
+ not_configured_charts.each (function() {
914
+ $(this).removeClass ('hidden');
915
+ });
916
+ if (no_delay_version_charts) {
917
+ configure_charts (version_charts_container);
918
+ } else setTimeout (function() {configure_charts (version_charts_container);}, 10);
919
+ }
920
+ });
921
+
922
+ if (version_charts_container_visible) {
923
+ container.find ("label.ai-version-charts-button.not-configured").addClass ('no-version-charts-delay').click ();
924
+ }
925
+
926
+ $("input#chart-start-date-"+block).css ('color', '#32373c');
927
+ $("input#chart-end-date-"+block).css ('color', '#32373c');
928
+ }
929
+ });
930
+ });
931
+
932
+ $("input#auto-refresh-"+tab).click (function () {
933
+ var block = $(this).attr ("id");
934
+ block = block.replace ("auto-refresh-","");
935
+ var label = $(this).next ().find ('.checkbox-icon');
936
+ label.toggleClass ('on');
937
+ if (label.hasClass ('on')) {
938
+ reload_statistics (block);
939
+ }
940
+ });
941
+
942
+ $("input#clear-range-"+tab).click (function () {
943
+ var block = $(this).attr ("id");
944
+ block = block.replace ("clear-range-","");
945
+
946
+ var delete_button = this;
947
+ var start_date = $("input#chart-start-date-" + block).attr('value');
948
+ var end_date = $("input#chart-end-date-" + block).attr('value');
949
+
950
+ var message = '';
951
+ if (start_date == '' && end_date == '')
952
+ var message = 'Delete all statistics data?'; else
953
+ if (start_date != '' && end_date != '') var message = 'Delete statistics data between ' + start_date + ' and ' + end_date + '?';
954
+
955
+ if (message != '')
956
+ $('<div />').html(message).attr ('title', 'Warning').dialog({
957
+ bgiframe: true,
958
+ draggable: false,
959
+ resizable: false,
960
+ modal: true,
961
+ height: "auto",
962
+ width: 400,
963
+ position: {my: 'center', at: 'center', of: '#ai-settings'},
964
+ buttons: {
965
+ "Delete": function() {
966
+ $(this).dialog ("close");
967
+
968
+ $(delete_button).addClass ('delete');
969
+ $("input#load-custom-range-"+block).click ();
970
+ $(delete_button).removeClass ('delete');
971
+ },
972
+ Cancel: function() {
973
+ $(this).dialog ("close");
974
+ },
975
+ },
976
+ open: function() {$(this).parent ().find ('button:nth-child(2)').focus();}
977
+ });
978
+ });
979
+
980
+ $("input#chart-start-date-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
981
+ $("input#chart-end-date-"+tab).datepicker ({dateFormat: dateFormat, autoSize: true});
982
+
983
+ $("input#chart-start-date-"+tab).change (function() {
984
+ disable_auto_refresh_statistics ();
985
+ var block = $(this).attr('id').replace ("chart-start-date-", "");
986
+ $(this).css ('color', 'red');
987
+ process_chart_dates (block);
988
+ });
989
+
990
+ $("input#chart-end-date-"+tab).change (function() {
991
+ disable_auto_refresh_statistics ();
992
+ var block = $(this).attr('id').replace ("chart-end-date-", "");
993
+ $(this).css ('color', 'red');
994
+ process_chart_dates (block);
995
+ });
996
+
997
+ $("div#custom-range-controls-"+tab+" span.data-range").click (function () {
998
+ disable_auto_refresh_statistics ();
999
+ var id = $(this).closest (".custom-range-controls").attr ("id");
1000
+ block = id.replace ("custom-range-controls-","");
1001
+ $("input#chart-start-date-"+block).attr ("value", $(this).data ("start-date"));
1002
+ $("input#chart-end-date-"+block).attr ("value", $(this).data ("end-date"));
1003
+ $("input#load-custom-range-"+block).click ();
1004
+ });
1005
+ }
1006
+
1007
  function configure_tab_0 () {
1008
 
1009
  if (debug) console.log ("configure_tab_0");
1010
 
1011
  $('#tab-0').addClass ('configured');
1012
 
 
1013
  $('#tab-0 input[type=submit]').button().show ();
1014
 
1015
  configure_editor ('h');
1065
  $('#simple-editor-f').checkboxButton ();
1066
  $('#process-php-f').checkboxButton ();
1067
 
1068
+ $('#tracking').checkboxButton ();
1069
+
1070
+ configure_statistics_toolbar (0);
1071
+
1072
+ $("input#statistics-button-0").checkboxButton ().click (function () {
1073
+ $("div#statistics-container-0").toggle ();
1074
+ $("div#tab-tracking-settings").toggle ();
1075
+ var container = $("div#statistics-container-0");
1076
+ if (container.is(':visible')) {
1077
+ if (!$(this).hasClass ('loaded')) {
1078
+ $("input#load-custom-range-0").click ();
1079
+ $(this).addClass ('loaded');
1080
+ }
1081
+ }
1082
+ });
1083
+
1084
  $('#enable-adb-detection').checkboxButton ();
1085
  $('#simple-editor-a').checkboxButton ();
1086
  $('#process-php-a').checkboxButton ();
1101
  var window_left = 120;
1102
  var window_top = (screen.height / 2) - (870 / 2);
1103
  var nonce = $(this).attr ('nonce');
 
 
 
 
 
1104
  var param = {'action': 'ai_ajax_backend', 'preview': 'adb', 'ai_check': nonce};
1105
  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);
1106
  });
1365
 
1366
  if ($("#export-container-" + block).is(':visible') && !$(this).hasClass ("loaded")) {
1367
  var nonce = $(this).attr ('nonce');
 
 
1368
  $("#export_settings_" + block).load (ajaxurl+"?action=ai_ajax_backend&export=" + block + "&ai_check=" + nonce, function() {
1369
  $("#export_settings_" + block).attr ("name", "export_settings_" + block);
1370
  $("#export-switch-"+block).addClass ("loaded");
1394
  }
1395
  });
1396
 
1397
+ $("input#adb-statistics-button-"+tab).checkboxButton ().click (function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1398
  var block = $(this).attr ("id");
1399
+ block = block.replace ("adb-statistics-button-","");
1400
+ setTimeout (function() {$("input#load-custom-range-"+block).click ();}, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1401
  });
1402
 
1403
+ configure_statistics_toolbar (tab);
1404
 
1405
  $("#device-detection-button-"+tab).button ({
1406
  }).show ().click (function () {
1508
  $('#ai-misc-container-' + tab).tabs();
1509
  $('#ai-misc-tabs-' + tab).show();
1510
 
1511
+ $('#ai-devices-container-' + tab).tabs();
1512
+ $('#ai-devices-tabs-' + tab).show();
1513
  }
1514
 
1515
  function generate_country_list (element_name_prefix, index) {
1618
  }
1619
 
1620
  function configure_chart (container) {
1621
+ var ai_adb_flag_blocked = 0x80;
1622
+
1623
  if (!$(container).hasClass ('not-configured')) return;
1624
  var template = $(container).data ('template');
1625
 
1629
  if (typeof color_indexes != 'undefined') {
1630
  var colors = $.elycharts.templates['ai-pie'].defaultSeries.values;
1631
  color_indexes.forEach (function (element) {
1632
+ if (element == ai_adb_flag_blocked )
1633
+ new_colors.push (colors [9]); else
1634
+ new_colors.push (colors [element]);
1635
  });
1636
  }
1637
 
1645
  if (values == null) values = $(container).data ('values-8');
1646
  if (values == null) values = $(container).data ('values-9');
1647
 
1648
+ var legend = $(container).data ('legend');
1649
+ if (typeof legend != 'undefined' && typeof legend ['serie' + (ai_adb_flag_blocked + 1)] != 'undefined') {
1650
+ var new_legend = {};
1651
+ for (var legend_item in legend) {
1652
+ if (legend_item == 'serie' + (ai_adb_flag_blocked + 1))
1653
+ new_legend ['serie10'] = legend [legend_item]; else
1654
+ new_legend [legend_item] = legend [legend_item];
1655
+ }
1656
+ legend = new_legend;
1657
+ }
1658
+
1659
  $(container).chart({
1660
  template: template,
1661
  labels: $(container).data ('labels'),
1669
  serie7: $(container).data ('values-7'),
1670
  serie8: $(container).data ('values-8'),
1671
  serie9: $(container).data ('values-9'),
1672
+ serie10: $(container).data ('values-' + (ai_adb_flag_blocked + 1)), // BLOCKED
1673
  },
1674
+ legend: legend,
1675
  tooltips: {serie1: $(container).data ('tooltips')},
1676
+ defaultSeries: {values: new_colors, tooltip: {height: $(container).data ('tooltip-height')}},
1677
  defaultAxis : {
1678
  max: $(container).data ('max'),
1679
  },
1692
  function update_rating (parameter = '') {
1693
  var rating_bar = $('#ai-rating-bar');
1694
  var nonce = rating_bar.attr ('nonce');
 
 
1695
  $("#rating-value span").load (ajaxurl+"?action=ai_ajax_backend&rating=" + parameter + "&ai_check=" + nonce, function() {
1696
+ var rating = $("#rating-value span").text ();
1697
  var rating_value = 0;
1698
  if (rating != '') var rating_value = parseFloat (rating);
1699
  $("#rating-value").css ('width', rating_value * 20 + '%');
1708
  function configure_charts (container) {
1709
  $(container).find ('.ai-chart.not-configured').each (function() {
1710
  if (!$(this).hasClass ('hidden')) {
1711
+ $(this).attr ('style', '');
1712
  configure_chart (this);
1713
  }
1714
  });
readme.txt CHANGED
@@ -2,11 +2,11 @@
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
- Requires PHP: 5.2
9
- Stable tag: 2.2.1
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
@@ -41,13 +41,15 @@ Ad Inserter is more than just ad manager plugin. It provides many advanced optio
41
  > * Insert Google Analytics, Piwik or any other web analytics code
42
  > * Insert HTML, CSS, Javascript or PHP code
43
  > * Manual insertion: widgets, shortcodes, PHP function call
44
- > * Sticky (fixed) widgets (the sidebar does not move when the page is scrolled, works with most themes)
45
- > * Custom block alignment and style
46
- > * Insert ads on AMP pages
47
  > * Custom CSS class name for wrapping divs to avoid ad blockers
48
  > * Use shortcodes from other plugins
 
49
  > * PHP code processing
50
  > * Ad rotation (server-side and client-side - works with caching)
 
51
  > * Desktop/mobile device detection (server-side and client-side - works with caching)
52
  > * Black/White-list categories, tags, taxonomies, post IDs, urls, url query parameters, referers
53
  > * Simple troubleshooting with many debugging functions
@@ -64,6 +66,8 @@ And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank
64
  > * A/B testing
65
  > * Sticky ad positions (left, top, right, bottom)
66
  > * Scheduling with fallback option
 
 
67
  > * Multisite options to limit settings on the sites
68
  > * Post/page exception management
69
  > * 6 custom viewports for client-side desktop/mobile device detection
@@ -117,11 +121,10 @@ Few very important things you need to know in order to <a href="http://adinserte
117
  * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
118
  * **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)
119
  * For Posts and Static pages **leave default BLANK selection value** after the checkbox unless you really know what are you doing (using individual exceptions)
120
- * 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)
121
- * 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.
122
 
123
- Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read <a href="https://wordpress.org/plugins/ad-inserter/installation/">Installation</a> page.
124
- For more detailed instructions please read <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a>.
125
 
126
  **Please support plugin development**
127
 
@@ -232,6 +235,9 @@ Automatic Insertion Options:
232
  * Insert Before Excerpt (on blog pages)
233
  * Insert After Excerpt (on blog pages)
234
  * Insert Between Posts (on blog pages)
 
 
 
235
 
236
  For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
237
 
@@ -390,33 +396,31 @@ Support the advancement of this plugin:
390
  3. Set automatic insertion option (for example: Before Post)
391
  4. Enable at least one page type (for example: Posts, some insertion options don't work on all page types)
392
  5. Save settings
393
- 6. Check also <a href="http://adinserter.pro/settings" target="_blank">common settings</a>
394
  7. Check inserted code on the posts
395
- 8. Ads are not showing? Check <a href="https://adinserter.pro/documentation#ads-not-displayed" target="_blank">troubleshooting guide</a> to find out how to fix the problem.
396
 
397
 
398
  = I have installed code for AdSense ads but the ad blocks are blank. =
399
 
400
  If you get blank ads then this might be because there is some error in the code (wrong IDs), your AdSense account is not fully approved yet, your website was not accepted or your AdSense account is banned.
401
-
402
 
403
  = Settings for widget =
404
 
405
  * Nothing needed, just enter the code and save settings - widget is enabled by default
406
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
407
- * 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
408
  * 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
409
- * 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
410
 
411
- Additional note regarding *sticky widgets*:
412
 
413
- Sticky widgets work by changing sidebar CSS to `position: sticky;`. This works in most themes but not all.
414
 
415
- If your widgets and sidebar aren't sticking as expected the first thing to check are the rules applied to the sidebar parent containers.
416
- Specifically, look for any overflow property set on the parent. You can't use: `overflow: hidden`, `overflow: scroll` or `overflow: auto` on the parent of a `position: sticky` sidebar.
417
 
418
- If your theme is not using overflow and still having problems it's worth checking if a height is set on the parent.
419
- This may constrain the sticky positioning, stopping it from occurring. Remove the height and see if that fixes the problem.
420
 
421
  = Settings for contextual Amazon Native Shopping Ads =
422
 
@@ -436,19 +440,19 @@ amzn_assoc_ad_type = "smart";
436
  amzn_assoc_marketplace = "amazon";
437
  amzn_assoc_region = "US";
438
  amzn_assoc_title = "Search Results from Amazon";
439
- amzn_assoc_default_search_phrase = "{smart_tag}";
440
  amzn_assoc_default_category = "All";
441
  amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
442
  </script>
443
  <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
444
 
445
- Use your own tracking id! Please note `{smart_tag}` as default search phrase. This makes this widget contextual. It will show products related to the tags for this post.
446
- You can also try with `{tag}', `{short_title}`, `{category}` or `{short_category}`. For more options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
447
 
448
 
449
  = Settings for ... =
450
 
451
- Check <a href="http://adinserter.pro/settings" target="_blank">common settings</a>
452
 
453
 
454
  = I wish to show ads side by side but not in the same block. How do I do this? =
@@ -471,7 +475,7 @@ Use block 3 to insert ads and make sure all 3 blocks are enabled for the same pa
471
 
472
  This happens because Ad Inserter processes posts last and therefore "sees" also content added by other plugins.
473
 
474
- Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab *).
475
 
476
 
477
  = How can I replace deprecated tags {adinserter n} for manual insertion with new ones [adinserter block="n"] in all posts? =
@@ -487,35 +491,40 @@ If this is a sidebar widget then you can simply name the widget. In other cases
487
 
488
  AD_CODE`
489
 
490
- Change title tag according to the theme style.
491
 
492
 
493
  = I like the plugin. How can I support it? =
494
 
495
  * Write a nice <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
496
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
497
- * Buy license for <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a>
498
 
499
 
500
  = How can I enable/disable ads on specific posts/pages? =
501
 
502
  There are two possible approaches.
503
 
504
- * Approach with page/post exceptions - use this one if there are many exceptions:
505
 
506
  1. Go to Ad Inserter settings page and define default insertion options for post/page.
507
- 2. Enable automatic insertion on posts/pages and choose default display: **On all**, **On all except selected** or **Only on selected**.
508
- 3. Go to post/page editor and open **Ad Inserter Exceptions** meta box below.
509
- 4. Check default insertion options for wanted code blocks.
510
- 5. Set exceptions for this post or page.
 
 
 
 
 
511
 
512
  * Approach with code block settings only - use this one if there are only few exceptions:
513
 
514
  1. Go to Ad Inserter settings page and define default insertion options for post/page.
515
- 2. Enable automatic insertion On all Posts/Pages.
516
  3. Click on Lists, enter url (or space separated urls) for Urls, e.g. `/permalink-url`, and white-list or black-list it.
517
 
518
- For details check <a href="https://adinserter.pro/exceptions" target="_blank">Ad Inserter Post/Page Exceptions</a>.
519
 
520
 
521
  = I'm using responsive theme. How can I show or hide some ads on mobile devices? =
@@ -537,7 +546,7 @@ To blacklist both enter `yourdomain.com, #`
537
 
538
  = How can I disable ads on error 404 page? =
539
 
540
- This is disabled by default. Uncheck Error 404 Page checkbox.
541
 
542
 
543
  = Is there a way to display country flag of the visitor? =
@@ -548,9 +557,9 @@ Possible if you are using Ad Inserter Pro. In the header put the following code:
548
 
549
  In the code block use the following code for flag
550
 
551
- `<span class="flag-icon flag-icon-{country_iso2}" style="width: 400px; height: 300px;"></span>`
552
 
553
- Adjust width and height according to your needs. Please not that `{country_iso2}` tag works only server-side - it won't work on cached pages.
554
  Of course, you can also use static code for flags. For example, for United States:
555
 
556
  `<span class="flag-icon flag-icon-us" style="width: 400px; height: 300px;"></span>`
@@ -605,24 +614,25 @@ Some HTML/Javascript code
605
 
606
  = How can I insert post category name into my ad code? =
607
 
608
- 1. Use {category} in the ad. This will be replaced with the post category name.
609
  2. You can also use
610
 
611
- * {title} - Title of the post
612
- * {short_title} - Short title (first 3 words) of the post title
613
- * {category} - Category of the post (or short title if there is no category)
614
- * {short_category} - First words before "," or "and" of the category of the post (or short title if there is no category)
615
- * {tag} - The first tag or general tag if the post has no tags (**works only inside posts**)
616
- * {smart_tag} - Smart selection of post tag in the following order:
617
  * If there is no tag then the category is used;
618
  * If there is a two-word tag then it is used;
619
  * If the first tag is a substring of the second (or vice versa) then the first tag is not taken into account
620
  * If the first and second tags are single words then both words are used
621
  * First three words of the first tag
622
- * General tag
623
- * {search_query} - Search engine query that brought visitor to your website (supports Google, Yahoo, Bing and Ask search engines), {smart_tag} is used when there is no search query. You need to disable caching to use this tag. Please note that most search queries are now encrypted.
624
- * {author} - Post author username (**works only inside posts**)
625
- * {author_name} Post author name (**works only inside posts**)
 
626
 
627
  For all options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
628
 
@@ -643,9 +653,15 @@ ad_code_3`
643
 
644
  Normally the code will not be inserted on AMP pages. There are two settings that can be used to insert code on AMP pages:
645
 
646
- 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.
647
  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.
648
 
 
 
 
 
 
 
649
  For details check <a href="https://adinserter.pro/settings#amp" target="_blank">settings for ads on AMP pages</a>.
650
 
651
 
@@ -667,15 +683,14 @@ Example for block 3:
667
 
668
  `<?php if (function_exists ('adinserter')) echo adinserter (3); ?>`
669
 
670
- This would generate code as defined for the code block number 3.
671
 
672
 
673
  = Center alignment does not work for some ads! =
674
 
675
- Some ads can not be centered using standard approach so some different CSS code is needed to put them in the middle.
676
- Try to use the following custom CSS:
677
 
678
- `margin: 8px 0; text-align: center; display: flex; justify-content: center;`
679
 
680
 
681
  = How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left? =
@@ -716,6 +731,16 @@ AD CODE RIGHT
716
 
717
  == Changelog ==
718
 
 
 
 
 
 
 
 
 
 
 
719
  = 2.2.2 =
720
  - Fix for mobile admin layout
721
  - Few other minor bug fixes
@@ -814,6 +839,14 @@ AD CODE RIGHT
814
 
815
  == Upgrade Notice ==
816
 
 
 
 
 
 
 
 
 
817
  = 2.2.2 =
818
  Fix for mobile admin layout;
819
  Few other minor bug fixes
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, sticky sidebar, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking, ad blocking, custom fields
6
  Requires at least: 4.0
7
+ Tested up to: 4.8.2
8
+ Requires PHP: 5.2.4
9
+ Stable tag: 2.2.2
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
41
  > * Insert Google Analytics, Piwik or any other web analytics code
42
  > * Insert HTML, CSS, Javascript or PHP code
43
  > * Manual insertion: widgets, shortcodes, PHP function call
44
+ > * Sticky (fixed) widgets (sticky sidebar - the sidebar does not move when the page is scrolled)
45
+ > * Custom block alignments and styles
46
+ > * Insert (different) ads on AMP pages
47
  > * Custom CSS class name for wrapping divs to avoid ad blockers
48
  > * Use shortcodes from other plugins
49
+ > * Use custom fields as defined in posts
50
  > * PHP code processing
51
  > * Ad rotation (server-side and client-side - works with caching)
52
+ > * Ad blocking detection - popup message, page redirection
53
  > * Desktop/mobile device detection (server-side and client-side - works with caching)
54
  > * Black/White-list categories, tags, taxonomies, post IDs, urls, url query parameters, referers
55
  > * Simple troubleshooting with many debugging functions
66
  > * A/B testing
67
  > * Sticky ad positions (left, top, right, bottom)
68
  > * Scheduling with fallback option
69
+ > * Ad blocking detection - ad replacement, content protection
70
+ > * Ad blocking statistics
71
  > * Multisite options to limit settings on the sites
72
  > * Post/page exception management
73
  > * 6 custom viewports for client-side desktop/mobile device detection
121
  * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
122
  * **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)
123
  * For Posts and Static pages **leave default BLANK selection value** after the checkbox unless you really know what are you doing (using individual exceptions)
124
+ * 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)
125
+ * 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. In such case you can try other ad networks for contextual ads. Check <a href="https://adinserter.pro/documentation#ads-not-displayed">Ads Not Displayed</a> for more information.
126
 
127
+ Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read <a href="https://wordpress.org/plugins/ad-inserter/installation/">Installation</a> page. For more detailed instructions please read <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a>.
 
128
 
129
  **Please support plugin development**
130
 
235
  * Insert Before Excerpt (on blog pages)
236
  * Insert After Excerpt (on blog pages)
237
  * Insert Between Posts (on blog pages)
238
+ * Insert Before Comments (on posts)
239
+ * Insert Between Comments (on posts)
240
+ * Insert After Comments (on posts)
241
 
242
  For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
243
 
396
  3. Set automatic insertion option (for example: Before Post)
397
  4. Enable at least one page type (for example: Posts, some insertion options don't work on all page types)
398
  5. Save settings
399
+ 6. Check also <a href="http://adinserter.pro/settings" target="_blank">common Ad Inserter settings</a>
400
  7. Check inserted code on the posts
401
+ 8. Ads are not showing? Check <a href="https://adinserter.pro/documentation#ads-not-displayed" target="_blank">troubleshooting guide</a> to find out what to check to fix the problem.
402
 
403
 
404
  = I have installed code for AdSense ads but the ad blocks are blank. =
405
 
406
  If you get blank ads then this might be because there is some error in the code (wrong IDs), your AdSense account is not fully approved yet, your website was not accepted or your AdSense account is banned.
407
+ In such case you can try other ad networks for contextual ads. Check <a href="https://adinserter.pro/documentation#ads-not-displayed">Ads Not Displayed</a> for more information.
408
 
409
  = Settings for widget =
410
 
411
  * Nothing needed, just enter the code and save settings - widget is enabled by default
412
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
413
+ * 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 - Sticky Sidebar
414
  * 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
415
+ * In general plugin settings (tab *) you can also define Sticky Widget Top Margin to precisely define top position where the first sticky widget will stick
416
 
417
+ Additional note regarding *Sticky Widgets* - *Sticky Sidebars*:
418
 
419
+ There are two modes for sticky widgets (or sticky sidebars) available as **Sticky widget mode** in general plugin settings (tab *):
420
 
421
+ * CSS mode - This mode is the best approach but may not work with all themes. CSS mode works by changing sidebar CSS to `position: sticky`. This works with most themes but not all. If your widgets and sidebar aren't sticking as expected you can use **JavaScript mode** described below.
422
+ * JavaScript mode - This mode should work with practically all themes but may reload ads on page load when sticky sidebar is initialized.
423
 
 
 
424
 
425
  = Settings for contextual Amazon Native Shopping Ads =
426
 
440
  amzn_assoc_marketplace = "amazon";
441
  amzn_assoc_region = "US";
442
  amzn_assoc_title = "Search Results from Amazon";
443
+ amzn_assoc_default_search_phrase = "[adinserter data='smart-tag']";
444
  amzn_assoc_default_category = "All";
445
  amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
446
  </script>
447
  <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
448
 
449
+ Use your own tracking id! Please note `[adinserter data='smart_tag']` as default search phrase. This makes this widget contextual. It will show products related to the tags for this post.
450
+ You can also try with `[adinserter data='tag']', `[adinserter data='short-title']`, `[adinserter data='category']` or `[adinserter data='short-category']`. For more options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
451
 
452
 
453
  = Settings for ... =
454
 
455
+ Check <a href="http://adinserter.pro/settings" target="_blank">common Ad Inserter settings</a>
456
 
457
 
458
  = I wish to show ads side by side but not in the same block. How do I do this? =
475
 
476
  This happens because Ad Inserter processes posts last and therefore "sees" also content added by other plugins.
477
 
478
+ Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab * / tab General).
479
 
480
 
481
  = How can I replace deprecated tags {adinserter n} for manual insertion with new ones [adinserter block="n"] in all posts? =
491
 
492
  AD_CODE`
493
 
494
+ Change the title tag according to the theme style.
495
 
496
 
497
  = I like the plugin. How can I support it? =
498
 
499
  * Write a nice <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
500
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
501
+ * Buy the license for <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a>
502
 
503
 
504
  = How can I enable/disable ads on specific posts/pages? =
505
 
506
  There are two possible approaches.
507
 
508
+ * Approach with page/post exceptions - use this one if there are many exceptions (more than two):
509
 
510
  1. Go to Ad Inserter settings page and define default insertion options for post/page.
511
+ 2. Enable automatic insertion on posts/pages and choose default insertion: **Individually disabled** or **Individually enabled**.
512
+ 3. Save settings.
513
+ 4. Go to post/page editor and open **Ad Inserter Individual Exceptions** meta box below.
514
+ 5. define insertion exceptions for this post or page.
515
+ 6. Save post/page.
516
+
517
+ **Individually disabled** means that insertion will be by default enabled on all posts (according to the settings for this code block), but you will be able to disable insertion on individual posts or pages (in post/page editor).
518
+
519
+ **Individually enabled** means that insertion will be by default disabled on all posts, but you will be able to enable insertion on individual posts or pages (in post/page editor) - of course, other settings (e.g. lists) for this code block will also apply.
520
 
521
  * Approach with code block settings only - use this one if there are only few exceptions:
522
 
523
  1. Go to Ad Inserter settings page and define default insertion options for post/page.
524
+ 2. Enable automatic insertion for Posts/Pages (use default value after checkbox - blank selection means no individual exceptions).
525
  3. Click on Lists, enter url (or space separated urls) for Urls, e.g. `/permalink-url`, and white-list or black-list it.
526
 
527
+ For details check <a href="https://adinserter.pro/exceptions" target="_blank">Individual Post/Page Exceptions</a>.
528
 
529
 
530
  = I'm using responsive theme. How can I show or hide some ads on mobile devices? =
546
 
547
  = How can I disable ads on error 404 page? =
548
 
549
+ This is disabled by default. Uncheck Error 404 Page checkbox (button Misc).
550
 
551
 
552
  = Is there a way to display country flag of the visitor? =
557
 
558
  In the code block use the following code for flag
559
 
560
+ `<span class="flag-icon flag-icon-[adinserter data='country-iso2']" style="width: 400px; height: 300px;"></span>`
561
 
562
+ Adjust width and height according to your needs. Please not that `[adinserter data='country_iso2']` tag works only server-side - it won't work on cached pages.
563
  Of course, you can also use static code for flags. For example, for United States:
564
 
565
  `<span class="flag-icon flag-icon-us" style="width: 400px; height: 300px;"></span>`
614
 
615
  = How can I insert post category name into my ad code? =
616
 
617
+ 1. Use `[adinserter data='category']` in the ad. This will be replaced with the post category name.
618
  2. You can also use
619
 
620
+ * `[adinserter data='title']` - Title of the post
621
+ * `[adinserter data='short-title']` - Short title (first 3 words) of the post title
622
+ * `[adinserter data='category']` - Category of the post (or short title if there is no category)
623
+ * `[adinserter data='short-category']` - First words before "," or "and" of the category of the post (or short title if there is no category)
624
+ * `[adinserter data='tag']` - The first tag or general tag (button Misc / tab General) if the post has no tags (**works only inside posts**)
625
+ * `[adinserter data='smart-tag']` - Smart selection of post tag in the following order:
626
  * If there is no tag then the category is used;
627
  * If there is a two-word tag then it is used;
628
  * If the first tag is a substring of the second (or vice versa) then the first tag is not taken into account
629
  * If the first and second tags are single words then both words are used
630
  * First three words of the first tag
631
+ * General tag (button Misc / tab General)
632
+ * `[adinserter data='search-query']` - Search engine query that brought visitor to your website (supports Google, Yahoo, Bing and Ask search engines), [adinserter data='smart_tag} is used when there is no search query. You need to disable caching to use this tag. Please note that most search queries are now encrypted.
633
+ * `[adinserter data='author']` - Post author username (**works only inside posts**)
634
+ * `[adinserter data='author-name']` Post author name (**works only inside posts**)
635
+ * `[adinserter custom-field='CUSTOM_FIELD_NAME']` - Custom fields as <a href="https://codex.wordpress.org/Custom_Fields">defined in posts</a>
636
 
637
  For all options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
638
 
653
 
654
  Normally the code will not be inserted on AMP pages. There are two settings that can be used to insert code on AMP pages:
655
 
656
+ 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.
657
  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.
658
 
659
+ The following AMP plugins have been tested with Ad Inserter:
660
+ * <a href="https://wordpress.org/plugins/accelerated-mobile-pages/" target="_blank">AMP for WP - Accelerated Mobile Pages</a> (free)
661
+ * <a href="https://wordpress.org/plugins/amp/" target="_blank">AMP</a> (free)
662
+ * <a href="https://wordpress.org/plugins/wp-amp-ninja/" target="_blank">WP AMP Ninja</a> (free)
663
+ * WP AMP - Accelerated Mobile Pages for WordPress (paid - you need to uncheck *Remove third-party the_content hooks for better compatibility*)
664
+
665
  For details check <a href="https://adinserter.pro/settings#amp" target="_blank">settings for ads on AMP pages</a>.
666
 
667
 
683
 
684
  `<?php if (function_exists ('adinserter')) echo adinserter (3); ?>`
685
 
686
+ This would generate code as defined for the code block number 3. Before you modifu theme files it makes sense to create a <a href="https://codex.wordpress.org/Child_Themes" target="_blank">child theme</a> first.
687
 
688
 
689
  = Center alignment does not work for some ads! =
690
 
691
+ Some ads can not be centered using the standard approach so some different CSS code is needed to put them in the middle.
 
692
 
693
+ In Preview window you can try alternative CSS code for centering the ad. Double-click on the icon for Center alignment and the code will toggle. The current code version is displayed next to Alignment and Style selection.
694
 
695
 
696
  = How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left? =
731
 
732
  == Changelog ==
733
 
734
+ = 2.2.3 =
735
+ - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
736
+ - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
737
+ - Added support for post-type:POST_TYPE taxonomy list items
738
+ - Added support for JavaScript based sticky widgets
739
+ - Added support for ad blocking statistics (Pro only)
740
+ - Added support for WP AMP and WP AMP Ninja plugins
741
+ - Post/Page Word Count moved to Misc section (now works also on widgets)
742
+ - Few minor bug fixes, cosmetic changes and code improvements
743
+
744
  = 2.2.2 =
745
  - Fix for mobile admin layout
746
  - Few other minor bug fixes
839
 
840
  == Upgrade Notice ==
841
 
842
+ = 2.2.3 =
843
+ Added support to insert custom fields via shortcode;
844
+ Added support for user:USERNAME, user-role:USER_ROLE and post-type:POST_TYPE taxonomy list items;
845
+ Added support for JavaScript based sticky widgets;
846
+ Added support for ad blocking statistics (Pro only);
847
+ Added support for WP AMP and WP AMP Ninja plugins;
848
+ Post/Page Word Count moved to Misc section (now works also on widgets)
849
+
850
  = 2.2.2 =
851
  Fix for mobile admin layout;
852
  Few other minor bug fixes
settings.php CHANGED
@@ -297,7 +297,12 @@ function generate_settings_form (){
297
 
298
  $obj = $block_object [$ad_number];
299
 
300
- $show_devices = $obj->get_detection_client_side () == AI_ENABLED || $obj->get_detection_server_side () == AI_ENABLED;
 
 
 
 
 
301
  if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
302
 
303
  $cat_list = $obj->get_ad_block_cat();
@@ -322,6 +327,10 @@ function generate_settings_form (){
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;
@@ -330,6 +339,7 @@ function generate_settings_form (){
330
 
331
  $show_misc =
332
  $insertion_options ||
 
333
  $scheduling_active ||
334
  $filter_active ||
335
  $adb_block_action_active;
@@ -337,6 +347,7 @@ function generate_settings_form (){
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 = "";
@@ -347,12 +358,6 @@ function generate_settings_form (){
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() ||
358
  $obj->get_paragraph_tags() != $default->get_paragraph_tags() ||
@@ -582,7 +587,7 @@ function generate_settings_form (){
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
587
  type="text"
588
  name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"
@@ -781,14 +786,6 @@ function generate_settings_form (){
781
  </div>
782
  </div>
783
 
784
- <div id="content-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php echo $content_settings ? "" : "display: none;" ?>">
785
- Post/Static page must have between
786
- <input type="text" name="<?php echo AI_OPTION_MIN_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_minimum_words(); ?>" value="<?php echo $obj->get_minimum_words() ?>" size="4" maxlength="6" />
787
- and
788
- <input type="text" name="<?php echo AI_OPTION_MAX_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" title="Maximum number of post/static page words, leave empty for no limit" default="<?php echo $default->get_maximum_words(); ?>" value="<?php echo $obj->get_maximum_words() ?>" size="4" maxlength="6" />
789
- words
790
- </div>
791
-
792
  <div class="responsive-table rounded" id="list-settings-<?php echo $ad_number; ?>" style="<?php if (!$show_lists) echo ' display: none;'; ?>">
793
  <table>
794
  <tbody>
@@ -952,58 +949,94 @@ function generate_settings_form (){
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>
958
- <td>
959
- <div style="margin-bottom: 5px;">
960
- <input type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
961
- <input id="client-side-detection-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
962
- <label for="client-side-detection-<?php echo $ad_number; ?>">Use client-side detection to show only on:</label>
963
- </div>
964
 
965
- <div style="margin: 5px 0 0 40px;">
966
-
967
- <?php
968
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
969
- $viewport_name = get_viewport_name ($viewport);
970
- if ($viewport_name != '') {
971
- ?>
972
- <div style="margin: 8px 0;">
973
- <input type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
974
- <input type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="viewport-<?php echo $viewport, "-", $ad_number; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
975
- <label for="viewport-<?php echo $viewport, "-", $ad_number; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
976
- </div>
977
- <?php
978
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
979
  }
980
- ?>
981
- </div>
982
- </td><td style="padding-left: 40px; vertical-align: top;">
983
- <input type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
984
- <input type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="server-side-detection-<?php echo $ad_number; ?>" value="1" default="<?php echo $default->get_detection_server_side(); ?>" <?php if ($obj->get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
985
- <label for="server-side-detection-<?php echo $ad_number; ?>">Use server-side detection to insert code only for </label>
986
-
987
- <div style="margin: 10px 0 10px 40px;">
988
- <select style="margin-bottom: 3px;" id="display-for-devices-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_display_for_devices(); ?>" style="width:160px">
989
- <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
990
- <option value="<?php echo AD_DISPLAY_MOBILE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_MOBILE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_MOBILE_DEVICES; ?></option>
991
- <option value="<?php echo AD_DISPLAY_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_TABLET_DEVICES; ?></option>
992
- <option value="<?php echo AD_DISPLAY_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_PHONE_DEVICES; ?></option>
993
- <option value="<?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?></option>
994
- <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
995
- </select>
996
- devices
997
- </div>
998
- </td>
999
- </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); ?>
@@ -1048,6 +1081,14 @@ function generate_settings_form (){
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;">
@@ -1139,8 +1180,9 @@ function generate_settings_form (){
1139
  <input style="display: none; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save Settings" type="submit" style="width:120px; font-weight: bold;" />
1140
  </div>
1141
 
1142
- <div style="float: left; color: red;">
1143
  <input onclick="if (confirm('Are you sure you want to reset all settings?')) return true; return false;" name="<?php echo AI_FORM_CLEAR; ?>" value="Reset All Settings" type="submit" style="display: none; width:125px; font-weight: bold; color: #e44;" />
 
1144
  </div>
1145
 
1146
  <div style="clear: both;"></div>
@@ -1177,7 +1219,7 @@ function generate_settings_form (){
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>
1183
  <select
@@ -1229,7 +1271,7 @@ function generate_settings_form (){
1229
  </tr>
1230
  <tr>
1231
  <td>
1232
- Block Class Name
1233
  </td>
1234
  <td>
1235
  <input style="margin-left: 0px;" title="CSS Class Name for the wrapping div" type="text" id="block-class-name" name="block-class-name" value="<?php echo $block_class_name; ?>" default="<?php echo DEFAULT_BLOCK_CLASS_NAME; ?>" size="15" maxlength="40" />
@@ -1237,7 +1279,7 @@ function generate_settings_form (){
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">
@@ -1259,7 +1301,7 @@ function generate_settings_form (){
1259
  </tr>
1260
  <tr>
1261
  <td>
1262
- Functions for Paragraph Counting
1263
  </td>
1264
  <td>
1265
  <select id="paragraph_counting_functions" name="paragraph_counting_functions" default="<?php echo DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS; ?>" title="Standard PHP functions are faster and work in most cases, use Multibyte functions if paragraphs are not counted properly on non-english pages.">
@@ -1270,7 +1312,7 @@ function generate_settings_form (){
1270
  </tr>
1271
  <tr>
1272
  <td>
1273
- No Paragraph Counting Inside
1274
  </td>
1275
  <td>
1276
  <input type="text" name="no-paragraph-counting-inside" value="<?php echo get_no_paragraph_counting_inside (); ?>" default="<?php echo DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE; ?>" size="40" maxlength="80" />
@@ -1278,7 +1320,18 @@ function generate_settings_form (){
1278
  </tr>
1279
  <tr>
1280
  <td>
1281
- Sticky Widget Top Margin
 
 
 
 
 
 
 
 
 
 
 
1282
  </td>
1283
  <td>
1284
  <input type="text" name="sticky-widget-margin" value="<?php echo get_sticky_widget_margin (); ?>" default="<?php echo DEFAULT_STICKY_WIDGET_MARGIN; ?>" size="6" maxlength="4" /> px
@@ -1625,13 +1678,14 @@ function generate_settings_form (){
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;">
@@ -1655,21 +1709,27 @@ function generate_settings_form (){
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
  } else {
1667
- if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 4) $sidebar = 4;
1668
  }
1669
 
1670
  // $sidebar = 4;
1671
 
1672
-
1673
  if (!function_exists ('ai_settings_side') && $sidebar >= 2) {
1674
 
1675
  switch ($sidebar) {
@@ -1678,9 +1738,11 @@ function generate_settings_form (){
1678
  case 1:
1679
  break;
1680
  case 2:
 
1681
  break;
1682
  case 3:
1683
- sidebar_ratings ();
 
1684
  break;
1685
  case 4:
1686
  sidebar_addense_alternative ();
@@ -1708,21 +1770,28 @@ function generate_settings_form (){
1708
  <?php
1709
  switch ($sidebar) {
1710
  case 0:
 
 
1711
  break;
1712
  case 1:
1713
- sidebar_support ();
 
 
1714
  break;
1715
  case 2:
1716
- sidebar_support ();
1717
- sidebar_addense_alternative ();
 
1718
  break;
1719
  case 3:
1720
- sidebar_support ();
1721
- sidebar_addense_alternative ();
 
1722
  break;
1723
  case 4:
1724
- sidebar_support ();
1725
- sidebar_ratings ();
 
1726
  sidebar_pro ();
1727
  break;
1728
  }
@@ -1746,7 +1815,6 @@ function generate_settings_form (){
1746
  if (!jQuery(image_selector + ":visible").length) {
1747
  var image = jQuery(image_selector);
1748
  image.hide ().after (image.clone ().attr ('class', '').attr ("id", image_id + '-ajax').
1749
- // 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'); ?>').
1750
  attr ('src', ajaxurl+'?action=ai_ajax_backend&image=' + image_src + '&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').
1751
  css ('display', css_display));
1752
  }
@@ -1763,6 +1831,7 @@ function generate_settings_form (){
1763
  replace_blocked_image ('ai-media-1', 'contextual-1.gif');
1764
  replace_blocked_image ('ai-media-2', 'contextual-2.jpg');
1765
  replace_blocked_image ('ai-pro-1', 'icon-256x256.jpg');
 
1766
  replace_blocked_image ('ai-stars-img', 'stars.png', 'inline');
1767
  replace_blocked_image ('ai-tw', 'twitter.png', 'inline');
1768
  replace_blocked_image ('ai-fb', 'facebook.png', 'inline');
@@ -1788,32 +1857,21 @@ function sidebar_addense_alternative () { ?>
1788
  <?php
1789
  }
1790
 
1791
- function sidebar_ratings () {
1792
  if (!wp_is_mobile () && is_super_admin ()) {
1793
  ?>
1794
-
1795
- <div class="ai-form header no-select rounded" style="position: relative;">
1796
- <ul style="margin: 0;">
1797
- <li>
1798
- 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.
1799
- </li>
1800
- <li>
1801
- 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>.
1802
- </li>
1803
- </ul>
1804
-
1805
- <p style="text-align: justify;">
1806
- You've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.
1807
- 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.
1808
- 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.
1809
- 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>
1810
  </div>
1811
 
1812
  <?php
1813
  }
1814
  }
1815
 
1816
- function sidebar_support () {
1817
  global $rating_value, $rating_string, $rating_css;
1818
  ?>
1819
 
@@ -1848,12 +1906,30 @@ function sidebar_support () {
1848
  <?php
1849
  }
1850
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1851
  function sidebar_pro () { ?>
1852
 
1853
- <div class="ai-form rounded no-select" style="background: #fff;">
1854
  <div style="float: right;" >
1855
  <div>
1856
- <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>
 
 
 
1857
  </div>
1858
  <div>
1859
  <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>
@@ -1867,17 +1943,17 @@ function sidebar_pro () { ?>
1867
  <li>64 code (ad) blocks</li>
1868
  <li>Syntax highlighting editor</li>
1869
  <li><a href="http://adinserter.pro/documentation#code-preview" class="simple-link" target="_blank">Code preview</a> with visual CSS editor</li>
1870
- <li>Automatic insertion before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1871
- <li>Automatic insertion between posts on blog pages</li>
1872
- <li>Automatic insertion before, between and after comments</li>
1873
- <li>Insertion exceptions for posts and pages</li>
1874
- <li><a href="http://adinserter.pro/documentation#manual" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1875
- <li>Sticky positions (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
1876
- <li>Sticky (fixed) widgets (sidebar does not move when the page scrolls)</li>
1877
  <li>Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
1878
  <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>
1879
- <li>Options to disable insertion on Ajax calls, 404 error pages or in feeds</li>
1880
- <li>Ad rotation (works also with caching)</li>
1881
  <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>
1882
  <li>Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
1883
  <li>Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
@@ -1887,8 +1963,10 @@ function sidebar_pro () { ?>
1887
  <li>Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
1888
  <li>Support for Google Analytics, Piwik or any other web analytics code</li>
1889
  <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1890
- <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>
1891
- <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>
 
 
1892
  <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>
1893
  <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1894
  <li>Import/Export block or plugin settings</li>
@@ -1903,10 +1981,71 @@ function sidebar_pro () { ?>
1903
 
1904
  <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.
1905
  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,
1906
- 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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1907
  </div>
1908
 
1909
  <?php
1910
  }
1911
 
1912
 
 
 
297
 
298
  $obj = $block_object [$ad_number];
299
 
300
+ $client_side_devices = $obj->get_detection_client_side () == AI_ENABLED;
301
+ $server_side_devices = $obj->get_detection_server_side () == AI_ENABLED;
302
+ if ($client_side_devices) $client_side_style = "font-weight: bold; color: #66f;"; else $client_side_style = "";
303
+ if ($server_side_devices) $server_side_style = "font-weight: bold; color: #66f;"; else $server_side_style = "";
304
+
305
+ $show_devices = $client_side_devices || $server_side_devices == AI_ENABLED;
306
  if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
307
 
308
  $cat_list = $obj->get_ad_block_cat();
327
  $obj->get_enable_404 () == AI_ENABLED ||
328
  $obj->get_enable_feed () == AI_ENABLED;
329
 
330
+ $word_count_options =
331
+ intval ($obj->get_minimum_words()) != 0 ||
332
+ intval ($obj->get_maximum_words()) != 0;
333
+
334
  $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
335
 
336
  $filter_active = $obj->get_call_filter() || $obj->get_inverted_filter() != 0;
339
 
340
  $show_misc =
341
  $insertion_options ||
342
+ $word_count_options ||
343
  $scheduling_active ||
344
  $filter_active ||
345
  $adb_block_action_active;
347
  if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
348
 
349
  if ($insertion_options) $insertion_style = "font-weight: bold; color: #66f;"; else $insertion_style = "";
350
+ if ($word_count_options) $word_count_style = "font-weight: bold; color: #66f;"; else $word_count_style = "";
351
  if ($scheduling_active) $scheduling_style = "font-weight: bold; color: #66f;"; else $scheduling_style = "";
352
  if ($filter_active) $filter_style = "font-weight: bold; color: #66f;"; else $filter_style = "";
353
  if ($adb_block_action_active) $adb_style = "font-weight: bold; color: #66f;"; else $adb_style = "";
358
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH ||
359
  $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH;
360
 
 
 
 
 
 
 
361
  $paragraph_counting =
362
  $obj->get_direction_type() != $default->get_direction_type() ||
363
  $obj->get_paragraph_tags() != $default->get_paragraph_tags() ||
587
  <div id="paragraph-settings-<?php echo $ad_number; ?>" class="rounded" style="<?php echo $paragraph_settings ? "" : " display: none;" ?>">
588
  <!-- <div>-->
589
  <div style="float: left; margin-top: 1px;">
590
+ Paragraph(s)
591
  <input
592
  type="text"
593
  name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"
786
  </div>
787
  </div>
788
 
 
 
 
 
 
 
 
 
789
  <div class="responsive-table rounded" id="list-settings-<?php echo $ad_number; ?>" style="<?php if (!$show_lists) echo ' display: none;'; ?>">
790
  <table>
791
  <tbody>
949
  </table>
950
  </div>
951
 
952
+ <div id="device-detection-settings-<?php echo $ad_number; ?>" style="<?php if (!$show_devices) echo 'display: none;'; ?>">
 
 
 
 
 
 
 
 
953
 
954
+ <div id="ai-devices-container-<?php echo $ad_number; ?>" style="padding: 0; margin 8px 0 0 0; border: 0;">
955
+ <ul id="ai-devices-tabs-<?php echo $ad_number; ?>" style="display: none;">
956
+ <li id="ai-client-side-detection-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-client-side-<?php echo $ad_number; ?>"><span style="<?php echo $client_side_style; ?>">Client-side device detection</span></a></li>
957
+ <li id="ai-server-side-detection<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-server-side-<?php echo $ad_number; ?>"><span style="<?php echo $server_side_style; ?>">Server-side device detection</span></a></li>
958
+ </ul>
959
+
960
+ <div id="tab-client-side-<?php echo $ad_number; ?>" class="rounded">
961
+ <div style="float: left; margin-top: 0px;">
962
+ <input type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
963
+ <input id="client-side-detection-<?php echo $ad_number; ?>" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
964
+ <label for="client-side-detection-<?php echo $ad_number; ?>" style="vertical-align: baseline;">Use client-side detection to show only on</label>
965
+ </div>
966
+
967
+ <div style="float: left; margin: -5px 0 -2px 0;">
968
+ <?php
969
+
970
+ $viewports = array ();
971
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
972
+ $viewport_name = get_viewport_name ($viewport);
973
+ if ($viewport_name != '') $viewports [$viewport] = $viewport_name;
974
+ }
975
+ $number_of_viewports = count ($viewports);
976
+ $columns = 3;
977
+
978
+ ?>
979
+ <table>
980
+ <tbody>
981
+ <?php
982
+
983
+ $column = 0;
984
+ foreach ($viewports as $viewport => $viewport_name) {
985
+ if ($column % $columns == 0) {
986
+ ?>
987
+ <tr>
988
+ <?php
989
  }
990
+ ?>
991
+ <td style='padding: 2px 0 0 20px;'>
992
+ <input type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
993
+ <input type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="viewport-<?php echo $viewport, "-", $ad_number; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
994
+ <label for="viewport-<?php echo $viewport, "-", $ad_number; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
995
+ </td>
996
+ <?php
997
+ $column ++;
998
+ }
999
+ if ($column % $columns != 0) {
1000
+ for ($fill = 1; $fill <= $columns - $column % $columns; $fill++) {
1001
+ ?>
1002
+ <td> </td>
1003
+ <?php
1004
+ }
1005
+ ?>
1006
+ </tr>
1007
+ <?php
1008
+ }
1009
+ ?>
1010
+ </tbody>
1011
+ </table>
1012
+ </div>
1013
+ <div style="clear: both"></div>
1014
+ </div>
1015
+
1016
+ <div id="tab-server-side-<?php echo $ad_number; ?>" class="rounded">
1017
+ <input type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
1018
+ <input type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="server-side-detection-<?php echo $ad_number; ?>" value="1" default="<?php echo $default->get_detection_server_side(); ?>" <?php if ($obj->get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
1019
+ <label for="server-side-detection-<?php echo $ad_number; ?>" style="vertical-align: baseline;">Use server-side detection to insert code only for </label>
1020
+
1021
+ <select id="display-for-devices-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" style="margin: -4px 1px -2px 1px;" default="<?php echo $default->get_display_for_devices(); ?>">
1022
+ <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
1023
+ <option value="<?php echo AD_DISPLAY_MOBILE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_MOBILE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_MOBILE_DEVICES; ?></option>
1024
+ <option value="<?php echo AD_DISPLAY_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_TABLET_DEVICES; ?></option>
1025
+ <option value="<?php echo AD_DISPLAY_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_PHONE_DEVICES; ?></option>
1026
+ <option value="<?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?></option>
1027
+ <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
1028
+ </select>
1029
+ devices
1030
+ </div>
1031
+ </div>
1032
+
1033
  </div>
1034
 
1035
  <div id="misc-settings-<?php echo $ad_number; ?>" style="<?php if (!$show_misc) echo 'display: none;'; ?>">
1036
  <div id="ai-misc-container-<?php echo $ad_number; ?>" style="padding: 0; margin 8px 0 0 0; border: 0;">
1037
  <ul id="ai-misc-tabs-<?php echo $ad_number; ?>" style="display: none;">
1038
  <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>
1039
+ <li id="ai-misc-word-count-<?php echo $ad_number; ?>" class="ai-plugin-tab"><a href="#tab-word-count-<?php echo $ad_number; ?>"><span style="<?php echo $word_count_style; ?>">Word Count</span></a></li>
1040
  <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>
1041
  <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>
1042
  <?php if (function_exists ('ai_adb_action_0')) ai_adb_action_0 ($ad_number, $adb_style); ?>
1081
  </div>
1082
  </div>
1083
 
1084
+ <div id="tab-word-count-<?php echo $ad_number; ?>" class="rounded">
1085
+ Post/Static page must have between
1086
+ <input type="text" name="<?php echo AI_OPTION_MIN_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_minimum_words(); ?>" value="<?php echo $obj->get_minimum_words() ?>" title="Minimum number of post/static page words, leave empty for no limit" size="4" maxlength="6" />
1087
+ and
1088
+ <input type="text" name="<?php echo AI_OPTION_MAX_WORDS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_maximum_words(); ?>" value="<?php echo $obj->get_maximum_words() ?>" title="Maximum number of post/static page words, leave empty for no limit" size="4" maxlength="6" />
1089
+ words
1090
+ </div>
1091
+
1092
  <div id="tab-filter-<?php echo $ad_number; ?>" class="rounded">
1093
  <div class="max-input">
1094
  <span style="display: table-cell;">
1180
  <input style="display: none; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save Settings" type="submit" style="width:120px; font-weight: bold;" />
1181
  </div>
1182
 
1183
+ <div style="float: left;">
1184
  <input onclick="if (confirm('Are you sure you want to reset all settings?')) return true; return false;" name="<?php echo AI_FORM_CLEAR; ?>" value="Reset All Settings" type="submit" style="display: none; width:125px; font-weight: bold; color: #e44;" />
1185
+ <?php if (function_exists ('ai_settings_global_actions')) ai_settings_global_actions (); ?>
1186
  </div>
1187
 
1188
  <div style="clear: both;"></div>
1219
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
1220
  <tr>
1221
  <td style="width: 34%;">
1222
+ Syntax highlighter theme
1223
  </td>
1224
  <td>
1225
  <select
1271
  </tr>
1272
  <tr>
1273
  <td>
1274
+ Block class name
1275
  </td>
1276
  <td>
1277
  <input style="margin-left: 0px;" title="CSS Class Name for the wrapping div" type="text" id="block-class-name" name="block-class-name" value="<?php echo $block_class_name; ?>" default="<?php echo DEFAULT_BLOCK_CLASS_NAME; ?>" size="15" maxlength="40" />
1279
  </tr>
1280
  <tr>
1281
  <td>
1282
+ Min. user role for ind. exceptions editing
1283
  </td>
1284
  <td>
1285
  <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">
1301
  </tr>
1302
  <tr>
1303
  <td>
1304
+ Functions for paragraph counting
1305
  </td>
1306
  <td>
1307
  <select id="paragraph_counting_functions" name="paragraph_counting_functions" default="<?php echo DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS; ?>" title="Standard PHP functions are faster and work in most cases, use Multibyte functions if paragraphs are not counted properly on non-english pages.">
1312
  </tr>
1313
  <tr>
1314
  <td>
1315
+ No paragraph counting inside
1316
  </td>
1317
  <td>
1318
  <input type="text" name="no-paragraph-counting-inside" value="<?php echo get_no_paragraph_counting_inside (); ?>" default="<?php echo DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE; ?>" size="40" maxlength="80" />
1320
  </tr>
1321
  <tr>
1322
  <td>
1323
+ Sticky widget mode
1324
+ </td>
1325
+ <td>
1326
+ <select name="sticky-widget-mode" default="<?php echo DEFAULT_STICKY_WIDGET_MODE; ?>" title="CSS mode is the best approach but may not work with all themes. JavaScript mode works with most themes but may reload ads on page load.">
1327
+ <option value="<?php echo AI_STICKY_WIDGET_MODE_CSS; ?>" <?php echo get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CSS; ?></option>
1328
+ <option value="<?php echo AI_STICKY_WIDGET_MODE_JS; ?>" <?php echo get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_JS ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_JS; ?></option>
1329
+ </select>
1330
+ </td>
1331
+ </tr>
1332
+ <tr>
1333
+ <td>
1334
+ Sticky widget top margin
1335
  </td>
1336
  <td>
1337
  <input type="text" name="sticky-widget-margin" value="<?php echo get_sticky_widget_margin (); ?>" default="<?php echo DEFAULT_STICKY_WIDGET_MARGIN; ?>" size="6" maxlength="4" /> px
1678
  Age
1679
  </td>
1680
  <td>
1681
+ <?php if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) printf ('%04d-%02d-%02d %02d:%02d:%02d (%d days)',
1682
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
1683
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
1684
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
1685
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
1686
  $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
1687
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s,
1688
+ isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) ? $ai_wp_data [AI_DAYS_SINCE_INSTAL] : null); ?>
1689
  </td>
1690
  </tr>
1691
  <tr class="system-debugging" style="display: none;">
1709
 
1710
  $sidebar = 0;
1711
  if (isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
1712
+ if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 2)
1713
+ $sidebar = 1;
1714
+
1715
+ if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 5 ||
1716
+ $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10)
1717
+ $sidebar = 2;
1718
 
1719
+ if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 7 ||
1720
+ $ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10 ||
1721
+ $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 15)
1722
+ $sidebar = 3;
1723
 
1724
+ if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20)
1725
+ $sidebar = 4;
1726
 
 
1727
  } else {
1728
+ if ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS] >= 3) $sidebar = 4;
1729
  }
1730
 
1731
  // $sidebar = 4;
1732
 
 
1733
  if (!function_exists ('ai_settings_side') && $sidebar >= 2) {
1734
 
1735
  switch ($sidebar) {
1738
  case 1:
1739
  break;
1740
  case 2:
1741
+ sidebar_addense_alternative ();
1742
  break;
1743
  case 3:
1744
+ sidebar_support_review ();
1745
+ sidebar_addense_alternative ();
1746
  break;
1747
  case 4:
1748
  sidebar_addense_alternative ();
1770
  <?php
1771
  switch ($sidebar) {
1772
  case 0:
1773
+ sidebar_help ();
1774
+ sidebar_pro ();
1775
  break;
1776
  case 1:
1777
+ sidebar_support_plugin ();
1778
+ sidebar_help ();
1779
+ sidebar_pro ();
1780
  break;
1781
  case 2:
1782
+ sidebar_support_plugin ();
1783
+ sidebar_help ();
1784
+ sidebar_pro ();
1785
  break;
1786
  case 3:
1787
+ sidebar_support_plugin ();
1788
+ sidebar_help ();
1789
+ sidebar_pro ();
1790
  break;
1791
  case 4:
1792
+ sidebar_support_plugin ();
1793
+ sidebar_support_review ();
1794
+ sidebar_help ();
1795
  sidebar_pro ();
1796
  break;
1797
  }
1815
  if (!jQuery(image_selector + ":visible").length) {
1816
  var image = jQuery(image_selector);
1817
  image.hide ().after (image.clone ().attr ('class', '').attr ("id", image_id + '-ajax').
 
1818
  attr ('src', ajaxurl+'?action=ai_ajax_backend&image=' + image_src + '&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').
1819
  css ('display', css_display));
1820
  }
1831
  replace_blocked_image ('ai-media-1', 'contextual-1.gif');
1832
  replace_blocked_image ('ai-media-2', 'contextual-2.jpg');
1833
  replace_blocked_image ('ai-pro-1', 'icon-256x256.jpg');
1834
+ replace_blocked_image ('ai-pro-2', 'ai-charts-250.png');
1835
  replace_blocked_image ('ai-stars-img', 'stars.png', 'inline');
1836
  replace_blocked_image ('ai-tw', 'twitter.png', 'inline');
1837
  replace_blocked_image ('ai-fb', 'facebook.png', 'inline');
1857
  <?php
1858
  }
1859
 
1860
+ function sidebar_support_review () {
1861
  if (!wp_is_mobile () && is_super_admin ()) {
1862
  ?>
1863
+ <div class="ai-form header no-select rounded" style="position: relative; text-align: justify;">
1864
+ You've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.
1865
+ 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.
1866
+ 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.
1867
+ 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;">
 
 
 
 
 
 
 
 
 
 
 
1868
  </div>
1869
 
1870
  <?php
1871
  }
1872
  }
1873
 
1874
+ function sidebar_support_plugin () {
1875
  global $rating_value, $rating_string, $rating_css;
1876
  ?>
1877
 
1906
  <?php
1907
  }
1908
 
1909
+ function sidebar_help () { ?>
1910
+
1911
+ <div class="ai-form header rounded">
1912
+ <div style="float: left;">
1913
+ <h2 style="display: inline-block; margin: 5px 0;">Need help with settings? Check plugin features with documentation links below.</h2>
1914
+ <div style="margin-bottom: 10px;">Most of these features are available in the free Ad Inserter you are using. Check <a href="https://adinserter.pro/documentation" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">feature list</a> for details.</div>
1915
+ <div>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.</div>
1916
+ <div>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>.</div>
1917
+ </div>
1918
+ <div style="clear: both;"></div>
1919
+ </div>
1920
+
1921
+ <?php
1922
+ }
1923
+
1924
  function sidebar_pro () { ?>
1925
 
1926
+ <div class="ai-form rounded no-select feature-list" style="background: #fff;">
1927
  <div style="float: right;" >
1928
  <div>
1929
+ <a href="http://adinserter.pro/" class="clear-link" 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>
1930
+ </div>
1931
+ <div>
1932
+ <a href="https://adinserter.pro/tracking" class="clear-link" title="A/B testing - Track ad impressions and clicks" target="_blank"><img id="ai-pro-2" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>ai-charts-250.png" style="margin-top: 10px;" /></a>
1933
  </div>
1934
  <div>
1935
  <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>
1943
  <li>64 code (ad) blocks</li>
1944
  <li>Syntax highlighting editor</li>
1945
  <li><a href="http://adinserter.pro/documentation#code-preview" class="simple-link" target="_blank">Code preview</a> with visual CSS editor</li>
1946
+ <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1947
+ <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> between posts on blog pages</li>
1948
+ <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> before, between and after comments</li>
1949
+ <li><a href="https://adinserter.pro/exceptions" class="simple-link" target="_blank">Insertion exceptions</a> for individual posts and pages</li>
1950
+ <li><a href="http://adinserter.pro/documentation#manual-insertion" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1951
+ <li><a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">Sticky positions</a> (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
1952
+ <li><a href="http://adinserter.pro/documentation#manual-insertion" class="simple-link" target="_blank">Sticky (fixed) widgets</a> (sidebar does not move when the page scrolls)</li>
1953
  <li>Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
1954
  <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>
1955
+ <li>Options to <a href="http://adinserter.pro/documentation#misc" class="simple-link" target="_blank">disable insertion</a> on Ajax calls, 404 error pages or in RSS feeds</li>
1956
+ <li><a href="http://adinserter.pro/documentation#ad-rotation" class="simple-link" target="_blank">Ad rotation</a> (works also with caching)</li>
1957
  <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>
1958
  <li>Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
1959
  <li>Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
1963
  <li>Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
1964
  <li>Support for Google Analytics, Piwik or any other web analytics code</li>
1965
  <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1966
+ <li>Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">mobile device detection</a> (works with caching, 6 custom viewports)</li>
1967
+ <li><a href="https://adinserter.pro/ad-blocking-detection" class="simple-link" target="_blank">Ad blocking detection</a> - popup message, ad replacement, content protection</li>
1968
+ <li><a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">Ad blocking statistics</a></li>
1969
+ <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> categories, tags, taxonomies, users, post IDs, urls, referers</li>
1970
  <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>
1971
  <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1972
  <li>Import/Export block or plugin settings</li>
1981
 
1982
  <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.
1983
  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,
1984
+ impression and click tracking, ad blocking detection actions 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>
1985
+ </div>
1986
+
1987
+ <?php
1988
+ }
1989
+
1990
+ function sidebar_pro_small () { ?>
1991
+
1992
+ <div class="ai-form header rounded" style="padding-bottom: 0;">
1993
+ <div style="float: left;">
1994
+ <a href="https://adinserter.pro/" class="simple-link" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="width: 100px;" /></a>
1995
+ </div>
1996
+ <div class="feature-list" style="float: right;">
1997
+ <h3 style="text-align: center; margin: 0;">Looking for <a href="https://adinserter.pro/" class="simple-link" target="_blank">Pro Ad Management plugin</a>?</h3>
1998
+ <hr style="margin-bottom: 0;" />
1999
+
2000
+ <div style="float: right; margin-left: 15px;">
2001
+ <ul>
2002
+ <li>Ads between posts</li>
2003
+ <li>Ads between comments</li>
2004
+ <li>Support via email</li>
2005
+ </ul>
2006
+ </div>
2007
+
2008
+ <div style="float: right; margin-left: 15px;">
2009
+ <ul>
2010
+ <li><a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">Sticky positions</a></li>
2011
+ <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Limit insertions</a></li>
2012
+ <li><a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options</li>
2013
+ </ul>
2014
+ </div>
2015
+
2016
+ <div style="float: right; margin-left: 15px;">
2017
+ <ul>
2018
+ <li>Ad rotation</li>
2019
+ <li><a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
2020
+ <li><a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">Ad tracking</a></li>
2021
+ </ul>
2022
+ </div>
2023
+
2024
+ <div style="float: right; margin-left: 15px;">
2025
+ <ul>
2026
+ <li>Support for <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
2027
+ <li><a href="https://adinserter.pro/ad-blocking-detection" class="simple-link" target="_blank">Ad blocking detection</a></li>
2028
+ <li><a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">Mobile device detection</a></li>
2029
+
2030
+ </ul>
2031
+ </div>
2032
+
2033
+ <div style="float: right; margin-left: 15px;">
2034
+ <ul>
2035
+ <li>64 code blocks</li>
2036
+ <li><a href="http://adinserter.pro/documentation#geo-targeting" class="simple-link" target="_blank">GEO targeting</a></li>
2037
+ <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a></li>
2038
+ </ul>
2039
+ </div>
2040
+
2041
+ <div style="clear: both;"></div>
2042
+ </div>
2043
+ <div style="clear: both;"></div>
2044
  </div>
2045
 
2046
  <?php
2047
  }
2048
 
2049
 
2050
+
2051
+