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

Version Description

  • Added support to insert raw HTTP response header lines
  • Added support to check for individual exceptions for shortcodes
  • Added support to trigger ad blocking detection action only on individual pages
  • Added support for automatic insertion position Footer
  • Added support for custom hooks
  • Url parameter list now checks url parameters ($GET) and cookies ($COOKIE)
  • Fix for |count| separator not processed
Download this release

Release Info

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

Code changes from version 2.2.3 to 2.2.4

ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.2.3
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes into your website.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -12,12 +12,21 @@ Plugin URI: http://adinserter.pro/documentation
12
 
13
  Change Log
14
 
 
 
 
 
 
 
 
 
 
15
  Ad Inserter 2.2.3 - 2017-09-26
16
- - Added support to insert custom fields via shortcut [adinserter custom-field='CUSTOM_FIELD_NAME']
17
  - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
18
  - Added support for post-type:POST_TYPE taxonomy list items
19
  - Added support for JavaScript based sticky widgets
20
- - Added support for ad blocking statistics
21
  - Added support for WP AMP and WP AMP Ninja plugins
22
  - Post/Page Word Count moved to Misc section (now works also on widgets)
23
  - Few minor bug fixes, cosmetic changes and code improvements
@@ -614,6 +623,7 @@ if (isset ($_POST [AI_FORM_SAVE]))
614
  define ('AI_SYNTAX_HIGHLIGHTING', isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] != AI_OPTION_DISABLED); else
615
  define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED);
616
 
 
617
  add_action ('admin_menu', 'ai_admin_menu_hook');
618
 
619
  add_action ('init', 'ai_init_hook');
@@ -975,14 +985,68 @@ function number_of_words (&$content) {
975
  return count (explode (" ", $text));
976
  }
977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
978
  function ai_wp_hook () {
979
- global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker;
980
 
981
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
982
  ai_log ("WP HOOK START");
983
  $start_time = microtime (true);
984
  }
985
 
 
 
986
  set_page_type ();
987
  set_user ();
988
 
@@ -1044,6 +1108,7 @@ function ai_wp_hook () {
1044
  $debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0;
1045
 
1046
  $plugin_priority = get_plugin_priority ();
 
1047
  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]]) != 0 || $debug_tags_positions)
1048
  add_filter ('the_content', 'ai_content_hook', $plugin_priority);
1049
 
@@ -1051,13 +1116,16 @@ function ai_wp_hook () {
1051
  add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
1052
 
1053
  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]]) != 0 || $debug_positions)
1054
- add_action ('loop_start', 'ai_loop_start_hook');
 
1055
 
1056
  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]]) != 0 || $debug_positions)
1057
- add_action ('loop_end', 'ai_loop_end_hook');
 
1058
 
1059
  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)
1060
- add_action ('the_post', 'ai_post_hook');
 
1061
 
1062
  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) ||
1063
  (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) ||
@@ -1069,6 +1137,77 @@ function ai_wp_hook () {
1069
  $ai_walker = new ai_Walker_Comment;
1070
  }
1071
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1072
 
1073
  if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1074
  // AMP, Accelerated Mobile Pages
@@ -1083,19 +1222,28 @@ function ai_wp_hook () {
1083
  // WP
1084
  add_action ('wp_head', 'ai_wp_head_hook');
1085
 
 
1086
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1087
  // AMP, Accelerated Mobile Pages
1088
- add_action ('amp_post_template_footer', 'ai_amp_footer_hook');
 
 
1089
 
1090
  // WP AMP Ninja
1091
- add_action ('wpamp_google_analytics_code', 'ai_amp_footer_hook');
 
 
1092
 
1093
  // WP AMP - Accelerated Mobile Pages for WordPress
1094
- // add_action ('amphtml_template_footer', 'ai_amp_footer_hook');
1095
- add_action ('amphtml_after_footer', 'ai_amp_footer_hook');
1096
- } else
1097
- // WP
1098
- add_action ('wp_footer', 'ai_wp_footer_hook');
 
 
 
 
1099
 
1100
 
1101
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
@@ -1356,7 +1504,7 @@ function ai_replace_js_data ($js) {
1356
  $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1357
  $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1358
  if (defined ('AI_STATISTICS') && AI_STATISTICS) {
1359
- $js = str_replace ('AI_TRACK_PAGEVIEWS', get_track_pageviews () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1360
  $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1361
 
1362
  if (!isset ($ai_wp_data [AI_VIEWPORTS])) {
@@ -1770,6 +1918,32 @@ function get_adb_status_debug_info () {
1770
  }
1771
 
1772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1773
  function ai_wp_head_hook () {
1774
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1775
 
@@ -1783,7 +1957,7 @@ function ai_wp_head_hook () {
1783
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
1784
 
1785
  $obj = $block_object [AI_HEADER_OPTION_NAME];
1786
- $obj->clear_code_cache ();
1787
 
1788
  if (!$obj->check_server_side_detection ()) return;
1789
 
@@ -1791,6 +1965,11 @@ function ai_wp_head_hook () {
1791
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
1792
  $processed_code = do_shortcode ($obj->ai_getCode ());
1793
 
 
 
 
 
 
1794
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1795
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1796
  $processed_code = $codes [0];
@@ -1841,7 +2020,7 @@ function ai_amp_head_hook () {
1841
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
1842
 
1843
  $obj = $block_object [AI_HEADER_OPTION_NAME];
1844
- $obj->clear_code_cache ();
1845
 
1846
  if (!$obj->check_server_side_detection ()) return;
1847
 
@@ -1849,6 +2028,11 @@ function ai_amp_head_hook () {
1849
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
1850
  $processed_code = do_shortcode ($obj->ai_getCode ());
1851
 
 
 
 
 
 
1852
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1853
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1854
  $processed_code = ltrim ($codes [1]);
@@ -1892,31 +2076,30 @@ function ai_wp_footer_hook () {
1892
  $start_time = microtime (true);
1893
  }
1894
 
1895
- // if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
1896
- if (!(defined ('DOING_AJAX') && DOING_AJAX) /*&& !$ai_wp_data [AI_WP_AMP_PAGE]*/) {
1897
- add_footer_inline_scripts ();
1898
- }
1899
-
1900
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
1901
 
1902
- $obj = $block_object [AI_FOOTER_OPTION_NAME];
1903
- $obj->clear_code_cache ();
1904
-
1905
- if (!$obj->check_server_side_detection ()) return;
1906
 
1907
- if ($obj->get_enable_manual ()) {
1908
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
1909
- $processed_code = do_shortcode ($obj->ai_getCode ());
 
1910
 
1911
- if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1912
- $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1913
- $processed_code = $codes [0];
1914
- } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
1915
 
1916
- echo $processed_code;
 
1917
  }
1918
  }
1919
 
 
 
 
 
1920
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1921
  echo get_page_type_debug_info () , "\n";
1922
  }
@@ -1958,9 +2141,9 @@ function ai_amp_footer_hook () {
1958
  }
1959
  }
1960
 
1961
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1962
- // echo get_page_type_debug_info () , "\n";
1963
- // }
1964
 
1965
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1966
  $ai_total_plugin_time += microtime (true) - $start_time;
@@ -1969,7 +2152,7 @@ function ai_amp_footer_hook () {
1969
  }
1970
 
1971
  function ai_write_debug_info ($write_processing_log = false) {
1972
- global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options, $block_insertion_log;
1973
 
1974
  echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
1975
  if (function_exists ('ai_debug_header')) ai_debug_header ();
@@ -2002,6 +2185,7 @@ function ai_write_debug_info ($write_processing_log = false) {
2002
  echo "\n";
2003
  echo "SETTINGS TIMESTAMP: ";
2004
  echo isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP']) ? date ("Y-m-d H:i:s", $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : "", "\n";
 
2005
  echo "MULTISITE: ", is_multisite() ? "YES" : "NO", "\n";
2006
  if (is_multisite()) {
2007
  echo "MAIN SITE: ", is_main_site () ? "YES" : "NO", "\n";
@@ -2113,6 +2297,20 @@ function ai_write_debug_info ($write_processing_log = false) {
2113
  elseif (AI_PHONE) echo "PHONE\n";
2114
  else echo "?\n";
2115
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2116
  echo 'BLOCK CLASS NAME: ', get_block_class_name (), "\n";
2117
  echo 'DYNAMIC BLOCKS: ';
2118
  switch (get_dynamic_blocks()) {
@@ -2161,7 +2359,7 @@ function ai_write_debug_info ($write_processing_log = false) {
2161
  echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2162
  echo 'ADB SELECTORS: ', get_adb_selectors (), "\n";
2163
  $redirection_page = get_redirection_page ();
2164
- echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : $redirection_page, "\n";
2165
  echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
2166
  echo 'ADB MESSAGE: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode (), "\n";
2167
  echo 'ADB MESSAGE CSS: ', get_message_css (), "\n";
@@ -2319,40 +2517,51 @@ function ai_write_debug_info ($write_processing_log = false) {
2319
 
2320
  echo "TOTAL BLOCKS\n";
2321
  if (count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]))
2322
- echo "CONTENT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2323
  if (count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]))
2324
- echo "EXCERPT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2325
  if (count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]))
2326
- echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2327
  if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]))
2328
- echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2329
  if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
2330
- echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2331
  if (count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
2332
- echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2333
  if (count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
2334
- echo "BETWEEN COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2335
  if (count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
2336
- echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2337
-
 
 
 
 
 
2338
 
2339
  echo "\nBLOCKS FOR THIS PAGE TYPE\n";
2340
  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]]))
2341
- echo "CONTENT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2342
  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]]))
2343
- echo "EXCERPT HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2344
  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]]))
2345
- echo "LOOP START HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2346
  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]]))
2347
- echo "LOOP END HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2348
  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]]))
2349
- echo "POST HOOK BLOCKS: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2350
  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]]))
2351
- echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2352
  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]]))
2353
- echo "BETWEEN COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2354
  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]]))
2355
- echo "AFTER COMMENTS BLOCKS: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
 
 
 
 
 
 
2356
 
2357
  if ($write_processing_log) {
2358
  echo "\nTIME EVENT\n";
@@ -2536,6 +2745,18 @@ function ai_check_plugin_options ($plugin_options = array ()) {
2536
  } else $plugin_options [$viewport_width_option_name] = '';
2537
  }
2538
 
 
 
 
 
 
 
 
 
 
 
 
 
2539
  if (function_exists ('ai_check_options')) ai_check_options ($plugin_options);
2540
 
2541
  return ($plugin_options);
@@ -2703,6 +2924,42 @@ function get_viewport_width ($viewport_number) {
2703
  return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]);
2704
  }
2705
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2706
  function get_country_group_name ($group_number) {
2707
  global $ai_db_options;
2708
 
@@ -2788,8 +3045,12 @@ function multisite_main_for_all_blogs () {
2788
  return DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
2789
  }
2790
 
2791
- function get_adb_action () {
2792
- global $ai_db_options;
 
 
 
 
2793
 
2794
  if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
2795
 
@@ -2895,6 +3156,16 @@ function filter_string ($str){
2895
  return $str;
2896
  }
2897
 
 
 
 
 
 
 
 
 
 
 
2898
  function filter_option ($option, $value, $delete_escaped_backslashes = true){
2899
  if ($delete_escaped_backslashes)
2900
  $value = str_replace (array ("\\\""), array ("\""), $value);
@@ -2945,6 +3216,7 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
2945
  $option == 'ADB_REDIRECTION_PAGE' ||
2946
  $option == 'ADB_CUSTOM_REDIRECTION_URL' ||
2947
  $option == AI_OPTION_CUSTOM_CSS ||
 
2948
  $option == 'ADB_OVERLAY_CSS' ||
2949
  $option == 'ADB_MESSAGE_CSS') {
2950
  $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
@@ -3039,18 +3311,13 @@ function ai_ajax_backend () {
3039
  }
3040
 
3041
  function ai_generate_extract (&$settings) {
 
 
 
3042
 
3043
  $obj = new ai_Block (1);
3044
 
3045
  $extract = array ();
3046
- $content_hook_blocks = array ();
3047
- $excerpt_hook_blocks = array ();
3048
- $loop_start_hook_blocks = array ();
3049
- $loop_end_hook_blocks = array ();
3050
- $post_hook_blocks = array ();
3051
- $before_comments_hook_blocks = array ();
3052
- $between_comments_hook_blocks = array ();
3053
- $after_comments_hook_blocks = array ();
3054
 
3055
  $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());
3056
  $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());
@@ -3060,6 +3327,11 @@ function ai_generate_extract (&$settings) {
3060
  $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());
3061
  $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());
3062
  $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());
 
 
 
 
 
3063
 
3064
  // Get blocks used in sidebar widgets
3065
  $sidebar_widgets = wp_get_sidebars_widgets();
@@ -3145,6 +3417,17 @@ function ai_generate_extract (&$settings) {
3145
  foreach ($page_types as $block_page_type) $after_comments_hook_blocks [$block_page_type][]= $block;
3146
  $after_comments_hook_blocks [AI_PT_ANY][]= $block;
3147
  break;
 
 
 
 
 
 
 
 
 
 
 
3148
  }
3149
  }
3150
 
@@ -3167,23 +3450,41 @@ function ai_generate_extract (&$settings) {
3167
  $extract [BEFORE_COMMENTS_HOOK_BLOCKS] = $before_comments_hook_blocks;
3168
  $extract [BETWEEN_COMMENTS_HOOK_BLOCKS] = $between_comments_hook_blocks;
3169
  $extract [AFTER_COMMENTS_HOOK_BLOCKS] = $after_comments_hook_blocks;
 
 
 
 
 
 
 
 
3170
 
3171
  return ($extract);
3172
  }
3173
 
3174
  function ai_load_settings () {
3175
- global $ai_db_options, $block_object, $ai_db_options_extract, $ai_wp_data, $version_string;
3176
 
3177
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START");
3178
 
3179
  ai_load_options ();
3180
 
 
 
 
 
 
 
 
 
 
3181
  if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) &&
3182
  isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
3183
  isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][POST_HOOK_BLOCKS]) &&
3184
  isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
3185
  isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
3186
- isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][AI_EXTRACT_USED_BLOCKS]))
 
3187
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
3188
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
3189
 
@@ -3408,10 +3709,15 @@ function ai_settings () {
3408
  if (isset ($_POST ['javascript_debugging'])) $options ['JAVASCRIPT_DEBUGGING'] = filter_option ('JAVASCRIPT_DEBUGGING', $_POST ['javascript_debugging']);
3409
 
3410
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
3411
- if (isset ($_POST ['viewport-name-'.$viewport]))
3412
- $options ['VIEWPORT_NAME_'.$viewport] = filter_string ($_POST ['viewport-name-'.$viewport]);
3413
- if (isset ($_POST ['viewport-width-'.$viewport]))
3414
- $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
 
 
 
 
 
3415
  }
3416
 
3417
  $options ['VIEWPORT_CSS'] = generate_viewport_css ();
@@ -3927,8 +4233,8 @@ function ai_excerpt_hook ($content = '') {
3927
  return $content;
3928
  }
3929
 
 
3930
  // Process Before / After Post postion
