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

Version Description

  • Improved support for sticky widgets (works with most themes)
  • Added support for ad counting (|count| separator)
  • Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
  • Added support for automatic insertion before, between and after comments
  • Added processing of shortcodes in the header and footer code
  • Debugging function Show positions shows also page type
  • Fixed page type detection when Post page was set to static page and it was not homepage
  • 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.1.11
Comparing to
See all releases

Code changes from version 2.1.9 to 2.1.11

ad-inserter.php CHANGED
@@ -1,16 +1,30 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.1.9
5
- Description: Ad management plugin with powerful advertising options to automatically insert ad codes into your website.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
8
  Plugin URI: http://adinserter.pro/documentation
9
  */
10
 
11
  /*
 
12
  Change Log
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  Ad Inserter 2.1.9 - 2017-06-30
15
  - Added support for sticky widgets
16
  - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
@@ -439,6 +453,17 @@ if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
439
  }
440
  }
441
 
 
 
 
 
 
 
 
 
 
 
 
442
  if (function_exists ('ai_load_globals')) ai_load_globals ();
443
 
444
  if (get_dynamic_blocks ()) {
@@ -456,7 +481,8 @@ if (get_dynamic_blocks ()) {
456
  }
457
 
458
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
459
- $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
 
460
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
461
  $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false;
462
  $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false;
@@ -477,7 +503,6 @@ $adF = $block_object [AI_FOOTER_OPTION_NAME];
477
  if ($adH->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
478
  if ($adF->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
479
 
480
-
481
  if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
482
  require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
483
 
@@ -505,11 +530,12 @@ add_action ('admin_notices', 'ai_admin_notice_hook');
505
 
506
  add_action ('wp', 'ai_wp_hook');
507
 
508
- if ($adH->get_enable_manual () ||
509
- $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
510
- get_remote_debugging () ||
511
- ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
512
- add_action ('wp_head', 'ai_wp_head_hook');
 
513
 
514
  //if ($adF->get_enable_manual () ||
515
  // $ai_wp_data [AI_TRACKING] ||
@@ -522,7 +548,6 @@ if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_ou
522
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
523
  add_action ('shutdown', 'ai_shutdown_hook');
524
 
525
- add_action ('get_sidebar', 'ai_get_sidebar');
526
  add_action ('widgets_init', 'ai_widgets_init_hook');
527
  add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
528
  add_action ('save_post', 'ai_save_meta_box_data_hook');
@@ -540,7 +565,6 @@ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
540
  }
541
 
542
 
543
-
544
  function ai_toolbar ($wp_admin_bar) {
545
  global $block_object, $ai_wp_data;
546
 
@@ -670,14 +694,16 @@ function ai_toolbar ($wp_admin_bar) {
670
  function set_user () {
671
  global $ai_wp_data;
672
 
673
- if ($ai_wp_data [AI_WP_USER] != AI_USER_NOT_SET) return;
674
 
675
- $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
676
 
677
  if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
678
  if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
679
 
680
  // if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
 
 
681
  }
682
 
683
  function set_page_type () {
@@ -686,14 +712,14 @@ function set_page_type () {
686
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
687
 
688
  if (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
689
- elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
690
- elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
691
- elseif (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
692
- elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
693
- elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
694
- elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
695
- elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
696
- elseif (is_archive()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
697
  }
698
 
699
  function ai_log_message ($message) {
@@ -740,6 +766,7 @@ function ai_log_block_status ($block, $ai_last_check) {
740
 
741
  case AI_CHECK_CATEGORY: $status .= "CATEGORY"; break;
742
  case AI_CHECK_TAG: $status .= "TAG"; break;
 
743
  case AI_CHECK_ID: $status .= "ID"; break;
744
  case AI_CHECK_URL: $status .= "URL"; break;
745
  case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
@@ -846,7 +873,7 @@ function number_of_words (&$content) {
846
  }
847
 
848
  function ai_wp_hook () {
849
- global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time;
850
 
851
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
852
  ai_log ("WP HOOK START");
@@ -923,6 +950,16 @@ function ai_wp_hook () {
923
  if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
924
  add_action ('the_post', 'ai_post_hook');
925
 
 
 
 
 
 
 
 
 
 
 
926
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
927
  $ai_total_plugin_time += microtime (true) - $start_time;
928
  ai_log ("WP HOOK END\n");
@@ -1038,10 +1075,56 @@ function add_head_inline_styles_and_scripts () {
1038
  }
1039
  }
1040
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1041
  function add_footer_inline_scripts () {
1042
  global $ai_wp_data;
1043
 
1044
- $inline_scripts = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE || $ai_wp_data [AI_TRACKING] || $ai_wp_data [AI_STICKY_WIDGETS];
 
 
 
 
 
 
 
1045
 
1046
  if ($inline_scripts) echo "<script type='text/javascript'>\n";
1047
 
@@ -1084,20 +1167,39 @@ if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrappin
1084
 
1085
  // echo 'jQuery(document).ready(function($) {
1086
  // var sticky_widget_margin = ', get_sticky_widget_margin (), ';
1087
- // $("div.ai-sidebar").each (function () {
1088
- // var sidebar = $(this).next ();
1089
- // var widget = sidebar.find ("div.ai-sticky").first ();
1090
- // if (widget.length == 1) {
1091
- // sidebar.css ("position", "sticky").css ("top", sidebar.offset ().top - widget.offset ().top + sticky_widget_margin);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1092
  // }
1093
  // });
1094
  // });
1095
  //';
1096
 
1097
- echo 'jQuery(document).ready(function($){var sticky_widget_margin=', get_sticky_widget_margin (), ';$("div.ai-sidebar").each(function(){var sidebar=$(this).next();var widget=sidebar.find("div.ai-sticky").first();if(widget.length==1)sidebar.css("position","sticky").css("top",sidebar.offset().top-widget.offset().top+sticky_widget_margin)})});';
 
1098
 
1099
  }
1100
 
 
 
 
 
1101
  if (function_exists ('add_footer_inline_scripts_2')) {
1102
  add_footer_inline_scripts_2 ();
1103
  }
@@ -1338,15 +1440,49 @@ function ai_save_meta_box_data_hook ($post_id) {
1338
  update_post_meta ($post_id, '_adinserter_block_exceptions', implode (",", $selected));
1339
  }
1340
 
1341
- function ai_get_sidebar ($name) {
1342
- echo "<div class='ai-sidebar'></div>\n";
1343
- }
1344
-
1345
  function ai_widgets_init_hook () {
1346
  if (is_multisite() && !is_main_site () && !multisite_widgets_enabled ()) return;
1347
  register_widget ('ai_widget');
1348
  }
1349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1350
  function ai_wp_head_hook () {
1351
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1352
 
@@ -1366,7 +1502,15 @@ function ai_wp_head_hook () {
1366
 
1367
  if ($obj->get_enable_manual ()) {
1368
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1369
- echo $obj->ai_getCode ();
 
 
 
 
 
 
 
 
1370
  }
1371
 
1372
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
@@ -1394,7 +1538,11 @@ function ai_wp_footer_hook () {
1394
 
1395
  if ($obj->get_enable_manual ()) {
1396
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1397
- echo $obj->ai_getCode ();
 
 
 
 
1398
  }
1399
 
1400
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
@@ -1445,24 +1593,45 @@ function ai_write_debug_info ($write_processing_log = false) {
1445
  case AI_PT_ARCHIVE: echo "ARCHIVE PAGE"; break;
1446
  case AI_PT_SEARCH: echo "SEARCH PAGE"; break;
1447
  case AI_PT_404: echo "404 PAGE"; break;
 
1448
  case AI_PT_FEED: echo "FEED"; break;
 
 
 
1449
  default: echo "?"; break;
1450
  }
1451
  echo "\n";
1452
- echo 'POST TYPE: ', get_post_type (), "\n";
1453
- $category_data = get_the_category();
1454
- $categories = array ();
1455
- foreach ($category_data as $category) {
1456
- $categories []= $category->slug;
1457
- }
1458
- echo 'CATEGORIES: ', implode (', ', $categories), "\n";
1459
- $tag_data = wp_get_post_tags (get_the_ID());
1460
- $tags = array ();
1461
- foreach ($tag_data as $tag) {
1462
- $tags []= $tag->slug;
1463
- }
1464
- echo 'TAGS: ', implode (', ', $tags), "\n";
1465
- echo 'ID: ', get_the_ID(), "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1466
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1467
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
1468
  if (function_exists ('ai_debug')) ai_debug ();
@@ -1647,19 +1816,31 @@ function ai_write_debug_info ($write_processing_log = false) {
1647
  echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
1648
  if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
1649
  echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
 
 
 
 
 
 
1650
 
1651
 
1652
- echo "\nPAGE TYPE BLOCKS\n";
1653
- if (count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1654
  echo "CONTENT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1655
- if (count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1656
  echo "EXCERPT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1657
- if (count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1658
  echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1659
- if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1660
  echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1661
- if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1662
  echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
 
 
 
 
 
 
1663
 
1664
  if ($write_processing_log) {
1665
  echo "\nTIME EVENT\n";
@@ -1701,7 +1882,10 @@ function ai_shutdown_hook () {
1701
  $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST ||
1702
  $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY ||
1703
  $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH ||
1704
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE) {
 
 
 
1705
  echo "\n<!--\n\n";
1706
  ai_write_debug_info (true);
1707
  echo "\n-->\n";
@@ -2139,6 +2323,28 @@ function ai_data () {
2139
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
2140
  }
2141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2142
  elseif (function_exists ('ai_data_ajax')) {
2143
  ai_data_ajax ();
2144
  }
@@ -2151,17 +2357,23 @@ function ai_generate_extract (&$settings) {
2151
  $obj = new ai_Block (1);
2152
 
2153
  $extract = array ();
2154
- $content_hook_blocks = array ();
2155
- $excerpt_hook_blocks = array ();
2156
- $loop_start_hook_blocks = array ();
2157
- $loop_end_hook_blocks = array ();
2158
- $post_hook_blocks = array ();
2159
-
2160
- $content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2161
- $excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2162
- $loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2163
- $loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2164
- $post_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
 
 
 
 
 
 
2165
 
2166
  // Generate extracted data
2167
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
@@ -2208,15 +2420,30 @@ function ai_generate_extract (&$settings) {
2208
  foreach ($page_types as $block_page_type) $post_hook_blocks [$block_page_type][]= $block;
2209
  $post_hook_blocks [AI_PT_ANY][]= $block;
2210
  break;
 
 
 
 
 
 
 
 
 
 
 
 
2211
  }
2212
  }
2213
  }
2214
 
2215
- $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
2216
- $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
2217
- $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
2218
- $extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks;
2219
- $extract [POST_HOOK_BLOCKS] = $post_hook_blocks;
 
 
 
2220
 
2221
  return ($extract);
2222
  }
@@ -2231,7 +2458,8 @@ function ai_load_settings () {
2231
  if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) &&
2232
  isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] == $version_string &&
2233
  isset ($ai_db_options_extract [POST_HOOK_BLOCKS]) &&
2234
- isset ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_AJAX]))
 
2235
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
2236
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
2237
 
@@ -2702,6 +2930,7 @@ function ai_content_hook ($content = '') {
2702
  $ai_last_check = AI_CHECK_NONE;
2703
  $current_block = 0;
2704
 
 
2705
  foreach ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2706
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2707
 
@@ -2845,6 +3074,7 @@ function ai_excerpt_hook ($content = '') {
2845
  $ai_last_check = AI_CHECK_NONE;
2846
  $current_block = 0;
2847
 
 
2848
  foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2849
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2850
 
@@ -2936,11 +3166,11 @@ function ai_before_after_post ($query, $automatic_insertion) {
2936
 
2937
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2938
 
2939
- $style = AI_DEBUG_POSITIONS_STYLE;
2940
-
2941
  $counter = $ad_inserter_globals [$globals_name];
2942
  if ($counter == 1) $counter = '';
2943
 
 
 
2944
  echo "<section style='$style'>".($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
2945
  }
2946
 
@@ -2954,7 +3184,10 @@ function ai_before_after_post ($query, $automatic_insertion) {
2954
  $ai_last_check = AI_CHECK_NONE;
2955
  $current_block = 0;
2956
 
2957
- foreach ($ai_db_options_extract [$automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? LOOP_START_HOOK_BLOCKS : LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
 
 
 
2958
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2959
 
2960
  if (!isset ($block_object [$block])) continue;
@@ -3021,8 +3254,7 @@ function ai_loop_end_hook ($query){
3021
 
3022
  // Process Between Posts postion
3023
  function ai_post_hook ($post) {
3024
- global $ai_wp_data, $ai_total_plugin_time;
3025
- global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
3026
 
3027
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
3028
 
@@ -3057,6 +3289,7 @@ function ai_post_hook ($post) {
3057
  $ai_last_check = AI_CHECK_NONE;
3058
  $current_block = 0;
3059
 
 
3060
  foreach ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3061
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3062
 
@@ -3096,6 +3329,257 @@ function ai_post_hook ($post) {
3096
  return $post;
3097
  }
3098
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3099
  function process_shortcode (&$block, $atts) {
3100
  global $block_object, $ai_last_check, $ai_wp_data;
3101
 
@@ -3296,6 +3780,22 @@ class ai_widget extends WP_Widget {
3296
  }
3297
  }
3298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3299
 
3300
  function ai_widget_draw ($args, $instance, &$block) {
3301
  global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
@@ -3312,7 +3812,11 @@ function ai_widget_draw ($args, $instance, &$block) {
3312
  if ($sticky) {
3313
  $ai_wp_data [AI_STICKY_WIDGETS] = true;
3314
  if ($block == - 1) {
3315
- echo "<div class='ai-sticky'></div>\n";
 
 
 
 
3316
  return;
3317
  }
3318
  }
@@ -3330,7 +3834,8 @@ function ai_widget_draw ($args, $instance, &$block) {
3330
  $ad_inserter_globals [$globals_name] = 1;
3331
  } else $ad_inserter_globals [$globals_name] ++;
3332
 
3333
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WIDGET (". $obj->number . ') ['.$ad_inserter_globals [$globals_name] . ']');
 
3334
 
3335
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET;
3336
 
@@ -3350,7 +3855,13 @@ function ai_widget_draw ($args, $instance, &$block) {
3350
  // Last check before counter check before insertion
3351
  $ai_last_check = AI_CHECK_CODE;
3352
  if ($obj->ai_getCode () == '') {
3353
- if ($sticky) echo "<div class='ai-sticky'></div>\n";
 
 
 
 
 
 
3354
  return;
3355
  }
3356
 
@@ -3359,12 +3870,16 @@ function ai_widget_draw ($args, $instance, &$block) {
3359
 
3360
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3361
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
 
3362
  $viewport_classes = trim ($obj->get_viewport_classes ());
3363
  $sticky_class = $sticky ? ' ai-sticky' : '';
3364
  $widget_classes = trim ($viewport_classes . $sticky_class);
3365
- if ($widget_classes != "") echo "<div class='" . $widget_classes . "'>";
3366
 
3367
- echo $args ['before_widget'];
 
 
 
 
3368
 
3369
  if (!empty ($title)) {
3370
  echo $args ['before_title'], apply_filters ('widget_title', $title), $args ['after_title'];
@@ -3374,8 +3889,6 @@ function ai_widget_draw ($args, $instance, &$block) {
3374
 
3375
  echo $args ['after_widget'];
3376
 
3377
- if ($widget_classes != "") echo "</div>";
3378
-
3379
  $ai_last_check = AI_CHECK_INSERTED;
3380
 
3381
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $obj->get_detection_client_side())
@@ -3388,12 +3901,10 @@ function ai_widget_draw_debugger ($args, $instance, &$block) {
3388
 
3389
  $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
3390
 
3391
- echo $args ['before_widget'];
3392
-
3393
  if ($sticky) {
3394
  $ai_wp_data [AI_STICKY_WIDGETS] = true;
3395
- echo "<div class='ai-sticky'></div>\n";
3396
- }
3397
 
3398
  $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
3399
 
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.1.11
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/
8
  Plugin URI: http://adinserter.pro/documentation
9
  */