3931
-
3932
  function ai_before_after_post ($query, $automatic_insertion) {
3933
  global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
3934
 
@@ -4009,6 +4315,7 @@ function ai_before_after_post ($query, $automatic_insertion) {
4009
  echo $ad_code;
4010
  }
4011
 
 
4012
  // Process Before Post postion
4013
  function ai_loop_start_hook ($query) {
4014
  global $ai_wp_data, $ai_total_plugin_time;
@@ -4025,6 +4332,7 @@ function ai_loop_start_hook ($query) {
4025
  }
4026
 
4027
 
 
4028
  // Process After Post postion
4029
  function ai_loop_end_hook ($query){
4030
  global $ai_wp_data, $ai_total_plugin_time;
@@ -4041,6 +4349,7 @@ function ai_loop_end_hook ($query){
4041
  }
4042
 
4043
 
 
4044
  // Process Between Posts postion
4045
  function ai_post_hook ($post) {
4046
  global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
@@ -4372,6 +4681,92 @@ function ai_comment_end_callback ($comment, $args, $depth) {
4372
  }
4373
  }
4374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4375
  function process_shortcode (&$block, $atts) {
4376
  global $block_object, $ai_last_check, $ai_wp_data;
4377
 
@@ -4381,6 +4776,7 @@ function process_shortcode (&$block, $atts) {
4381
  "block" => "",
4382
  "name" => "",
4383
  "ignore" => "",
 
4384
  "debugger" => "",
4385
  "adb" => "",
4386
  "css" => "",
@@ -4389,6 +4785,7 @@ function process_shortcode (&$block, $atts) {
4389
  "amp" => "",
4390
  "rotate" => "",
4391
  "count" => "",
 
4392
  "custom-field" => "",
4393
  "data" => "",
4394
  ), $atts);
@@ -4399,6 +4796,26 @@ function process_shortcode (&$block, $atts) {
4399
  if ($output != '') return $output;
4400
  }
4401
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4402
  $block = - 1;
4403
  if (is_numeric ($parameters ['block'])) {
4404
  $block = intval ($parameters ['block']);
@@ -4426,6 +4843,9 @@ function process_shortcode (&$block, $atts) {
4426
  if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
4427
  return AD_AMP_SEPARATOR;
4428
  }
 
 
 
4429
  if ($parameters ['custom-field'] != '') {
4430
  $post_meta = get_post_meta (get_the_ID(), $parameters ['custom-field']);
4431
  if (is_array ($post_meta)) {
@@ -4456,14 +4876,22 @@ function process_shortcode (&$block, $atts) {
4456
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("SHORTCODE $block (".($parameters ['block'] != '' ? 'block="'.$parameters ['block'].'"' : '').($parameters ['name'] != '' ? 'name="'.$parameters ['name'].'"' : '').")");
4457
 
4458
  // IGNORE SETTINGS
4459
- // page_type
4460
- // *block_counter
 
 
 
4461
 
4462
  $ignore_array = array ();
4463
  if (trim ($parameters ['ignore']) != '') {
4464
  $ignore_array = explode (",", str_replace (" ", "", $parameters ['ignore']));
4465
  }
4466
 
 
 
 
 
 
4467
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_SHORTCODE;
4468
 
4469
  $obj = $block_object [$block];
@@ -4475,6 +4903,14 @@ function process_shortcode (&$block, $atts) {
4475
  if (!$obj->check_server_side_detection ()) return "";
4476
  if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
4477
 
 
 
 
 
 
 
 
 
4478
  // Last check before counter check before insertion
4479
  $ai_last_check = AI_CHECK_CODE;
4480
  if ($obj->ai_getCode () == '') return "";
@@ -4695,7 +5131,6 @@ function ai_widget_draw ($args, $instance, &$block) {
4695
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
4696
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
4697
  $selected_blocks = explode (",", $meta_value);
4698
-
4699
  if (!$obj->check_post_page_exceptions ($selected_blocks)) return;
4700
  }
4701
 
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.2.4
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes into your website.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
12
 
13
  Change Log
14
 
15
+ Ad Inserter 2.2.4 - 2017-10-14
16
+ - Added support to insert raw HTTP response header lines
17
+ - Added support to check for individual exceptions for shortcodes
18
+ - Added support to trigger ad blocking detection action only on individual pages
19
+ - Added support for automatic insertion position Footer
20
+ - Added support for custom hooks
21
+ - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE)
22
+ - Fix for |count| separator not processed
23
+
24
  Ad Inserter 2.2.3 - 2017-09-26
25
+ - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
26
  - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
27
  - Added support for post-type:POST_TYPE taxonomy list items
28
  - Added support for JavaScript based sticky widgets
29
+ - Added support for ad blocking statistics (Pro only)
30
  - Added support for WP AMP and WP AMP Ninja plugins
31
  - Post/Page Word Count moved to Misc section (now works also on widgets)
32
  - Few minor bug fixes, cosmetic changes and code improvements
623
  define ('AI_SYNTAX_HIGHLIGHTING', isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] != AI_OPTION_DISABLED); else
624
  define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED);
625
 
626
+
627
  add_action ('admin_menu', 'ai_admin_menu_hook');
628
 
629
  add_action ('init', 'ai_init_hook');
985
  return count (explode (" ", $text));
986
  }
987
 
988
+ function ai_loop_check ($query, $action) {
989
+ global $ai_wp_data;
990
+
991
+ $ai_wp_data [AI_CONTEXT] = $action == 'loop_start' ? AI_CONTEXT_BEFORE_POST : AI_CONTEXT_AFTER_POST;
992
+
993
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) return true;
994
+
995
+ if (isset ($query) && method_exists ($query, 'is_main_query')) {
996
+ if ($query->is_main_query()) return true;
997
+ }
998
+
999
+ return false;
1000
+ }
1001
+
1002
+ function ai_post_check ($post, $action) {
1003
+ global $ai_wp_data, $ad_inserter_globals;
1004
+
1005
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return false;
1006
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return false;
1007
+
1008
+ // Not used on AMP pages (yet)
1009
+ if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
1010
+ if (!in_the_loop()) return false;
1011
+ }
1012
+
1013
+ // Skip insertion before the first post
1014
+ if (!defined ('AI_POST_CHECK')) {
1015
+ define ('AI_POST_CHECK', true);
1016
+ return false;
1017
+ }
1018
+
1019
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS;
1020
+
1021
+ return true;;
1022
+ }
1023
+
1024
+ function ai_hook_function_loop_start ($hook_parameter) {
1025
+ ai_custom_hook ('loop_start', AI_TEXT_BEFORE_POST, $hook_parameter, 'ai_loop_check');
1026
+ }
1027
+
1028
+ function ai_hook_function_loop_end ($hook_parameter) {
1029
+ ai_custom_hook ('loop_end', AI_TEXT_AFTER_POST, $hook_parameter, 'ai_loop_check');
1030
+ }
1031
+
1032
+ function ai_hook_function_post ($hook_parameter) {
1033
+ ai_custom_hook ('the_post', AI_TEXT_BETWEEN_POSTS, $hook_parameter, 'ai_post_check');
1034
+ }
1035
+
1036
+ function ai_hook_function_footer () {
1037
+ ai_custom_hook ('wp_footer', AI_TEXT_FOOTER);
1038
+ }
1039
+
1040
  function ai_wp_hook () {
1041
+ global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker, $ai_custom_hooks;
1042
 
1043
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1044
  ai_log ("WP HOOK START");
1045
  $start_time = microtime (true);
1046
  }
1047
 
1048
+ ai_http_header ();
1049
+
1050
  set_page_type ();
1051
  set_user ();
1052
 
1108
  $debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0;
1109
 
1110
  $plugin_priority = get_plugin_priority ();
1111
+
1112
  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]]) != 0 || $debug_tags_positions)
1113
  add_filter ('the_content', 'ai_content_hook', $plugin_priority);
1114
 
1116
  add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
1117
 
1118
  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]]) != 0 || $debug_positions)
1119
+ // add_action ('loop_start', 'ai_loop_start_hook');
1120
+ add_action ('loop_start', 'ai_hook_function_loop_start');
1121
 
1122
  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]]) != 0 || $debug_positions)
1123
+ // add_action ('loop_end', 'ai_loop_end_hook');
1124
+ add_action ('loop_end', 'ai_hook_function_loop_end');
1125
 
1126
  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)
1127
+ // add_action ('the_post', 'ai_post_hook');
1128
+ add_action ('the_post', 'ai_hook_function_post');
1129
 
1130
  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) ||
1131
  (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) ||
1137
  $ai_walker = new ai_Walker_Comment;
1138
  }
1139
 
1140
+ // Code for PHP VERSION >= 5.3.0
1141
+ // function ai_get_custom_hook_function ($action, $name) {
1142
+ // return function () use ($action, $name) {
1143
+ // ai_custom_hook ($action, $name);
1144
+ // };
1145
+ // }
1146
+
1147
+ // foreach ($ai_custom_hooks as $index => $custom_hook) {
1148
+ // if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
1149
+ // add_action ($custom_hook ['action'], ai_get_custom_hook_function ($custom_hook ['action'], $custom_hook ['name']), $custom_hook ['priority']);
1150
+ // }
1151
+
1152
+ // Code for PHP VERSION < 5.3.0
1153
+ function ai_custom_hook_function_0 () {
1154
+ global $ai_custom_hooks;
1155
+ ai_custom_hook ($ai_custom_hooks [0]['action'], $ai_custom_hooks [0]['name']);
1156
+ }
1157
+
1158
+ function ai_custom_hook_function_1 () {
1159
+ global $ai_custom_hooks;
1160
+ ai_custom_hook ($ai_custom_hooks [1]['action'], $ai_custom_hooks [1]['name']);
1161
+ }
1162
+
1163
+ function ai_custom_hook_function_2 () {
1164
+ global $ai_custom_hooks;
1165
+ ai_custom_hook ($ai_custom_hooks [2]['action'], $ai_custom_hooks [2]['name']);
1166
+ }
1167
+
1168
+ function ai_custom_hook_function_3 () {
1169
+ global $ai_custom_hooks;
1170
+ ai_custom_hook ($ai_custom_hooks [3]['action'], $ai_custom_hooks [3]['name']);
1171
+ }
1172
+
1173
+ function ai_custom_hook_function_4 () {
1174
+ global $ai_custom_hooks;
1175
+ ai_custom_hook ($ai_custom_hooks [4]['action'], $ai_custom_hooks [4]['name']);
1176
+ }
1177
+
1178
+ function ai_custom_hook_function_5 () {
1179
+ global $ai_custom_hooks;
1180
+ ai_custom_hook ($ai_custom_hooks [5]['action'], $ai_custom_hooks [5]['name']);
1181
+ }
1182
+
1183
+ function ai_custom_hook_function_6 () {
1184
+ global $ai_custom_hooks;
1185
+ ai_custom_hook ($ai_custom_hooks [6]['action'], $ai_custom_hooks [6]['name']);
1186
+ }
1187
+
1188
+ function ai_custom_hook_function_7 () {
1189
+ global $ai_custom_hooks;
1190
+ ai_custom_hook ($ai_custom_hooks [7]['action'], $ai_custom_hooks [7]['name']);
1191
+ }
1192
+
1193
+ function ai_custom_hook_function_8 () {
1194
+ global $ai_custom_hooks;
1195
+ ai_custom_hook ($ai_custom_hooks [8]['action'], $ai_custom_hooks [8]['name']);
1196
+ }
1197
+
1198
+ function ai_custom_hook_function_9 () {
1199
+ global $ai_custom_hooks;
1200
+ ai_custom_hook ($ai_custom_hooks [9]['action'], $ai_custom_hooks [9]['name']);
1201
+ }
1202
+
1203
+ foreach ($ai_custom_hooks as $index => $custom_hook) {
1204
+ if ($index > 9) break;
1205
+
1206
+ if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
1207
+ add_action ($custom_hook ['action'], 'ai_custom_hook_function_' . $index, $custom_hook ['priority']);
1208
+ }
1209
+
1210
+
1211
 
1212
  if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1213
  // AMP, Accelerated Mobile Pages
1222
  // WP
1223
  add_action ('wp_head', 'ai_wp_head_hook');
1224
 
1225
+ $automatic_insertion_footer_hook = isset ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions;
1226
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1227
  // AMP, Accelerated Mobile Pages
1228
+ if ($automatic_insertion_footer_hook)
1229
+ add_action ('amp_post_template_footer', 'ai_hook_function_footer');
1230
+ add_action ('amp_post_template_footer', 'ai_amp_footer_hook');
1231
 
1232
  // WP AMP Ninja
1233
+ if ($automatic_insertion_footer_hook)
1234
+ add_action ('wpamp_google_analytics_code', 'ai_hook_function_footer');
1235
+ add_action ('wpamp_google_analytics_code', 'ai_amp_footer_hook');
1236
 
1237
  // WP AMP - Accelerated Mobile Pages for WordPress
1238
+ if ($automatic_insertion_footer_hook)
1239
+ add_action ('amphtml_after_footer', 'ai_hook_function_footer');
1240
+ add_action ('amphtml_after_footer', 'ai_amp_footer_hook');
1241
+ } else {
1242
+ // WP
1243
+ if ($automatic_insertion_footer_hook)
1244
+ add_action ('wp_footer', 'ai_hook_function_footer');
1245
+ add_action ('wp_footer', 'ai_wp_footer_hook');
1246
+ }
1247
 
1248
 
1249
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1504
  $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1505
  $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1506
  if (defined ('AI_STATISTICS') && AI_STATISTICS) {
1507
+ $js = str_replace ('AI_TRACK_PAGEVIEWS', get_track_pageviews () == AI_TRACKING_ENABLED ? 1 : 0, $js);
1508
  $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1509
 
1510
  if (!isset ($ai_wp_data [AI_VIEWPORTS])) {
1918
  }
1919
 
1920
 
1921
+ function ai_http_header () {
1922
+ global $block_object, $ai_wp_data;
1923
+
1924
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_HTTP_HEADER;
1925
+
1926
+ $obj = $block_object [AI_HEADER_OPTION_NAME];
1927
+ $obj->clear_code_cache ();
1928
+
1929
+ if ($obj->get_enable_manual ()) {
1930
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
1931
+ $processed_code = do_shortcode ($obj->ai_getCode ());
1932
+
1933
+ if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
1934
+ $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
1935
+ $processed_code = $codes [0];
1936
+ } else $processed_code = '';
1937
+
1938
+ $header_lines = explode ("\n", $processed_code);
1939
+ foreach ($header_lines as $header_line) {
1940
+ if (trim ($header_line) != '' && strpos ($header_line, ':') !== false)
1941
+ header (trim ($header_line));
1942
+ }
1943
+ }
1944
+ }
1945
+ }
1946
+
1947
  function ai_wp_head_hook () {
1948
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
1949
 
1957
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
1958
 
1959
  $obj = $block_object [AI_HEADER_OPTION_NAME];
1960
+ // $obj->clear_code_cache (); // cleared at ai_http_header
1961
 
1962
  if (!$obj->check_server_side_detection ()) return;
1963
 
1965
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
1966
  $processed_code = do_shortcode ($obj->ai_getCode ());
1967
 
1968
+ if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
1969
+ $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
1970
+ $processed_code = ltrim ($codes [1]);
1971
+ }
1972
+
1973
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
1974
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
1975
  $processed_code = $codes [0];
2020
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2021
 
2022
  $obj = $block_object [AI_HEADER_OPTION_NAME];
2023
+ // $obj->clear_code_cache (); // cleared at ai_http_header
2024
 
2025
  if (!$obj->check_server_side_detection ()) return;
2026
 
2028
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2029
  $processed_code = do_shortcode ($obj->ai_getCode ());
2030
 
2031
+ if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2032
+ $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2033
+ $processed_code = ltrim ($codes [1]);
2034
+ }
2035
+
2036
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2037
  $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2038
  $processed_code = ltrim ($codes [1]);
2076
  $start_time = microtime (true);
2077
  }
2078
 
 
 
 
 
 
2079
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
2080
 
2081
+ $footer = $block_object [AI_FOOTER_OPTION_NAME];
2082
+ $footer->clear_code_cache ();
 
 
2083
 
2084
+ if ($footer->check_server_side_detection ()) {
2085
+ if ($footer->get_enable_manual ()) {
2086
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
2087
+ $processed_code = do_shortcode ($footer->ai_getCode ());
2088
 
2089
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2090
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2091
+ $processed_code = $codes [0];
2092
+ } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2093
 
2094
+ echo $processed_code;
2095
+ }
2096
  }
2097
  }
2098
 
2099
+ if (!(defined ('DOING_AJAX') && DOING_AJAX)) {
2100
+ add_footer_inline_scripts ();
2101
+ }
2102
+
2103
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2104
  echo get_page_type_debug_info () , "\n";
2105
  }
2141
  }
2142
  }
2143
 
2144
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2145
+ echo get_page_type_debug_info ('AMP ') , "\n";
2146
+ }
2147
 
2148
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2149
  $ai_total_plugin_time += microtime (true) - $start_time;
2152
  }
2153
 
2154
  function ai_write_debug_info ($write_processing_log = false) {
2155
+ global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options, $block_insertion_log, $ai_custom_hooks;
2156
 
2157
  echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
2158
  if (function_exists ('ai_debug_header')) ai_debug_header ();
2185
  echo "\n";
2186
  echo "SETTINGS TIMESTAMP: ";
2187
  echo isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP']) ? date ("Y-m-d H:i:s", $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : "", "\n";
2188
+ echo "SETTINGS EXTRACT: ", defined ('AI_GENERATE_EXTRACT') ? "NO" : "YES", "\n";
2189
  echo "MULTISITE: ", is_multisite() ? "YES" : "NO", "\n";
2190
  if (is_multisite()) {
2191
  echo "MAIN SITE: ", is_main_site () ? "YES" : "NO", "\n";
2297
  elseif (AI_PHONE) echo "PHONE\n";
2298
  else echo "?\n";
2299
  }
2300
+
2301
+ $enabled_custom_hooks = array ();
2302
+ foreach ($ai_custom_hooks as $ai_custom_hook) {
2303
+ $hook = $ai_custom_hook ['index'];
2304
+ $enabled_custom_hooks [] = $ai_custom_hook ['action'];
2305
+ }
2306
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
2307
+ $name = str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($hook));
2308
+ $action = get_hook_action ($hook);
2309
+ if (get_hook_enabled ($hook) /*&& $name != '' && $action != ''*/) {
2310
+ $priority = get_hook_priority ($hook);
2311
+ echo 'CUSTOM HOOK ', $hook, ': ', sprintf ("%-30s %-35s %d %s", $name, $action, $priority, !in_array ($action, $enabled_custom_hooks) ? 'INVALID' : ''), "\n";
2312
+ }
2313
+ }
2314
  echo 'BLOCK CLASS NAME: ', get_block_class_name (), "\n";
2315
  echo 'DYNAMIC BLOCKS: ';
2316
  switch (get_dynamic_blocks()) {
2359
  echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2360
  echo 'ADB SELECTORS: ', get_adb_selectors (), "\n";
2361
  $redirection_page = get_redirection_page ();
2362
+ echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : 'Custom Url', "\n";
2363
  echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
2364
  echo 'ADB MESSAGE: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode (), "\n";
2365
  echo 'ADB MESSAGE CSS: ', get_message_css (), "\n";
2517
 
2518
  echo "TOTAL BLOCKS\n";
2519
  if (count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]))
2520
+ echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2521
  if (count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]))
2522
+ echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2523
  if (count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]))
2524
+ echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2525
  if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]))
2526
+ echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2527
  if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
2528
+ echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2529
  if (count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
2530
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2531
  if (count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
2532
+ echo "BETWEEN COMMENTS HOOK ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2533
  if (count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
2534
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2535
+ if (count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]))
2536
+ echo "FOOTER HOOK: ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2537
+ foreach ($ai_custom_hooks as $hook_index => $custom_hook) {
2538
+ if (count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY]))
2539
+ echo substr (strtoupper (str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY]), "\n";
2540
+ }
2541
 
2542
  echo "\nBLOCKS FOR THIS PAGE TYPE\n";
2543
  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]]))
2544
+ echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2545
  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]]))
2546
+ echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2547
  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]]))
2548
+ echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2549
  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]]))
2550
+ echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2551
  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]]))
2552
+ echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2553
  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]]))
2554
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2555
  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]]))
2556
+ echo "BETWEEN COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2557
  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]]))
2558
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2559
+ if (isset ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
2560
+ echo "FOOTER HOOK ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2561
+ foreach ($ai_custom_hooks as $hook_index => $custom_hook) {
2562
+ if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
2563
+ echo substr (strtoupper (str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
2564
+ }
2565
 
2566
  if ($write_processing_log) {
2567
  echo "\nTIME EVENT\n";
2745
  } else $plugin_options [$viewport_width_option_name] = '';
2746
  }
2747
 
2748
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
2749
+ $hook_enabled_settins_name = 'HOOK_ENABLED_' . $hook;
2750
+ $hook_name_settins_name = 'HOOK_NAME_' . $hook;
2751
+ $hook_action_settins_name = 'HOOK_ACTION_' . $hook;
2752
+ $hook_priority_settins_name = 'HOOK_PRIORITY_' . $hook;
2753
+
2754
+ if (!isset ($plugin_options [$hook_enabled_settins_name])) $plugin_options [$hook_enabled_settins_name] = AI_DISABLED;
2755
+ if (!isset ($plugin_options [$hook_name_settins_name])) $plugin_options [$hook_name_settins_name] = '';
2756
+ if (!isset ($plugin_options [$hook_action_settins_name])) $plugin_options [$hook_action_settins_name] = '';
2757
+ if (!isset ($plugin_options [$hook_priority_settins_name]) || !is_int ($plugin_options [$hook_priority_settins_name])) $plugin_options [$hook_priority_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY;
2758
+ }
2759
+
2760
  if (function_exists ('ai_check_options')) ai_check_options ($plugin_options);
2761
 
2762
  return ($plugin_options);
2924
  return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]);
2925
  }
2926
 
2927
+ function get_hook_enabled ($hook_number) {
2928
+ global $ai_db_options;
2929
+
2930
+ $hook_settins_name = 'HOOK_ENABLED_' . $hook_number;
2931
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = AI_DISABLED;
2932
+
2933
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
2934
+ }
2935
+
2936
+ function get_hook_name ($hook_number) {
2937
+ global $ai_db_options;
2938
+
2939
+ $hook_settins_name = 'HOOK_NAME_' . $hook_number;
2940
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = "";
2941
+
2942
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
2943
+ }
2944
+
2945
+ function get_hook_action ($hook_number) {
2946
+ global $ai_db_options;
2947
+
2948
+ $hook_settins_name = 'HOOK_ACTION_' . $hook_number;
2949
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = "";
2950
+
2951
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
2952
+ }
2953
+
2954
+ function get_hook_priority ($hook_number) {
2955
+ global $ai_db_options;
2956
+
2957
+ $hook_settins_name = 'HOOK_PRIORITY_' . $hook_number;
2958
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY;
2959
+
2960
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
2961
+ }
2962
+
2963
  function get_country_group_name ($group_number) {
2964
  global $ai_db_options;
2965
 
3045
  return DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
3046
  }
3047
 
3048
+ function get_adb_action ($saved_value = false) {
3049
+ global $ai_db_options, $ai_wp_data;
3050
+
3051
+ if (!$saved_value) {
3052
+ if (isset ($ai_wp_data [AI_ADB_SHORTCODE_ACTION])) return ($ai_wp_data [AI_ADB_SHORTCODE_ACTION]);
3053
+ }
3054
 
3055
  if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
3056
 
3156
  return $str;
3157
  }
3158
 
3159
+ function filter_string_tags ($str){
3160
+
3161
+ $str = str_replace (array ("\\\""), array ("\""), $str);
3162
+ $str = str_replace (array ("\""), "", $str);
3163
+ $str = str_replace (array ("<", ">"), array ("&lt;", "&gt;"), $str);
3164
+ $str = trim (esc_html ($str));
3165
+
3166
+ return $str;
3167
+ }
3168
+
3169
  function filter_option ($option, $value, $delete_escaped_backslashes = true){
3170
  if ($delete_escaped_backslashes)
3171
  $value = str_replace (array ("\\\""), array ("\""), $value);
3216
  $option == 'ADB_REDIRECTION_PAGE' ||
3217
  $option == 'ADB_CUSTOM_REDIRECTION_URL' ||
3218
  $option == AI_OPTION_CUSTOM_CSS ||
3219
+ $option == 'HOOK_PRIORITY' ||
3220
  $option == 'ADB_OVERLAY_CSS' ||
3221
  $option == 'ADB_MESSAGE_CSS') {
3222
  $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
3311
  }
3312
 
3313
  function ai_generate_extract (&$settings) {
3314
+ global $ai_custom_hooks;
3315
+
3316
+ define ('AI_GENERATE_EXTRACT', true);
3317
 
3318
  $obj = new ai_Block (1);
3319
 
3320
  $extract = array ();
 
 
 
 
 
 
 
 
3321
 
3322
  $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());
3323
  $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());
3327
  $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());
3328
  $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());
3329
  $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());
3330
+ $footer_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());
3331
+ $custom_hook_blocks = array ();
3332
+ for ($custom_hook = 1; $custom_hook <= AD_INSERTER_HOOKS; $custom_hook ++) {
3333
+ $custom_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());
3334
+ }
3335
 
3336
  // Get blocks used in sidebar widgets
3337
  $sidebar_widgets = wp_get_sidebars_widgets();
3417
  foreach ($page_types as $block_page_type) $after_comments_hook_blocks [$block_page_type][]= $block;
3418
  $after_comments_hook_blocks [AI_PT_ANY][]= $block;
3419
  break;
3420
+ case AI_AUTOMATIC_INSERTION_FOOTER:
3421
+ foreach ($page_types as $block_page_type) $footer_hook_blocks [$block_page_type][]= $block;
3422
+ $footer_hook_blocks [AI_PT_ANY][]= $block;
3423
+ break;
3424
+ default:
3425
+ if ($automatic_insertion >= AI_AUTOMATIC_INSERTION_CUSTOM_HOOK && $automatic_insertion < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + AD_INSERTER_HOOKS) {
3426
+ $hook_index = $automatic_insertion - AI_AUTOMATIC_INSERTION_CUSTOM_HOOK;
3427
+ foreach ($page_types as $block_page_type) $custom_hook_blocks [$hook_index][$block_page_type][]= $block;
3428
+ $custom_hook_blocks [$hook_index][AI_PT_ANY][]= $block;
3429
+ }
3430
+ break;
3431
  }
3432
  }
3433
 
3450
  $extract [BEFORE_COMMENTS_HOOK_BLOCKS] = $before_comments_hook_blocks;
3451
  $extract [BETWEEN_COMMENTS_HOOK_BLOCKS] = $between_comments_hook_blocks;
3452
  $extract [AFTER_COMMENTS_HOOK_BLOCKS] = $after_comments_hook_blocks;
3453
+ $extract [FOOTER_HOOK_BLOCKS] = $footer_hook_blocks;
3454
+
3455
+ for ($custom_hook = 1; $custom_hook <= AD_INSERTER_HOOKS; $custom_hook ++) {
3456
+ $action = get_hook_action ($custom_hook);
3457
+ if (get_hook_enabled ($custom_hook) && get_hook_name ($custom_hook) != '' && $action != '') {
3458
+ $extract [$action . CUSTOM_HOOK_BLOCKS] = $custom_hook_blocks [$custom_hook - 1];
3459
+ }
3460
+ }
3461
 
3462
  return ($extract);
3463
  }
3464
 
3465
  function ai_load_settings () {
3466
+ global $ai_db_options, $block_object, $ai_db_options_extract, $ai_wp_data, $version_string, $ai_custom_hooks;
3467
 
3468
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START");
3469
 
3470
  ai_load_options ();
3471
 
3472
+ $ai_custom_hooks = array ();
3473
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
3474
+ $name = get_hook_name ($hook);
3475
+ $action = get_hook_action ($hook);
3476
+ if (get_hook_enabled ($hook) && $name != '' && $action != '') {
3477
+ $ai_custom_hooks [] = array ('index' => $hook, 'name' => $name, 'action' => $action, 'priority' => get_hook_priority ($hook));
3478
+ }
3479
+ }
3480
+
3481
  if (isset ($ai_db_options [AI_EXTRACT_OPTION_NAME]) &&
3482
  isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
3483
  isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][POST_HOOK_BLOCKS]) &&
3484
  isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
3485
  isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
3486
+ isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][AI_EXTRACT_USED_BLOCKS]) &&
3487
+ isset ($ai_db_options [AI_EXTRACT_OPTION_NAME][FOOTER_HOOK_BLOCKS]))
3488
  $ai_db_options_extract = $ai_db_options [AI_EXTRACT_OPTION_NAME]; else
3489
  $ai_db_options_extract = ai_generate_extract ($ai_db_options);
3490
 
3709
  if (isset ($_POST ['javascript_debugging'])) $options ['JAVASCRIPT_DEBUGGING'] = filter_option ('JAVASCRIPT_DEBUGGING', $_POST ['javascript_debugging']);
3710
 
3711
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
3712
+ if (isset ($_POST ['viewport-name-'.$viewport])) $options ['VIEWPORT_NAME_'.$viewport] = filter_string ($_POST ['viewport-name-'.$viewport]);
3713
+ if (isset ($_POST ['viewport-width-'.$viewport])) $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
3714
+ }
3715
+
3716
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
3717
+ if (isset ($_POST ['hook-enabled-'.$hook])) $options ['HOOK_ENABLED_'.$hook] = filter_option ('HOOK_ENABLED', $_POST ['hook-enabled-'.$hook]);
3718
+ if (isset ($_POST ['hook-name-'.$hook])) $options ['HOOK_NAME_'.$hook] = filter_string_tags ($_POST ['hook-name-'.$hook]);
3719
+ if (isset ($_POST ['hook-action-'.$hook])) $options ['HOOK_ACTION_'.$hook] = filter_string ($_POST ['hook-action-'.$hook]);
3720
+ if (isset ($_POST ['hook-priority-'.$hook])) $options ['HOOK_PRIORITY_'.$hook] = filter_option ('HOOK_PRIORITY', $_POST ['hook-enabled-'.$hook]);
3721
  }
3722
 
3723
  $options ['VIEWPORT_CSS'] = generate_viewport_css ();
4233
  return $content;
4234
  }
4235
 
4236
+ // Deprecated
4237
  // Process Before / After Post postion
 
4238
  function ai_before_after_post ($query, $automatic_insertion) {
4239
  global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
4240
 
4315
  echo $ad_code;
4316
  }
4317
 
4318
+ // Deprecated
4319
  // Process Before Post postion
4320
  function ai_loop_start_hook ($query) {
4321
  global $ai_wp_data, $ai_total_plugin_time;
4332
  }
4333
 
4334
 
4335
+ // Deprecated
4336
  // Process After Post postion
4337
  function ai_loop_end_hook ($query){
4338
  global $ai_wp_data, $ai_total_plugin_time;
4349
  }
4350
 
4351
 
4352
+ // Deprecated
4353
  // Process Between Posts postion
4354
  function ai_post_hook ($post) {
4355
  global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
4681
  }
4682
  }
4683
 
4684
+ function ai_custom_hook ($action, $name, $hook_parameter = null, $hook_check = null) {
4685
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
4686
+
4687
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
4688
+
4689
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
4690
+
4691
+ if (isset ($hook_check)) {
4692
+ if (!call_user_func ($hook_check, $hook_parameter, $action)) return;
4693
+ }
4694
+
4695
+ $hook_name = strtoupper ($name);
4696
+
4697
+ if ($debug_processing) {
4698
+ ai_log (str_replace (array ('&LT;', '&GT;'), array ('<', '>'), $hook_name) . " HOOK START");
4699
+ $start_time = microtime (true);
4700
+ }
4701
+
4702
+ $globals_name = 'AI_' . strtoupper ($action) . '_COUNTER';
4703
+
4704
+ if (!isset ($ad_inserter_globals [$globals_name])) {
4705
+ $ad_inserter_globals [$globals_name] = 1;
4706
+ } else $ad_inserter_globals [$globals_name] ++;
4707
+
4708
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
4709
+
4710
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
4711
+
4712
+ $counter = $ad_inserter_globals [$globals_name];
4713
+ if ($counter == 1) $counter = '';
4714
+
4715
+ $style = AI_DEBUG_POSITIONS_STYLE;
4716
+
4717
+ echo "<section style='$style'>".$hook_name." ".$counter."</section>";
4718
+ }
4719
+
4720
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
4721
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
4722
+ $selected_blocks = explode (",", $meta_value);
4723
+ } else $selected_blocks = array ();
4724
+
4725
+ $ad_code = "";
4726
+
4727
+ $ai_last_check = AI_CHECK_NONE;
4728
+ $current_block = 0;
4729
+
4730
+ if (isset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
4731
+ foreach ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
4732
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
4733
+
4734
+ if (!isset ($block_object [$block])) continue;
4735
+
4736
+ $current_block = $block;
4737
+
4738
+ $obj = $block_object [$block];
4739
+ $obj->clear_code_cache ();
4740
+
4741
+ if (!$obj->check_server_side_detection ()) continue;
4742
+ if (!$obj->check_page_types_lists_users ()) continue;
4743
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
4744
+ if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
4745
+ if (!$obj->check_number_of_words ()) continue;
4746
+
4747
+ // Last check before counter check before insertion
4748
+ $ai_last_check = AI_CHECK_CODE;
4749
+ if ($obj->ai_getCode () == '') continue;
4750
+
4751
+ // Last check before insertion
4752
+ if (!$obj->check_and_increment_block_counter ()) continue;
4753
+
4754
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
4755
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
4756
+ $ad_code .= $obj->get_code_for_insertion ();
4757
+ $ai_last_check = AI_CHECK_INSERTED;
4758
+ }
4759
+ }
4760
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
4761
+
4762
+ echo $ad_code;
4763
+
4764
+ if ($debug_processing) {
4765
+ $ai_total_plugin_time += microtime (true) - $start_time;
4766
+ ai_log (str_replace (array ('&LT;', '&GT;'), array ('<', '>'), $hook_name) . " HOOK END\n");
4767
+ }
4768
+ }
4769
+
4770
  function process_shortcode (&$block, $atts) {
4771
  global $block_object, $ai_last_check, $ai_wp_data;
4772
 
4776
  "block" => "",
4777
  "name" => "",
4778
  "ignore" => "",
4779
+ "check" => "",
4780
  "debugger" => "",
4781
  "adb" => "",
4782
  "css" => "",
4785
  "amp" => "",
4786
  "rotate" => "",
4787
  "count" => "",
4788
+ "http" => "",
4789
  "custom-field" => "",
4790
  "data" => "",
4791
  ), $atts);