10
 
11
  /*
12
+
13
  Change Log
14
 
15
+ Ad Inserter 2.1.11 - 2017-07-21
16
+ - Improved support for sticky widgets
17
+ - Added support for ad counting (|count| separator)
18
+ - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
19
+ - Added support for automatic insertion before, between and after comments
20
+ - Added processing of shortcodes in the header and footer code
21
+ - Debugging function Show positions shows also page type
22
+ - Fixed page type detection when Post page was set to static page and it was not homepage
23
+ - Few minor bug fixes, cosmetic changes and code improvements
24
+
25
+ Ad Inserter 2.1.10 - 2017-07-01
26
+ - Fix for shifted sidebars in some themes
27
+
28
  Ad Inserter 2.1.9 - 2017-06-30
29
  - Added support for sticky widgets
30
  - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
453
  }
454
  }
455
 
456
+ if (defined ('AI_ADBLOCKER_DETECTION') && AI_ADBLOCKER_DETECTION) {
457
+ define ('AI_ADB_2_NAME', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY).md5 (NONCE_KEY))), 0, 8));
458
+
459
+ $script = AD_INSERTER_PLUGIN_DIR.'includes/js/sponsors.js';
460
+
461
+ if (!file_exists ($script)) {
462
+ file_put_contents ($script, 'window.' . AI_ADB_2_NAME . '=true;');
463
+ }
464
+
465
+ if (function_exists ('ai_check_files')) ai_check_files ();
466
+ }
467
  if (function_exists ('ai_load_globals')) ai_load_globals ();
468
 
469
  if (get_dynamic_blocks ()) {
481
  }
482
 
483
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
484
+ $ai_wp_data [AI_WP_USER_SET] = false;
485
+ $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
486
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
487
  $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false;
488
  $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false;
503
  if ($adH->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
504
  if ($adF->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
505
 
 
506
  if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
507
  require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
508
 
530
 
531
  add_action ('wp', 'ai_wp_hook');
532
 
533
+ //if ($adH->get_enable_manual () ||
534
+ // $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
535
+ // get_remote_debugging () ||
536
+ // ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 ||
537
+ // ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
538
+ add_action ('wp_head', 'ai_wp_head_hook');
539
 
540
  //if ($adF->get_enable_manual () ||
541
  // $ai_wp_data [AI_TRACKING] ||
548
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
549
  add_action ('shutdown', 'ai_shutdown_hook');
550
 
 
551
  add_action ('widgets_init', 'ai_widgets_init_hook');
552
  add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
553
  add_action ('save_post', 'ai_save_meta_box_data_hook');
565
  }
566
 
567
 
 
568
  function ai_toolbar ($wp_admin_bar) {
569
  global $block_object, $ai_wp_data;
570
 
694
  function set_user () {
695
  global $ai_wp_data;
696
 
697
+ if ($ai_wp_data [AI_WP_USER_SET]) return;
698
 
699
+ // $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
700
 
701
  if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
702
  if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
703
 
704
  // if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
705
+
706
+ $ai_wp_data [AI_WP_USER_SET] = true;
707
  }
708
 
709
  function set_page_type () {
712
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
713
 
714
  if (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
715
+ elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
716
+ elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
717
+ elseif (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
718
+ elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
719
+ elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
720
+ elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
721
+ elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
722
+ elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
723
  }
724
 
725
  function ai_log_message ($message) {
766
 
767
  case AI_CHECK_CATEGORY: $status .= "CATEGORY"; break;
768
  case AI_CHECK_TAG: $status .= "TAG"; break;
769
+ case AI_CHECK_TAXONOMY: $status .= "TAXONOMY"; break;
770
  case AI_CHECK_ID: $status .= "ID"; break;
771
  case AI_CHECK_URL: $status .= "URL"; break;
772
  case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
873
  }
874
 
875
  function ai_wp_hook () {
876
+ global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker;
877
 
878
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
879
  ai_log ("WP HOOK START");
950
  if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
951
  add_action ('the_post', 'ai_post_hook');
952
 
953
+ if ((isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) ||
954
+ (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) ||
955
+ (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) ||
956
+ $debug_positions) {
957
+ $ai_wp_data [AI_NUMBER_OF_COMMENTS] = 0;
958
+ add_filter ('comments_array' , 'ai_comments_array' , 10, 2);
959
+ add_filter ('wp_list_comments_args' , 'ai_wp_list_comments_args');
960
+ $ai_walker = new ai_Walker_Comment;
961
+ }
962
+
963
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
964
  $ai_total_plugin_time += microtime (true) - $start_time;
965
  ai_log ("WP HOOK END\n");
1075
  }
1076
  }
1077
 
1078
+ function ai_adb_code () {
1079
+ return "
1080
+ var ai_adb_debugging = " . (get_javascript_debugging () ? 'true' : 'false') . ";
1081
+ var ai_adb_active = false;
1082
+
1083
+ var ai_adb_detected = function() {
1084
+ if (!ai_adb_active) {
1085
+ ai_adb_active = true;
1086
+ if (ai_adb_debugging) console.log ('AI AdBlocker DETECTED');
1087
+
1088
+
1089
+ }
1090
+ }
1091
+ var ai_adb_undetected = function() {
1092
+ // if (!ai_adb_active) {
1093
+ // if (ai_adb_debugging) console.log ('AI AdBlocker not detected');
1094
+ // }
1095
+ }
1096
+
1097
+ if (!document.getElementById ('" . AI_ADB_1_NAME . "')){
1098
+ if (ai_adb_debugging) console.log ('AI AdBlocker 1 DETECTED');
1099
+ jQuery (document).ready (ai_adb_detected);
1100
+ } else {
1101
+ if (ai_adb_debugging) console.log ('AI AdBlocker 1 not detected');
1102
+ jQuery (document).ready (ai_adb_undetected);
1103
+ }
1104
+
1105
+ if (typeof window." . AI_ADB_2_NAME . " == 'undefined') {
1106
+ if (ai_adb_debugging) console.log ('AI AdBlocker 2 DETECTED');
1107
+ jQuery (document).ready (ai_adb_detected);
1108
+ } else {
1109
+ if (ai_adb_debugging) console.log ('AI AdBlocker 2 not detected');
1110
+ jQuery (document).ready (ai_adb_undetected);
1111
+ }
1112
+ ";
1113
+
1114
+ // return "";
1115
+ }
1116
+
1117
  function add_footer_inline_scripts () {
1118
  global $ai_wp_data;
1119
 
1120
+ if (defined ('AI_ADBLOCKER_DETECTION') && AI_ADBLOCKER_DETECTION) {
1121
+ if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1122
+ echo "<script type='text/javascript' src='", plugins_url ('includes/js/ads.js?', __FILE__ ), "'></script>\n";
1123
+ echo "<script type='text/javascript' src='", plugins_url ('includes/js/sponsors.js?', __FILE__ ), "'></script>\n";
1124
+ }
1125
+ }
1126
+
1127
+ $inline_scripts = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE || $ai_wp_data [AI_TRACKING] || $ai_wp_data [AI_STICKY_WIDGETS] || (defined ('AI_ADBLOCKER_DETECTION') && AI_ADBLOCKER_DETECTION);
1128
 
1129
  if ($inline_scripts) echo "<script type='text/javascript'>\n";
1130
 
1167
 
1168
  // echo 'jQuery(document).ready(function($) {
1169
  // var sticky_widget_margin = ', get_sticky_widget_margin (), ';
1170
+ // var document_width = $(document).width();
1171
+
1172
+ // $(".ai-sticky").each (function () {
1173
+ // var widget = $(this);
1174
+ // var widget_width = widget.width();
1175
+ //// console.log ("WIDGET:", widget.width (), widget.prop ("tagName"), widget.attr ("id"));
1176
+ // var sidebar = widget.parent ();
1177
+ // while (sidebar.prop ("tagName") != "BODY") {
1178
+ //// console.log ("SIDEBAR:", sidebar.width (), sidebar.prop ("tagName"), sidebar.attr ("id"));
1179
+ // var parent_element = sidebar.parent ();
1180
+ // var parent_element_width = parent_element.width();
1181
+ // if (parent_element_width > widget_width * 1.2 || parent_element_width > document_width / 2) break;
1182
+ // sidebar = parent_element;
1183
+ // }
1184
+ // var new_sidebar_top = sidebar.offset ().top - widget.offset ().top + sticky_widget_margin;
1185
+ //// console.log ("NEW SIDEBAR TOP:", new_sidebar_top);
1186
+ // if (sidebar.css ("position") != "sticky" || isNaN (parseInt (sidebar.css ("top"))) || sidebar.css ("top") < new_sidebar_top) {
1187
+ // sidebar.css ("position", "sticky").css ("top", new_sidebar_top);
1188
+ //// console.log ("SET SIDEBAR TOP:", new_sidebar_top);
1189
  // }
1190
  // });
1191
  // });
1192
  //';
1193
 
1194
+ echo 'jQuery(document).ready(function($){var sticky_widget_margin=', get_sticky_widget_margin (), ';var document_width=$(document).width();$(".ai-sticky").each(function(){var widget=$(this);var widget_width=widget.width();var sidebar=widget.parent();while(sidebar.prop("tagName")!="BODY"){var parent_element=sidebar.parent();var parent_element_width=parent_element.width();if(parent_element_width>widget_width*1.2||parent_element_width>document_width/2)break;sidebar=parent_element}var new_sidebar_top=sidebar.offset().top-widget.offset().top+
1195
+ 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)})});';
1196
 
1197
  }
1198
 
1199
+ if (defined ('AI_ADBLOCKER_DETECTION') && AI_ADBLOCKER_DETECTION) {
1200
+ if (!function_exists ('add_footer_inline_scripts_2')) echo ai_adb_code ();
1201
+ }
1202
+
1203
  if (function_exists ('add_footer_inline_scripts_2')) {
1204
  add_footer_inline_scripts_2 ();
1205
  }
1440
  update_post_meta ($post_id, '_adinserter_block_exceptions', implode (",", $selected));
1441
  }
1442
 
 
 
 
 
1443
  function ai_widgets_init_hook () {
1444
  if (is_multisite() && !is_main_site () && !multisite_widgets_enabled ()) return;
1445
  register_widget ('ai_widget');
1446
  }
1447
 
1448
+ function get_page_type_debug_info () {
1449
+ global $ai_wp_data;
1450
+
1451
+ switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
1452
+ case AI_PT_STATIC:
1453
+ $page_type = 'STATIC PAGE';
1454
+ break;
1455
+ case AI_PT_POST:
1456
+ $page_type = 'POST';
1457
+ break;
1458
+ case AI_PT_HOMEPAGE:
1459
+ $page_type = 'HOMEPAGE';
1460
+ break;
1461
+ case AI_PT_CATEGORY:
1462
+ $page_type = 'CATEGORY PAGE';
1463
+ break;
1464
+ case AI_PT_SEARCH:
1465
+ $page_type = 'SEARCH PAGE';
1466
+ break;
1467
+ case AI_PT_ARCHIVE:
1468
+ $page_type = 'ARCHIVE PAGE';
1469
+ break;
1470
+ case AI_PT_404:
1471
+ $page_type = 'ERROR 404 PAGE';
1472
+ break;
1473
+ case AI_PT_AJAX:
1474
+ $page_type = 'AJAX CALL';
1475
+ break;
1476
+ default:
1477
+ $page_type = 'UNKNOWN PAGE TYPE';
1478
+ break;
1479
+ }
1480
+ $style = AI_DEBUG_PAGE_TYPE_STYLE;
1481
+
1482
+ return "<section style='$style'>".$page_type."</section>";
1483
+ }
1484
+
1485
+
1486
  function ai_wp_head_hook () {
1487
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1488
 
1502
 
1503
  if ($obj->get_enable_manual ()) {
1504
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1505
+ echo do_shortcode ($obj->ai_getCode ());
1506
+ }
1507
+
1508
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1509
+ echo "<script>
1510
+ jQuery(document).ready(function($) {
1511
+ $('body').prepend (\"", get_page_type_debug_info () , "\");
1512
+ });
1513
+ </script>\n";
1514
  }
1515
 
1516
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1538
 
1539
  if ($obj->get_enable_manual ()) {
1540
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 && !$obj->get_enable_404()) return;
1541
+ echo do_shortcode ($obj->ai_getCode ());
1542
+ }
1543
+
1544
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1545
+ echo get_page_type_debug_info () , "\n";
1546
  }
1547
 
1548
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1593
  case AI_PT_ARCHIVE: echo "ARCHIVE PAGE"; break;
1594
  case AI_PT_SEARCH: echo "SEARCH PAGE"; break;
1595
  case AI_PT_404: echo "404 PAGE"; break;
1596
+ case AI_PT_ADMIN: echo "ADMIN"; break;
1597
  case AI_PT_FEED: echo "FEED"; break;
1598
+ case AI_PT_AJAX: echo "AJAX"; break;
1599
+ case AI_PT_ANY: echo "ANY ?"; break;
1600
+ case AI_PT_NONE: echo "NONE ?"; break;
1601
  default: echo "?"; break;
1602
  }
1603
  echo "\n";
1604
+
1605
+ switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
1606
+ case AI_PT_STATIC:
1607
+ case AI_PT_POST:
1608
+ echo 'POST TYPE: ', get_post_type (), "\n";
1609
+ $category_data = get_the_category();
1610
+ $categories = array ();
1611
+ foreach ($category_data as $category) {
1612
+ $categories []= $category->slug;
1613
+ }
1614
+ echo 'CATEGORIES: ', implode (', ', $categories), "\n";
1615
+ $tag_data = wp_get_post_tags (get_the_ID());
1616
+ $tags = array ();
1617
+ foreach ($tag_data as $tag) {
1618
+ $tags []= $tag->slug;
1619
+ }
1620
+ echo 'TAGS: ', implode (', ', $tags), "\n";
1621
+ $taxonomies = array ();
1622
+ $taxonomy_names = get_post_taxonomies ();
1623
+ foreach ($taxonomy_names as $taxonomy_name) {
1624
+ $terms = get_the_terms (0, $taxonomy_name);
1625
+ if (is_array ($terms)) {
1626
+ foreach ($terms as $term) {
1627
+ $taxonomies [] = strtolower ($term->taxonomy) . ':' . strtolower ($term->slug);
1628
+ }
1629
+ }
1630
+ }
1631
+ echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
1632
+ echo 'ID: ', get_the_ID(), "\n";
1633
+ }
1634
+
1635
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1636
  echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
1637
  if (function_exists ('ai_debug')) ai_debug ();
1816
  echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
1817
  if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
1818
  echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
1819
+ if (count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
1820
+ echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
1821
+ if (count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
1822
+ echo "BETWEEN COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
1823
+ if (count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
1824
+ echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
1825
 
1826
 
1827
+ echo "\nBLOCKS FOR THIS PAGE TYPE\n";
1828
+ if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1829
  echo "CONTENT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1830
+ if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1831
  echo "EXCERPT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1832
+ if (isset ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1833
  echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1834
+ if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1835
  echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1836
+ if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1837
  echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1838
+ if (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1839
+ echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1840
+ if (isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1841
+ echo "BETWEEN COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1842
+ if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
1843
+ echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
1844
 
1845
  if ($write_processing_log) {
1846
  echo "\nTIME EVENT\n";
1882
  $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST ||
1883
  $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY ||
1884
  $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH ||
1885
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE ||
1886
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 ||
1887
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_NONE ||
1888
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ANY) {
1889
  echo "\n<!--\n\n";
1890
  ai_write_debug_info (true);
1891
  echo "\n-->\n";
2323
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
2324
  }
2325
 
2326
+ elseif (isset ($_GET ["rating"])) {
2327
+ $cache_time = $_GET ["rating"] == 'update' ? 5 * 60 : 24 * 3600;
2328
+ if (!file_exists (AI_RATING_FILE) || time () - filemtime (AI_RATING_FILE) > $cache_time) {
2329
+ if (preg_match_all ("#<span class=\"counter-count\">(.+?)</span>#", file_get_contents ('https://wordpress.org/plugins/ad-inserter/'), $ratings)) {
2330
+ if (count ($ratings [1]) == 5) {
2331
+ $total_rating = 0;
2332
+ $total_count = 0;
2333
+ foreach ($ratings [1] as $index => $count) {
2334
+ $total_rating += (5 - $index) * $count;
2335
+ $total_count += $count;
2336
+ }
2337
+ $rating = number_format ($total_rating / $total_count, 4);
2338
+ file_put_contents (AI_RATING_FILE, $rating);
2339
+ }
2340
+ }
2341
+ }
2342
+ if (file_exists (AI_RATING_FILE)) {
2343
+ $rating = file_get_contents (AI_RATING_FILE);
2344
+ if ($rating > 1 && $rating <= 5) echo $rating;
2345
+ }
2346
+ }
2347
+
2348
  elseif (function_exists ('ai_data_ajax')) {
2349
  ai_data_ajax ();
2350
  }
2357
  $obj = new ai_Block (1);
2358
 
2359
  $extract = array ();
2360
+ $content_hook_blocks = array ();
2361
+ $excerpt_hook_blocks = array ();
2362
+ $loop_start_hook_blocks = array ();
2363
+ $loop_end_hook_blocks = array ();
2364
+ $post_hook_blocks = array ();
2365
+ $before_comments_hook_blocks = array ();
2366
+ $between_comments_hook_blocks = array ();
2367
+ $after_comments_hook_blocks = array ();
2368
+
2369
+ $content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2370
+ $excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2371
+ $loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2372
+ $loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2373
+ $post_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2374
+ $before_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2375
+ $between_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2376
+ $after_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array());
2377
 
2378
  // Generate extracted data
2379
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2420
  foreach ($page_types as $block_page_type) $post_hook_blocks [$block_page_type][]= $block;
2421
  $post_hook_blocks [AI_PT_ANY][]= $block;
2422
  break;
2423
+ case AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS:
2424
+ foreach ($page_types as $block_page_type) $before_comments_hook_blocks [$block_page_type][]= $block;
2425
+ $before_comments_hook_blocks [AI_PT_ANY][]= $block;
2426
+ break;
2427
+ case AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS:
2428
+ foreach ($page_types as $block_page_type) $between_comments_hook_blocks [$block_page_type][]= $block;
2429
+ $between_comments_hook_blocks [AI_PT_ANY][]= $block;
2430
+ break;
2431
+ case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS:
2432
+ foreach ($page_types as $block_page_type) $after_comments_hook_blocks [$block_page_type][]= $block;
2433
+ $after_comments_hook_blocks [AI_PT_ANY][]= $block;
2434
+ break;
2435
  }
2436
  }
2437
  }
2438
 
2439
+ $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
2440
+ $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
2441
+ $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
2442
+ $extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks;
2443
+ $extract [POST_HOOK_BLOCKS] = $post_hook_blocks;
2444
+ $extract [BEFORE_COMMENTS_HOOK_BLOCKS] = $before_comments_hook_blocks;
2445
+ $extract [BETWEEN_COMMENTS_HOOK_BLOCKS] = $between_comments_hook_blocks;
2446
+ $extract [AFTER_COMMENTS_HOOK_BLOCKS] = $after_comments_hook_blocks;
2447
 
2448
  return ($extract);
2449
  }
2458
  if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) &&
2459
  isset ($ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION']) && $ai_db_options [AI_GLOBAL_OPTION_NAME]['VERSION'] == $version_string &&
2460
  isset ($ai_db_options_extract [POST_HOOK_BLOCKS]) &&
2461
+ isset ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
2462
+ isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS]))
2463
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
2464
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
2465
 
2930
  $ai_last_check = AI_CHECK_NONE;
2931
  $current_block = 0;
2932
 
2933
+ if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
2934
  foreach ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
2935
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
2936
 
3074
  $ai_last_check = AI_CHECK_NONE;
3075
  $current_block = 0;
3076
 
3077
+ if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
3078
  foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3079
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3080
 
3166
 
3167
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
3168
 
 
 
3169
  $counter = $ad_inserter_globals [$globals_name];
3170
  if ($counter == 1) $counter = '';
3171
 
3172
+ $style = AI_DEBUG_POSITIONS_STYLE;
3173
+
3174
  echo "<section style='$style'>".($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? "BEFORE" : "AFTER")." POST ".$counter."</section>";
3175
  }
3176
 
3184
  $ai_last_check = AI_CHECK_NONE;
3185
  $current_block = 0;
3186
 
3187
+
3188
+ $extract_index = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST ? LOOP_START_HOOK_BLOCKS : LOOP_END_HOOK_BLOCKS;
3189
+ if (isset ($ai_db_options_extract [$extract_index][$ai_wp_data [AI_WP_PAGE_TYPE]]))
3190
+ foreach ($ai_db_options_extract [$extract_index][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3191
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3192
 
3193
  if (!isset ($block_object [$block])) continue;
3254
 
3255
  // Process Between Posts postion
3256
  function ai_post_hook ($post) {
3257
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
 
3258
 
3259
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
3260
 
3289
  $ai_last_check = AI_CHECK_NONE;
3290
  $current_block = 0;
3291
 
3292
+ if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
3293
  foreach ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3294
  if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3295
 
3329
  return $post;
3330
  }
3331
 
3332
+ function ai_comments_array ($comments , $post_id ){
3333
+ global $ai_wp_data;
3334
+
3335
+ $thread_comments = get_option ('thread_comments');
3336
+ $comment_counter = 0;
3337
+ foreach ($comments as $comment) {
3338
+ if (!$thread_comments || empty ($comment->comment_parent))
3339
+ $comment_counter ++;
3340
+ }
3341
+ $ai_wp_data [AI_NUMBER_OF_COMMENTS] = $comment_counter;
3342
+
3343
+ return $comments;
3344
+ }
3345
+
3346
+ function ai_wp_list_comments_args ($args) {
3347
+ global $ai_wp_data;
3348
+
3349
+ // print_r ($args);
3350
+ // $args['per_page'] = 3;
3351
+ // $args['page'] = 2;
3352
+
3353
+ $ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'] = $args ['callback'];
3354
+ $args ['callback'] = 'ai_comment_callback';
3355
+
3356
+ $ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'] = $args ['end-callback'];
3357
+ $args ['end-callback'] = 'ai_comment_end_callback';
3358
+
3359
+ return $args;
3360
+ }
3361
+
3362
+ // Process comments counter + Before Comments postion
3363
+ function ai_comment_callback ($comment, $args, $depth) {
3364
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $ai_walker;
3365
+
3366
+ if ($depth == 1) {
3367
+ if (!isset ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) {
3368
+ $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] = 1;
3369
+ } else $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] ++;
3370
+ }
3371
+
3372
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
3373
+ if ($debug_processing) {
3374
+ ai_log ('COMMENT START HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. $depth . ']');
3375
+ $start_time = microtime (true);
3376
+ }
3377
+
3378
+ if ($depth == 1 && $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == 1) {
3379
+
3380
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BEFORE_COMMENTS;
3381
+
3382
+ if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li';
3383
+
3384
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
3385
+
3386
+ $style = AI_DEBUG_POSITIONS_STYLE;
3387
+
3388
+ echo "<$tag>\n";
3389
+ echo "<section style='$style'>BEFORE COMMENTS</section>";
3390
+ echo "</$tag>\n";
3391
+ }
3392
+
3393
+ $ad_code = "";
3394
+
3395
+ $ai_last_check = AI_CHECK_NONE;
3396
+ $current_block = 0;
3397
+
3398
+ if (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
3399
+ foreach ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3400
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3401
+
3402
+ if (!isset ($block_object [$block])) continue;
3403
+
3404
+ $current_block = $block;
3405
+
3406
+ $obj = $block_object [$block];
3407
+ $obj->clear_code_cache ();
3408
+
3409
+ if (!$obj->check_server_side_detection ()) continue;
3410
+ if (!$obj->check_page_types_lists_users ()) continue;
3411
+ // No filter check
3412
+
3413
+ // Last check before counter check before insertion
3414
+ $ai_last_check = AI_CHECK_CODE;
3415
+ if ($obj->ai_getCode () == '') continue;
3416
+
3417
+ // Last check before insertion
3418
+ if (!$obj->check_and_increment_block_counter ()) continue;
3419
+
3420
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3421
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3422
+ $ad_code .= $obj->get_code_for_insertion ();
3423
+ $ai_last_check = AI_CHECK_INSERTED;
3424
+ }
3425
+ }
3426
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3427
+
3428
+ echo "<$tag>\n";
3429
+ echo $ad_code;
3430
+ echo "</$tag>\n";
3431
+ }
3432
+
3433
+ if ($debug_processing) {
3434
+ $ai_total_plugin_time += microtime (true) - $start_time;
3435
+ ai_log ("COMMENT END HOOK END\n");
3436
+ }
3437
+
3438
+ if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'])) {
3439
+ echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'], $comment, $args, $depth );
3440
+ } else {
3441
+ $ai_walker->comment_callback ($comment, $args, $depth);
3442
+ }
3443
+ }
3444
+
3445
+ // Process Between Comments postion
3446
+ function ai_comment_end_callback ($comment, $args, $depth) {
3447
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
3448
+
3449
+ if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li';
3450
+
3451
+ if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'])) {
3452
+ echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'], $comment, $args, $depth);
3453
+ } else echo "</$tag><!-- #comment-## -->\n";
3454
+
3455
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
3456
+ if ($debug_processing) {
3457
+ ai_log ('COMMENT END HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. ($depth + 1) . ']');
3458
+ $start_time = microtime (true);
3459
+ }
3460
+
3461
+ if ($depth == 0) {
3462
+
3463
+ if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) &&
3464
+ $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] != 0 &&
3465
+ !empty ($args ['per_page']) && !empty ($args ['page'])) {
3466
+ $number_of_comments_mod_per_page = $ai_wp_data [AI_NUMBER_OF_COMMENTS] % $args ['per_page'];
3467
+ if ($number_of_comments_mod_per_page != 0) {
3468
+ $last_page = (int) ($ai_wp_data [AI_NUMBER_OF_COMMENTS] / $args ['per_page']) + 1;
3469
+ $last_comment_number = $args ['page'] == $last_page ? $number_of_comments_mod_per_page : $args ['per_page'];
3470
+ } else $last_comment_number = $args ['per_page'];
3471
+ } else $last_comment_number = $ai_wp_data [AI_NUMBER_OF_COMMENTS];
3472
+
3473
+ if ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == $last_comment_number) {
3474
+
3475
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_AFTER_COMMENTS;
3476
+
3477
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
3478
+
3479
+ $style = AI_DEBUG_POSITIONS_STYLE;
3480
+
3481
+ echo "<$tag>\n";
3482
+ echo "<section style='$style'>AFTER COMMENTS</section>";
3483
+ echo "</$tag>\n";
3484
+ }
3485
+
3486
+ $ad_code = "";
3487
+
3488
+ $ai_last_check = AI_CHECK_NONE;
3489
+ $current_block = 0;
3490
+
3491
+ if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
3492
+ foreach ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3493
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3494
+
3495
+ if (!isset ($block_object [$block])) continue;
3496
+
3497
+ $current_block = $block;
3498
+
3499
+ $obj = $block_object [$block];
3500
+ $obj->clear_code_cache ();
3501
+
3502
+ if (!$obj->check_server_side_detection ()) continue;
3503
+ if (!$obj->check_page_types_lists_users ()) continue;
3504
+ // No filter check
3505
+
3506
+ // Last check before counter check before insertion
3507
+ $ai_last_check = AI_CHECK_CODE;
3508
+ if ($obj->ai_getCode () == '') continue;
3509
+
3510
+ // Last check before insertion
3511
+ if (!$obj->check_and_increment_block_counter ()) continue;
3512
+
3513
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3514
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3515
+ $ad_code .= $obj->get_code_for_insertion ();
3516
+ $ai_last_check = AI_CHECK_INSERTED;
3517
+ }
3518
+ }
3519
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3520
+
3521
+ echo "<$tag>\n";
3522
+ echo $ad_code;
3523
+ echo "</$tag>\n";
3524
+ } else {
3525
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_COMMENTS;
3526
+
3527
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
3528
+
3529
+ $style = AI_DEBUG_POSITIONS_STYLE;
3530
+
3531
+ echo "<$tag>\n";
3532
+ echo "<section style='$style'>BETWEEN COMMENTS ".$ad_inserter_globals [AI_COMMENT_COUNTER_NAME]."</section>";
3533
+ echo "</$tag>\n";
3534
+ }
3535
+
3536
+ $ad_code = "";
3537
+
3538
+ $ai_last_check = AI_CHECK_NONE;
3539
+ $current_block = 0;
3540
+
3541
+ if (isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
3542
+ foreach ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
3543
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3544
+
3545
+ if (!isset ($block_object [$block])) continue;
3546
+
3547
+ $current_block = $block;
3548
+
3549
+ $obj = $block_object [$block];
3550
+ $obj->clear_code_cache ();
3551
+
3552
+ if (!$obj->check_server_side_detection ()) continue;
3553
+ if (!$obj->check_page_types_lists_users ()) continue;
3554
+ if (!$obj->check_filter ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) continue;
3555
+
3556
+ // Last check before counter check before insertion
3557
+ $ai_last_check = AI_CHECK_CODE;
3558
+ if ($obj->ai_getCode () == '') continue;
3559
+
3560
+ // Last check before insertion
3561
+ if (!$obj->check_and_increment_block_counter ()) continue;
3562
+
3563
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3564
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3565
+ $ad_code .= $obj->get_code_for_insertion ();
3566
+ $ai_last_check = AI_CHECK_INSERTED;
3567
+ }
3568
+ }
3569
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
3570
+
3571
+ echo "<$tag>\n";
3572
+ echo $ad_code;
3573
+ echo "</$tag>\n";
3574
+ }
3575
+ }
3576
+
3577
+ if ($debug_processing) {
3578
+ $ai_total_plugin_time += microtime (true) - $start_time;
3579
+ ai_log ("COMMENT END HOOK END\n");
3580
+ }
3581
+ }
3582
+
3583
  function process_shortcode (&$block, $atts) {
3584
  global $block_object, $ai_last_check, $ai_wp_data;
3585
 
3780
  }
3781
  }
3782
 
3783
+ function ai_add_attr_data (&$tag, $attr, $new_data) {
3784
+
3785
+ if (trim ($tag) != '' && strpos ($tag, '<!--') === false) {
3786
+ if (stripos ($tag, $attr."=") !== false) {
3787
+ preg_match ("/$attr=[\'\"](.+?)[\'\"]/", $tag, $classes);
3788
+ $tag = str_replace ($classes [1], $classes [1]. ' ' . $new_data, $tag);
3789
+ return true;
3790
+ }
3791
+ elseif (strpos ($tag, ">") !== false) {
3792
+ $tag = str_replace ('>', ' ' . $attr . '="' . $new_data . '">', $tag);
3793
+ return true;
3794
+ }
3795
+ }
3796
+
3797
+ return false;
3798
+ }
3799
 
3800
  function ai_widget_draw ($args, $instance, &$block) {
3801
  global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
3812
  if ($sticky) {
3813
  $ai_wp_data [AI_STICKY_WIDGETS] = true;
3814
  if ($block == - 1) {
3815
+ $before_widget = $args ['before_widget'];
3816
+ ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;');
3817
+ ai_add_attr_data ($before_widget, 'class', 'ai-sticky');
3818
+ echo $before_widget;
3819
+ echo $args ['after_widget'];
3820
  return;
3821
  }
3822
  }
3834
  $ad_inserter_globals [$globals_name] = 1;
3835
  } else $ad_inserter_globals [$globals_name] ++;
3836
 
3837
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0)
3838
+ ai_log ("WIDGET (". $obj->number . ') ['.$ad_inserter_globals [$globals_name] . ']');
3839
 
3840
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET;
3841
 
3855
  // Last check before counter check before insertion
3856
  $ai_last_check = AI_CHECK_CODE;
3857
  if ($obj->ai_getCode () == '') {
3858
+ if ($sticky) {
3859
+ $before_widget = $args ['before_widget'];
3860
+ ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;');
3861
+ ai_add_attr_data ($before_widget, 'class', 'ai-sticky');
3862
+ echo $before_widget;
3863
+ echo $args ['after_widget'];
3864
+ }
3865
  return;
3866
  }
3867
 
3870
 
3871
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3872
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3873
+
3874
  $viewport_classes = trim ($obj->get_viewport_classes ());
3875
  $sticky_class = $sticky ? ' ai-sticky' : '';
3876
  $widget_classes = trim ($viewport_classes . $sticky_class);
 
3877
 
3878
+ if ($widget_classes != "") {
3879
+ $before_widget = $args ['before_widget'];
3880
+ ai_add_attr_data ($before_widget, 'class', $widget_classes);
3881
+ echo $before_widget;
3882
+ } else echo $args ['before_widget'];
3883
 
3884
  if (!empty ($title)) {
3885
  echo $args ['before_title'], apply_filters ('widget_title', $title), $args ['after_title'];
3889
 
3890
  echo $args ['after_widget'];
3891
 
 
 
3892
  $ai_last_check = AI_CHECK_INSERTED;
3893
 
3894
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $obj->get_detection_client_side())
3901
 
3902
  $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
3903
 
 
 
3904
  if ($sticky) {
3905
  $ai_wp_data [AI_STICKY_WIDGETS] = true;
3906
+ echo ai_add_attr_data ($args ['before_widget'], 'class', 'ai-sticky');
3907
+ } else echo $args ['before_widget'];
3908
 
3909
  $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
3910
 
class.php CHANGED
@@ -409,6 +409,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
409
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
410
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
411
  $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
 
 
412
  $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AI_ENABLED;
413
  $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AI_DISABLED;
414
  $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AI_DISABLED;
@@ -487,6 +489,15 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
487
  case AI_AUTOMATIC_INSERTION_BETWEEN_POSTS:
488
  return AI_TEXT_BETWEEN_POSTS;
489
  break;
 
 
 
 
 
 
 
 
 
490
  default:
491
  return '';
492
  break;
@@ -993,7 +1004,22 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
993
  public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false){
994
  global $ai_wp_data, $ad_inserter_globals, $block_object;
995
 
996
- $processed_code = do_shortcode ($this->replace_ai_tags ($this->ai_getCode ()));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
997
  $dynamic_blocks = get_dynamic_blocks ();
998
  if ($force_server_side_code || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
999
 
@@ -1245,6 +1271,17 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1245
  return $option;
1246
  }
1247
 
 
 
 
 
 
 
 
 
 
 
 
1248
  public function get_ad_enabled_on_which_pages (){
1249
  $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] : "";
1250
  if ($option == '') $option = AD_ENABLED_ON_ALL;
@@ -2316,6 +2353,76 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2316
  }
2317
  }
2318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2319
  function check_id () {
2320
  global $ai_wp_data;
2321
 
@@ -2570,6 +2677,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2570
  $ai_last_check = AI_CHECK_TAG;
2571
  if (!$this->check_tag ()) return false;
2572
 
 
 
 
2573
  $ai_last_check = AI_CHECK_ID;
2574
  if (!$this->check_id ()) return false;
2575
 
@@ -2677,6 +2787,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2677
  if (isset ($ad_inserter_globals [AI_POST_COUNTER_NAME]))
2678
  $counter_for_filter = $ad_inserter_globals [AI_POST_COUNTER_NAME]; else return false;
2679
  break;
 
 
 
 
2680
  }
2681
 
2682
  $filter_values = array ();
@@ -2923,3 +3037,18 @@ class ai_AdF extends ai_BaseCodeBlock {
2923
  parent::__construct();
2924
  }
2925
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AD_BLACK_LIST;
410
  $this->wp_options [AI_OPTION_TAG_LIST] = AD_EMPTY_DATA;
411
  $this->wp_options [AI_OPTION_TAG_LIST_TYPE] = AD_BLACK_LIST;
412
+ $this->wp_options [AI_OPTION_TAXONOMY_LIST] = AD_EMPTY_DATA;
413
+ $this->wp_options [AI_OPTION_TAXONOMY_LIST_TYPE] = AD_BLACK_LIST;
414
  $this->wp_options [AI_OPTION_DISPLAY_ON_POSTS] = AI_ENABLED;
415
  $this->wp_options [AI_OPTION_DISPLAY_ON_PAGES] = AI_DISABLED;
416
  $this->wp_options [AI_OPTION_DISPLAY_ON_HOMEPAGE] = AI_DISABLED;
489
  case AI_AUTOMATIC_INSERTION_BETWEEN_POSTS:
490
  return AI_TEXT_BETWEEN_POSTS;
491
  break;
492
+ case AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS:
493
+ return AI_TEXT_BEFORE_COMMENTS;
494
+ break;
495
+ case AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS:
496
+ return AI_TEXT_BETWEEN_COMMENTS;
497
+ break;
498
+ case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS:
499
+ return AI_TEXT_AFTER_COMMENTS;
500
+ break;
501
  default:
502
  return '';
503
  break;
1004
  public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false){
1005
  global $ai_wp_data, $ad_inserter_globals, $block_object;
1006
 
1007
+ $code = $this->ai_getCode ();
1008
+
1009
+ if (strpos ($code, AD_COUNT_SEPARATOR) !== false) {
1010
+ $ads = explode (AD_COUNT_SEPARATOR, $code);
1011
+
1012
+ if (isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number])) {
1013
+ $counter_for_filter = $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number];
1014
+
1015
+ if ($counter_for_filter != 0 && $counter_for_filter <= count ($ads)) {
1016
+ $code = $ads [$counter_for_filter - 1];
1017
+ } else $code = '';
1018
+ } else $code = $ads [rand (0, count ($ads) - 1)];
1019
+ }
1020
+
1021
+ $processed_code = do_shortcode ($this->replace_ai_tags ($code));
1022
+
1023
  $dynamic_blocks = get_dynamic_blocks ();
1024
  if ($force_server_side_code || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
1025
 
1271
  return $option;
1272
  }
1273
 
1274
+ public function get_ad_block_taxonomy(){
1275
+ $option = isset ($this->wp_options [AI_OPTION_TAXONOMY_LIST]) ? $this->wp_options [AI_OPTION_TAXONOMY_LIST] : "";
1276
+ return $option;
1277
+ }
1278
+
1279
+ public function get_ad_block_taxonomy_type(){
1280
+ $option = isset ($this->wp_options [AI_OPTION_TAXONOMY_LIST_TYPE]) ? $this->wp_options [AI_OPTION_TAXONOMY_LIST_TYPE] : "";
1281
+ if ($option == '') $option = AD_BLACK_LIST;
1282
+ return $option;
1283
+ }
1284
+
1285
  public function get_ad_enabled_on_which_pages (){
1286
  $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] : "";
1287
  if ($option == '') $option = AD_ENABLED_ON_ALL;
2353
  }
2354
  }
2355
 
2356
+ function check_taxonomy () {
2357
+
2358
+ $taxonomies = trim (strtolower ($this->get_ad_block_taxonomy()));
2359
+ $taxonomy_type = $this->get_ad_block_taxonomy_type();
2360
+
2361
+ if ($taxonomy_type == AD_BLACK_LIST) {
2362
+
2363
+ if ($taxonomies == AD_EMPTY_DATA) return true;
2364
+
2365
+ $taxonomies_listed = explode (",", $taxonomies);
2366
+
2367
+ $taxonomy_names = get_post_taxonomies ();
2368
+ foreach ($taxonomy_names as $taxonomy_name) {
2369
+ $terms = get_the_terms (0, $taxonomy_name);
2370
+ if (is_array ($terms)) {
2371
+ foreach ($terms as $term) {
2372
+
2373
+ foreach ($taxonomies_listed as $taxonomy_disabled){
2374
+
2375
+ $taxonomy_disabled = trim ($taxonomy_disabled);
2376
+
2377
+ $post_term_name = strtolower ($term->name);
2378
+ $post_term_slug = strtolower ($term->slug);
2379
+ $post_taxonomy = strtolower ($term->taxonomy);
2380
+
2381
+ if ($post_term_name == $taxonomy_disabled || $post_term_slug == $taxonomy_disabled) return false;
2382
+
2383
+ $post_taxonomy = strtolower ($term->taxonomy);
2384
+ if ($post_taxonomy == $taxonomy_disabled) return false;
2385
+
2386
+ if ($post_taxonomy . ':' . $post_term_slug == $taxonomy_disabled) return false;
2387
+ }
2388
+ }
2389
+ }
2390
+ }
2391
+ return true;
2392
+
2393
+ } else {
2394
+
2395
+ if ($taxonomies == AD_EMPTY_DATA) return false;
2396
+
2397
+ $taxonomies_listed = explode (",", $taxonomies);
2398
+
2399
+ $taxonomy_names = get_post_taxonomies ();
2400
+ foreach ($taxonomy_names as $taxonomy_name) {
2401
+ $terms = get_the_terms (0, $taxonomy_name);
2402
+ if (is_array ($terms)) {
2403
+ foreach ($terms as $term) {
2404
+
2405
+ foreach ($taxonomies_listed as $taxonomy_enabled) {
2406
+
2407
+ $taxonomy_enabled = trim ($taxonomy_enabled);
2408
+
2409
+ $post_term_name = strtolower ($term->name);
2410
+ $post_term_slug = strtolower ($term->slug);
2411
+
2412
+ if ($post_term_name == $taxonomy_enabled || $post_term_slug == $taxonomy_enabled) return true;
2413
+
2414
+ $post_taxonomy = strtolower ($term->taxonomy);
2415
+ if ($post_taxonomy == $taxonomy_enabled) return true;
2416
+
2417
+ if ($post_taxonomy . ':' . $post_term_slug == $taxonomy_enabled) return true;
2418
+ }
2419
+ }
2420
+ }
2421
+ }
2422
+ return false;
2423
+ }
2424
+ }
2425
+
2426
  function check_id () {
2427
  global $ai_wp_data;
2428
 
2677
  $ai_last_check = AI_CHECK_TAG;
2678
  if (!$this->check_tag ()) return false;
2679
 
2680
+ $ai_last_check = AI_CHECK_TAXONOMY;
2681
+ if (!$this->check_taxonomy ()) return false;
2682
+
2683
  $ai_last_check = AI_CHECK_ID;
2684
  if (!$this->check_id ()) return false;
2685
 
2787
  if (isset ($ad_inserter_globals [AI_POST_COUNTER_NAME]))
2788
  $counter_for_filter = $ad_inserter_globals [AI_POST_COUNTER_NAME]; else return false;
2789
  break;
2790
+ case AI_OPTION_FILTER_COMMENTS:
2791
+ if (isset ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME]))
2792
+ $counter_for_filter = $ad_inserter_globals [AI_COMMENT_COUNTER_NAME]; else return false;
2793
+ break;
2794
  }
2795
 
2796
  $filter_values = array ();
3037
  parent::__construct();
3038
  }
3039
  }
3040
+
3041
+ class ai_Walker_Comment extends Walker_Comment {
3042
+
3043
+ public function comment_callback ($comment, $args, $depth) {
3044
+ if (($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback') && $args ['short_ping']) {
3045
+ $this->ping ($comment, $depth, $args);
3046
+ } elseif ($args['format'] === 'html5') {
3047
+ $this->html5_comment ($comment, $depth, $args);
3048
+ } else {
3049
+ $this->comment ($comment, $depth, $args);
3050
+ }
3051
+ }
3052
+
3053
+ }
3054
+
constants.php CHANGED
@@ -14,7 +14,7 @@ if (!defined( 'AD_INSERTER_NAME'))
14
  define ('AD_INSERTER_NAME', 'Ad Inserter');
15
 
16
  if (!defined( 'AD_INSERTER_VERSION'))
17
- define ('AD_INSERTER_VERSION', '2.1.9');
18
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -97,6 +97,8 @@ define ('AI_OPTION_CATEGORY_LIST', 'category_list');
97
  define ('AI_OPTION_CATEGORY_LIST_TYPE', 'category_list_type');
98
  define ('AI_OPTION_TAG_LIST', 'tag_list');
99
  define ('AI_OPTION_TAG_LIST_TYPE', 'tag_list_type');
 
 
100
  define ('AI_OPTION_DISPLAY_ON_HOMEPAGE', 'display_on_homepage');
101
  define ('AI_OPTION_DISPLAY_ON_PAGES', 'display_on_pages');
102
  define ('AI_OPTION_DISPLAY_ON_POSTS', 'display_on_posts');
@@ -131,6 +133,7 @@ define('AI_FORM_CLEAR_STATISTICS','ai-clear-statistics');
131
 
132
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
133
  define('AD_ROTATE_SEPARATOR', '|rotate|');
 
134
 
135
  //form select options
136
  define('AD_SELECT_SELECTED','selected');
@@ -160,6 +163,9 @@ define('AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH', 6);
160
  define('AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT', 7);
161
  define('AI_AUTOMATIC_INSERTION_AFTER_EXCERPT', 8);
162
  define('AI_AUTOMATIC_INSERTION_BETWEEN_POSTS', 9);
 
 
 
163
 
164
  define('AI_TEXT_DISABLED', 'Disabled');
165
  define('AI_TEXT_BEFORE_POST', 'Before Post');
@@ -171,6 +177,9 @@ define('AI_TEXT_AFTER_PARAGRAPH', 'After Paragraph');
171
  define('AI_TEXT_BEFORE_EXCERPT', 'Before Excerpt');
172
  define('AI_TEXT_AFTER_EXCERPT', 'After Excerpt');
173
  define('AI_TEXT_BETWEEN_POSTS', 'Between Posts');
 
 
 
174
 
175
  //Display options
176
  define('AD_DISPLAY_ALL_USERS','all users');
@@ -256,6 +265,7 @@ define ('AI_OPTION_FILTER_AFTER_POST_PROCESSING', 'After post processing');
256
  define ('AI_OPTION_FILTER_WIDGET_DRAWING', 'Widget drawing');
257
  define ('AI_OPTION_FILTER_SUBPAGES', 'Subpages');
258
  define ('AI_OPTION_FILTER_POSTS', 'Posts');
 
259
 
260
  //Counter names
261
  define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
@@ -266,6 +276,7 @@ define ('AI_LOOP_BEFORE_COUNTER_NAME', 'AI_LOOP_BEFORE_COUNTER');
266
  define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_AFTER_COUNTER');
267
  define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
268
  define ('AI_POST_COUNTER_NAME', 'AI_POST_COUNTER');
 
269
 
270
  //Text List Type
271
  define('AD_CONTAIN','contain');
@@ -355,11 +366,14 @@ define ('DEFAULT_VIEWPORT_WIDTH_3', 0);
355
 
356
  define ('DEFAULT_COUNTRY_GROUP_NAME', "Group");
357
 
358
- define ('CONTENT_HOOK_BLOCKS', 'content_hook');
359
- define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
360
- define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
361
- define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
362
- define ('POST_HOOK_BLOCKS', 'post_hook');
 
 
 
363
 
364
  define ('AI_CHECK_NONE', - 1);
365
  define ('AI_CHECK_INSERTED', 0);
@@ -417,6 +431,7 @@ define ('AI_CHECK_IP_ADDRESS', 47);
417
  define ('AI_CHECK_PARAGRAPH_NUMBER', 48);
418
  define ('AI_CHECK_MIN_NUMBER_OF_WORDS', 49);
419
  define ('AI_CHECK_MAX_NUMBER_OF_WORDS', 50);
 
420
 
421
  define ('AI_PT_NONE', - 1);
422
  define ('AI_PT_ANY', 0);
@@ -431,21 +446,24 @@ define ('AI_PT_FEED', 8);
431
  define ('AI_PT_ADMIN', 9);
432
  define ('AI_PT_AJAX', 10);
433
 
434
- define ('AI_USER_NOT_SET', - 1);
435
  define ('AI_USER_NOT_LOGGED_IN', 0);
436
  define ('AI_USER_LOGGED_IN', 1);
437
  define ('AI_USER_ADMINISTRATOR', 2);
438
 
439
  define ('AI_WP_PAGE_TYPE', 0);
440
- define ('AI_WP_USER', 1);
441
- define ('AI_WP_DEBUGGING', 2);
442
- define ('AI_WP_DEBUG_BLOCK', 3);
443
- define ('AI_WP_URL', 4);
444
- define ('AI_SERVER_SIDE_DETECTION', 5);
445
- define ('AI_CLIENT_SIDE_DETECTION', 6);
446
- define ('AI_CONTEXT', 7);
447
- define ('AI_TRACKING', 8);
448
- define ('AI_STICKY_WIDGETS', 9);
 
 
 
 
449
 
450
  define ('AI_CONTEXT_NONE', 0);
451
  define ('AI_CONTEXT_CONTENT', 1);
@@ -458,6 +476,9 @@ define ('AI_CONTEXT_SHORTCODE', 7);
458
  define ('AI_CONTEXT_HEADER', 8);
459
  define ('AI_CONTEXT_FOOTER', 9);
460
  define ('AI_CONTEXT_BETWEEN_POSTS', 10);
 
 
 
461
 
462
  define ('AI_URL_DEBUG', 'ai-debug');
463
  define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing');
@@ -481,10 +502,18 @@ if (!defined ('AD_INSERTER_BLOCKS'))
481
  if (!defined ('AD_INSERTER_VIEWPORTS'))
482
  define ('AD_INSERTER_VIEWPORTS', 3);
483
 
 
 
484
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
485
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
 
486
  define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
487
 
488
- define ('SPECIAL_ELEMENT_TAGS', 'blockquote, figure, li');
 
 
 
 
 
489
 
490
 
14
  define ('AD_INSERTER_NAME', 'Ad Inserter');
15
 
16
  if (!defined( 'AD_INSERTER_VERSION'))
17
+ define ('AD_INSERTER_VERSION', '2.1.11');
18
 
19
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
20
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
97
  define ('AI_OPTION_CATEGORY_LIST_TYPE', 'category_list_type');
98
  define ('AI_OPTION_TAG_LIST', 'tag_list');
99
  define ('AI_OPTION_TAG_LIST_TYPE', 'tag_list_type');
100
+ define ('AI_OPTION_TAXONOMY_LIST', 'taxonomy_list');
101
+ define ('AI_OPTION_TAXONOMY_LIST_TYPE', 'taxonomy_list_type');
102
  define ('AI_OPTION_DISPLAY_ON_HOMEPAGE', 'display_on_homepage');
103
  define ('AI_OPTION_DISPLAY_ON_PAGES', 'display_on_pages');
104
  define ('AI_OPTION_DISPLAY_ON_POSTS', 'display_on_posts');
133
 
134
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
135
  define('AD_ROTATE_SEPARATOR', '|rotate|');
136
+ define('AD_COUNT_SEPARATOR', '|count|');
137
 
138
  //form select options
139
  define('AD_SELECT_SELECTED','selected');
163
  define('AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT', 7);
164
  define('AI_AUTOMATIC_INSERTION_AFTER_EXCERPT', 8);
165
  define('AI_AUTOMATIC_INSERTION_BETWEEN_POSTS', 9);
166
+ define('AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS', 10);
167
+ define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
168
+ define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
169
 
170
  define('AI_TEXT_DISABLED', 'Disabled');
171
  define('AI_TEXT_BEFORE_POST', 'Before Post');
177
  define('AI_TEXT_BEFORE_EXCERPT', 'Before Excerpt');
178
  define('AI_TEXT_AFTER_EXCERPT', 'After Excerpt');
179
  define('AI_TEXT_BETWEEN_POSTS', 'Between Posts');
180
+ define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
181
+ define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
182
+ define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
183
 
184
  //Display options
185
  define('AD_DISPLAY_ALL_USERS','all users');
265
  define ('AI_OPTION_FILTER_WIDGET_DRAWING', 'Widget drawing');
266
  define ('AI_OPTION_FILTER_SUBPAGES', 'Subpages');
267
  define ('AI_OPTION_FILTER_POSTS', 'Posts');
268
+ define ('AI_OPTION_FILTER_COMMENTS', 'Comments');
269
 
270
  //Counter names
271
  define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
276
  define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_AFTER_COUNTER');
277
  define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
278
  define ('AI_POST_COUNTER_NAME', 'AI_POST_COUNTER');
279
+ define ('AI_COMMENT_COUNTER_NAME', 'AI_COMMENT_COUNTER');
280
 
281
  //Text List Type
282
  define('AD_CONTAIN','contain');
366
 
367
  define ('DEFAULT_COUNTRY_GROUP_NAME', "Group");
368
 
369
+ define ('CONTENT_HOOK_BLOCKS', 'content_hook');
370
+ define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
371
+ define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
372
+ define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
373
+ define ('POST_HOOK_BLOCKS', 'post_hook');
374
+ define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
375
+ define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
376
+ define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
377
 
378
  define ('AI_CHECK_NONE', - 1);
379
  define ('AI_CHECK_INSERTED', 0);
431
  define ('AI_CHECK_PARAGRAPH_NUMBER', 48);
432
  define ('AI_CHECK_MIN_NUMBER_OF_WORDS', 49);
433
  define ('AI_CHECK_MAX_NUMBER_OF_WORDS', 50);
434
+ define ('AI_CHECK_TAXONOMY', 51);
435
 
436
  define ('AI_PT_NONE', - 1);
437
  define ('AI_PT_ANY', 0);
446
  define ('AI_PT_ADMIN', 9);
447
  define ('AI_PT_AJAX', 10);
448
 
 
449
  define ('AI_USER_NOT_LOGGED_IN', 0);
450
  define ('AI_USER_LOGGED_IN', 1);
451
  define ('AI_USER_ADMINISTRATOR', 2);
452
 
453
  define ('AI_WP_PAGE_TYPE', 0);
454
+ define ('AI_WP_USER_SET', 1);
455
+ define ('AI_WP_USER', 2);
456
+ define ('AI_WP_DEBUGGING', 3);
457
+ define ('AI_WP_DEBUG_BLOCK', 4);
458
+ define ('AI_WP_URL', 5);
459
+ define ('AI_SERVER_SIDE_DETECTION', 6);
460
+ define ('AI_CLIENT_SIDE_DETECTION', 7);
461
+ define ('AI_CONTEXT', 8);
462
+ define ('AI_TRACKING', 9);
463
+ define ('AI_STICKY_WIDGETS', 10);
464
+ define ('AI_NUMBER_OF_COMMENTS', 11);
465
+ define ('AI_COMMENTS_SAVED_CALLBACK', 12);
466
+ define ('AI_COMMENTS_SAVED_END_CALLBACK',13);
467
 
468
  define ('AI_CONTEXT_NONE', 0);
469
  define ('AI_CONTEXT_CONTENT', 1);
476
  define ('AI_CONTEXT_HEADER', 8);
477
  define ('AI_CONTEXT_FOOTER', 9);
478
  define ('AI_CONTEXT_BETWEEN_POSTS', 10);
479
+ define ('AI_CONTEXT_BEFORE_COMMENTS', 11);
480
+ define ('AI_CONTEXT_BETWEEN_COMMENTS', 12);
481
+ define ('AI_CONTEXT_AFTER_COMMENTS', 13);
482
 
483
  define ('AI_URL_DEBUG', 'ai-debug');
484
  define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing');
502
  if (!defined ('AD_INSERTER_VIEWPORTS'))
503
  define ('AD_INSERTER_VIEWPORTS', 3);
504
 
505
+ define ('AI_RATING_FILE', AD_INSERTER_PLUGIN_DIR.'includes/rating.txt');
506
+
507
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
508
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
509
+ define ('AI_DEBUG_PAGE_TYPE_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;');
510
  define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
511
 
512
+ define ('SPECIAL_ELEMENT_TAGS', 'blockquote, figure, li');
513
+
514
+ //define ('AI_ADBLOCKER_DETECTION', true);
515
+
516
+ define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
517
+
518
 
519
 
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.1.9"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -8,7 +8,7 @@
8
 
9
  .ui-widget {
10
  font-family: sans-serif,Arial,Verdana;
11
- font-size: 12px;
12
  }
13
 
14
  #ai-form .ui-widget {
@@ -198,6 +198,10 @@ div.ai-tooltip .version {
198
  margin-right: 24px;
199
  }
200
 
 
 
 
 
201
  #ai-tabs a {
202
  width: 14px;
203
  text-align: center;
1
  #ai-data {
2
+ font-family: "2.1.11"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
8
 
9
  .ui-widget {
10
  font-family: sans-serif,Arial,Verdana;
11
+ font-size: 12px!important;
12
  }
13
 
14
  #ai-form .ui-widget {
198
  margin-right: 24px;
199
  }
200
 
201
+ .ui-tabs .ui-tabs-nav li {
202
+ margin: 1px 0.18em 0 0;
203
+ }
204
+
205
  #ai-tabs a {
206
  width: 14px;
207
  text-align: center;
images/after-comments.png ADDED
Binary file
images/before-comments.png ADDED
Binary file
images/between-comments.png ADDED
Binary file
images/{media.net_728x90.gif → contextual-1.gif} RENAMED
File without changes
images/{media.net_250x250_2.jpg → contextual-2.jpg} RENAMED
File without changes
images/how-to-monetize-a-small-blog.png ADDED
Binary file
images/stars.png ADDED
Binary file
includes/js/ads.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ var e=document.createElement('div');
2
+ e.id='dqwpediwqswqma';
3
+ e.style.display='none';
4
+ document.body.appendChild(e);
index.html CHANGED
@@ -7,7 +7,7 @@
7
 
8
  <title>Ad Inserter - Adsense and Amazon ads for Wordpress</title>
9
  <meta name="description" content="Ad Inserter - Insert Adsense, Amazon or any other code into Wordpress" />
10
- <meta name="keywords" content="ad inserter, wordpress, adsense, amazon, html, code, javascript, php" />
11
 
12
  <style>
13
  body {
@@ -22,13 +22,13 @@
22
  <h1 style="text-align: center;">Ad Inserter - Insert Any Code Anywhere</h1>
23
  <div style="margin: 8px 0; padding: 0 8px; text-align: center;">
24
  <h2 style="display: inline-block; margin: 16px 0;">Follow Ad Inserter</h2>
25
- <a href="https://twitter.com/AdInserter" class="clear-link" target="_blank"><img src="images/twitter.png" style="vertical-align: middle; margin: 0 10px 7px 10px;" title="Ad Inserter on Twitter" alt="Ad Inserter on Twitter" /></a>
26
- <a href="https://www.facebook.com/AdInserter/" class="clear-link" target="_blank"><img src="images/facebook.png" style="vertical-align: middle; margin: 0 10px 7px 10px;" title="Ad Inserter on Facebook" alt="Ad Inserter on Facebook" /></a>
27
  </div>
28
- <p>
29
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
30
- Need more than 64 code blocks? <a href="http://adinserter.pro/" target="_blank" rel="nofollow">Ad Inserter Pro</a> supports
31
- 64 blocks, 6 viewports, import/export settings and has additional multisite support.
32
  </p>
33
  <div>
34
  <a href="http://adinserter.pro/documentation" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="https://ps.w.org/ad-inserter/assets/screenshot-1.jpg" /></a>
@@ -45,14 +45,14 @@
45
  </p>
46
  <hr />
47
  <div>
48
- <img style="display: block;margin: 0 auto;" src="https://ps.w.org/ad-inserter/assets/screenshot-2.jpg" />
49
  </div>
50
  <p>
51
  Code preview with visual CSS editor
52
  </p>
53
  <hr />
54
  <div>
55
- <img style="display: block;margin: 0 auto;" src="https://ps.w.org/ad-inserter/assets/screenshot-3.jpg" width="800"/>
56
  </div>
57
  <p>
58
  Code preview with visual CSS editor - highlighted code
@@ -70,11 +70,10 @@
70
  <div style="float: left;">
71
  <div style="width: 800px; padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
72
  <h1 style="text-align: center;">Tiny Monitor</h1>
73
- <h2 style="text-align: center;">Monitor Google AdSense, Amazon Associates and PayPal earnings</h2>
74
  <p style="text-align: justify;">
75
  Tiny Monitor for
76
- <a href="http://tinymonitor.com/adsense-monitor-documentation" target="_blank" rel="nofollow">AdSense</a>,
77
- <a href="http://tinymonitor.com/amazon-monitor-documentation" target="_blank" rel="nofollow">Amazon</a> and
78
  <a href="http://tinymonitor.com/paypal-monitor-documentation" target="_blank" rel="nofollow">PayPal</a> is a perfect solution to track your online earnings.
79
  This is a small PHP script that can be installed on any <a href="http://tinymonitor.com/installing-web-server" target="_blank" rel="nofollow">home web server</a> or commercial web hosting.
80
  If you already have some website (very likely as you are using Ad Inserter plugin) then you can simply put it into a folder.
7
 
8
  <title>Ad Inserter - Adsense and Amazon ads for Wordpress</title>
9
  <meta name="description" content="Ad Inserter - Insert Adsense, Amazon or any other code into Wordpress" />
10
+ <meta name="keywords" content="ad inserter, wordpress, adsense, amazon, ads, code, javascript, php" />
11
 
12
  <style>
13
  body {
22
  <h1 style="text-align: center;">Ad Inserter - Insert Any Code Anywhere</h1>
23
  <div style="margin: 8px 0; padding: 0 8px; text-align: center;">
24
  <h2 style="display: inline-block; margin: 16px 0;">Follow Ad Inserter</h2>
25
+ <a href="https://twitter.com/AdInserter" class="clear-link" target="_blank"><img src="images/twitter.png" style="vertical-align: middle; margin: 0 10px 7px 10px;" title="Ad Inserter on Twitter" alt="Ad Inserter - WordPress plugin for ad managenet" /></a>
26
+ <a href="https://www.facebook.com/AdInserter/" class="clear-link" target="_blank"><img src="images/facebook.png" style="vertical-align: middle; margin: 0 10px 7px 10px;" title="Ad Inserter on Facebook" alt="Ad Inserter - WordPress plugin for advertising" /></a>
27
  </div>
28
+ <p style="text-align: justify;">
29
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
30
+ Need more than 64 code blocks? Ad Inserter Pro is a all-in-one <a href="http://adinserter.pro/" target="_blank">WordPress plugin for ads</a> - it supports
31
+ 64 blocks, impression and click tracking (supports also Javascript ads like AdSense), A/B testing, sticky positions, 6 viewports, import/export of plugin settings and has additional multisite support.
32
  </p>
33
  <div>
34
  <a href="http://adinserter.pro/documentation" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="https://ps.w.org/ad-inserter/assets/screenshot-1.jpg" /></a>
45
  </p>
46
  <hr />
47
  <div>
48
+ <a href="https://adinserter.pro/alignments-and-styles" target="_blank"><img style="display: block;margin: 0 auto;" src="https://ps.w.org/ad-inserter/assets/screenshot-2.jpg" alt="CSS editor for alignments and styles" /></a>
49
  </div>
50
  <p>
51
  Code preview with visual CSS editor
52
  </p>
53
  <hr />
54
  <div>
55
+ <a href="https://adinserter.pro/alignments-and-styles" target="_blank"><img style="display: block;margin: 0 auto;" src="https://ps.w.org/ad-inserter/assets/screenshot-3.jpg" width="800" alt="Alignments and styles"/></a>
56
  </div>
57
  <p>
58
  Code preview with visual CSS editor - highlighted code
70
  <div style="float: left;">
71
  <div style="width: 800px; padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
72
  <h1 style="text-align: center;">Tiny Monitor</h1>
73
+ <h2 style="text-align: center;">Monitor Google AdSense and PayPal earnings</h2>
74
  <p style="text-align: justify;">
75
  Tiny Monitor for
76
+ <a href="http://tinymonitor.com/adsense-monitor-documentation" target="_blank" rel="nofollow">AdSense</a> and
 
77
  <a href="http://tinymonitor.com/paypal-monitor-documentation" target="_blank" rel="nofollow">PayPal</a> is a perfect solution to track your online earnings.
78
  This is a small PHP script that can be installed on any <a href="http://tinymonitor.com/installing-web-server" target="_blank" rel="nofollow">home web server</a> or commercial web hosting.
79
  If you already have some website (very likely as you are using Ad Inserter plugin) then you can simply put it into a folder.
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.1.9";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -1516,6 +1516,23 @@ jQuery(document).ready(function($) {
1516
  }
1517
  }
1518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1519
  function configure_charts (container) {
1520
  $(container).find ('.ai-chart.not-configured').each (function() {
1521
  if (!$(this).hasClass ('hidden')) {
@@ -1657,6 +1674,21 @@ jQuery(document).ready(function($) {
1657
  $("#system-debugging").toggle();
1658
  });
1659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1660
  if (debug) console.log ("");
1661
  if (debug) console.log ("READY END");
1662
  if (debug) {
1
+ var javascript_version = "2.1.11";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
1516
  }
1517
  }
1518
 
1519
+ function update_rating (parameter = '') {
1520
+ var rating_bar = $('#ai-rating-bar');
1521
+ var nonce = rating_bar.attr ('nonce');
1522
+ var site_url = rating_bar.attr ('site-url');
1523
+ $("#rating-value span").load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&rating=" + parameter + "&ai_check=" + nonce, function() {
1524
+ var rating = $("#rating-value span").text ()
1525
+ var rating_value = 0;
1526
+ if (rating != '') var rating_value = parseFloat (rating);
1527
+ $("#rating-value").css ('width', rating_value * 20 + '%');
1528
+
1529
+ if ($("#rating-value span").text () == '') {
1530
+ $("#ai-rating-bar").hide ();
1531
+ $('#ai-stars').show ();
1532
+ }
1533
+ });
1534
+ }
1535
+
1536
  function configure_charts (container) {
1537
  $(container).find ('.ai-chart.not-configured').each (function() {
1538
  if (!$(this).hasClass ('hidden')) {
1674
  $("#system-debugging").toggle();
1675
  });
1676
 
1677
+ $('#ai-stars').click (function () {
1678
+ if ($("#rating-value span").text () != '') {
1679
+ $("#ai-rating-bar").css ('display', 'inline-block');
1680
+ $('#ai-stars').hide ();
1681
+ }
1682
+ update_rating ('update');
1683
+ });
1684
+
1685
+ $("#ai-rating-bar").click (function () {
1686
+ $("#ai-rating-bar").hide ();
1687
+ $('#ai-stars').show ();
1688
+ });
1689
+
1690
+ setTimeout (update_rating, 6000);
1691
+
1692
  if (debug) console.log ("");
1693
  if (debug) console.log ("READY END");
1694
  if (debug) {
readme.txt CHANGED
@@ -1,54 +1,64 @@
1
- === Ad Inserter ===
 
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
- Tags: ads, adsense, ad management, advertising, widgets, contextual ads, ad rotation, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, widgets, PHP, Javascript, HTML, header, footer, tracking, sticky
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
- Stable tag: 2.1.8
8
  License: GPLv3
9
 
10
- Ad management plugin to automate advertising: AdSense, Amazon, AMP, banner rotation, header/footer code; insert anything anywhere on the page.
11
 
12
  == Description ==
13
 
14
- Ad management plugin with many advertising features to automatically insert adverts. **Perfect for all kinds of ads including AdSense.** Great also for contextual Amazon Native Shopping Ads and rotating banners. Ad Inserter provides many options to insert any Javascript, HTML, PHP or advert code anywhere on the page.
 
 
15
 
16
  > **Features**
17
  >
18
  > * 16 code (ad) blocks
19
  > * Syntax highlighting editor
20
  > * Code preview with visual CSS editor
21
- > * Automatic insertion before / after post, content, paragraph or excerpt
22
- > * Automatic insertion before or after random paragraph
23
- > * Automatic insertion before or after multiple paragraphs
24
- > * Automatic insertion before or after any HTML element in post
25
- > * Automatic insertion at relative position in posts
 
 
 
 
 
 
 
26
  > * Clearance options to avoid insertion near images or headers
27
- > * Automatic insertion between posts on blog pages
28
  > * Insertion exceptions for posts and pages
29
- > * Insertion of header and footer code
30
- > * Insertion of Google Analytics, Piwik or any other web analytics code
 
31
  > * Manual insertion: widgets, shortcodes, PHP function call
32
- > * Sticky widgets
33
  > * Custom block alignment and style
34
- > * Insertion of ads on AMP pages
35
  > * Custom CSS class name for wrapping divs to avoid ad blockers
36
- > * Insertion of shortcodes from other plugins
37
  > * PHP code processing
38
  > * Ad rotation (server-side and client-side - works with caching)
39
  > * Desktop/mobile device detection (server-side and client-side - works with caching)
40
- > * Black/White-list categories, tags, post IDs, urls, url parameters, referers
41
  > * Simple troubleshooting with many debugging functions
42
  > * Function to visualize inserted code blocks
43
  > * Function to visualize available insertion positions
44
  > * Function to visualize HTML tags
45
 
46
- And <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> has even more features:
47
 
48
  > * 64 code (ad) blocks
49
  > * GEO targeting (works also with caching)
50
  > * Black/White-list IP addresses or countries (works also with caching)
51
- > * Ad impression and click tracking
52
  > * A/B testing
53
  > * Sticky ad positions (left, top, right, bottom)
54
  > * Scheduling with fallback option
@@ -61,7 +71,7 @@ And <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> has eve
61
  Ad Inserter Wordpress plugin has many features and options to automate ad insertion and to optimally monetize your website on desktop, tablet and phone displays. It provides many simple ways to insert any Javascript, HTML, PHP or advert code anywhere on the page. For best ad placement and to use optimal advertising positions please read the user manual to get the most of the plugin.
62
 
63
  > * Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features and some <a href="http://adinserter.pro/settings" target="_blank">common settings</a> for quick start
64
- > * Download **PDF user guide** for Ad Inserter: go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> page and below you can find button for free download of Ad Inserter User Guide
65
 
66
  **Endorsed by Amazon**
67
 
@@ -74,17 +84,23 @@ Ad Inserter Wordpress plugin has many features and options to automate ad insert
74
 
75
  Do you enjoy finding the right plugin to solve a particular problem on your site? For example:
76
 
77
- * to insert and manage ads
 
 
 
 
78
  * to insert different ads for mobile devices
79
  * for ad rotation
80
- * for sticky (fixed) widgets
81
  * for PHP code widgets
82
- * to insert some PHP code into posts
83
- * to insert header or footer code
 
 
84
  * to insert Google analytics code
85
- * to insert various forms
86
 
87
  Maintaining several plugins (often from different vendors) is not easy. And each plugin is slowing down the speed of your website.
 
88
  **Speed Up Your WordPress: Replace them all with free Ad Inserter!**
89
 
90
  **Quick Start**
@@ -96,6 +112,7 @@ Few very important things you need to know in order to <a href="http://adinserte
96
  * **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)
97
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
98
  * 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)
 
99
 
100
  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.
101
  For more detailed instructions please read <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a>.
@@ -110,7 +127,7 @@ Support the advancement of this plugin:
110
 
111
  * Write a nice <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
112
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
113
- * Buy license for <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a>
114
 
115
  == Installation ==
116
 
@@ -374,17 +391,26 @@ Support the advancement of this plugin:
374
  = I have installed code for AdSense ads but the ad blocks are blank. =
375
 
376
  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.
377
-
378
- In most cases once Google approves your account you'll get ads. This may take few days, sometimes longer.
379
- However, if after a week you still see blank ads or you know your AdSense account was banned you can try <a href="http://bit.ly/2oF81Oh" target="_blank">Media net ads</a> as good AdSense alternative.
380
 
381
 
382
  = Settings for widget =
383
 
384
  * Nothing needed, just enter the code and save settings - widget is enabled by default
385
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
386
- * 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
387
  * 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
 
 
 
 
 
 
 
 
 
 
 
388
 
389
  = Settings for contextual Amazon Native Shopping Ads =
390
 
@@ -614,9 +640,11 @@ Asumming AMP urls end with `/amp/` use the following settings:
614
  * Automatic Insertion: set as needed
615
  * Select **No wrapping** style
616
  * Whitelist url `*/amp/`
617
- * Put AMP head script in the Header code block (tab *)
618
  * For all other ads on standard (non AMP) pages blacklist url `*/amp/`
619
 
 
 
620
  For details check <a href="https://adinserter.pro/settings#amp" target="_blank">settings for ads on AMP pages</a>.
621
 
622
 
@@ -689,6 +717,19 @@ AD CODE RIGHT
689
 
690
  == Changelog ==
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  = 2.1.9 =
693
  - Added support for sticky widgets
694
  - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
@@ -910,6 +951,17 @@ AD CODE RIGHT
910
 
911
  == Upgrade Notice ==
912
 
 
 
 
 
 
 
 
 
 
 
 
913
  = 2.1.9 =
914
  Added support for sticky widgets;
915
  Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img);
1
+ === Ad Inserter - Complete Ad Management ===
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, widgets, contextual ads, ad rotation, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, widgets, PHP, Javascript, HTML, header, footer, tracking, sticky, taxonomy, term, custom post
6
  Requires at least: 4.0
7
  Tested up to: 4.8
8
+ Stable tag: 2.1.10
9
  License: GPLv3
10
 
11
+ Ad management plugin: AdSense, Amazon ads, banners, ad rotation, sticky widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
12
 
13
  == Description ==
14
 
15
+ Ad management plugin with many advanced advertising features. **Supports all kinds of ads including Google AdSense, contextual Amazon Native Shopping Ads and rotating banners.**
16
+
17
+ Ad Inserter is more than just ad manager, it provides many advanced options to insert any Javascript, CSS, HTML, PHP or advert code anywhere on the page.
18
 
19
  > **Features**
20
  >
21
  > * 16 code (ad) blocks
22
  > * Syntax highlighting editor
23
  > * Code preview with visual CSS editor
24
+ > * Insert before or after post
25
+ > * Insert before or after content
26
+ > * Insert before or after paragraph
27
+ > * Insert before or after random paragraph
28
+ > * Insert before or after multiple paragraphs
29
+ > * Insert before or after comments
30
+ > * Insert before or after excerpt
31
+ > * Insert before or after any HTML element in post
32
+ > * Insert at relative position in posts
33
+ > * Insert between posts on blog pages
34
+ > * Insert between excerpt on blog pages
35
+ > * Insert between comments
36
  > * Clearance options to avoid insertion near images or headers
 
37
  > * Insertion exceptions for posts and pages
38
+ > * Insert header and footer code
39
+ > * Insert Google Analytics, Piwik or any other web analytics code
40
+ > * Insert HTML, CSS, Javascript or PHP code
41
  > * Manual insertion: widgets, shortcodes, PHP function call
42
+ > * Sticky (fixed) widgets (the sidebar does not move when the page is scrolled, works with most themes)
43
  > * Custom block alignment and style
44
+ > * Insert ads on AMP pages
45
  > * Custom CSS class name for wrapping divs to avoid ad blockers
46
+ > * Use shortcodes from other plugins
47
  > * PHP code processing
48
  > * Ad rotation (server-side and client-side - works with caching)
49
  > * Desktop/mobile device detection (server-side and client-side - works with caching)
50
+ > * Black/White-list categories, tags, taxonomies, post IDs, urls, url query parameters, referers
51
  > * Simple troubleshooting with many debugging functions
52
  > * Function to visualize inserted code blocks
53
  > * Function to visualize available insertion positions
54
  > * Function to visualize HTML tags
55
 
56
+ And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank">WordPress ad management plugin</a> has even more features:
57
 
58
  > * 64 code (ad) blocks
59
  > * GEO targeting (works also with caching)
60
  > * Black/White-list IP addresses or countries (works also with caching)
61
+ > * Ad impression and click tracking (works also with `<iframe>` Javascript ads like AdSense)
62
  > * A/B testing
63
  > * Sticky ad positions (left, top, right, bottom)
64
  > * Scheduling with fallback option
71
  Ad Inserter Wordpress plugin has many features and options to automate ad insertion and to optimally monetize your website on desktop, tablet and phone displays. It provides many simple ways to insert any Javascript, HTML, PHP or advert code anywhere on the page. For best ad placement and to use optimal advertising positions please read the user manual to get the most of the plugin.
72
 
73
  > * Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features and some <a href="http://adinserter.pro/settings" target="_blank">common settings</a> for quick start
74
+ > * Download **PDF user guide** for Ad Inserter: go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro plugin</a> page and below you can find button for free download of Ad Inserter User Guide
75
 
76
  **Endorsed by Amazon**
77
 
84
 
85
  Do you enjoy finding the right plugin to solve a particular problem on your site? For example:
86
 
87
+ * to manage ads
88
+ * to insert ads between paragraphs
89
+ * to insert ads between posts
90
+ * to insert ads between comments
91
+ * to insert ads on AMP pages
92
  * to insert different ads for mobile devices
93
  * for ad rotation
 
94
  * for PHP code widgets
95
+ * for sticky (fixed) widgets
96
+ * to insert PHP or HTML code into posts
97
+ * to insert header, footer or tracking code
98
+ * to insert PHP, HTML, CSS, shortcodes
99
  * to insert Google analytics code
100
+ * to insert various opt-in forms
101
 
102
  Maintaining several plugins (often from different vendors) is not easy. And each plugin is slowing down the speed of your website.
103
+
104
  **Speed Up Your WordPress: Replace them all with free Ad Inserter!**
105
 
106
  **Quick Start**
112
  * **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)
113
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
114
  * 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)
115
+ * 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 AdSense account is not fully approved yet, your website was not accepted or your AdSense account is banned. Try <a href="http://bit.ly/2oF81Oh" target="_blank">Media net ads</a> - they seem to be a good alternative for contextual ads.
116
 
117
  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.
118
  For more detailed instructions please read <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a>.
127
 
128
  * Write a nice <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
129
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
130
+ * Buy license for Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank">Wordpress plugin for ads</a>
131
 
132
  == Installation ==
133
 
391
  = I have installed code for AdSense ads but the ad blocks are blank. =
392
 
393
  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.
394
+ You can also try <a href="http://bit.ly/2oF81Oh" target="_blank">Media net ads</a> as good AdSense alternative for contextual ads.
 
 
395
 
396
 
397
  = Settings for widget =
398
 
399
  * Nothing needed, just enter the code and save settings - widget is enabled by default
400
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
401
+ * 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
402
  * 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
403
+ * In general plugin settings (tab *) you can also define Sticky Widget Top Margin to precisely define top position where first sticky widget will stop
404
+
405
+ Additional note regarding *sticky widgets*:
406
+
407
+ Sticky widgets work by changing sidebar CSS to `position: sticky;`. This works in most themes but not all.
408
+
409
+ If your widgets and sidebar aren't sticking as expected the first thing to check are the rules applied to the sidebar parent containers.
410
+ 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.
411
+
412
+ If your theme is not using overflow and still having problems it's worth checking if a height is set on the parent.
413
+ This may constrain the sticky positioning, stopping it from occurring. Remove the height and see if that fixes the problem.
414
 
415
  = Settings for contextual Amazon Native Shopping Ads =
416
 
640
  * Automatic Insertion: set as needed
641
  * Select **No wrapping** style
642
  * Whitelist url `*/amp/`
643
+ * Put AMP head script in the Header code block (tab * / tab Header) and enable it
644
  * For all other ads on standard (non AMP) pages blacklist url `*/amp/`
645
 
646
+ If you have different url structure you'll have to adjust url pattern accordingly.
647
+
648
  For details check <a href="https://adinserter.pro/settings#amp" target="_blank">settings for ads on AMP pages</a>.
649
 
650
 
717
 
718
  == Changelog ==
719
 
720
+ = 2.1.11 =
721
+ - Improved support for sticky widgets (works with most themes)
722
+ - Added support for ad counting (|count| separator)
723
+ - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
724
+ - Added support for automatic insertion before, between and after comments
725
+ - Added processing of shortcodes in the header and footer code
726
+ - Debugging function Show positions shows also page type
727
+ - Fixed page type detection when Post page was set to static page and it was not homepage
728
+ - Few minor bug fixes, cosmetic changes and code improvements
729
+
730
+ = 2.1.10 =
731
+ - Fix for shifted sidebars in some themes
732
+
733
  = 2.1.9 =
734
  - Added support for sticky widgets
735
  - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
951
 
952
  == Upgrade Notice ==
953
 
954
+ = 2.1.11 =
955
+ Improved support for sticky widgets (works with most themes);
956
+ Added support for ad counting (|count| separator);
957
+ Added support to black/white-list arbitrary taxonomies;
958
+ Added support for automatic insertion before, between and after comments;
959
+ Added processing of shortcodes in the header and footer code;
960
+ Fixed page type detection on blog pages in some cases;
961
+
962
+ = 2.1.10 =
963
+ Fix for shifted sidebars in some themes
964
+
965
  = 2.1.9 =
966
  Added support for sticky widgets;
967
  Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img);
settings.php CHANGED
@@ -79,6 +79,14 @@ function generate_settings_form (){
79
  }
80
  }
81
  }
 
 
 
 
 
 
 
 
82
  ?>
83
 
84
  <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
@@ -102,7 +110,7 @@ function generate_settings_form (){
102
  <div id="header-buttons">
103
  <a style="text-decoration: none;" href="http://adinserter.pro/documentation" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button></a>
104
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 68px;" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button></a>
105
- <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="Support Free Ad Inserter development">Donate</button></a>
106
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter please write a nice review" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
107
  <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" title="Upgrade to Ad Inserter Pro" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
108
  </div>
@@ -254,7 +262,7 @@ function generate_settings_form (){
254
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
255
  if ($enabled_h || $enabled_f) $class_hf = " on"; else $class_hf = "";
256
  ?>
257
- <li id="ai-tab0" class="ai-tab" title="<?php echo AD_INSERTER_NAME ?> Settings<?php echo $title_hf ?>"><a href="#tab-0" style="padding: 5px 14px 6px 12px;"><div class="ai-icon-gear<?php echo $class_hf ?>"></div></a></li>
258
  </ul>
259
 
260
  <?php
@@ -270,14 +278,15 @@ function generate_settings_form (){
270
  $show_devices = $obj->get_detection_client_side () == AI_ENABLED || $obj->get_detection_server_side () == AI_ENABLED;
271
  if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
272
 
273
- $cat_list = $obj->get_ad_block_cat();
274
- $tag_list = $obj->get_ad_block_tag();
275
- $id_list = $obj->get_id_list();
276
- $url_list = $obj->get_ad_url_list();
 
277
  $url_parameter_list = $obj->get_url_parameter_list();
278
  $domain_list = $obj->get_ad_domain_list();
279
  if (function_exists ('ai_lists')) $lists = ai_lists ($obj); else $lists = false;
280
- $show_lists = $cat_list != '' || $tag_list != '' || $id_list != '' || $url_list != '' || $url_parameter_list != '' || $domain_list != '' || $lists;
281
  if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = "";
282
 
283
  $show_manual = $manual [$ad_number];
@@ -367,6 +376,9 @@ function generate_settings_form (){
367
  <option data-img-src="<?php echo plugins_url ('images/before-excerpt.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_EXCERPT; ?></option>
368
  <option data-img-src="<?php echo plugins_url ('images/after-excerpt.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_EXCERPT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_EXCERPT; ?></option>
369
  <option data-img-src="<?php echo plugins_url ('images/between-posts.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BETWEEN_POSTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BETWEEN_POSTS; ?></option>
 
 
 
370
  </select>
371
  </div>
372
 
@@ -379,7 +391,7 @@ function generate_settings_form (){
379
  <option data-img-src="<?php echo plugins_url ('images/align-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
380
  <option data-img-src="<?php echo plugins_url ('images/float-left.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
381
  <option data-img-src="<?php echo plugins_url ('images/float-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
382
- <?php $css_code_height = 190; if (function_exists ('ai_style_options')) $css_code_height = ai_style_options ($obj); ?>
383
  <option data-img-src="<?php echo plugins_url ('images/custom-css.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
384
  <option data-img-src="<?php echo plugins_url ('images/no-wrapping.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
385
  </select>
@@ -742,6 +754,22 @@ function generate_settings_form (){
742
  <label for="tag-whitelist-<?php echo $ad_number; ?>" title="Whitelist tags"><?php echo AD_WHITE_LIST; ?></label>
743
  </td>
744
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
745
  <tr>
746
  <td style="padding-right: 7px;">
747
  Post IDs
@@ -896,6 +924,7 @@ function generate_settings_form (){
896
  <option value="<?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_WIDGET_DRAWING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?></option>
897
  <option value="<?php echo AI_OPTION_FILTER_SUBPAGES; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_SUBPAGES; ?></option>
898
  <option value="<?php echo AI_OPTION_FILTER_POSTS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_POSTS; ?></option>
 
899
  </select>
900
  counter
901
  </span>
@@ -1320,9 +1349,16 @@ function generate_settings_form (){
1320
  </div>
1321
 
1322
  <div class="ai-form" style="height: 90px; margin: 8px 0; padding: 8px 4px 8px 12px;border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1323
- <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>media.net_728x90.gif" /></a>
1324
  </div>
1325
 
 
 
 
 
 
 
 
1326
  <?php } ?>
1327
 
1328
  <input id="ai-active-tab" type="hidden" name="ai-active-tab" value="<?php echo $active_tab; ?>" />
@@ -1340,7 +1376,7 @@ function generate_settings_form (){
1340
  <div style="float: left;">
1341
  <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1342
  <div style="float: left;">
1343
- <h2 style="display: inline-block; margin: 13px 0;">Please support plugin development</h2>
1344
  </div>
1345
  <div style="float: right;">
1346
  <h2 style="display: inline-block; margin: 13px 0;">Follow Ad Inserter</h2>
@@ -1351,9 +1387,30 @@ function generate_settings_form (){
1351
  <div style="clear: both;"></div>
1352
  </div>
1353
 
1354
- <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1355
- <p>If you are using Ad Inserter and you like it, then please write about it and spread the word on the <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">review page</a>.</p>
1356
- <p>Positive reviews are a great way to show your appreciation for my work. Besides being an incredible boost to my morale, they are also a great incentive to fix any bug found in the software and to add new features for better monetization of your website.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1357
  </div>
1358
 
1359
  <div class="ai-form" style="padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
@@ -1362,37 +1419,42 @@ function generate_settings_form (){
1362
  <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 src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="margin-top: 10px;" /></a>
1363
  </div>
1364
  <div>
1365
- <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>media.net_250x250_2.jpg" style="margin-top: 10px;" /></a>
 
 
 
1366
  </div>
1367
  </div>
1368
 
1369
- <h3 style="text-align: justify;">Need a plugin for ad management? <a href="http://adinserter.pro/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">Ad Inserter Pro</a> features:</h3>
 
1370
 
1371
  <ul>
1372
- <li><strong>&squf;</strong> Email support</li>
1373
  <li><strong>&squf;</strong> 64 code (ad) blocks</li>
1374
  <li><strong>&squf;</strong> Syntax highlighting editor</li>
1375
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#code-preview" class="simple-link" target="_blank">Code preview</a> with visual CSS editor</li>
1376
  <li><strong>&squf;</strong> Automatic insertion before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1377
  <li><strong>&squf;</strong> Automatic insertion between posts on blog pages</li>
 
1378
  <li><strong>&squf;</strong> Insertion exceptions for posts and pages</li>
1379
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#manual" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1380
  <li><strong>&squf;</strong> Sticky positions (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
1381
  <li><strong>&squf;</strong> Sticky (fixed) widgets (sidebar does not move when the page scrolls)</li>
1382
- <li><strong>&squf;</strong> Block alignment and style customizations</li>
1383
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options to avoid insertion near images or headers (AdSense TOS)</li>
1384
  <li><strong>&squf;</strong> Options to disable insertion on Ajax calls, 404 error pages or in feeds</li>
1385
  <li><strong>&squf;</strong> Ad rotation (works also with caching)</li>
1386
- <li><strong>&squf;</strong> Ad impression and click tracking</li>
1387
- <li><strong>&squf;</strong> A/B testing</li>
1388
  <li><strong>&squf;</strong> Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
 
1389
  <li><strong>&squf;</strong> Custom CSS class name for wrapping divs to avoid ad blockers</li>
1390
  <li><strong>&squf;</strong> PHP code processing</li>
1391
  <li><strong>&squf;</strong> Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
1392
  <li><strong>&squf;</strong> Support for Google Analytics, Piwik or any other web analytics code</li>
1393
  <li><strong>&squf;</strong> Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1394
  <li><strong>&squf;</strong> Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a> (works with caching, 6 custom viewports)</li>
1395
- <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> categories, tags, post IDs, urls, referers</li>
1396
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> IP addresses or countries (works also with caching)</li>
1397
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1398
  <li><strong>&squf;</strong> Import/Export block or plugin settings</li>
@@ -1402,11 +1464,12 @@ function generate_settings_form (){
1402
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
1403
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
1404
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of HTML tags for easier ad placement between paragraphs</li>
 
1405
  </ul>
1406
 
1407
- <p style="text-align: justify;">Ad Inserter Pro is a complete ad management plugin with many advertising features to automatically insert adverts on posts and pages.
1408
  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,
1409
- 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>
1410
  </div>
1411
 
1412
  </div>
79
  }
80
  }
81
  }
82
+
83
+ $rating = '';
84
+ if (file_exists (AI_RATING_FILE)) {
85
+ $rating = file_get_contents (AI_RATING_FILE);
86
+ if ($rating < 1 && $rating > 5) $rating = '';
87
+ }
88
+ $rating_css = $rating == '' ? 'width: 100%;' : 'width: '.number_format ($rating * 20, 4).'%;';
89
+
90
  ?>
91
 
92
  <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
110
  <div id="header-buttons">
111
  <a style="text-decoration: none;" href="http://adinserter.pro/documentation" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button></a>
112
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 68px;" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button></a>
113
+ <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button></a>
114
  <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter please write a nice review" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
115
  <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" title="Upgrade to Ad Inserter Pro" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
116
  </div>
262
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
263
  if ($enabled_h || $enabled_f) $class_hf = " on"; else $class_hf = "";
264
  ?>
265
+ <li id="ai-tab0" class="ai-tab" title="<?php echo AD_INSERTER_NAME ?> Settings<?php echo $title_hf ?>" style=" margin: 1px 0 0 0;"><a href="#tab-0" style="padding: 5px 14px 6px 12px;"><div class="ai-icon-gear<?php echo $class_hf ?>"></div></a></li>
266
  </ul>
267
 
268
  <?php
278
  $show_devices = $obj->get_detection_client_side () == AI_ENABLED || $obj->get_detection_server_side () == AI_ENABLED;
279
  if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
280
 
281
+ $cat_list = $obj->get_ad_block_cat();
282
+ $tag_list = $obj->get_ad_block_tag();
283
+ $taxonomy_list = $obj->get_ad_block_taxonomy();
284
+ $id_list = $obj->get_id_list();
285
+ $url_list = $obj->get_ad_url_list();
286
  $url_parameter_list = $obj->get_url_parameter_list();
287
  $domain_list = $obj->get_ad_domain_list();
288
  if (function_exists ('ai_lists')) $lists = ai_lists ($obj); else $lists = false;
289
+ $show_lists = $cat_list != '' || $tag_list != '' || $taxonomy_list != '' || $id_list != '' || $url_list != '' || $url_parameter_list != '' || $domain_list != '' || $lists;
290
  if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = "";
291
 
292
  $show_manual = $manual [$ad_number];
376
  <option data-img-src="<?php echo plugins_url ('images/before-excerpt.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_EXCERPT; ?></option>
377
  <option data-img-src="<?php echo plugins_url ('images/after-excerpt.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_EXCERPT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_EXCERPT; ?></option>
378
  <option data-img-src="<?php echo plugins_url ('images/between-posts.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BETWEEN_POSTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BETWEEN_POSTS; ?></option>
379
+ <option data-img-src="<?php echo plugins_url ('images/before-comments.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_COMMENTS; ?></option>
380
+ <option data-img-src="<?php echo plugins_url ('images/between-comments.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BETWEEN_COMMENTS; ?></option>
381
+ <option data-img-src="<?php echo plugins_url ('images/after-comments.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_COMMENTS; ?></option>
382
  </select>
383
  </div>
384
 
391
  <option data-img-src="<?php echo plugins_url ('images/align-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
392
  <option data-img-src="<?php echo plugins_url ('images/float-left.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
393
  <option data-img-src="<?php echo plugins_url ('images/float-right.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
394
+ <?php $css_code_height = 260; if (function_exists ('ai_style_options')) $css_code_height = ai_style_options ($obj); ?>
395
  <option data-img-src="<?php echo plugins_url ('images/custom-css.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
396
  <option data-img-src="<?php echo plugins_url ('images/no-wrapping.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
397
  </select>
754
  <label for="tag-whitelist-<?php echo $ad_number; ?>" title="Whitelist tags"><?php echo AD_WHITE_LIST; ?></label>
755
  </td>
756
  </tr>
757
+ <tr>
758
+ <td style="padding-right: 7px;">
759
+ Taxonomies
760
+ </td>
761
+ <td style="padding-right: 7px; width: 70%;">
762
+ <input style="border-radius: 5px; width: 100%;" title="Comma separated slugs: taxonomy, term or taxonomy:term" type="text" name="<?php echo AI_OPTION_TAXONOMY_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_block_taxonomy(); ?>" value="<?php echo $taxonomy_list; ?>" size="54" maxlength="500" />
763
+ </td>
764
+ <td style="padding-right: 7px;">
765
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAXONOMY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="taxonomy-blacklist-<?php echo $ad_number; ?>" default="<?php echo $default->get_ad_block_taxonomy_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_taxonomy_type() == AD_BLACK_LIST) echo 'checked '; ?> />
766
+ <label for="category-blacklist-<?php echo $ad_number; ?>" title="Blacklist taxonomies"><?php echo AD_BLACK_LIST; ?></label>
767
+ </td>
768
+ <td>
769
+ <input style="border-radius: 5px;" type="radio" name="<?php echo AI_OPTION_TAXONOMY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="taxonomy-whitelist-<?php echo $ad_number; ?>" default="<?php echo $default->get_ad_block_taxonomy_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_taxonomy_type() == AD_WHITE_LIST) echo 'checked '; ?> />
770
+ <label for="category-whitelist-<?php echo $ad_number; ?>" title="Whitelist taxonomies"><?php echo AD_WHITE_LIST; ?></label>
771
+ </td>
772
+ </tr>
773
  <tr>
774
  <td style="padding-right: 7px;">
775
  Post IDs
924
  <option value="<?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_WIDGET_DRAWING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_WIDGET_DRAWING; ?></option>
925
  <option value="<?php echo AI_OPTION_FILTER_SUBPAGES; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_SUBPAGES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_SUBPAGES; ?></option>
926
  <option value="<?php echo AI_OPTION_FILTER_POSTS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_POSTS; ?></option>
927
+ <option value="<?php echo AI_OPTION_FILTER_COMMENTS; ?>" <?php echo ($obj->get_filter_type()==AI_OPTION_FILTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_OPTION_FILTER_COMMENTS; ?></option>
928
  </select>
929
  counter
930
  </span>
1349
  </div>
1350
 
1351
  <div class="ai-form" style="height: 90px; margin: 8px 0; padding: 8px 4px 8px 12px;border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1352
+ <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>contextual-1.gif" /></a>
1353
  </div>
1354
 
1355
+ <!--<div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">-->
1356
+ <!-- <div style="float: left;">-->
1357
+ <!-- <h2 style="display: inline-block; margin: 13px 0;">WordPress [Great Content] + Ad Inserter [AdSense, Amazon, media.net] = ?</h2>-->
1358
+ <!-- </div>-->
1359
+ <!-- <div style="clear: both;"></div>-->
1360
+ <!--</div>-->
1361
+
1362
  <?php } ?>
1363
 
1364
  <input id="ai-active-tab" type="hidden" name="ai-active-tab" value="<?php echo $active_tab; ?>" />
1376
  <div style="float: left;">
1377
  <div class="ai-form header" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1378
  <div style="float: left;">
1379
+ <h2 style="display: inline-block; margin: 13px 0;">Support plugin development</h2>
1380
  </div>
1381
  <div style="float: right;">
1382
  <h2 style="display: inline-block; margin: 13px 0;">Follow Ad Inserter</h2>
1387
  <div style="clear: both;"></div>
1388
  </div>
1389
 
1390
+ <div class="ai-form header no-select" style="margin: 8px 0; padding: 0 8px; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1391
+ <ul>
1392
+ <li><strong>&squf;</strong>
1393
+ If you like Ad Inserter please do me a big favor and give plugin a 5 star rating on the <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">review page</a>.
1394
+
1395
+ <img id="ai-stars" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>stars.png" style="margin: 0 0 -3px 80px; cursor: pointer;" />
1396
+
1397
+ <div id="ai-rating-bar" class="header" style="cursor: pointer; margin-left: 4px; width: 148px; display: none;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">
1398
+ <div class="header" style="background: #ccc;" title="Average rating of the plugin - Thank you!">
1399
+ <div id="rating-value" style="text-align: center; font-size: 11px; line-height: 12px; border-radius: 2px; background: #fddf87; height: 100%; <?php echo $rating_css; ?>"><span style=""><?php echo $rating; ?></span></div>
1400
+ </div>
1401
+ </div>
1402
+ </li>
1403
+ <li><strong>&squf;</strong>
1404
+ If you're not happy then please open a thread on the <a href="https://wordpress.org/support/plugin/ad-inserter/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">support forum</a> and <a href="https://wordpress.org/support/topic/please-read-how-to-ask-for-help-2/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">describe the problem</a>.
1405
+ </li>
1406
+ <li><strong>&squf;</strong>
1407
+ 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.
1408
+ </li>
1409
+ </ul>
1410
+
1411
+ <p style="text-align: justify;">Positive reviews are a great way to show your appreciation for my work. Besides being an incredible boost to my morale,<br />
1412
+ they are also a great incentive to fix bugs and to add new features for better monetization of your website.
1413
+ 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>
1414
  </div>
1415
 
1416
  <div class="ai-form" style="padding: 2px 8px 6px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; background: #fff;">
1419
  <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 src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-256x256.jpg" style="margin-top: 10px;" /></a>
1420
  </div>
1421
  <div>
1422
+ <a href='http://bit.ly/2oF81Oh' class="clear-link" title="Looking for AdSense alternative?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>contextual-2.jpg" style="margin-top: 10px;" /></a>
1423
+ </div>
1424
+ <div>
1425
+ <a href='http://amzn.to/2uWiu8w' class="clear-link" title="Do you want to earn a living doing what you love?" target="_blank"><img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>how-to-monetize-a-small-blog.png" style="margin-top: 10px;" /></a>
1426
  </div>
1427
  </div>
1428
 
1429
+ <h3 style="text-align: justify;">Looking for Pro Ad Management plugin?</h3>
1430
+ <h4 style="text-align: justify;">To Optimally Monetize your WordPress website?</h4>
1431
 
1432
  <ul>
 
1433
  <li><strong>&squf;</strong> 64 code (ad) blocks</li>
1434
  <li><strong>&squf;</strong> Syntax highlighting editor</li>
1435
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#code-preview" class="simple-link" target="_blank">Code preview</a> with visual CSS editor</li>
1436
  <li><strong>&squf;</strong> Automatic insertion before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1437
  <li><strong>&squf;</strong> Automatic insertion between posts on blog pages</li>
1438
+ <li><strong>&squf;</strong> Automatic insertion before, between and after comments</li>
1439
  <li><strong>&squf;</strong> Insertion exceptions for posts and pages</li>
1440
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#manual" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1441
  <li><strong>&squf;</strong> Sticky positions (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
1442
  <li><strong>&squf;</strong> Sticky (fixed) widgets (sidebar does not move when the page scrolls)</li>
1443
+ <li><strong>&squf;</strong> Block <a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">alignment and style</a> customizations</li>
1444
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options to avoid insertion near images or headers (AdSense TOS)</li>
1445
  <li><strong>&squf;</strong> Options to disable insertion on Ajax calls, 404 error pages or in feeds</li>
1446
  <li><strong>&squf;</strong> Ad rotation (works also with caching)</li>
1447
+ <li><strong>&squf;</strong> Ad impression and click <a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">tracking</a> (works also with Javascript ads like AdSense)</li>
1448
+ <li><strong>&squf;</strong> Support for <a href="https://adinserter.pro/tracking#ab-testing" class="simple-link" target="_blank">A/B testing</a></li>
1449
  <li><strong>&squf;</strong> Support for ads on <a href="http://adinserter.pro/settings#amp" class="simple-link" target="_blank">AMP pages</a></li>
1450
+ <li><strong>&squf;</strong> Support for contextual <a href="https://adinserter.pro/settings#amazon" class="simple-link" target="_blank">Amazon Native Shopping Ads</a> (responsive)</li>
1451
  <li><strong>&squf;</strong> Custom CSS class name for wrapping divs to avoid ad blockers</li>
1452
  <li><strong>&squf;</strong> PHP code processing</li>
1453
  <li><strong>&squf;</strong> Support for <a href="http://adinserter.pro/documentation#header-footer" class="simple-link" target="_blank">header and footer</a> code</li>
1454
  <li><strong>&squf;</strong> Support for Google Analytics, Piwik or any other web analytics code</li>
1455
  <li><strong>&squf;</strong> Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1456
  <li><strong>&squf;</strong> Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a> (works with caching, 6 custom viewports)</li>
1457
+ <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> categories, tags, taxonomies, post IDs, urls, referers</li>
1458
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> IP addresses or countries (works also with caching)</li>
1459
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1460
  <li><strong>&squf;</strong> Import/Export block or plugin settings</li>
1464
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
1465
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
1466
  <li><strong>&squf;</strong> <a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of HTML tags for easier ad placement between paragraphs</li>
1467
+ <li><strong>&squf;</strong> Support via email</li>
1468
  </ul>
1469
 
1470
+ <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.
1471
  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,
1472
+ 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>
1473
  </div>
1474
 
1475
  </div>