4796
  if ($output != '') return $output;
4797
  }
4798
 
4799
+ if (($adb = trim ($parameters ['adb'])) != '') {
4800
+ // message html
4801
+ // message css
4802
+ // overlay css
4803
+ // undismissible
4804
+
4805
+ // redirection page
4806
+ // redirection url
4807
+
4808
+ switch (strtolower ($adb)) {
4809
+ case 'message':
4810
+ $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_MESSAGE;
4811
+ break;
4812
+ case 'redirection':
4813
+ $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_REDIRECTION;
4814
+ break;
4815
+ }
4816
+ return "";
4817
+ }
4818
+
4819
  $block = - 1;
4820
  if (is_numeric ($parameters ['block'])) {
4821
  $block = intval ($parameters ['block']);
4843
  if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
4844
  return AD_AMP_SEPARATOR;
4845
  }
4846
+ if ($parameters ['http'] != '' || in_array ('HTTP', $atts) || in_array ('http', $atts)) {
4847
+ return AD_HTTP_SEPARATOR;
4848
+ }
4849
  if ($parameters ['custom-field'] != '') {
4850
  $post_meta = get_post_meta (get_the_ID(), $parameters ['custom-field']);
4851
  if (is_array ($post_meta)) {
4876
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("SHORTCODE $block (".($parameters ['block'] != '' ? 'block="'.$parameters ['block'].'"' : '').($parameters ['name'] != '' ? 'name="'.$parameters ['name'].'"' : '').")");
4877
 
4878
  // IGNORE SETTINGS
4879
+ // page-type
4880
+ // *block-counter
4881
+
4882
+ // CHECK SETTINGS
4883
+ // exceptions
4884
 
4885
  $ignore_array = array ();
4886
  if (trim ($parameters ['ignore']) != '') {
4887
  $ignore_array = explode (",", str_replace (" ", "", $parameters ['ignore']));
4888
  }
4889
 
4890
+ $check_array = array ();
4891
+ if (trim ($parameters ['check']) != '') {
4892
+ $check_array = explode (",", str_replace (" ", "", $parameters ['check']));
4893
+ }
4894
+
4895
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_SHORTCODE;
4896
 
4897
  $obj = $block_object [$block];
4903
  if (!$obj->check_server_side_detection ()) return "";
4904
  if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
4905
 
4906
+ if (in_array ("exceptions", $check_array)) {
4907
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
4908
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
4909
+ $selected_blocks = explode (",", $meta_value);
4910
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) return "";
4911
+ }
4912
+ }
4913
+
4914
  // Last check before counter check before insertion
4915
  $ai_last_check = AI_CHECK_CODE;
4916
  if ($obj->ai_getCode () == '') return "";
5131
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5132
  $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5133
  $selected_blocks = explode (",", $meta_value);
 
5134
  if (!$obj->check_post_page_exceptions ($selected_blocks)) return;
5135
  }
5136
 
class.php CHANGED
@@ -490,7 +490,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
490
  }
491
 
492
  public function get_automatic_insertion_text (){
493
- switch ($this->get_automatic_insertion()) {
 
494
  case AI_AUTOMATIC_INSERTION_DISABLED:
495
  return AI_TEXT_DISABLED;
496
  break;
@@ -530,7 +531,15 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
530
  case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS:
531
  return AI_TEXT_AFTER_COMMENTS;
532
  break;
 
 
 
533
  default:
 
 
 
 
 
534
  return '';
535
  break;
536
  }
@@ -1117,9 +1126,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1117
  $counter_for_filter = $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number];
1118
 
1119
  if ($counter_for_filter != 0 && $counter_for_filter <= count ($ads)) {
1120
- $code = $ads [$counter_for_filter - 1];
1121
- } else $code = '';
1122
- } else $code = $ads [rand (0, count ($ads) - 1)];
1123
  }
1124
 
1125
  $dynamic_blocks = get_dynamic_blocks ();
@@ -2842,7 +2851,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2842
 
2843
  if ($parameter_list_type == AD_BLACK_LIST) $return = false; else $return = true;
2844
 
2845
- if ($parameter_list == AD_EMPTY_DATA || count ($_GET) == 0) {
 
 
2846
  return !$return;
2847
  }
2848
 
@@ -2862,8 +2873,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2862
  foreach ($parameters_listed as $parameter) {
2863
  if (strpos ($parameter, "=") !== false) {
2864
  $parameter_value = explode ("=", $parameter);
2865
- if (array_key_exists ($parameter_value [0], $_GET) && $_GET [$parameter_value [0]] == $parameter_value [1]) return $return;
2866
- } else if (array_key_exists ($parameter, $_GET)) return $return;
2867
  }
2868
 
2869
  return !$return;
@@ -3066,9 +3077,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3066
  global $ai_last_check, $ai_wp_data;
3067
 
3068
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) {
3069
- // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
3070
- // $selected_blocks = explode (",", $meta_value);
3071
-
3072
  $enabled_on = $this->get_ad_enabled_on_which_posts ();
3073
  if ($enabled_on == AI_INDIVIDUALLY_DISABLED) {
3074
  $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED;
@@ -3079,9 +3087,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3079
  if (!in_array ($this->number, $selected_blocks)) return false;
3080
  }
3081
  } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
3082
- // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
3083
- // $selected_blocks = explode (",", $meta_value);
3084
-
3085
  $enabled_on = $this->get_ad_enabled_on_which_pages ();
3086
  if ($enabled_on == AI_INDIVIDUALLY_DISABLED) {
3087
  $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED;
490
  }
491
 
492
  public function get_automatic_insertion_text (){
493
+ $automatic_insertion = $this->get_automatic_insertion();
494
+ switch ($automatic_insertion) {
495
  case AI_AUTOMATIC_INSERTION_DISABLED:
496
  return AI_TEXT_DISABLED;
497
  break;
531
  case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS:
532
  return AI_TEXT_AFTER_COMMENTS;
533
  break;
534
+ case AI_AUTOMATIC_INSERTION_FOOTER:
535
+ return AI_TEXT_FOOTER;
536
+ break;
537
  default:
538
+ if ($automatic_insertion >= AI_AUTOMATIC_INSERTION_CUSTOM_HOOK && $automatic_insertion < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + AD_INSERTER_HOOKS) {
539
+ $hook_index = $automatic_insertion - AI_AUTOMATIC_INSERTION_CUSTOM_HOOK;
540
+ return get_hook_name ($hook_index + 1);
541
+ }
542
+
543
  return '';
544
  break;
545
  }
1126
  $counter_for_filter = $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number];
1127
 
1128
  if ($counter_for_filter != 0 && $counter_for_filter <= count ($ads)) {
1129
+ $processed_code = $ads [$counter_for_filter - 1];
1130
+ } else $processed_code = '';
1131
+ } else $processed_code = $ads [rand (0, count ($ads) - 1)];
1132
  }
1133
 
1134
  $dynamic_blocks = get_dynamic_blocks ();
2851
 
2852
  if ($parameter_list_type == AD_BLACK_LIST) $return = false; else $return = true;
2853
 
2854
+ $parameters = array_merge ($_COOKIE, $_GET);
2855
+
2856
+ if ($parameter_list == AD_EMPTY_DATA || count ($parameters) == 0) {
2857
  return !$return;
2858
  }
2859
 
2873
  foreach ($parameters_listed as $parameter) {
2874
  if (strpos ($parameter, "=") !== false) {
2875
  $parameter_value = explode ("=", $parameter);
2876
+ if (array_key_exists ($parameter_value [0], $parameters) && $parameters [$parameter_value [0]] == $parameter_value [1]) return $return;
2877
+ } else if (array_key_exists ($parameter, $parameters)) return $return;
2878
  }
2879
 
2880
  return !$return;
3077
  global $ai_last_check, $ai_wp_data;
3078
 
3079
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) {
 
 
 
3080
  $enabled_on = $this->get_ad_enabled_on_which_posts ();
3081
  if ($enabled_on == AI_INDIVIDUALLY_DISABLED) {
3082
  $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED;
3087
  if (!in_array ($this->number, $selected_blocks)) return false;
3088
  }
3089
  } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
 
 
 
3090
  $enabled_on = $this->get_ad_enabled_on_which_pages ();
3091
  if ($enabled_on == AI_INDIVIDUALLY_DISABLED) {
3092
  $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED;
constants.php CHANGED
@@ -18,7 +18,7 @@ if (!defined( 'AD_INSERTER_NAME'))
18
  define ('AD_INSERTER_NAME', 'Ad Inserter');
19
 
20
  if (!defined( 'AD_INSERTER_VERSION'))
21
- define ('AD_INSERTER_VERSION', '2.2.3');
22
 
23
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
24
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -157,6 +157,7 @@ define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
157
  define('AD_ROTATE_SEPARATOR', '|rotate|');
158
  define('AD_COUNT_SEPARATOR', '|count|');
159
  define('AD_AMP_SEPARATOR', '|amp|');
 
160
 
161
  //form select options
162
  define('AD_SELECT_SELECTED','selected');
@@ -189,6 +190,8 @@ define('AI_AUTOMATIC_INSERTION_BETWEEN_POSTS', 9);
189
  define('AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS', 10);
190
  define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
191
  define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
 
 
192
 
193
  define('AI_TEXT_DISABLED', 'Disabled');
194
  define('AI_TEXT_BEFORE_POST', 'Before Post');
@@ -203,6 +206,7 @@ define('AI_TEXT_BETWEEN_POSTS', 'Between Posts');
203
  define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
204
  define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
205
  define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
 
206
 
207
  //Display options
208
  define('AD_DISPLAY_ALL_USERS','all users');
@@ -435,6 +439,8 @@ define ('AI_TRANSIENT_ADB_CLASS_5', 'ai-adb-class-5');
435
  define ('AI_TRANSIENT_ADB_CLASS_6', 'ai-adb-class-6');
436
  define ('AI_TRANSIENT_ADB_CLASS_EXPIRATION', 48 * 3600);
437
 
 
 
438
  define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
439
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
440
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
@@ -460,6 +466,7 @@ define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
460
  define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
461
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
462
  define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
 
463
 
464
  define ('AI_ADBLOCKING_DETECTION', true);
465
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
@@ -496,10 +503,12 @@ define ('CONTENT_HOOK_BLOCKS', 'content_hook');
496
  define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
497
  define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
498
  define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
499
- define ('POST_HOOK_BLOCKS', 'post_hook');
500
  define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
501
  define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
502
  define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
 
 
503
  define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
504
 
505
  define ('AI_CHECK_NONE', - 1);
@@ -599,6 +608,7 @@ define ('AI_DAYS_SINCE_INSTAL', 18);
599
  define ('AI_TAGS', 19);
600
  define ('AI_VIEWPORTS', 20);
601
  define ('AI_WORD_COUNT', 21);
 
602
 
603
  define ('AI_CONTEXT_NONE', 0);
604
  define ('AI_CONTEXT_CONTENT', 1);
@@ -608,12 +618,13 @@ define ('AI_CONTEXT_AFTER_POST', 4);
608
  define ('AI_CONTEXT_WIDGET', 5);
609
  define ('AI_CONTEXT_PHP_FUNCTION', 6);
610
  define ('AI_CONTEXT_SHORTCODE', 7);
611
- define ('AI_CONTEXT_HEADER', 8);
612
- define ('AI_CONTEXT_FOOTER', 9);
613
- define ('AI_CONTEXT_BETWEEN_POSTS', 10);
614
- define ('AI_CONTEXT_BEFORE_COMMENTS', 11);
615
- define ('AI_CONTEXT_BETWEEN_COMMENTS', 12);
616
- define ('AI_CONTEXT_AFTER_COMMENTS', 13);
 
617
 
618
  define ('AI_URL_DEBUG', 'ai-debug'); // AI_URL_DEBUG_
619
  define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing'); // AI_URL_DEBUG_PROCESSING_
@@ -641,6 +652,9 @@ if (!defined ('AD_INSERTER_BLOCKS'))
641
  if (!defined ('AD_INSERTER_VIEWPORTS'))
642
  define ('AD_INSERTER_VIEWPORTS', 3);
643
 
 
 
 
644
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
645
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
646
  define ('AI_DEBUG_PAGE_TYPE_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;');
18
  define ('AD_INSERTER_NAME', 'Ad Inserter');
19
 
20
  if (!defined( 'AD_INSERTER_VERSION'))
21
+ define ('AD_INSERTER_VERSION', '2.2.4');
22
 
23
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
24
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
157
  define('AD_ROTATE_SEPARATOR', '|rotate|');
158
  define('AD_COUNT_SEPARATOR', '|count|');
159
  define('AD_AMP_SEPARATOR', '|amp|');
160
+ define('AD_HTTP_SEPARATOR', '|http|');
161
 
162
  //form select options
163
  define('AD_SELECT_SELECTED','selected');
190
  define('AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS', 10);
191
  define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
192
  define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
193
+ define('AI_AUTOMATIC_INSERTION_FOOTER', 13);
194
+ define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
195
 
196
  define('AI_TEXT_DISABLED', 'Disabled');
197
  define('AI_TEXT_BEFORE_POST', 'Before Post');
206
  define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
207
  define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
208
  define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
209
+ define('AI_TEXT_FOOTER', 'Footer');
210
 
211
  //Display options
212
  define('AD_DISPLAY_ALL_USERS','all users');
439
  define ('AI_TRANSIENT_ADB_CLASS_6', 'ai-adb-class-6');
440
  define ('AI_TRANSIENT_ADB_CLASS_EXPIRATION', 48 * 3600);
441
 
442
+ define ('AI_TRANSIENT_ADB_FILES_VERSION', 'ai-adb-version');
443
+
444
  define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
445
  define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
446
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
466
  define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
467
  define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
468
  define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
469
+ define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
470
 
471
  define ('AI_ADBLOCKING_DETECTION', true);
472
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
503
  define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
504
  define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
505
  define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
506
+ define ('POST_HOOK_BLOCKS', 'the_post_hook');
507
  define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
508
  define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
509
  define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
510
+ define ('FOOTER_HOOK_BLOCKS', 'wp_footer_hook');
511
+ define ('CUSTOM_HOOK_BLOCKS', '_hook');
512
  define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
513
 
514
  define ('AI_CHECK_NONE', - 1);
608
  define ('AI_TAGS', 19);
609
  define ('AI_VIEWPORTS', 20);
610
  define ('AI_WORD_COUNT', 21);
611
+ define ('AI_ADB_SHORTCODE_ACTION', 22);
612
 
613
  define ('AI_CONTEXT_NONE', 0);
614
  define ('AI_CONTEXT_CONTENT', 1);
618
  define ('AI_CONTEXT_WIDGET', 5);
619
  define ('AI_CONTEXT_PHP_FUNCTION', 6);
620
  define ('AI_CONTEXT_SHORTCODE', 7);
621
+ define ('AI_CONTEXT_HTTP_HEADER', 8);
622
+ define ('AI_CONTEXT_HEADER', 9);
623
+ define ('AI_CONTEXT_FOOTER', 10);
624
+ define ('AI_CONTEXT_BETWEEN_POSTS', 11);
625
+ define ('AI_CONTEXT_BEFORE_COMMENTS', 12);
626
+ define ('AI_CONTEXT_BETWEEN_COMMENTS', 13);
627
+ define ('AI_CONTEXT_AFTER_COMMENTS', 14);
628
 
629
  define ('AI_URL_DEBUG', 'ai-debug'); // AI_URL_DEBUG_
630
  define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing'); // AI_URL_DEBUG_PROCESSING_
652
  if (!defined ('AD_INSERTER_VIEWPORTS'))
653
  define ('AD_INSERTER_VIEWPORTS', 3);
654
 
655
+ if (!defined ('AD_INSERTER_HOOKS'))
656
+ define ('AD_INSERTER_HOOKS', 2);
657
+
658
  define ('AI_DEBUG_TAGS_STYLE', 'font-weight: bold; color: white; padding: 2px;');
659
  define ('AI_DEBUG_POSITIONS_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;');
660
  define ('AI_DEBUG_PAGE_TYPE_STYLE', 'text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;');
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.2.3"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -223,7 +223,7 @@ div.ai-tooltip .version {
223
  }
224
 
225
  .ui-tabs .ui-tabs-nav li {
226
- margin: 1px 0.18em 0 0;
227
  }
228
 
229
  #ai-tabs a {
@@ -240,7 +240,7 @@ div.ai-tooltip .version {
240
  }
241
 
242
  #ai-plugin-settings-tabs li a {
243
- padding: .5em 0.6em;
244
  font-size: 12px;
245
  }
246
 
@@ -407,6 +407,192 @@ div.automatic-insertion img {
407
  vertical-align: middle;
408
  }
409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  .checkbox-icon.icon-tracking {
411
  background: url('images/icons.png') -40px -20px;
412
  }
1
  #ai-data {
2
+ font-family: "2.2.4"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
223
  }
224
 
225
  .ui-tabs .ui-tabs-nav li {
226
+ margin: 1px 0.17em 0 0;
227
  }
228
 
229
  #ai-tabs a {
240
  }
241
 
242
  #ai-plugin-settings-tabs li a {
243
+ padding: .5em 0.4em;
244
  font-size: 12px;
245
  }
246
 
407
  vertical-align: middle;
408
  }
409
 
410
+ img.automatic-insertion.disabled {
411
+ background: url('images/insertions-alignmets.png') 0 0;
412
+ }
413
+
414
+ img.automatic-insertion.before-post {
415
+ background: url('images/insertions-alignmets.png') -56px 0;
416
+ }
417
+
418
+ img.automatic-insertion.after-post {
419
+ background: url('images/insertions-alignmets.png') -112px 0;
420
+ }
421
+
422
+ img.automatic-insertion.before-content {
423
+ background: url('images/insertions-alignmets.png') -168px 0;
424
+ }
425
+
426
+ img.automatic-insertion.after-content {
427
+ background: url('images/insertions-alignmets.png') -224px 0;
428
+ }
429
+
430
+ img.automatic-insertion.before-paragraph {
431
+ background: url('images/insertions-alignmets.png') -280px 0;
432
+ }
433
+
434
+ img.automatic-insertion.after-paragraph {
435
+ background: url('images/insertions-alignmets.png') -336px 0;
436
+ }
437
+
438
+ img.automatic-insertion.before-excerpts {
439
+ background: url('images/insertions-alignmets.png') -392px 0;
440
+ }
441
+
442
+ img.automatic-insertion.after-excerpts {
443
+ background: url('images/insertions-alignmets.png') 0 -56px;
444
+ }
445
+
446
+ img.automatic-insertion.between-posts {
447
+ background: url('images/insertions-alignmets.png') -56px -56px;
448
+ }
449
+
450
+ img.automatic-insertion.before-comments {
451
+ background: url('images/insertions-alignmets.png') -112px -56px;
452
+ }
453
+
454
+ img.automatic-insertion.between-comments {
455
+ background: url('images/insertions-alignmets.png') -168px -56px;
456
+ }
457
+
458
+ img.automatic-insertion.after-comments {
459
+ background: url('images/insertions-alignmets.png') -224px -56px;
460
+ }
461
+
462
+ img.automatic-insertion.footer {
463
+ background: url('images/insertions-alignmets.png') -280px -56px;
464
+ }
465
+
466
+ img.automatic-insertion.custom-hook {
467
+ background: url('images/insertions-alignmets.png') -336px -56px;
468
+ }
469
+
470
+ img.automatic-insertion.no-wrapping {
471
+ background: url('images/insertions-alignmets.png') -392px -56px;
472
+ }
473
+
474
+ img.automatic-insertion.custom-css {
475
+ background: url('images/insertions-alignmets.png') 0 -112px;
476
+ }
477
+
478
+ img.automatic-insertion.default {
479
+ background: url('images/insertions-alignmets.png') -56px -112px;
480
+ }
481
+
482
+ img.automatic-insertion.align-left {
483
+ background: url('images/insertions-alignmets.png') -112px -112px;
484
+ }
485
+
486
+ img.automatic-insertion.center {
487
+ background: url('images/insertions-alignmets.png') -168px -112px;
488
+ }
489
+
490
+ img.automatic-insertion.align-right {
491
+ background: url('images/insertions-alignmets.png') -224px -112px;
492
+ }
493
+
494
+ img.automatic-insertion.float-left {
495
+ background: url('images/insertions-alignmets.png') -280px -112px;
496
+ }
497
+
498
+ img.automatic-insertion.float-right {
499
+ background: url('images/insertions-alignmets.png') -336px -112px;
500
+ }
501
+
502
+ img.automatic-insertion.sticky-left {
503
+ background: url('images/insertions-alignmets.png') -392px -112px;
504
+ }
505
+
506
+ img.automatic-insertion.sticky-right {
507
+ background: url('images/insertions-alignmets.png') 0 -168px;
508
+ }
509
+
510
+ img.automatic-insertion.sticky-top {
511
+ background: url('images/insertions-alignmets.png') -56px -168px;
512
+ }
513
+
514
+ img.automatic-insertion.sticky-bottom {
515
+ background: url('images/insertions-alignmets.png') -112px -168px;
516
+ }
517
+
518
+ /*img.automatic-insertion.center {*/
519
+ /* background: url('images/insertions-alignmets.png') -168px -168px;*/
520
+ /*}*/
521
+
522
+ /*img.automatic-insertion.align-right {*/
523
+ /* background: url('images/insertions-alignmets.png') -224px -168px;*/
524
+ /*}*/
525
+
526
+ /*img.automatic-insertion.float-left {*/
527
+ /* background: url('images/insertions-alignmets.png') -280px -168px;*/
528
+ /*}*/
529
+
530
+ /*img.automatic-insertion.float-right {*/
531
+ /* background: url('images/insertions-alignmets.png') -336px -168px;*/
532
+ /*}*/
533
+
534
+ /*img.automatic-insertion.sticky-left {*/
535
+ /* background: url('images/insertions-alignmets.png') -392px -168px;*/
536
+ /*}*/
537
+
538
+ img.automatic-insertion {
539
+ background-size: 448px!important;
540
+ }
541
+
542
+
543
+ img.automatic-insertion.preview.no-wrapping {
544
+ background: url('images/insertions-alignmets.png') -350px -50px;
545
+ }
546
+
547
+ img.automatic-insertion.preview.custom-css {
548
+ background: url('images/insertions-alignmets.png') 0 -100px;
549
+ }
550
+
551
+ img.automatic-insertion.preview.default {
552
+ background: url('images/insertions-alignmets.png') -50px -100px;
553
+ }
554
+
555
+ img.automatic-insertion.preview.align-left {
556
+ background: url('images/insertions-alignmets.png') -100px -100px;
557
+ }
558
+
559
+ img.automatic-insertion.preview.center {
560
+ background: url('images/insertions-alignmets.png') -150px -100px;
561
+ }
562
+
563
+ img.automatic-insertion.preview.align-right {
564
+ background: url('images/insertions-alignmets.png') -200px -100px;
565
+ }
566
+
567
+ img.automatic-insertion.preview.float-left {
568
+ background: url('images/insertions-alignmets.png') -250px -100px;
569
+ }
570
+
571
+ img.automatic-insertion.preview.float-right {
572
+ background: url('images/insertions-alignmets.png') -300px -100px;
573
+ }
574
+
575
+ img.automatic-insertion.preview.sticky-left {
576
+ background: url('images/insertions-alignmets.png') -350px -100px;
577
+ }
578
+
579
+ img.automatic-insertion.preview.sticky-right {
580
+ background: url('images/insertions-alignmets.png') 0 -150px;
581
+ }
582
+
583
+ img.automatic-insertion.preview.sticky-top {
584
+ background: url('images/insertions-alignmets.png') -50px -150px;
585
+ }
586
+
587
+ img.automatic-insertion.preview.sticky-bottom {
588
+ background: url('images/insertions-alignmets.png') -100px -150px;
589
+ }
590
+
591
+ img.automatic-insertion.preview {
592
+ background-size: 400px!important;
593
+ }
594
+
595
+
596
  .checkbox-icon.icon-tracking {
597
  background: url('images/icons.png') -40px -20px;
598
  }
css/images/insertions-alignmets.png ADDED
Binary file
images/ad-inserter-pro.jpg DELETED
Binary file
images/after-comments.png DELETED
Binary file
images/after-content.png DELETED
Binary file
images/after-excerpt.png DELETED
Binary file
images/after-paragraph.png DELETED
Binary file
images/after-post.png DELETED
Binary file
images/align-left.png DELETED
Binary file
images/align-right.png DELETED
Binary file
images/before-comments.png DELETED
Binary file
images/before-content.png DELETED
Binary file
images/before-excerpt.png DELETED
Binary file
images/before-paragraph.png DELETED
Binary file
images/before-post.png DELETED
Binary file
images/between-comments.png DELETED
Binary file
images/between-posts.png DELETED
Binary file
images/blank.png ADDED
Binary file
images/center.png DELETED
Binary file
images/default.png DELETED
Binary file
images/disabled.png DELETED
Binary file
images/float-left.png DELETED
Binary file
images/float-right.png DELETED
Binary file
images/no-wrapping.png DELETED
Binary file
includes/ace/mode-ai-html.js CHANGED
@@ -33,9 +33,9 @@ exports.AiHtmlHighlightRules = AiHtmlHighlightRules;
33
  function add_ai_highlighting_rules (highlighter, highlight_rules) {
34
 
35
  highlighter.$ai_shortcodes = highlighter.$lang.arrayToMap ("adinserter".split ("|"));
36
- highlighter.$ai_separators1 = highlighter.$lang.arrayToMap ("rotate|count".split ("|"));
37
  highlighter.$ai_separators2 = highlighter.$lang.arrayToMap ("amp".split ("|"));
38
- highlighter.$ai_attributes = highlighter.$lang.arrayToMap ("block|name|ignore|debugger|adb|css|text|selectors|custom-field|data".split ("|"));
39
 
40
  //WP shortcodes
41
  highlighter.$rules ['start'].unshift (
@@ -77,7 +77,7 @@ function add_ai_highlighting_rules (highlighter, highlight_rules) {
77
  highlighter.$ai_attributes.hasOwnProperty (attribute.toLowerCase()) ? "entity.other.attribute-name.xml" : "text";
78
  },
79
  regex: "[a-zA-Z][-a-zA-Z0-9]*"
80
- },
81
  );
82
 
83
  // console.log (highlighter.$rules);
33
  function add_ai_highlighting_rules (highlighter, highlight_rules) {
34
 
35
  highlighter.$ai_shortcodes = highlighter.$lang.arrayToMap ("adinserter".split ("|"));
36
+ highlighter.$ai_separators1 = highlighter.$lang.arrayToMap ("http|rotate|count".split ("|"));
37
  highlighter.$ai_separators2 = highlighter.$lang.arrayToMap ("amp".split ("|"));
38
+ highlighter.$ai_attributes = highlighter.$lang.arrayToMap ("block|name|ignore|check|debugger|adb|css|text|selectors|custom-field|data".split ("|"));
39
 
40
  //WP shortcodes
41
  highlighter.$rules ['start'].unshift (
77
  highlighter.$ai_attributes.hasOwnProperty (attribute.toLowerCase()) ? "entity.other.attribute-name.xml" : "text";
78
  },
79
  regex: "[a-zA-Z][-a-zA-Z0-9]*"
80
+ }
81
  );
82
 
83
  // console.log (highlighter.$rules);
includes/js/ai-adb.js CHANGED
@@ -10,7 +10,7 @@ var ai_adb_act_cookie_name = "aiADB";
10
  var ai_adb_pgv_cookie_name = "aiADB_PV";
11
  var ai_adb_page_redirection_cookie_name = "aiADB_PR";
12
  var ai_adb_message_cookie_lifetime = AI_FUNCT_GET_NO_ACTION_PERIOD;
13
- var ai_adb_action = AI_FUNCT_GET_ADB_ACTION;
14
  var ai_adb_page_views = AI_FUNCT_GET_DELAY_ACTION;
15
  var ai_adb_selectors = "AI_ADB_SELECTORS";
16
  var ai_adb_redirection_url = "AI_ADB_REDIRECTION_PAGE";
10
  var ai_adb_pgv_cookie_name = "aiADB_PV";
11
  var ai_adb_page_redirection_cookie_name = "aiADB_PR";
12
  var ai_adb_message_cookie_lifetime = AI_FUNCT_GET_NO_ACTION_PERIOD;
13
+ var ai_adb_action = AI_FUNC_GET_ADB_ACTION;
14
  var ai_adb_page_views = AI_FUNCT_GET_DELAY_ACTION;
15
  var ai_adb_selectors = "AI_ADB_SELECTORS";
16
  var ai_adb_redirection_url = "AI_ADB_REDIRECTION_PAGE";
includes/js/ai-adb.min.js CHANGED
@@ -1,5 +1,5 @@
1
  var ai_adb=false;var ai_adb_wrapping_div_selector=".AI_BLOCK_CLASS_NAME";var ai_adb_debugging=AI_DATAB_AI_JS_DEBUGGING;var ai_adb_active=false;var ai_adb_counter=0;var ai_adb_overlay=AI_ADB_OVERLAY_WINDOW;var ai_adb_message_window=AI_ADB_MESSAGE_WINDOW;var ai_adb_message_undismissible=AI_FUNCB_GET_UNDISMISSIBLE_MESSAGE;var ai_adb_act_cookie_name="aiADB";var ai_adb_pgv_cookie_name="aiADB_PV";var ai_adb_page_redirection_cookie_name="aiADB_PR";var ai_adb_message_cookie_lifetime=AI_FUNCT_GET_NO_ACTION_PERIOD;
2
- var ai_adb_action=AI_FUNCT_GET_ADB_ACTION;var ai_adb_page_views=AI_FUNCT_GET_DELAY_ACTION;var ai_adb_selectors="AI_ADB_SELECTORS";var ai_adb_redirection_url="AI_ADB_REDIRECTION_PAGE";
3
  function ai_adb_process_content(){(function($){$(".AI_ADB_CONTENT_CSS_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_css=$(this).data("css");if(typeof ai_adb_css=="undefined")ai_adb_css="display: none !important;";var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_CSS_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_CSS_BEGIN_CLASS")){$(this).remove();
4
  ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_CSS_END_CLASS")){$(this).remove();ai_adb_action=false}else if(ai_adb_action){var ai_adb_style=$(this).attr("style");if(typeof ai_adb_style=="undefined")ai_adb_style="";$(this).attr("style",ai_adb_style+";"+ai_adb_css)}})});$(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";
5
  var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_DELETE_BEGIN_CLASS")){$(this).remove();ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_DELETE_END_CLASS")){$(this).remove();ai_adb_action=false}else if(ai_adb_action)$(this).remove()})});$(".AI_ADB_CONTENT_REPLACE_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_text=$(this).data("text");if(typeof ai_adb_text==
1
  var ai_adb=false;var ai_adb_wrapping_div_selector=".AI_BLOCK_CLASS_NAME";var ai_adb_debugging=AI_DATAB_AI_JS_DEBUGGING;var ai_adb_active=false;var ai_adb_counter=0;var ai_adb_overlay=AI_ADB_OVERLAY_WINDOW;var ai_adb_message_window=AI_ADB_MESSAGE_WINDOW;var ai_adb_message_undismissible=AI_FUNCB_GET_UNDISMISSIBLE_MESSAGE;var ai_adb_act_cookie_name="aiADB";var ai_adb_pgv_cookie_name="aiADB_PV";var ai_adb_page_redirection_cookie_name="aiADB_PR";var ai_adb_message_cookie_lifetime=AI_FUNCT_GET_NO_ACTION_PERIOD;
2
+ var ai_adb_action=AI_FUNC_GET_ADB_ACTION;var ai_adb_page_views=AI_FUNCT_GET_DELAY_ACTION;var ai_adb_selectors="AI_ADB_SELECTORS";var ai_adb_redirection_url="AI_ADB_REDIRECTION_PAGE";
3
  function ai_adb_process_content(){(function($){$(".AI_ADB_CONTENT_CSS_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_css=$(this).data("css");if(typeof ai_adb_css=="undefined")ai_adb_css="display: none !important;";var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_CSS_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_CSS_BEGIN_CLASS")){$(this).remove();
4
  ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_CSS_END_CLASS")){$(this).remove();ai_adb_action=false}else if(ai_adb_action){var ai_adb_style=$(this).attr("style");if(typeof ai_adb_style=="undefined")ai_adb_style="";$(this).attr("style",ai_adb_style+";"+ai_adb_css)}})});$(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_selectors=$(this).data("selectors");if(typeof ai_adb_selectors=="undefined"||ai_adb_selectors=="")ai_adb_selectors="p";
5
  var ai_adb_action=false;$(ai_adb_parent).find(".AI_ADB_CONTENT_DELETE_BEGIN_CLASS, "+ai_adb_selectors).each(function(){if($(this).hasClass("AI_ADB_CONTENT_DELETE_BEGIN_CLASS")){$(this).remove();ai_adb_action=true}else if($(this).hasClass("AI_ADB_CONTENT_DELETE_END_CLASS")){$(this).remove();ai_adb_action=false}else if(ai_adb_action)$(this).remove()})});$(".AI_ADB_CONTENT_REPLACE_BEGIN_CLASS").each(function(){var ai_adb_parent=$(this).parent();var ai_adb_text=$(this).data("text");if(typeof ai_adb_text==
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.2.3";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -24,6 +24,10 @@ var AI_AFTER_PARAGRAPH = 6;
24
  var AI_BEFORE_EXCERPT = 7;
25
  var AI_AFTER_EXCERPT = 8;
26
  var AI_BETWEEN_POSTS = 9;
 
 
 
 
27
 
28
  var AI_ALIGNMENT_DEFAULT = 0;
29
  var AI_ALIGNMENT_LEFT = 1;
@@ -809,7 +813,7 @@ jQuery(document).ready(function($) {
809
 
810
  function configure_editor (block) {
811
 
812
- if (debug) console.log ("configure_editor: " + block);
813
 
814
  if (syntax_highlighting) {
815
  var syntax_highlighter = new SyntaxHighlight ('#block-' + block, block, shSettings);
@@ -1108,6 +1112,8 @@ jQuery(document).ready(function($) {
1108
 
1109
  function configure_tab (tab) {
1110
 
 
 
1111
  $('#tab-' + tab).addClass ('configured');
1112
 
1113
  $('#tab-' + tab + ' input[type=submit], #tab-' + tab + ' button').button().show ();
@@ -1128,7 +1134,7 @@ jQuery(document).ready(function($) {
1128
  var block = $(this).attr('id').replace ("block-alignment-", "");
1129
  var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1130
  if (alignment == AI_ALIGNMENT_STICKY_LEFT || alignment == AI_ALIGNMENT_STICKY_RIGHT || alignment == AI_ALIGNMENT_STICKY_TOP || alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
1131
- $("select#display-type-"+block).val (AI_AFTER_POST).change ();
1132
  }
1133
  process_display_elements (block);
1134
  });
@@ -1689,7 +1695,7 @@ jQuery(document).ready(function($) {
1689
  }
1690
  }
1691
 
1692
- function update_rating (parameter = '') {
1693
  var rating_bar = $('#ai-rating-bar');
1694
  var nonce = rating_bar.attr ('nonce');
1695
  $("#rating-value span").load (ajaxurl+"?action=ai_ajax_backend&rating=" + parameter + "&ai_check=" + nonce, function() {
@@ -1728,12 +1734,14 @@ jQuery(document).ready(function($) {
1728
  start = parseInt ($('#ai-form').attr('start'));
1729
  end = parseInt ($('#ai-form').attr('end'));
1730
 
1731
- active_tab = 1;
1732
  active_tab_0 = 0;
1733
  try {
1734
  var active_tabs = JSON.parse ($("#ai-active-tab").attr ("value"));
1735
  if (typeof active_tabs !== "undefined" && active_tabs.constructor === Array && Number.isInteger (active_tabs [0]) && Number.isInteger (active_tabs [1])) {
1736
  active_tab = parseInt (active_tabs [0]);
 
 
1737
  active_tab_0 = parseInt (active_tabs [1]);
1738
  }
1739
  } catch (e) {}
@@ -1872,7 +1880,7 @@ jQuery(document).ready(function($) {
1872
  $("#ai-rating-bar").css ('display', 'inline-block');
1873
  $('#ai-stars').hide ();
1874
  }
1875
- update_rating ('update');
1876
  });
1877
 
1878
  $("#ai-rating-bar").click (function () {
1
+ var javascript_version = "2.2.4";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
24
  var AI_BEFORE_EXCERPT = 7;
25
  var AI_AFTER_EXCERPT = 8;
26
  var AI_BETWEEN_POSTS = 9;
27
+ var AI_BEFORE_COMMENTS = 10;
28
+ var AI_BETWEEN_COMMENTS = 11;
29
+ var AI_AFTER_COMMENTS = 12;
30
+ var AI_FOOTER = 13;
31
 
32
  var AI_ALIGNMENT_DEFAULT = 0;
33
  var AI_ALIGNMENT_LEFT = 1;
813
 
814
  function configure_editor (block) {
815
 
816
+ if (debug) console.log ("configure_editor:", block);
817
 
818
  if (syntax_highlighting) {
819
  var syntax_highlighter = new SyntaxHighlight ('#block-' + block, block, shSettings);
1112
 
1113
  function configure_tab (tab) {
1114
 
1115
+ // if (debug) console.log ("configure_tab:", tab);
1116
+
1117
  $('#tab-' + tab).addClass ('configured');
1118
 
1119
  $('#tab-' + tab + ' input[type=submit], #tab-' + tab + ' button').button().show ();
1134
  var block = $(this).attr('id').replace ("block-alignment-", "");
1135
  var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1136
  if (alignment == AI_ALIGNMENT_STICKY_LEFT || alignment == AI_ALIGNMENT_STICKY_RIGHT || alignment == AI_ALIGNMENT_STICKY_TOP || alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
1137
+ $("select#display-type-"+block).val (AI_FOOTER).change ();
1138
  }
1139
  process_display_elements (block);
1140
  });
1695
  }
1696
  }
1697
 
1698
+ function update_rating (parameter) {
1699
  var rating_bar = $('#ai-rating-bar');
1700
  var nonce = rating_bar.attr ('nonce');
1701
  $("#rating-value span").load (ajaxurl+"?action=ai_ajax_backend&rating=" + parameter + "&ai_check=" + nonce, function() {
1734
  start = parseInt ($('#ai-form').attr('start'));
1735
  end = parseInt ($('#ai-form').attr('end'));
1736
 
1737
+ active_tab = start;
1738
  active_tab_0 = 0;
1739
  try {
1740
  var active_tabs = JSON.parse ($("#ai-active-tab").attr ("value"));
1741
  if (typeof active_tabs !== "undefined" && active_tabs.constructor === Array && Number.isInteger (active_tabs [0]) && Number.isInteger (active_tabs [1])) {
1742
  active_tab = parseInt (active_tabs [0]);
1743
+ if (active_tab != 0)
1744
+ if (active_tab < start || active_tab > end) active_tab = start;
1745
  active_tab_0 = parseInt (active_tabs [1]);
1746
  }
1747
  } catch (e) {}
1880
  $("#ai-rating-bar").css ('display', 'inline-block');
1881
  $('#ai-stars').hide ();
1882
  }
1883
+ update_rating ('update', '');
1884
  });
1885
 
1886
  $("#ai-rating-bar").click (function () {
preview.php CHANGED
@@ -972,15 +972,15 @@ div.automatic-insertion img {
972
  <div style="margin: 20px 0 0 0;">
973
  Alignment and Style:&nbsp;&nbsp;&nbsp;
974
  <select id="block-alignment" style="border-radius: 5px; width:120px;">
975
- <option data-img-src="<?php echo plugins_url ('images/default.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
976
- <option data-img-src="<?php echo plugins_url ('images/align-left.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
977
- <option data-img-src="<?php echo plugins_url ('images/center.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
978
- <option data-img-src="<?php echo plugins_url ('images/align-right.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
979
- <option data-img-src="<?php echo plugins_url ('images/float-left.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
980
- <option data-img-src="<?php echo plugins_url ('images/float-right.png', __FILE__); ?>" data-img-class="automatic-insertion" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
981
  <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type); ?>
982
- <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 ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
983
- <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 ($alignment_type == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
984
  </select>
985
  <span id="css-index" style="margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
986
  </div>
972
  <div style="margin: 20px 0 0 0;">
973
  Alignment and Style:&nbsp;&nbsp;&nbsp;
974
  <select id="block-alignment" style="border-radius: 5px; width:120px;">
975
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview default" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
976
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview align-left" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
977
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview center" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
978
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview align-right" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
979
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview float-left" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
980
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview float-right" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
981
  <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type); ?>
982
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview custom-css" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
983
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion preview no-wrapping" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
984
  </select>
985
  <span id="css-index" style="margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
986
  </div>
readme.txt CHANGED
@@ -2,11 +2,11 @@
2
 
3
  Contributors: spacetime
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
5
- Tags: ads, adsense, ad management, advertising manager, advanced contextual ads, ad rotation, ad injection, adverts, sticky widgets, sticky sidebar, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking, ad blocking, custom fields
6
  Requires at least: 4.0
7
  Tested up to: 4.8.2
8
  Requires PHP: 5.2.4
9
- Stable tag: 2.2.2
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
@@ -35,9 +35,11 @@ Ad Inserter is more than just ad manager plugin. It provides many advanced optio
35
  > * Insert between posts on blog pages (in-feed AdSense ads)
36
  > * Insert between excerpts on blog pages
37
  > * Insert between comments
 
38
  > * Clearance options to avoid insertion near images or headers
39
  > * Insertion exceptions for posts and pages
40
  > * Insert header and footer code
 
41
  > * Insert Google Analytics, Piwik or any other web analytics code
42
  > * Insert HTML, CSS, Javascript or PHP code
43
  > * Manual insertion: widgets, shortcodes, PHP function call
@@ -51,7 +53,7 @@ Ad Inserter is more than just ad manager plugin. It provides many advanced optio
51
  > * Ad rotation (server-side and client-side - works with caching)
52
  > * Ad blocking detection - popup message, page redirection
53
  > * Desktop/mobile device detection (server-side and client-side - works with caching)
54
- > * Black/White-list categories, tags, taxonomies, post IDs, urls, url query parameters, referers
55
  > * Simple troubleshooting with many debugging functions
56
  > * Function to visualize inserted code blocks
57
  > * Function to visualize available insertion positions
@@ -70,7 +72,8 @@ And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank
70
  > * Ad blocking statistics
71
  > * Multisite options to limit settings on the sites
72
  > * Post/page exception management
73
- > * 6 custom viewports for client-side desktop/mobile device detection
 
74
  > * Export and import of settings
75
  > * Support via email
76
 
@@ -96,6 +99,7 @@ Ad Inserter is not just another plugin for WordPress ads. Do you enjoy finding t
96
  * to insert ads between comments
97
  * to insert ads on AMP pages
98
  * to insert different ads for mobile devices
 
99
  * to hide ads on specific pages
100
  * for ad rotation
101
  * for PHP code widgets
@@ -189,7 +193,8 @@ activate it and then click "Enter License Key" and enter license key you got in
189
 
190
  If you deactivate and delete Ad Inserter, the settings will stay in the database. To completely remove the plugin and settings do the following:
191
 
192
- 1. Go to Ad Inserter Settings (tab *) and click on Reset All Settings
 
193
  2. Deactivate Ad Inserter
194
  3. Delete Ad Inserter plugin
195
 
@@ -238,6 +243,8 @@ Automatic Insertion Options:
238
  * Insert Before Comments (on posts)
239
  * Insert Between Comments (on posts)
240
  * Insert After Comments (on posts)
 
 
241
 
242
  For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
243
 
@@ -447,6 +454,9 @@ amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
447
  <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
448
 
449
  Use your own tracking id! Please note `[adinserter data='smart_tag']` as default search phrase. This makes this widget contextual. It will show products related to the tags for this post.
 
 
 
450
  You can also try with `[adinserter data='tag']', `[adinserter data='short-title']`, `[adinserter data='category']` or `[adinserter data='short-category']`. For more options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
451
 
452
 
@@ -731,6 +741,15 @@ AD CODE RIGHT
731
 
732
  == Changelog ==
733
 
 
 
 
 
 
 
 
 
 
734
  = 2.2.3 =
735
  - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
736
  - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
@@ -839,6 +858,15 @@ AD CODE RIGHT
839
 
840
  == Upgrade Notice ==
841
 
 
 
 
 
 
 
 
 
 
842
  = 2.2.3 =
843
  Added support to insert custom fields via shortcode;
844
  Added support for user:USERNAME, user-role:USER_ROLE and post-type:POST_TYPE taxonomy list items;
2
 
3
  Contributors: spacetime
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
5
+ Tags: ads, adsense, ad management, advertising manager, advanced contextual ads, ad rotation, ad injection, adverts, sticky widgets, sticky sidebar, hook, amazon, banners, automatic insertion, amp, geo targeting, multisite, shortcodes, PHP, Javascript, HTML, header, footer, tracking, ad blocking, custom fields
6
  Requires at least: 4.0
7
  Tested up to: 4.8.2
8
  Requires PHP: 5.2.4
9
+ Stable tag: 2.2.3
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
35
  > * Insert between posts on blog pages (in-feed AdSense ads)
36
  > * Insert between excerpts on blog pages
37
  > * Insert between comments
38
+ > * Insert at custom hook positions (e.g. using <a href="https://genesistutorials.com/visual-hook-guide/" target="_blank">Genesis Theme Framework Hook Guide</a>)
39
  > * Clearance options to avoid insertion near images or headers
40
  > * Insertion exceptions for posts and pages
41
  > * Insert header and footer code
42
+ > * Insert raw HTTP response header lines
43
  > * Insert Google Analytics, Piwik or any other web analytics code
44
  > * Insert HTML, CSS, Javascript or PHP code
45
  > * Manual insertion: widgets, shortcodes, PHP function call
53
  > * Ad rotation (server-side and client-side - works with caching)
54
  > * Ad blocking detection - popup message, page redirection
55
  > * Desktop/mobile device detection (server-side and client-side - works with caching)
56
+ > * Black/White-list categories, tags, taxonomies, post IDs, urls, url query parameters, cookies, referers
57
  > * Simple troubleshooting with many debugging functions
58
  > * Function to visualize inserted code blocks
59
  > * Function to visualize available insertion positions
72
  > * Ad blocking statistics
73
  > * Multisite options to limit settings on the sites
74
  > * Post/page exception management
75
+ > * more custom viewports for client-side desktop/mobile device detection
76
+ > * more custom hooks for custom theme insertions
77
  > * Export and import of settings
78
  > * Support via email
79
 
99
  * to insert ads between comments
100
  * to insert ads on AMP pages
101
  * to insert different ads for mobile devices
102
+ * to insert ads at custom action hooks (e.g. using <a href="https://genesistutorials.com/visual-hook-guide/" target="_blank">Genesis Theme Framework Hook Guide</a>)
103
  * to hide ads on specific pages
104
  * for ad rotation
105
  * for PHP code widgets
193
 
194
  If you deactivate and delete Ad Inserter, the settings will stay in the database. To completely remove the plugin and settings do the following:
195
 
196
+ 1. Go to Ad Inserter general settings (tab *) and click on Reset All Settings
197
+ 1. Go to Ad Inserter general settings (tab *) and click on Clear All Statistics Data
198
  2. Deactivate Ad Inserter
199
  3. Delete Ad Inserter plugin
200
 
243
  * Insert Before Comments (on posts)
244
  * Insert Between Comments (on posts)
245
  * Insert After Comments (on posts)
246
+ * Insert into HTML Footer (before `</body>` tag)
247
+ * Insert at custom hook positions (define them on the tab * / tab Hooks)
248
 
249
  For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
250
 
454
  <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
455
 
456
  Use your own tracking id! Please note `[adinserter data='smart_tag']` as default search phrase. This makes this widget contextual. It will show products related to the tags for this post.
457
+
458
+ You can also use <a href="https://codex.wordpress.org/Custom_Fields" target="_blank">custom fields</a> to make the widget contextual. For example, if you define in posts custom field named `amazon-keyword` you can use `[adinserter custom-field='amazon-keyword']' for `amzn_assoc_default_search_phrase` variable.
459
+
460
  You can also try with `[adinserter data='tag']', `[adinserter data='short-title']`, `[adinserter data='category']` or `[adinserter data='short-category']`. For more options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
461
 
462
 
741
 
742
  == Changelog ==
743
 
744
+ = 2.2.4 =
745
+ - Added support to insert raw HTTP response header lines
746
+ - Added support to check for individual exceptions for shortcodes
747
+ - Added support to trigger ad blocking detection action only on individual pages
748
+ - Added support for automatic insertion position Footer
749
+ - Added support for custom hooks
750
+ - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE)
751
+ - Fix for |count| separator not processed
752
+
753
  = 2.2.3 =
754
  - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
755
  - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
858
 
859
  == Upgrade Notice ==
860
 
861
+ = 2.2.4 =
862
+ Added support to insert raw HTTP response header lines;
863
+ Added support to check for individual exceptions for shortcodes;
864
+ Added support to trigger ad blocking detection action only on individual pages;
865
+ Added support for automatic insertion position Footer;
866
+ Added support for custom hooks;
867
+ Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE);
868
+ Fix for |count| separator not processed;
869
+
870
  = 2.2.3 =
871
  Added support to insert custom fields via shortcode;
872
  Added support for user:USERNAME, user-role:USER_ROLE and post-type:POST_TYPE taxonomy list items;
settings.php CHANGED
@@ -4,7 +4,7 @@ require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
 
5
  function generate_settings_form (){
6
  global $ai_db_options, $block_object, $ai_wp_data, $ai_db_options_extract;
7
- global $rating_value, $rating_string, $rating_css;
8
 
9
  $save_url = $_SERVER ['REQUEST_URI'];
10
  if (isset ($_GET ['tab'])) {
@@ -23,11 +23,11 @@ function generate_settings_form (){
23
 
24
  if (isset ($_POST ['ai-active-tab'])) {
25
  $active_tabs = json_decode ($_POST ['ai-active-tab']);
26
- if ($active_tabs == null) $active_tabs = array (1, 0);
27
  }
28
 
29
  if (isset ($_GET ['tab'])) $active_tab = $_GET ['tab']; else
30
- $active_tab = isset ($active_tabs [0]) ? $active_tabs [0] : 1;
31
  if (!is_numeric ($active_tab)) $active_tab = 1;
32
  if ($active_tab != 0)
33
  if ($active_tab < $start || $active_tab > $end) $active_tab = $start;
@@ -119,11 +119,11 @@ function generate_settings_form (){
119
  <h2 id="plugin_name" style="display: inline-block; margin: 5px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
120
  </div>
121
  <div id="header-buttons">
122
- <a style="text-decoration: none;" href="http://adinserter.pro/documentation" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button></a>
123
- <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 68px;" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button></a>
124
- <a style="text-decoration: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank"><button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button></a>
125
- <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/ad-inserter/reviews/" target="_blank"><button type="button" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres" style="display: none; margin: 0 10px 0 0; width: 62px;">Review</button></a>
126
- <a style="text-decoration: none;" href="http://adinserter.pro/" target="_blank"><button type="button" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro" style="display: none; margin: 0 10px 0 0; width: 62px;">Go&nbsp;Pro</button></a>
127
  </div>
128
 
129
  <div style="clear: both;"></div>
@@ -273,6 +273,7 @@ function generate_settings_form (){
273
  if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $title_hfa .= ", Header code";
274
  if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $title_hfa .= ", Footer code";
275
 
 
276
  $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
277
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
278
  if ($enabled_h || $enabled_f) $class_hfa = " on"; else $class_hfa = "";
@@ -425,34 +426,38 @@ function generate_settings_form (){
425
  <div style="float: left;">
426
  Automatic Insertion:
427
  <select style="margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_automatic_insertion(); ?>" style="width:200px;">
428
- <option data-img-src="<?php echo plugins_url ('images/disabled.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
429
- <option data-img-src="<?php echo plugins_url ('images/before-post.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
430
- <option data-img-src="<?php echo plugins_url ('images/before-content.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_CONTENT; ?></option>
431
- <option data-img-src="<?php echo plugins_url ('images/before-paragraph.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_PARAGRAPH; ?></option>
432
- <option data-img-src="<?php echo plugins_url ('images/after-paragraph.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_PARAGRAPH; ?></option>
433
- <option data-img-src="<?php echo plugins_url ('images/after-content.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_CONTENT; ?></option>
434
- <option data-img-src="<?php echo plugins_url ('images/after-post.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_POST; ?></option>
435
- <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>
436
- <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>
437
- <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>
438
- <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>
439
- <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>
440
- <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>
 
 
 
 
441
  </select>
442
  </div>
443
 
444
  <div style="float: right;">
445
  Alignment and Style:&nbsp;&nbsp;&nbsp;
446
  <select style="width:120px;" id="block-alignment-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ALIGNMENT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_alignment_type(); ?>">
447
- <option data-img-src="<?php echo plugins_url ('images/default.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
448
- <option data-img-src="<?php echo plugins_url ('images/align-left.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
449
- <option data-img-src="<?php echo plugins_url ('images/center.png', __FILE__); ?>" data-img-class="automatic-insertion" value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
450
- <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>
451
- <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>
452
- <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>
453
  <?php $css_code_height = 260; if (function_exists ('ai_style_options')) $css_code_height = ai_style_options ($obj); ?>
454
- <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>
455
- <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>
456
  </select>
457
  &nbsp;
458
  <button id="show-css-button-<?php echo $ad_number; ?>" type="button" style="min-width: 60px; margin-right: 0px;">Show</button>
@@ -487,13 +492,13 @@ function generate_settings_form (){
487
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
488
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $ad_number; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />
489
 
490
- <select style="margin: 0 0 0 10px;" title="Individual post exceptions (if enabled here) can be configured in post editor. Leave blank for no individual post exceptions." id="enabled-on-which-posts-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
491
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
492
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
493
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
494
  </select>
495
  &nbsp;
496
- <label for="display-posts-<?php echo $ad_number; ?>">Posts</label>
497
 
498
  <?php
499
  if (!empty ($block_exceptions [$ad_number])) {
@@ -523,13 +528,13 @@ function generate_settings_form (){
523
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
524
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $ad_number; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />
525
 
526
- <select style="margin: 0 0 0 10px;" title="Individual static page exceptions (if enabled here) can be configured in page editor. Leave blank for no individual page exceptions." id="enabled-on-which-pages-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
527
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
528
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
529
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
530
  </select>
531
  &nbsp;
532
- <label for="display-pages-<?php echo $ad_number; ?>">Static pages</label>
533
  </td>
534
  <td style="padding-left: 8px;">
535
  </td>
@@ -858,7 +863,9 @@ function generate_settings_form (){
858
  Urls
859
  </td>
860
  <td style="padding-right: 7px;">
861
- <input style="width: 100%;" title="SPACE separated urls (page addresses) starting with / after domain name (e.g. /permalink-url, use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_url_list(); ?>" value="<?php echo $url_list; ?>" size="54" maxlength="500"/>
 
 
862
  </td>
863
  <td style="padding-right: 7px;">
864
  <input type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="url-blacklist-<?php echo $ad_number; ?>" default="<?php echo $default->get_ad_url_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
@@ -874,7 +881,7 @@ function generate_settings_form (){
874
  Url parameters
875
  </td>
876
  <td style="padding-right: 7px;">
877
- <input style="width: 100%;" title="Comma separated url query parameters with optional values (use either 'prameter' or 'prameter=value')" type="text" name="<?php echo AI_OPTION_URL_PARAMETER_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_url_parameter_list(); ?>" value="<?php echo $url_parameter_list; ?>" size="54" maxlength="500"/>
878
  </td>
879
  <td style="padding-right: 7px;">
880
  <input type="radio" name="<?php echo AI_OPTION_URL_PARAMETER_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="url-parameter-blacklist-<?php echo $ad_number; ?>" default="<?php echo $default->get_url_parameter_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_url_parameter_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
@@ -1170,7 +1177,7 @@ function generate_settings_form (){
1170
  <h3 style="margin: 0; float: left;"><?php echo AD_INSERTER_NAME ?> Settings <?php if (isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'])) echo (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][0].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][1]), '.',
1171
  (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][2].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][3]), '.',
1172
  (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][4].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][5]); ?></h3>
1173
- <h4 style="margin: 0px; float: right;" title="Settings timestamp"><?php echo isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP']) ? date ("Y-m-d H:i:s", $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : ""; ?></h4>
1174
  <div style="clear: both;"></div>
1175
  </div>
1176
 
@@ -1191,10 +1198,11 @@ function generate_settings_form (){
1191
  <?php
1192
  if (function_exists ('ai_global_settings')) ai_global_settings ();
1193
 
 
1194
  if ($enabled_h) $style_h = "font-weight: bold; color: #66f;"; else $style_h = "";
1195
  if ($enabled_f) $style_f = "font-weight: bold; color: #66f;"; else $style_f = "";
1196
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1197
- $adb_action = get_adb_action();
1198
  if ($enabled_a) $style_a = "font-weight: bold; color: " . ($adb_action == AI_ADB_ACTION_NONE ? "#66f;" : "#f00;"); else $style_a = "";
1199
  }
1200
  if (false) $style_d = "font-weight: bold; color: #e44;"; else $style_d = "";
@@ -1204,6 +1212,7 @@ function generate_settings_form (){
1204
  <ul id="ai-plugin-settings-tabs" style="display: none;">
1205
  <li id="ai-g" class="ai-plugin-tab"><a href="#tab-general">General</a></li>
1206
  <li id="ai-v" class="ai-plugin-tab"><a href="#tab-viewports">Viewports</a></li>
 
1207
  <li id="ai-h" class="ai-plugin-tab"><a href="#tab-header"><span style="<?php echo $style_h ?>">Header</span></a></li>
1208
  <li id="ai-f" class="ai-plugin-tab"><a href="#tab-footer"><span style="<?php echo $style_f ?>">Footer</span></a></li>
1209
  <?php if (function_exists ('ai_plugin_settings_tab')) ai_plugin_settings_tab ($exceptions); ?>
@@ -1350,13 +1359,13 @@ function generate_settings_form (){
1350
 
1351
  <div id="tab-viewports" class="rounded">
1352
  <div style="margin: 0 0 8px 0;">
1353
- Viewport Settings used for client-side device detection
1354
  </div>
1355
  <?php
1356
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1357
- $bottom_margin = $viewport == AD_INSERTER_VIEWPORTS ? 0 : 8;
1358
  ?>
1359
- <div style="margin: 8px 0 <?php echo $bottom_margin; ?>px 0;">
1360
  Viewport <?php echo $viewport; ?> name&nbsp;&nbsp;&nbsp;
1361
  <input style="margin-left: 0px;" type="text" name="viewport-name-<?php echo $viewport; ?>" value="<?php echo get_viewport_name ($viewport); ?>" default="<?php echo defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : ""; ?>" size="15" maxlength="40" />
1362
  <?php if ($viewport == AD_INSERTER_VIEWPORTS) echo '<span style="display: none;">' ?>
@@ -1369,6 +1378,47 @@ function generate_settings_form (){
1369
  ?>
1370
  </div>
1371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1372
  <div id="tab-header" style="margin: 0px 0; padding: 0; ">
1373
  <div style="margin: 8px 0;">
1374
  <div style="float: right;">
@@ -1662,7 +1712,7 @@ function generate_settings_form (){
1662
  </td>
1663
  <td>
1664
  <input type="hidden" name="javascript_debugging" value="0" />
1665
- <input type="checkbox" name="javascript_debugging"id="javascript-debugging" value="1" default="<?php echo DEFAULT_JAVASCRIPT_DEBUGGING; ?>" <?php if (get_javascript_debugging ()==AI_ENABLED) echo 'checked '; ?> />
1666
  </td>
1667
  </tr>
1668
  <tr class="system-debugging" style="display: none;">
@@ -1810,7 +1860,7 @@ function generate_settings_form (){
1810
 
1811
  function check_blocked_images () {
1812
 
1813
- function replace_blocked_image (image_id, image_src, css_display = 'block') {
1814
  var image_selector = "#" + image_id;
1815
  if (!jQuery(image_selector + ":visible").length) {
1816
  var image = jQuery(image_selector);
@@ -1828,13 +1878,13 @@ function generate_settings_form (){
1828
  jQuery("#blocked-warning .blocked-warning-text").css ('color', '#00f');
1829
  }
1830
 
1831
- replace_blocked_image ('ai-media-1', 'contextual-1.gif');
1832
- replace_blocked_image ('ai-media-2', 'contextual-2.jpg');
1833
- replace_blocked_image ('ai-pro-1', 'icon-256x256.jpg');
1834
- replace_blocked_image ('ai-pro-2', 'ai-charts-250.png');
1835
- replace_blocked_image ('ai-stars-img', 'stars.png', 'inline');
1836
- replace_blocked_image ('ai-tw', 'twitter.png', 'inline');
1837
- replace_blocked_image ('ai-fb', 'facebook.png', 'inline');
1838
  }
1839
  </script>
1840
 
@@ -1946,6 +1996,7 @@ function sidebar_pro () { ?>
1946
  <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1947
  <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> between posts on blog pages</li>
1948
  <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> before, between and after comments</li>
 
1949
  <li><a href="https://adinserter.pro/exceptions" class="simple-link" target="_blank">Insertion exceptions</a> for individual posts and pages</li>
1950
  <li><a href="http://adinserter.pro/documentation#manual-insertion" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
1951
  <li><a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">Sticky positions</a> (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
@@ -1965,13 +2016,13 @@ function sidebar_pro () { ?>
1965
  <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
1966
  <li>Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">mobile device detection</a> (works with caching, 6 custom viewports)</li>
1967
  <li><a href="https://adinserter.pro/ad-blocking-detection" class="simple-link" target="_blank">Ad blocking detection</a> - popup message, ad replacement, content protection</li>
1968
- <li><a href="https://adinserter.pro/tracking" class="simple-link" target="_blank">Ad blocking statistics</a></li>
1969
- <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> categories, tags, taxonomies, users, post IDs, urls, referers</li>
1970
- <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Black/White-list</a> IP addresses or countries (works also with caching)</li>
1971
  <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
1972
  <li>Import/Export block or plugin settings</li>
1973
  <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a> with fallback option</li>
1974
- <li>Country-level <a href="http://adinserter.pro/documentation#geo-targeting" class="simple-link" target="_blank">GEO targeting</a> (works also with caching)</li>
1975
  <li>Simple troubleshooting with many <a href="http://adinserter.pro/documentation#debugging" class="simple-link" target="_blank">debugging functions</a></li>
1976
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
1977
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
@@ -2008,7 +2059,7 @@ function sidebar_pro_small () { ?>
2008
  <div style="float: right; margin-left: 15px;">
2009
  <ul>
2010
  <li><a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">Sticky positions</a></li>
2011
- <li><a href="http://adinserter.pro/documentation#lists" class="simple-link" target="_blank">Limit insertions</a></li>
2012
  <li><a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options</li>
2013
  </ul>
2014
  </div>
@@ -2033,7 +2084,7 @@ function sidebar_pro_small () { ?>
2033
  <div style="float: right; margin-left: 15px;">
2034
  <ul>
2035
  <li>64 code blocks</li>
2036
- <li><a href="http://adinserter.pro/documentation#geo-targeting" class="simple-link" target="_blank">GEO targeting</a></li>
2037
  <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a></li>
2038
  </ul>
2039
  </div>
4
 
5
  function generate_settings_form (){
6
  global $ai_db_options, $block_object, $ai_wp_data, $ai_db_options_extract;
7
+ global $rating_value, $rating_string, $rating_css, $ai_custom_hooks;
8
 
9
  $save_url = $_SERVER ['REQUEST_URI'];
10
  if (isset ($_GET ['tab'])) {
23
 
24
  if (isset ($_POST ['ai-active-tab'])) {
25
  $active_tabs = json_decode ($_POST ['ai-active-tab']);
26
+ if ($active_tabs == null) $active_tabs = array ($start, 0);
27
  }
28
 
29
  if (isset ($_GET ['tab'])) $active_tab = $_GET ['tab']; else
30
+ $active_tab = isset ($active_tabs [0]) ? $active_tabs [0] : $start;
31
  if (!is_numeric ($active_tab)) $active_tab = 1;
32
  if ($active_tab != 0)
33
  if ($active_tab < $start || $active_tab > $end) $active_tab = $start;
119
  <h2 id="plugin_name" style="display: inline-block; margin: 5px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
120
  </div>
121
  <div id="header-buttons">
122
+ <button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('http://adinserter.pro/documentation')" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button>
123
+ <button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter')" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button>
124
+ <button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" 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>
125
+ <button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
126
+ <button type="button" style="display: none; margin: 0 10px 0 0; width: 62px;" onclick="window.open('http://adinserter.pro/')" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go&nbsp;Pro</button>
127
  </div>
128
 
129
  <div style="clear: both;"></div>
273
  if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $title_hfa .= ", Header code";
274
  if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $title_hfa .= ", Footer code";
275
 
276
+ $enabled_k = count ($ai_custom_hooks) != 0;
277
  $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
278
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
279
  if ($enabled_h || $enabled_f) $class_hfa = " on"; else $class_hfa = "";
426
  <div style="float: left;">
427
  Automatic Insertion:
428
  <select style="margin-bottom: 3px;" id="display-type-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_automatic_insertion(); ?>" style="width:200px;">
429
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion disabled" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
430
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-post" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
431
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-content" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_CONTENT; ?></option>
432
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-paragraph" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_PARAGRAPH; ?></option>
433
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion after-paragraph" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_PARAGRAPH; ?></option>
434
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion after-content" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_CONTENT; ?></option>
435
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion after-post" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_POST; ?></option>
436
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-excerpts" 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>
437
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion after-excerpts" 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>
438
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion between-posts" 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>
439
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-comments" 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>
440
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion between-comments" 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>
441
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion after-comments" 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>
442
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion footer" value="<?php echo AI_AUTOMATIC_INSERTION_FOOTER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_FOOTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FOOTER; ?></option>
443
+ <?php foreach ($ai_custom_hooks as $hook_index => $custom_hook) { ?>
444
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion custom-hook" value="<?php echo AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo $custom_hook ['name']; ?></option>
445
+ <?php } ?>
446
  </select>
447
  </div>
448
 
449
  <div style="float: right;">
450
  Alignment and Style:&nbsp;&nbsp;&nbsp;
451
  <select style="width:120px;" id="block-alignment-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ALIGNMENT_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_alignment_type(); ?>">
452
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion default" value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
453
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion align-left" value="<?php echo AI_ALIGNMENT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
454
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion center" value="<?php echo AI_ALIGNMENT_CENTER; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
455
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion align-right" 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>
456
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion float-left" 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>
457
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion float-right" 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>
458
  <?php $css_code_height = 260; if (function_exists ('ai_style_options')) $css_code_height = ai_style_options ($obj); ?>
459
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion custom-css" 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>
460
+ <option data-img-src="<?php echo plugins_url ('images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion no-wrapping" 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>
461
  </select>
462
  &nbsp;
463
  <button id="show-css-button-<?php echo $ad_number; ?>" type="button" style="min-width: 60px; margin-right: 0px;">Show</button>
492
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
493
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $ad_number; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />
494
 
495
+ <select style="margin: 0 0 0 10px;" id="enabled-on-which-posts-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px">
496
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
497
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
498
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
499
  </select>
500
  &nbsp;
501
+ <label for="display-posts-<?php echo $ad_number; ?>" title="Individual post exceptions (if enabled here) can be configured in post editor. Leave blank for no individual post exceptions.">Posts</label>
502
 
503
  <?php
504
  if (!empty ($block_exceptions [$ad_number])) {
528
  <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="0" />
529
  <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $ad_number; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />
530
 
531
+ <select style="margin: 0 0 0 10px;" id="enabled-on-which-pages-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px">
532
  <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
533
  <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
534
  <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
535
  </select>
536
  &nbsp;
537
+ <label for="display-pages-<?php echo $ad_number; ?>" title="Individual static page exceptions (if enabled here) can be configured in page editor. Leave blank for no individual page exceptions.">Static pages</label>
538
  </td>
539
  <td style="padding-left: 8px;">
540
  </td>
863
  Urls
864
  </td>
865
  <td style="padding-right: 7px;">
866
+ <input style="width: 100%;" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_ad_url_list(); ?>" value="<?php echo $url_list; ?>" size="54" maxlength="500" title="SPACE separated urls (page addresses) starting with / after domain name (e.g. /permalink-url, use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" />
867
+ <br />
868
+ <!-- <textarea id="urls2-<?php echo $ad_number; ?>" style="width: 100%; height: 100px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" name="XX_<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>"><?php echo esc_textarea (str_replace (' ', "\n", $url_list)); ?></textarea>-->
869
  </td>
870
  <td style="padding-right: 7px;">
871
  <input type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="url-blacklist-<?php echo $ad_number; ?>" default="<?php echo $default->get_ad_url_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
881
  Url parameters
882
  </td>
883
  <td style="padding-right: 7px;">
884
+ <input style="width: 100%;" title="Comma separated url query parameters or cookies with optional values (use 'prameter', 'prameter=value', 'cookie' or 'cookie=value')" type="text" name="<?php echo AI_OPTION_URL_PARAMETER_LIST, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_url_parameter_list(); ?>" value="<?php echo $url_parameter_list; ?>" size="54" maxlength="500"/>
885
  </td>
886
  <td style="padding-right: 7px;">
887
  <input type="radio" name="<?php echo AI_OPTION_URL_PARAMETER_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" id="url-parameter-blacklist-<?php echo $ad_number; ?>" default="<?php echo $default->get_url_parameter_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_url_parameter_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1177
  <h3 style="margin: 0; float: left;"><?php echo AD_INSERTER_NAME ?> Settings <?php if (isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'])) echo (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][0].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][1]), '.',
1178
  (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][2].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][3]), '.',
1179
  (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][4].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][5]); ?></h3>
1180
+ <h4 style="margin: 0px; float: right;<?php if (defined ('AI_GENERATE_EXTRACT')) echo ' color: #00f;'; ?>" title="Settings timestamp"><?php echo isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP']) ? date ("Y-m-d H:i:s", $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : "";?></h4>
1181
  <div style="clear: both;"></div>
1182
  </div>
1183
 
1198
  <?php
1199
  if (function_exists ('ai_global_settings')) ai_global_settings ();
1200
 
1201
+ if ($enabled_k) $style_k = "font-weight: bold; color: #66f;"; else $style_k = "";
1202
  if ($enabled_h) $style_h = "font-weight: bold; color: #66f;"; else $style_h = "";
1203
  if ($enabled_f) $style_f = "font-weight: bold; color: #66f;"; else $style_f = "";
1204
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1205
+ $adb_action = get_adb_action (true);
1206
  if ($enabled_a) $style_a = "font-weight: bold; color: " . ($adb_action == AI_ADB_ACTION_NONE ? "#66f;" : "#f00;"); else $style_a = "";
1207
  }
1208
  if (false) $style_d = "font-weight: bold; color: #e44;"; else $style_d = "";
1212
  <ul id="ai-plugin-settings-tabs" style="display: none;">
1213
  <li id="ai-g" class="ai-plugin-tab"><a href="#tab-general">General</a></li>
1214
  <li id="ai-v" class="ai-plugin-tab"><a href="#tab-viewports">Viewports</a></li>
1215
+ <li id="ai-k" class="ai-plugin-tab"><a href="#tab-hooks"><span style="<?php echo $style_k ?>">Hooks</span></a></li>
1216
  <li id="ai-h" class="ai-plugin-tab"><a href="#tab-header"><span style="<?php echo $style_h ?>">Header</span></a></li>
1217
  <li id="ai-f" class="ai-plugin-tab"><a href="#tab-footer"><span style="<?php echo $style_f ?>">Footer</span></a></li>
1218
  <?php if (function_exists ('ai_plugin_settings_tab')) ai_plugin_settings_tab ($exceptions); ?>
1359
 
1360
  <div id="tab-viewports" class="rounded">
1361
  <div style="margin: 0 0 8px 0;">
1362
+ <strong>Viewport Settings used for client-side device detection</strong>
1363
  </div>
1364
  <?php
1365
  for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1366
+ $bottom_margin = $viewport == AD_INSERTER_VIEWPORTS ? 0 : 4;
1367
  ?>
1368
+ <div style="margin: 4px 0 <?php echo $bottom_margin; ?>px 0;">
1369
  Viewport <?php echo $viewport; ?> name&nbsp;&nbsp;&nbsp;
1370
  <input style="margin-left: 0px;" type="text" name="viewport-name-<?php echo $viewport; ?>" value="<?php echo get_viewport_name ($viewport); ?>" default="<?php echo defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : ""; ?>" size="15" maxlength="40" />
1371
  <?php if ($viewport == AD_INSERTER_VIEWPORTS) echo '<span style="display: none;">' ?>
1378
  ?>
1379
  </div>
1380
 
1381
+ <div id="tab-hooks" class="rounded">
1382
+ <div style="margin: 0 0 8px 0;">
1383
+ <strong>Custom Hooks</strong>
1384
+ </div>
1385
+
1386
+ <table>
1387
+ <tbody>
1388
+ <?php
1389
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
1390
+ ?>
1391
+ <tr>
1392
+ <td style="padding: 0 0 2px 0;">
1393
+ <input type="hidden" name="hook-enabled-<?php echo $hook; ?>" value="0" />
1394
+ <input type="checkbox" name="hook-enabled-<?php echo $hook; ?>" value="1" default="<?php echo AI_DISABLED; ?>" id="hook-enabled-<?php echo $hook; ?>" title="Enable or disable hook" <?php if (get_hook_enabled ($hook) == AI_ENABLED) echo 'checked '; ?> />
1395
+ </td>
1396
+ <td style="white-space: nowrap;">
1397
+ <label for="hook-enabled-<?php echo $hook; ?>" title="Enable or disable hook">Hook <?php echo $hook; ?> name</label>
1398
+ </td>
1399
+ <td style="width: 25%;">
1400
+ <input style="width: 100%;" title="Hook name for automatic insertion selection" type="text" name="hook-name-<?php echo $hook; ?>" default="" value="<?php echo get_hook_name ($hook); ?>" size="30" maxlength="80" />
1401
+ </td>
1402
+ <td style="padding-left: 7px;">
1403
+ action
1404
+ </td>
1405
+ <td style="">
1406
+ <input style="width: 100%;" title="Action tag as used in the do_action () function" type="text" name="hook-action-<?php echo $hook; ?>" default="" value="<?php echo get_hook_action ($hook); ?>" size="30" maxlength="80" />
1407
+ </td>
1408
+ <td style="padding-left: 7px;">
1409
+ priority
1410
+ </td>
1411
+ <td>
1412
+ <input title="Priority for the hook (default is 10)" type="text" name="hook-priority-<?php echo $hook; ?>" default="<?php echo DEFAULT_CUSTOM_HOOK_PRIORITY; ?>" value="<?php echo get_hook_priority ($hook); ?>" size="5" maxlength="7" />
1413
+ </td>
1414
+ </tr>
1415
+ <?php
1416
+ }
1417
+ ?>
1418
+ </tbody>
1419
+ </table>
1420
+ </div>
1421
+
1422
  <div id="tab-header" style="margin: 0px 0; padding: 0; ">
1423
  <div style="margin: 8px 0;">
1424
  <div style="float: right;">
1712
  </td>
1713
  <td>
1714
  <input type="hidden" name="javascript_debugging" value="0" />
1715
+ <input type="checkbox" name="javascript_debugging" id="javascript-debugging" value="1" default="<?php echo DEFAULT_JAVASCRIPT_DEBUGGING; ?>" <?php if (get_javascript_debugging ()==AI_ENABLED) echo 'checked '; ?> />
1716
  </td>
1717
  </tr>
1718
  <tr class="system-debugging" style="display: none;">
1860
 
1861
  function check_blocked_images () {
1862
 
1863
+ function replace_blocked_image (image_id, image_src, css_display) {
1864
  var image_selector = "#" + image_id;
1865
  if (!jQuery(image_selector + ":visible").length) {
1866
  var image = jQuery(image_selector);
1878
  jQuery("#blocked-warning .blocked-warning-text").css ('color', '#00f');
1879
  }
1880
 
1881
+ replace_blocked_image ('ai-media-1', 'contextual-1.gif', 'block');
1882
+ replace_blocked_image ('ai-media-2', 'contextual-2.jpg', 'block');
1883
+ replace_blocked_image ('ai-pro-1', 'icon-256x256.jpg', 'block');
1884
+ replace_blocked_image ('ai-pro-2', 'ai-charts-250.png', 'block');
1885
+ replace_blocked_image ('ai-stars-img', 'stars.png', 'inline');
1886
+ replace_blocked_image ('ai-tw', 'twitter.png', 'inline');
1887
+ replace_blocked_image ('ai-fb', 'facebook.png', 'inline');
1888
  }
1889
  </script>
1890
 
1996
  <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> before or after post / content / <a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">paragraph</a> / excerpt</li>
1997
  <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> between posts on blog pages</li>
1998
  <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> before, between and after comments</li>
1999
+ <li><a href="http://adinserter.pro/documentation#automatic-insertion" class="simple-link" target="_blank">Automatic insertion</a> at custom hook positions</li>
2000
  <li><a href="https://adinserter.pro/exceptions" class="simple-link" target="_blank">Insertion exceptions</a> for individual posts and pages</li>
2001
  <li><a href="http://adinserter.pro/documentation#manual-insertion" class="simple-link" target="_blank">Manual insertion</a>: widgets, shortcodes, PHP function call</li>
2002
  <li><a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">Sticky positions</a> (left, top, right, bottom - ads stay fixed when the page scrolls)</li>
2016
  <li>Desktop, tablet and phone server-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">device detection</a></li>
2017
  <li>Client-side <a href="http://adinserter.pro/documentation#devices" class="simple-link" target="_blank">mobile device detection</a> (works with caching, 6 custom viewports)</li>
2018
  <li><a href="https://adinserter.pro/ad-blocking-detection" class="simple-link" target="_blank">Ad blocking detection</a> - popup message, ad replacement, content protection</li>
2019
+ <li><a href="https://adinserter.pro/tracking#ad-blocking-statistics" class="simple-link" target="_blank">Ad blocking statistics</a></li>
2020
+ <li><a href="http://adinserter.pro/lists" class="simple-link" target="_blank">Black/White-list </a>categories, tags, taxonomies, users, post IDs, urls, referers</li>
2021
+ <li><a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">Black/White-list </a>IP addresses or countries (works also with caching)</li>
2022
  <li><a href="http://adinserter.pro/documentation#multisite" class="simple-link" target="_blank">Multisite options</a> to limit settings on the sites</li>
2023
  <li>Import/Export block or plugin settings</li>
2024
  <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a> with fallback option</li>
2025
+ <li>Country-level <a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">GEO targeting</a> (works also with caching)</li>
2026
  <li>Simple troubleshooting with many <a href="http://adinserter.pro/documentation#debugging" class="simple-link" target="_blank">debugging functions</a></li>
2027
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of inserted code blocks or ads for easier placement</li>
2028
  <li><a href="http://adinserter.pro/documentation#visualization" class="simple-link" target="_blank">Visualization</a> of available positions for automatic ad insertion</li>
2059
  <div style="float: right; margin-left: 15px;">
2060
  <ul>
2061
  <li><a href="https://adinserter.pro/alignments-and-styles" class="simple-link" target="_blank">Sticky positions</a></li>
2062
+ <li><a href="http://adinserter.pro/lists" class="simple-link" target="_blank">Limit insertions</a></li>
2063
  <li><a href="http://adinserter.pro/documentation#paragraphs" class="simple-link" target="_blank">Clearance</a> options</li>
2064
  </ul>
2065
  </div>
2084
  <div style="float: right; margin-left: 15px;">
2085
  <ul>
2086
  <li>64 code blocks</li>
2087
+ <li><a href="http://adinserter.pro/lists#geo-targeting" class="simple-link" target="_blank">GEO targeting</a></li>
2088
  <li><a href="http://adinserter.pro/documentation#scheduling" class="simple-link" target="_blank">Scheduling</a></li>
2089
  </ul>
2090
  </div>