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

Version Description

  • Added support for client-side rotation (works with caching)
  • Added support for server-side rotation with W3 Total Cache
  • Added support for client-side country detection (works with caching, Pro only)
  • Added support for server-side country detection with W3 Total Cache (Pro only)
  • Added debugging functions to measure plugin processing time
  • Added option to black/white-list IP addresses (Pro only)
  • Added option for fallback code when scheduling between dates expires (Pro only)
  • On multisite installations Ad Inserter debug menu item on sites is available only if settings page is enabled
  • Added option for multisite installations to use Ad Inserter settings of main site for all blogs
  • Added flags to country list (Pro only)
  • Bug fix: Code preview did not work if Wordpress was installed in a folder
  • Few minor bug fixes and cosmetic changes
Download this release

Release Info

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

Code changes from version 2.0.7 to 2.0.8

ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.0.7
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,20 @@ Plugin URI: http://adinserter.pro/documentation
11
  /*
12
  Change Log
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  Ad Inserter 2.0.7 - 23 December 2016
15
  - Delayed display moved to Misc group
16
  - Added option for scheduling to insert code only between specified dates (Pro only)
@@ -292,7 +306,7 @@ if (version_compare ($wp_version, "4.0", "<")) {
292
  exit ($exit_msg);
293
  }
294
 
295
- global $block_object, $ai_wp_data, $ad_interter_globals, $ai_last_check, $ai_last_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options;
296
 
297
  //include required files
298
  require_once AD_INSERTER_PLUGIN_DIR.'class.php';
@@ -301,8 +315,10 @@ require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
301
  require_once AD_INSERTER_PLUGIN_DIR.'preview.php';
302
 
303
  if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
304
- ini_set ('display_errors', 1);
305
- error_reporting (E_ALL);
 
 
306
  }
307
 
308
  $version_array = explode (".", AD_INSERTER_VERSION);
@@ -320,6 +336,9 @@ if (!is_admin()) {
320
  if (!isset ($_GET [AI_URL_DEBUG_PROCESSING]) || $_GET [AI_URL_DEBUG_PROCESSING] == 1) {
321
  $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_PROCESSING;
322
 
 
 
 
323
  $ai_last_time = microtime ();
324
  $ai_processing_log = array ();
325
  ai_log ("INITIALIZATION START");
@@ -332,8 +351,29 @@ $block_object = array ();
332
 
333
  ai_load_settings ();
334
 
 
 
 
 
 
 
 
335
  if (function_exists ('ai_load_globals')) ai_load_globals ();
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
338
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
339
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
@@ -399,10 +439,13 @@ add_action ('wp_enqueue_scripts', 'ai_enqueue_scripts_hook');
399
 
400
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
401
  add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
402
- add_action ('wp_ajax_ai_preview', 'ai_preview');
403
- add_action ('wp_ajax_nopriv_ai_preview', 'ai_preview');
404
 
405
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("INITIALIZATION END\n");
 
 
 
406
 
407
 
408
 
@@ -609,6 +652,7 @@ function ai_log_block_status ($block, $ai_last_check) {
609
  case AI_CHECK_URL: $status .= "URL"; break;
610
  case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
611
  case AI_CHECK_REFERER: $status .= "REFERER ". $obj->get_ad_domain_list(); break;
 
612
  case AI_CHECK_COUNTRY: $status .= "COUNTRY ". $obj->get_ad_country_list (true); break;
613
  case AI_CHECK_SCHEDULING: $status .= "SCHEDULING"; break;
614
  case AI_CHECK_CODE: $status .= "CODE NOT EMPTY"; break;
@@ -618,7 +662,7 @@ function ai_log_block_status ($block, $ai_last_check) {
618
 
619
  case AI_CHECK_ENABLED_ON_ALL_EXCEPT_ON_SELECTED: $status .= "ENABLED ON ALL EXCEPT ON SELECTED"; break;
620
  case AI_CHECK_ENABLED_ONLY_ON_SELECTED: $status .= "ENABLED ONLY ON SELECTED"; break;
621
- case AI_CHECK_DISABLED_MANUALLY: $status .= "404"; break;
622
 
623
  case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break;
624
  case AI_CHECK_FILTER: $status .= "FILTER " . $obj->get_call_filter(); break;
@@ -708,13 +752,20 @@ function number_of_words (&$content) {
708
  }
709
 
710
  function ai_wp_hook () {
711
- global $ai_wp_data, $ai_db_options_extract;
 
 
 
 
 
712
 
713
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WP HOOK START");
714
  set_page_type ();
715
  set_user ();
716
 
717
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN && ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_admin_toolbar_debugging ())
 
 
 
718
  add_action ('admin_bar_menu', 'ai_toolbar', 20);
719
 
720
  $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
@@ -775,7 +826,10 @@ function ai_wp_hook () {
775
  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)
776
  add_action ('loop_end', 'ai_loop_end_hook');
777
 
778
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WP HOOK END\n");
 
 
 
779
  };
780
 
781
  function ai_init_hook() {
@@ -805,11 +859,11 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
805
  'jquery-ui-tooltip',
806
  'jquery-ui-datepicker',
807
  ), AD_INSERTER_VERSION);
808
- wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), false, null);
809
 
810
  if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
811
 
812
- wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), false, AD_INSERTER_VERSION);
813
 
814
  // wp_add_inline_style ('ai-admin', AI_SETTINGS_STYLE);
815
 
@@ -823,7 +877,12 @@ function ai_admin_enqueue_scripts ($hook_suffix) {
823
  }
824
 
825
  function ai_enqueue_scripts_hook () {
826
- global $ai_wp_data;
 
 
 
 
 
827
 
828
  $style = "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
829
  content: '\\f111';
@@ -866,13 +925,168 @@ function ai_enqueue_scripts_hook () {
866
  }";
867
 
868
  if ($ai_wp_data [CLIENT_SIDE_DETECTION] || get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
869
- wp_enqueue_style ('ai-frontend', plugins_url ('css/dummy.css', __FILE__), false, filemtime (plugin_dir_path (__FILE__ ).'css/dummy.css'));
870
 
871
  if ($ai_wp_data [CLIENT_SIDE_DETECTION])
872
  wp_add_inline_style ('ai-frontend', get_viewport_css ());
873
 
874
  if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
875
  wp_add_inline_style ('ai-frontend', $style);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
876
  }
877
 
878
  function ai_admin_notice_hook () {
@@ -1026,7 +1240,8 @@ function ai_meta_box_callback ($post) {
1026
  if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF";
1027
  echo '<tr style="background: ', $background, ';">';
1028
  echo ' <td style="text-align: right;">', $obj->number, '</td>';
1029
- echo ' <td style="padding: 0 10px 0 10px;">', $obj->get_ad_name(), '</td>';
 
1030
  echo ' <td style="padding: 0 10px 0 10px;">', $display_type, '</td>';
1031
 
1032
  echo ' <td style="padding: 0 10px 0 10px; text-align: center;">';
@@ -1058,7 +1273,7 @@ function ai_meta_box_callback ($post) {
1058
  echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
1059
  if ($individual_option_enabled)
1060
  echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
1061
-
1062
  echo '<label for="ai-selected-block-', $block, '">';
1063
  if ($individual_option_enabled) {
1064
  if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
@@ -1073,7 +1288,9 @@ function ai_meta_box_callback ($post) {
1073
  echo '</tbody>';
1074
  echo '</table>';
1075
 
1076
- echo '<p>Default behavior for all code blocks for ', $post_type, 's (enabled or disabled) can be configured on <a href="', admin_url ('options-general.php?page=ad-inserter.php'), '" target="_blank">', AD_INSERTER_NAME, ' Settings page</a>. Here you can configure exceptions for this ', $post_type, '.</p>';
 
 
1077
  }
1078
 
1079
  function ai_save_meta_box_data_hook ($post_id) {
@@ -1114,9 +1331,12 @@ function ai_widgets_init_hook () {
1114
  }
1115
 
1116
  function ai_wp_head_hook () {
1117
- global $block_object, $ai_wp_data;
1118
 
1119
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("HEAD HOOK START");
 
 
 
1120
 
1121
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
1122
 
@@ -1130,13 +1350,19 @@ function ai_wp_head_hook () {
1130
  echo $obj->ai_getCode ();
1131
  }
1132
 
1133
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("HEAD HOOK END\n");
 
 
 
1134
  }
1135
 
1136
  function ai_wp_footer_hook () {
1137
- global $block_object, $ai_wp_data;
1138
 
1139
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("FOOTER HOOK START");
 
 
 
1140
 
1141
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
1142
 
@@ -1150,15 +1376,21 @@ function ai_wp_footer_hook () {
1150
  echo $obj->ai_getCode ();
1151
  }
1152
 
1153
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("FOOTER HOOK END\n");
 
 
 
1154
  }
1155
 
1156
  function ai_write_debug_info ($write_processing_log = false) {
1157
- global $block_object, $ai_last_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options;
1158
 
1159
  echo sprintf ("%-25s%s\n\n", AD_INSERTER_NAME, AD_INSERTER_VERSION);
1160
  echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
1161
  echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
 
 
 
1162
 
1163
  echo "SETTINGS: ";
1164
  if (isset ($ai_db_options ['global']['VERSION']))
@@ -1193,9 +1425,18 @@ function ai_write_debug_info ($write_processing_log = false) {
1193
  echo "\n";
1194
  echo 'ID: ', get_the_ID(), "\n";
1195
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1196
- echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? remove_parameters_from_url ($_SERVER['HTTP_REFERER']) : "", "\n";
1197
  if (function_exists ('ai_debug')) ai_debug ();
1198
  echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
 
 
 
 
 
 
 
 
 
1199
  echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1200
  if ($ai_wp_data [SERVER_SIDE_DETECTION]) {
1201
  echo 'SERVER-SIDE DEVICE: ';
@@ -1348,9 +1589,10 @@ function ai_shutdown_hook () {
1348
  }
1349
 
1350
  function ai_check_multisite_options (&$multisite_options) {
1351
- if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1352
- if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
1353
- if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
 
1354
  }
1355
 
1356
  function ai_check_plugin_options ($plugin_options = array ()) {
@@ -1379,6 +1621,8 @@ function ai_check_plugin_options ($plugin_options = array ()) {
1379
  }
1380
  $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
1381
 
 
 
1382
  if (!isset ($plugin_options ['ADMIN_TOOLBAR_DEBUGGING'])) $plugin_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
1383
  if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
1384
  if (!isset ($plugin_options ['JAVASCRIPT_DEBUGGING'])) $plugin_options ['JAVASCRIPT_DEBUGGING'] = DEFAULT_JAVASCRIPT_DEBUGGING;
@@ -1452,14 +1696,20 @@ function ai_load_options () {
1452
 
1453
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS START");
1454
 
1455
- $ai_db_options = get_option (WP_OPTION_NAME);
1456
- option_stripslashes ($ai_db_options);
1457
-
1458
  if (is_multisite()) {
1459
  $ai_db_options_multisite = get_site_option (WP_OPTION_NAME);
1460
  option_stripslashes ($ai_db_options_multisite);
 
1461
  }
1462
 
 
 
 
 
 
 
 
 
1463
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS END");
1464
  }
1465
 
@@ -1526,6 +1776,19 @@ function get_plugin_priority () {
1526
  return ($plugin_db_options ['PLUGIN_PRIORITY']);
1527
  }
1528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1529
  function get_admin_toolbar_debugging () {
1530
  global $ai_db_options;
1531
 
@@ -1570,6 +1833,8 @@ function multisite_settings_page_enabled () {
1570
  $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1571
  }
1572
 
 
 
1573
  return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']);
1574
  }
1575
 
@@ -1604,6 +1869,20 @@ function multisite_exceptions_enabled () {
1604
  return DEFAULT_MULTISITE_EXCEPTIONS;
1605
  }
1606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1607
  function get_viewport_name ($viewport_number) {
1608
  global $ai_db_options;
1609
 
@@ -1686,8 +1965,9 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
1686
  $value = str_replace (array ("\\\""), array ("\""), $value);
1687
 
1688
  if ($option == AI_OPTION_DOMAIN_LIST ||
 
1689
  $option == AI_OPTION_COUNTRY_LIST) {
1690
- $value = str_replace (array ("\\", "/", "?", "\"", "<", ">", "[", "]"), "", $value);
1691
  $value = esc_html ($value);
1692
  }
1693
  elseif (
@@ -1700,7 +1980,6 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
1700
  elseif ($option == AI_OPTION_NAME ||
1701
  $option == AI_OPTION_GENERAL_TAG ||
1702
  $option == AI_OPTION_DOMAIN_LIST ||
1703
- $option == AI_OPTION_COUNTRY_LIST ||
1704
  $option == AI_OPTION_CATEGORY_LIST ||
1705
  $option == AI_OPTION_TAG_LIST ||
1706
  $option == AI_OPTION_ID_LIST ||
@@ -1720,6 +1999,7 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
1720
  $option == AI_OPTION_AFTER_DAYS ||
1721
  $option == AI_OPTION_START_DATE ||
1722
  $option == AI_OPTION_END_DATE ||
 
1723
  $option == AI_OPTION_EXCERPT_NUMBER ||
1724
  $option == AI_OPTION_CUSTOM_CSS) {
1725
  $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
@@ -1743,7 +2023,7 @@ function filter_option_hf ($option, $value){
1743
  return $value;
1744
  }
1745
 
1746
- function ai_preview () {
1747
  global $ai_db_options, $block_object;
1748
 
1749
  check_admin_referer ("adinserter_data", "ai_check");
@@ -1772,6 +2052,19 @@ function ai_preview () {
1772
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
1773
  }
1774
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1775
  die ();
1776
  }
1777
 
@@ -2026,6 +2319,7 @@ function ai_settings () {
2026
  $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
2027
  $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
2028
  $options ['PLUGIN_PRIORITY'] = filter_option ('plugin_priority', $_POST ['plugin_priority']);
 
2029
  $options ['ADMIN_TOOLBAR_DEBUGGING'] = filter_option ('admin_toolbar_debugging', $_POST ['admin_toolbar_debugging']);
2030
  $options ['REMOTE_DEBUGGING'] = filter_option ('remote_debugging', $_POST ['remote_debugging']);
2031
  $options ['JAVASCRIPT_DEBUGGING'] = filter_option ('javascript_debugging', $_POST ['javascript_debugging']);
@@ -2058,9 +2352,11 @@ function ai_settings () {
2058
  // Multisite
2059
  if (is_multisite () && is_main_site ()) {
2060
  $options = array ();
2061
- $options ['MULTISITE_SETTINGS_PAGE'] = filter_option ('multisite_settings_page', $_POST ['multisite_settings_page']);
2062
- $options ['MULTISITE_WIDGETS'] = filter_option ('multisite_widgets', $_POST ['multisite_widgets']);
2063
- $options ['MULTISITE_EXCEPTIONS'] = filter_option ('multisite_exceptions', $_POST ['multisite_exceptions']);
 
 
2064
  ai_check_multisite_options ($options);
2065
  update_site_option (WP_OPTION_NAME, $options);
2066
  }
@@ -2154,21 +2450,27 @@ function ai_adinserter ($ad_number = '', $ignore = ''){
2154
  }
2155
 
2156
  function adinserter ($block = '', $ignore = '') {
2157
- global $ai_last_check, $ai_wp_data;
2158
 
2159
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
 
 
2160
  $ai_last_check = AI_CHECK_NONE;
2161
  $code = ai_adinserter ($block, $ignore);
2162
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
2163
- if ($debug_processing) ai_log ("PHP FUNCTION CALL END\n");
 
 
 
 
2164
 
2165
  return $code;
2166
  }
2167
 
2168
 
2169
 
2170
- function ai_content_hook ($content = ''){
2171
- global $block_object, $ad_interter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
2172
 
2173
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
2174
 
@@ -2179,7 +2481,10 @@ function ai_content_hook ($content = ''){
2179
  $ad_interter_globals [$globals_name] = 1;
2180
  } else $ad_interter_globals [$globals_name] ++;
2181
 
2182
- if ($debug_processing) ai_log ("CONTENT HOOK START [" . $ad_interter_globals [$globals_name] . ']');
 
 
 
2183
 
2184
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_CONTENT;
2185
 
@@ -2312,14 +2617,17 @@ function ai_content_hook ($content = ''){
2312
  $content = '<kbd style="display: none">[HTML TAGS REMOVED]</kbd>' . $content;
2313
  }
2314
 
2315
- if ($debug_processing) ai_log ("CONTENT HOOK END\n");
 
 
 
2316
 
2317
  return $content;
2318
  }
2319
 
2320
  // Process Before/After Excerpt postion
2321
- function ai_excerpt_hook ($content = ''){
2322
- global $ad_interter_globals, $block_object, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
2323
 
2324
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
2325
 
@@ -2330,7 +2638,10 @@ function ai_excerpt_hook ($content = ''){
2330
  $ad_interter_globals [$globals_name] = 1;
2331
  } else $ad_interter_globals [$globals_name] ++;
2332
 
2333
- if ($debug_processing) ai_log ("EXCERPT HOOK START [" . $ad_interter_globals [$globals_name] . ']');
 
 
 
2334
 
2335
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_EXCERPT;
2336
 
@@ -2394,14 +2705,17 @@ function ai_excerpt_hook ($content = ''){
2394
  $content = preg_replace ("/\[AI\](.+?)\[\/AI\]/", "", $content);
2395
  }
2396
 
2397
- if ($debug_processing) ai_log ("EXCERPT HOOK END\n");
 
 
 
2398
 
2399
  return $content;
2400
  }
2401
 
2402
  // Process Before / After Post postion
2403
 
2404
- function ai_before_after_post ($query, $display_type){
2405
  global $block_object, $ad_interter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
2406
 
2407
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
@@ -2467,22 +2781,34 @@ function ai_before_after_post ($query, $display_type){
2467
  }
2468
 
2469
  // Process Before Post postion
2470
- function ai_loop_start_hook ($query){
2471
- global $ai_wp_data;
2472
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2473
- if ($debug_processing) ai_log ("LOOP START HOOK START");
 
 
 
2474
  ai_before_after_post ($query, AD_SELECT_BEFORE_POST);
2475
- if ($debug_processing) ai_log ("LOOP START HOOK END\n");
 
 
 
2476
  }
2477
 
2478
 
2479
  // Process After Post postion
2480
  function ai_loop_end_hook ($query){
2481
- global $ai_wp_data;
2482
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2483
- if ($debug_processing) ai_log ("LOOP END HOOK START");
 
 
 
2484
  ai_before_after_post ($query, AD_SELECT_AFTER_POST);
2485
- if ($debug_processing) ai_log ("LOOP END HOOK END\n");
 
 
 
2486
  }
2487
 
2488
  function process_shortcode (&$block, $atts) {
@@ -2559,21 +2885,28 @@ function process_shortcode (&$block, $atts) {
2559
 
2560
 
2561
  function process_shortcodes ($atts) {
2562
- global $ai_last_check, $ai_wp_data;
2563
 
2564
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2565
  if ($debug_processing) {
2566
  $atts_string = '';
2567
- foreach ($atts as $index => $att) {
2568
- $atts_string .= $index . '="'.$att.'" ';
2569
- }
 
2570
  ai_log ("PROCESS SHORTCODES [adinserter ".trim ($atts_string).']');
 
2571
  }
2572
  $ai_last_check = AI_CHECK_NONE;
2573
  $block = - 1;
2574
  $shortcode = process_shortcode ($block, $atts);
2575
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
2576
- if ($debug_processing) ai_log ("SHORTCODE END\n");
 
 
 
 
 
2577
  return $shortcode;
2578
  }
2579
 
@@ -2621,7 +2954,7 @@ class ai_widget extends WP_Widget {
2621
  for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
2622
  $obj = $block_object [$block_index];
2623
  ?>
2624
- <option value='<?php echo $block_index; ?>' <?php if ($block_index == $block) echo 'selected="selected"'; ?>><?php echo $obj->get_ad_name(), !$obj->get_enable_widget ()? ' - DISABLED' : ''; ?></option>
2625
  <?php } ?>
2626
  <option value='0' <?php if ($block == 0) echo 'selected="selected"'; ?>>Debugger</option>
2627
  </select>
@@ -2646,17 +2979,21 @@ class ai_widget extends WP_Widget {
2646
  }
2647
 
2648
  function widget ($args, $instance) {
2649
- global $ai_last_check, $ai_wp_data;
 
 
 
2650
 
2651
  $ai_last_check = AI_CHECK_NONE;
2652
 
2653
  $block = 0;
2654
  ai_widget_draw ($args, $instance, $block);
2655
 
2656
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2657
-
2658
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
2659
- if ($debug_processing) ai_log ("WIDGET END\n");
 
2660
  }
2661
  }
2662
 
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.0.8
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.0.8 - 6 January 2016
15
+ - Added support for client-side rotation (works with caching)
16
+ - Added support for server-side rotation with W3 Total Cache
17
+ - Added support for client-side country detection (works with caching, Pro only)
18
+ - Added support for server-side country detection with W3 Total Cache (Pro only)
19
+ - Added debugging functions to measure plugin processing time
20
+ - Added option to black/white-list IP addresses (Pro only)
21
+ - Added option for fallback code when scheduling between dates expires (Pro only)
22
+ - On multisite installations Ad Inserter debug menu item on sites is available only if settings page is enabled
23
+ - Added option for multisite installations to use Ad Inserter settings of main site for all blogs
24
+ - Added flags to country list (Pro only)
25
+ - Bug fix: Code preview did not work if Wordpress was installed in a folder
26
+ - Few minor bug fixes and cosmetic changes
27
+
28
  Ad Inserter 2.0.7 - 23 December 2016
29
  - Delayed display moved to Misc group
30
  - Added option for scheduling to insert code only between specified dates (Pro only)
306
  exit ($exit_msg);
307
  }
308
 
309
+ global $block_object, $ai_wp_data, $ad_interter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options;
310
 
311
  //include required files
312
  require_once AD_INSERTER_PLUGIN_DIR.'class.php';
315
  require_once AD_INSERTER_PLUGIN_DIR.'preview.php';
316
 
317
  if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
318
+ if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
319
+ ini_set ('display_errors', 1);
320
+ error_reporting (E_ALL);
321
+ }
322
  }
323
 
324
  $version_array = explode (".", AD_INSERTER_VERSION);
336
  if (!isset ($_GET [AI_URL_DEBUG_PROCESSING]) || $_GET [AI_URL_DEBUG_PROCESSING] == 1) {
337
  $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_PROCESSING;
338
 
339
+ $ai_total_plugin_time = 0;
340
+ $start_time = microtime ();
341
+ $ai_total_php_time = 0;
342
  $ai_last_time = microtime ();
343
  $ai_processing_log = array ();
344
  ai_log ("INITIALIZATION START");
351
 
352
  ai_load_settings ();
353
 
354
+ if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] != '') {
355
+ if (get_remote_debugging ()) {
356
+ ini_set ('display_errors', 1);
357
+ error_reporting (E_ALL);
358
+ }
359
+ }
360
+
361
  if (function_exists ('ai_load_globals')) ai_load_globals ();
362
 
363
+ if (get_dynamic_blocks ()) {
364
+ if (!in_array ('w3-total-cache/w3-total-cache.php', get_option ('active_plugins'))) {
365
+ define ('AI_NO_W3TC', true);
366
+ if (!defined ('W3TC_DYNAMIC_SECURITY')) define ('W3TC_DYNAMIC_SECURITY', 'W3 Total Cache plugin not active');
367
+ }
368
+ if (!defined ('W3TC_DYNAMIC_SECURITY')) {
369
+ $string = AD_INSERTER_PLUGIN_DIR;
370
+ if (defined ('AUTH_KEY')) $string .= AUTH_KEY;
371
+ if (defined ('LOGGED_IN_KEY')) $string .= LOGGED_IN_KEY;
372
+
373
+ define ('W3TC_DYNAMIC_SECURITY', md5 ($string));
374
+ }
375
+ }
376
+
377
  $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
378
  $ai_wp_data [AI_WP_USER] = AI_USER_NOT_SET;
379
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
439
 
440
  add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
441
  add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
442
+ add_action ('wp_ajax_ai_data', 'ai_data');
443
+ add_action ('wp_ajax_nopriv_ai_data', 'ai_data');
444
 
445
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
446
+ $ai_total_plugin_time += microtime () - $start_time;
447
+ ai_log ("INITIALIZATION END\n");
448
+ }
449
 
450
 
451
 
652
  case AI_CHECK_URL: $status .= "URL"; break;
653
  case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
654
  case AI_CHECK_REFERER: $status .= "REFERER ". $obj->get_ad_domain_list(); break;
655
+ case AI_CHECK_IP_ADDRESS: $status .= "IP ADDRESS ". $obj->get_ad_ip_address_list(); break;
656
  case AI_CHECK_COUNTRY: $status .= "COUNTRY ". $obj->get_ad_country_list (true); break;
657
  case AI_CHECK_SCHEDULING: $status .= "SCHEDULING"; break;
658
  case AI_CHECK_CODE: $status .= "CODE NOT EMPTY"; break;
662
 
663
  case AI_CHECK_ENABLED_ON_ALL_EXCEPT_ON_SELECTED: $status .= "ENABLED ON ALL EXCEPT ON SELECTED"; break;
664
  case AI_CHECK_ENABLED_ONLY_ON_SELECTED: $status .= "ENABLED ONLY ON SELECTED"; break;
665
+ case AI_CHECK_DISABLED_MANUALLY: $status .= "DISABLED BY HTML COMMENT"; break;
666
 
667
  case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break;
668
  case AI_CHECK_FILTER: $status .= "FILTER " . $obj->get_call_filter(); break;
752
  }
753
 
754
  function ai_wp_hook () {
755
+ global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time;
756
+
757
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
758
+ ai_log ("WP HOOK START");
759
+ $start_time = microtime ();
760
+ }
761
 
 
762
  set_page_type ();
763
  set_user ();
764
 
765
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN &&
766
+ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 &&
767
+ get_admin_toolbar_debugging () &&
768
+ (!is_multisite() || is_main_site () || multisite_settings_page_enabled ()))
769
  add_action ('admin_bar_menu', 'ai_toolbar', 20);
770
 
771
  $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
826
  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)
827
  add_action ('loop_end', 'ai_loop_end_hook');
828
 
829
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
830
+ $ai_total_plugin_time += microtime () - $start_time;
831
+ ai_log ("WP HOOK END\n");
832
+ }
833
  };
834
 
835
  function ai_init_hook() {
859
  'jquery-ui-tooltip',
860
  'jquery-ui-datepicker',
861
  ), AD_INSERTER_VERSION);
862
+ wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null);
863
 
864
  if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
865
 
866
+ wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
867
 
868
  // wp_add_inline_style ('ai-admin', AI_SETTINGS_STYLE);
869
 
877
  }
878
 
879
  function ai_enqueue_scripts_hook () {
880
+ global $ai_wp_data, $ai_wp_data, $ai_total_plugin_time;
881
+
882
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
883
+ ai_log ("WP ENQUEUE SCRIPTS START");
884
+ $start_time = microtime ();
885
+ }
886
 
887
  $style = "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
888
  content: '\\f111';
925
  }";
926
 
927
  if ($ai_wp_data [CLIENT_SIDE_DETECTION] || get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
928
+ wp_enqueue_style ('ai-frontend', plugins_url ('includes/dummy.txt', __FILE__), array (), null);
929
 
930
  if ($ai_wp_data [CLIENT_SIDE_DETECTION])
931
  wp_add_inline_style ('ai-frontend', get_viewport_css ());
932
 
933
  if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)
934
  wp_add_inline_style ('ai-frontend', $style);
935
+
936
+ // $rotation_script = ' jQuery (function ($) {
937
+ // $("div.ai-rotate").each (function () {
938
+ // var rotate_options = $(".ai-rotate-option", this);
939
+ // var random_index = Math.floor (Math.random () * rotate_options.length);
940
+ // rotate_options.hide ();
941
+ // $(rotate_options [random_index]).css ({"display": "", "visibility": "", "position": "", "width": "", "height": "", "top": "", "left": ""});
942
+ // $(this).css ({"position": ""});
943
+ // });
944
+ // });
945
+ //';
946
+
947
+ $rotation_script = 'jQuery(function($){$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);rotate_options.hide();$(rotate_options[random_index]).css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""});$(this).css({"position":""})})});';
948
+
949
+ // $ip_address_detection_script = ' jQuery (function ($) {
950
+ // function getParameterByName (name, url) {
951
+ // if (!url) {
952
+ // url = window.location.href;
953
+ // }
954
+ // name = name.replace(/[\[\]]/g, "\\$&");
955
+ // var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
956
+ // results = regex.exec(url);
957
+ // if (!results) return null;
958
+ // if (!results[2]) return "";
959
+ // return decodeURIComponent(results[2].replace(/\+/g, " "));
960
+ // }
961
+
962
+ // var nonce = "'.wp_create_nonce ("adinserter_data").'";
963
+ // var site_url = "'.wp_make_link_relative (get_site_url()).'";
964
+ // var page = site_url+"/wp-admin/admin-ajax.php?action=ai_data&ip-data=ip-address-country&ai_check=" + nonce;
965
+
966
+ // var debug_ip_address = getParameterByName ("ai-debug-ip-address");
967
+ // if (debug_ip_address != null) page += "&ai-debug-ip-address=" + debug_ip_address;
968
+ // var debug_ip_address = getParameterByName ("ai-debug-country");
969
+ // if (debug_ip_address != null) page += "&ai-debug-country=" + debug_ip_address;
970
+
971
+ // var enable_block = false;
972
+
973
+ // $.get (page, function (ip_data) {
974
+
975
+ // $("div.ai-ip-data").each (function () {
976
+ // var ip_data_array = ip_data.split (",");
977
+ // var ip_address = ip_data_array [0];
978
+ // var country = ip_data_array [1];
979
+ // var block_div = $("." + $(this).attr ("class-name"));
980
+
981
+ // enable_block = true;
982
+ // var found = false;
983
+
984
+ // var ip_addresses_list = $(this).attr ("ip-addresses");
985
+ // if (typeof ip_addresses_list != "undefined") {
986
+ // var ip_address_array = ip_addresses_list.split (",");
987
+ // var ip_address_list_type = $(this).attr ("ip-address-list");
988
+
989
+ // $.each (ip_address_array, function (index, list_ip_address) {
990
+ // if (list_ip_address.charAt (0) == "*") {
991
+ // if (list_ip_address.charAt (list_ip_address.length - 1) == "*") {
992
+ // list_ip_address = list_ip_address.substr (1, list_ip_address.length - 2);
993
+ // if (ip_address.indexOf (list_ip_address) != - 1) {
994
+ // found = true;
995
+ // return false;
996
+ // }
997
+ // } else {
998
+ // list_ip_address = list_ip_address.substr (1);
999
+ // if (ip_address.substr (- list_ip_address.length) == list_ip_address) {
1000
+ // found = true;
1001
+ // return false;
1002
+ // }
1003
+ // }
1004
+ // }
1005
+ // else if (list_ip_address.charAt (list_ip_address.length - 1) == "*") {
1006
+ // list_ip_address = list_ip_address.substr (0, list_ip_address.length - 1);
1007
+ // if (ip_address.indexOf (list_ip_address) == 0) {
1008
+ // found = true;
1009
+ // return false;
1010
+ // }
1011
+ // }
1012
+ // else if (list_ip_address == "#" && ip_address == "") {
1013
+ // found = true;
1014
+ // return false;
1015
+ // }
1016
+
1017
+ // else if (list_ip_address == ip_address) {
1018
+ // found = true;
1019
+ // return false;
1020
+ // }
1021
+ // });
1022
+
1023
+ // switch (ip_address_list_type) {
1024
+ // case "B":
1025
+ // if (found) enable_block = false;
1026
+ // break;
1027
+ // case "W":
1028
+ // if (!found) enable_block = false;
1029
+ // break;
1030
+ // }
1031
+ // }
1032
+
1033
+ // if (enable_block) {
1034
+ // var countries_list = $(this).attr ("countries");
1035
+ // if (typeof countries_list != "undefined") {
1036
+ // var country_array = countries_list.split (",");
1037
+ // var country_list_type = $(this).attr ("country-list");
1038
+
1039
+ // var found = false;
1040
+
1041
+ // $.each (country_array, function (index, list_country) {
1042
+ // if (list_country == country) {
1043
+ // found = true;
1044
+ // return false;
1045
+ // }
1046
+ // });
1047
+ // switch (country_list_type) {
1048
+ // case "B":
1049
+ // if (found) enable_block = false;
1050
+ // break;
1051
+ // case "W":
1052
+ // if (!found) enable_block = false;
1053
+ // break;
1054
+ // }
1055
+ // }
1056
+ // }
1057
+
1058
+ // $(this).css ({"visibility": "", "position": "", "width": "", "height": "", "z-index": ""});
1059
+ // block_div.css ({"visibility": "", "position": "", "z-index": ""});
1060
+ // if (!enable_block) {
1061
+ // $(this).hide ();
1062
+ // block_div.hide ();
1063
+ // }
1064
+ // });
1065
+ // }).fail (function() {
1066
+ // $("div.ai-ip-data").each (function () {
1067
+ // $(this).css ({"display": "none", "visibility": "", "position": "", "width": "", "height": "", "z-index": ""});
1068
+ // });
1069
+ // });
1070
+ // });
1071
+ //';
1072
+
1073
+ $ip_address_detection_script = 'jQuery(function($){function getParameterByName(name,url){if(!url)url=window.location.href;name=name.replace(/[\[\]]/g,"\\$&");var regex=new RegExp("[?&]"+name+"(=([^&#]*)|&|#|$)"),results=regex.exec(url);if(!results)return null;if(!results[2])return"";return decodeURIComponent(results[2].replace(/\+/g," "))}var nonce="'.wp_create_nonce ("adinserter_data").'";var site_url="'.wp_make_link_relative (get_site_url()).'";var page=site_url+"/wp-admin/admin-ajax.php?action=ai_data&ip-data=ip-address-country&ai_check="+nonce;var debug_ip_address=getParameterByName("ai-debug-ip-address");
1074
+ if(debug_ip_address!=null)page+="&ai-debug-ip-address="+debug_ip_address;var debug_ip_address=getParameterByName("ai-debug-country");if(debug_ip_address!=null)page+="&ai-debug-country="+debug_ip_address;var enable_block=false;$.get(page,function(ip_data){$("div.ai-ip-data").each(function(){var ip_data_array=ip_data.split(",");var ip_address=ip_data_array[0];var country=ip_data_array[1];var block_div=$("."+$(this).attr("class-name"));enable_block=true;var found=false;var ip_addresses_list=$(this).attr("ip-addresses");
1075
+ if(typeof ip_addresses_list!="undefined"){var ip_address_array=ip_addresses_list.split(",");var ip_address_list_type=$(this).attr("ip-address-list");$.each(ip_address_array,function(index,list_ip_address){if(list_ip_address.charAt(0)=="*")if(list_ip_address.charAt(list_ip_address.length-1)=="*"){list_ip_address=list_ip_address.substr(1,list_ip_address.length-2);if(ip_address.indexOf(list_ip_address)!=-1){found=true;return false}}else{list_ip_address=list_ip_address.substr(1);if(ip_address.substr(-list_ip_address.length)==
1076
+ list_ip_address){found=true;return false}}else if(list_ip_address.charAt(list_ip_address.length-1)=="*"){list_ip_address=list_ip_address.substr(0,list_ip_address.length-1);if(ip_address.indexOf(list_ip_address)==0){found=true;return false}}else if(list_ip_address=="#"&&ip_address==""){found=true;return false}else if(list_ip_address==ip_address){found=true;return false}});switch(ip_address_list_type){case "B":if(found)enable_block=false;break;case "W":if(!found)enable_block=false;break}}if(enable_block){var countries_list=
1077
+ $(this).attr("countries");if(typeof countries_list!="undefined"){var country_array=countries_list.split(",");var country_list_type=$(this).attr("country-list");var found=false;$.each(country_array,function(index,list_country){if(list_country==country){found=true;return false}});switch(country_list_type){case "B":if(found)enable_block=false;break;case "W":if(!found)enable_block=false;break}}}$(this).css({"visibility":"","position":"","width":"","height":"","z-index":""});block_div.css({"visibility":"",
1078
+ "position":"","z-index":""});if(!enable_block){$(this).hide();block_div.hide()}})}).fail(function(){$("div.ai-ip-data").each(function(){$(this).css({"display":"none","visibility":"","position":"","width":"","height":"","z-index":""})})})});';
1079
+
1080
+ if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1081
+ wp_enqueue_script ('ai-frontend-js', plugins_url ('includes/dummy.txt', __FILE__), array ('jquery'), null, true);
1082
+ wp_add_inline_script ('ai-frontend-js', $rotation_script);
1083
+ wp_add_inline_script ('ai-frontend-js', $ip_address_detection_script);
1084
+ }
1085
+
1086
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1087
+ $ai_total_plugin_time += microtime () - $start_time;
1088
+ ai_log ("WP ENQUEUE SCRIPTS END\n");
1089
+ }
1090
  }
1091
 
1092
  function ai_admin_notice_hook () {
1240
  if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF";
1241
  echo '<tr style="background: ', $background, ';">';
1242
  echo ' <td style="text-align: right;">', $obj->number, '</td>';
1243
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = "";
1244
+ echo ' <td style="padding: 0 10px 0 10px;"><a href="', admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, '&tab=', $block, '" target="_blank">', $obj->get_ad_name(), '</a></td>';
1245
  echo ' <td style="padding: 0 10px 0 10px;">', $display_type, '</td>';
1246
 
1247
  echo ' <td style="padding: 0 10px 0 10px; text-align: center;">';
1273
  echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
1274
  if ($individual_option_enabled)
1275
  echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
1276
+ // else echo 'No exceptions';
1277
  echo '<label for="ai-selected-block-', $block, '">';
1278
  if ($individual_option_enabled) {
1279
  if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
1288
  echo '</tbody>';
1289
  echo '</table>';
1290
 
1291
+ echo '<p>Default insertion for all code blocks for ', $post_type, 's can be configured on <a href="', admin_url ('options-general.php?page=ad-inserter.php'), '" target="_blank">', AD_INSERTER_NAME, ' Settings page</a>: enabled or disabled on all ', $post_type, 's (exceptions ignored), enabled or disabled with exceptions set here.';
1292
+ echo '<br /><strong>Enabled on all ', $post_type, 's</strong> or <strong>Disabled on all ', $post_type, 's</strong> means that exceptions are not enabled. Use <strong>On all except selected</strong> or <strong>Only on selected</strong> to enable exceptions for each block.</p>';
1293
+
1294
  }
1295
 
1296
  function ai_save_meta_box_data_hook ($post_id) {
1331
  }
1332
 
1333
  function ai_wp_head_hook () {
1334
+ global $block_object, $ai_wp_data, $ai_total_plugin_time;
1335
 
1336
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1337
+ ai_log ("HEAD HOOK START");
1338
+ $start_time = microtime ();
1339
+ }
1340
 
1341
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
1342
 
1350
  echo $obj->ai_getCode ();
1351
  }
1352
 
1353
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1354
+ $ai_total_plugin_time += microtime () - $start_time;
1355
+ ai_log ("HEAD HOOK END\n");
1356
+ }
1357
  }
1358
 
1359
  function ai_wp_footer_hook () {
1360
+ global $block_object, $ai_wp_data, $ai_total_plugin_time;
1361
 
1362
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1363
+ ai_log ("FOOTER HOOK START");
1364
+ $start_time = microtime ();
1365
+ }
1366
 
1367
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
1368
 
1376
  echo $obj->ai_getCode ();
1377
  }
1378
 
1379
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1380
+ $ai_total_plugin_time += microtime () - $start_time;
1381
+ ai_log ("FOOTER HOOK END\n");
1382
+ }
1383
  }
1384
 
1385
  function ai_write_debug_info ($write_processing_log = false) {
1386
+ 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;
1387
 
1388
  echo sprintf ("%-25s%s\n\n", AD_INSERTER_NAME, AD_INSERTER_VERSION);
1389
  echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
1390
  echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
1391
+ echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2) , " ms\n";
1392
+ echo "USER CODE PROCESSING: ", number_format ($ai_total_php_time * 1000, 2), " ms\n";
1393
+ echo "TOTAL PROCESSING TIME: ", number_format ($ai_total_plugin_time * 1000, 2), " ms\n";
1394
 
1395
  echo "SETTINGS: ";
1396
  if (isset ($ai_db_options ['global']['VERSION']))
1425
  echo "\n";
1426
  echo 'ID: ', get_the_ID(), "\n";
1427
  echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
1428
+ echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
1429
  if (function_exists ('ai_debug')) ai_debug ();
1430
  echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1431
+ if ($ai_wp_data [CLIENT_SIDE_DETECTION] || 1) {
1432
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1433
+ $viewport_name = get_viewport_name ($viewport);
1434
+ $viewport_width = get_viewport_width ($viewport);
1435
+ if ($viewport_name != '') {
1436
+ echo 'VIEWPORT ', $viewport, ': ', sprintf ("%-16s min width %s", $viewport_name.' ', $viewport_width), " px\n";
1437
+ }
1438
+ }
1439
+ }
1440
  echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
1441
  if ($ai_wp_data [SERVER_SIDE_DETECTION]) {
1442
  echo 'SERVER-SIDE DEVICE: ';
1589
  }
1590
 
1591
  function ai_check_multisite_options (&$multisite_options) {
1592
+ if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1593
+ if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
1594
+ if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
1595
+ if (!isset ($multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
1596
  }
1597
 
1598
  function ai_check_plugin_options ($plugin_options = array ()) {
1621
  }
1622
  $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
1623
 
1624
+
1625
+ if (!isset ($plugin_options ['DYNAMIC_BLOCKS'])) $plugin_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
1626
  if (!isset ($plugin_options ['ADMIN_TOOLBAR_DEBUGGING'])) $plugin_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
1627
  if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
1628
  if (!isset ($plugin_options ['JAVASCRIPT_DEBUGGING'])) $plugin_options ['JAVASCRIPT_DEBUGGING'] = DEFAULT_JAVASCRIPT_DEBUGGING;
1696
 
1697
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS START");
1698
 
 
 
 
1699
  if (is_multisite()) {
1700
  $ai_db_options_multisite = get_site_option (WP_OPTION_NAME);
1701
  option_stripslashes ($ai_db_options_multisite);
1702
+
1703
  }
1704
 
1705
+ if (is_multisite() && multisite_main_for_all_blogs () && defined ('BLOG_ID_CURRENT_SITE')) {
1706
+ $ai_db_options = get_blog_option (BLOG_ID_CURRENT_SITE, WP_OPTION_NAME);
1707
+ option_stripslashes ($ai_db_options);
1708
+ } else {
1709
+ $ai_db_options = get_option (WP_OPTION_NAME);
1710
+ option_stripslashes ($ai_db_options);
1711
+ }
1712
+
1713
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS END");
1714
  }
1715
 
1776
  return ($plugin_db_options ['PLUGIN_PRIORITY']);
1777
  }
1778
 
1779
+ function get_dynamic_blocks(){
1780
+ global $ai_db_options;
1781
+
1782
+ if (isset ($ai_db_options [AI_GLOBAL_OPTION_NAME])) $plugin_db_options = $ai_db_options [AI_GLOBAL_OPTION_NAME]; else $plugin_db_options = '';
1783
+ if (!$plugin_db_options) $plugin_db_options = get_option (AD_OPTIONS);
1784
+
1785
+ if (!isset ($plugin_db_options ['DYNAMIC_BLOCKS']) || $plugin_db_options ['DYNAMIC_BLOCKS'] == '') {
1786
+ $plugin_db_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
1787
+ }
1788
+
1789
+ return ($plugin_db_options ['DYNAMIC_BLOCKS']);
1790
+ }
1791
+
1792
  function get_admin_toolbar_debugging () {
1793
  global $ai_db_options;
1794
 
1833
  $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
1834
  }
1835
 
1836
+ if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AD_SETTINGS_NOT_CHECKED;
1837
+
1838
  return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']);
1839
  }
1840
 
1869
  return DEFAULT_MULTISITE_EXCEPTIONS;
1870
  }
1871
 
1872
+ function multisite_main_for_all_blogs () {
1873
+ global $ai_db_options_multisite;
1874
+
1875
+ if (is_multisite()) {
1876
+ if (!isset ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS']) || $ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS'] == '') {
1877
+ $ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
1878
+ }
1879
+
1880
+ return ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS']);
1881
+ }
1882
+
1883
+ return DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
1884
+ }
1885
+
1886
  function get_viewport_name ($viewport_number) {
1887
  global $ai_db_options;
1888
 
1965
  $value = str_replace (array ("\\\""), array ("\""), $value);
1966
 
1967
  if ($option == AI_OPTION_DOMAIN_LIST ||
1968
+ $option == AI_OPTION_IP_ADDRESS_LIST ||
1969
  $option == AI_OPTION_COUNTRY_LIST) {
1970
+ $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "[", "]"), "", $value);
1971
  $value = esc_html ($value);
1972
  }
1973
  elseif (
1980
  elseif ($option == AI_OPTION_NAME ||
1981
  $option == AI_OPTION_GENERAL_TAG ||
1982
  $option == AI_OPTION_DOMAIN_LIST ||
 
1983
  $option == AI_OPTION_CATEGORY_LIST ||
1984
  $option == AI_OPTION_TAG_LIST ||
1985
  $option == AI_OPTION_ID_LIST ||
1999
  $option == AI_OPTION_AFTER_DAYS ||
2000
  $option == AI_OPTION_START_DATE ||
2001
  $option == AI_OPTION_END_DATE ||
2002
+ $option == AI_OPTION_FALLBACK ||
2003
  $option == AI_OPTION_EXCERPT_NUMBER ||
2004
  $option == AI_OPTION_CUSTOM_CSS) {
2005
  $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
2023
  return $value;
2024
  }
2025
 
2026
+ function ai_data () {
2027
  global $ai_db_options, $block_object;
2028
 
2029
  check_admin_referer ("adinserter_data", "ai_check");
2052
  readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
2053
  }
2054
 
2055
+ elseif (isset ($_GET ["ip-data"])) {
2056
+ $client_ip_address = get_client_ip_address ();
2057
+ if ($_GET ["ip-data"] == 'country') {
2058
+ echo ip_to_country ($client_ip_address);
2059
+ }
2060
+ elseif ($_GET ["ip-data"] == 'ip-address') {
2061
+ echo $client_ip_address;
2062
+ }
2063
+ elseif ($_GET ["ip-data"] == 'ip-address-country') {
2064
+ echo $client_ip_address, ',', ip_to_country ($client_ip_address);
2065
+ }
2066
+ }
2067
+
2068
  die ();
2069
  }
2070
 
2319
  $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
2320
  $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
2321
  $options ['PLUGIN_PRIORITY'] = filter_option ('plugin_priority', $_POST ['plugin_priority']);
2322
+ $options ['DYNAMIC_BLOCKS'] = filter_option ('dynamic_blocks', $_POST ['dynamic_blocks']);
2323
  $options ['ADMIN_TOOLBAR_DEBUGGING'] = filter_option ('admin_toolbar_debugging', $_POST ['admin_toolbar_debugging']);
2324
  $options ['REMOTE_DEBUGGING'] = filter_option ('remote_debugging', $_POST ['remote_debugging']);
2325
  $options ['JAVASCRIPT_DEBUGGING'] = filter_option ('javascript_debugging', $_POST ['javascript_debugging']);
2352
  // Multisite
2353
  if (is_multisite () && is_main_site ()) {
2354
  $options = array ();
2355
+ $options ['MULTISITE_SETTINGS_PAGE'] = filter_option ('multisite_settings_page', $_POST ['multisite_settings_page']);
2356
+ $options ['MULTISITE_WIDGETS'] = filter_option ('multisite_widgets', $_POST ['multisite_widgets']);
2357
+ $options ['MULTISITE_EXCEPTIONS'] = filter_option ('multisite_exceptions', $_POST ['multisite_exceptions']);
2358
+ $options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = filter_option ('multisite_main_for_all_blogs', $_POST ['multisite_main_for_all_blogs']);
2359
+
2360
  ai_check_multisite_options ($options);
2361
  update_site_option (WP_OPTION_NAME, $options);
2362
  }
2450
  }
2451
 
2452
  function adinserter ($block = '', $ignore = '') {
2453
+ global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
2454
 
2455
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2456
+ if ($debug_processing) $start_time = microtime ();
2457
+
2458
  $ai_last_check = AI_CHECK_NONE;
2459
  $code = ai_adinserter ($block, $ignore);
2460
+
2461
+ if ($debug_processing) {
2462
+ $ai_total_plugin_time += microtime () - $start_time;
2463
+ if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
2464
+ ai_log ("PHP FUNCTION CALL END\n");
2465
+ }
2466
 
2467
  return $code;
2468
  }
2469
 
2470
 
2471
 
2472
+ function ai_content_hook ($content = '') {
2473
+ global $block_object, $ad_interter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
2474
 
2475
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
2476
 
2481
  $ad_interter_globals [$globals_name] = 1;
2482
  } else $ad_interter_globals [$globals_name] ++;
2483
 
2484
+ if ($debug_processing) {
2485
+ ai_log ("CONTENT HOOK START [" . $ad_interter_globals [$globals_name] . ']');
2486
+ $start_time = microtime ();
2487
+ }
2488
 
2489
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_CONTENT;
2490
 
2617
  $content = '<kbd style="display: none">[HTML TAGS REMOVED]</kbd>' . $content;
2618
  }
2619
 
2620
+ if ($debug_processing) {
2621
+ $ai_total_plugin_time += microtime () - $start_time;
2622
+ ai_log ("CONTENT HOOK END\n");
2623
+ }
2624
 
2625
  return $content;
2626
  }
2627
 
2628
  // Process Before/After Excerpt postion
2629
+ function ai_excerpt_hook ($content = '') {
2630
+ global $ad_interter_globals, $block_object, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
2631
 
2632
  if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
2633
 
2638
  $ad_interter_globals [$globals_name] = 1;
2639
  } else $ad_interter_globals [$globals_name] ++;
2640
 
2641
+ if ($debug_processing) {
2642
+ ai_log ("EXCERPT HOOK START [" . $ad_interter_globals [$globals_name] . ']');
2643
+ $start_time = microtime ();
2644
+ }
2645
 
2646
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_EXCERPT;
2647
 
2705
  $content = preg_replace ("/\[AI\](.+?)\[\/AI\]/", "", $content);
2706
  }
2707
 
2708
+ if ($debug_processing) {
2709
+ $ai_total_plugin_time += microtime () - $start_time;
2710
+ ai_log ("EXCERPT HOOK END\n");
2711
+ }
2712
 
2713
  return $content;
2714
  }
2715
 
2716
  // Process Before / After Post postion
2717
 
2718
+ function ai_before_after_post ($query, $display_type) {
2719
  global $block_object, $ad_interter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check;
2720
 
2721
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2781
  }
2782
 
2783
  // Process Before Post postion
2784
+ function ai_loop_start_hook ($query) {
2785
+ global $ai_wp_data, $ai_total_plugin_time;
2786
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2787
+ if ($debug_processing) {
2788
+ ai_log ("LOOP START HOOK START");
2789
+ $start_time = microtime ();
2790
+ }
2791
  ai_before_after_post ($query, AD_SELECT_BEFORE_POST);
2792
+ if ($debug_processing) {
2793
+ $ai_total_plugin_time += microtime () - $start_time;
2794
+ ai_log ("LOOP START HOOK END\n");
2795
+ }
2796
  }
2797
 
2798
 
2799
  // Process After Post postion
2800
  function ai_loop_end_hook ($query){
2801
+ global $ai_wp_data, $ai_total_plugin_time;
2802
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2803
+ if ($debug_processing) {
2804
+ ai_log ("LOOP END HOOK START");
2805
+ $start_time = microtime ();
2806
+ }
2807
  ai_before_after_post ($query, AD_SELECT_AFTER_POST);
2808
+ if ($debug_processing) {
2809
+ $ai_total_plugin_time += microtime () - $start_time;
2810
+ ai_log ("LOOP END HOOK END\n");
2811
+ }
2812
  }
2813
 
2814
  function process_shortcode (&$block, $atts) {
2885
 
2886
 
2887
  function process_shortcodes ($atts) {
2888
+ global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
2889
 
2890
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2891
  if ($debug_processing) {
2892
  $atts_string = '';
2893
+ if (is_array ($atts))
2894
+ foreach ($atts as $index => $att) {
2895
+ $atts_string .= $index . '="'.$att.'" ';
2896
+ }
2897
  ai_log ("PROCESS SHORTCODES [adinserter ".trim ($atts_string).']');
2898
+ $start_time = microtime ();
2899
  }
2900
  $ai_last_check = AI_CHECK_NONE;
2901
  $block = - 1;
2902
  $shortcode = process_shortcode ($block, $atts);
2903
+
2904
+ if ($debug_processing) {
2905
+ $ai_total_plugin_time += microtime () - $start_time;
2906
+ if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
2907
+ ai_log ("SHORTCODE END\n");
2908
+ }
2909
+
2910
  return $shortcode;
2911
  }
2912
 
2954
  for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
2955
  $obj = $block_object [$block_index];
2956
  ?>
2957
+ <option value='<?php echo $block_index; ?>' <?php if ($block_index == $block) echo 'selected="selected"'; ?>><?php echo $block_index, ' - ', $obj->get_ad_name(), !$obj->get_enable_widget ()? ' - DISABLED' : ''; ?></option>
2958
  <?php } ?>
2959
  <option value='0' <?php if ($block == 0) echo 'selected="selected"'; ?>>Debugger</option>
2960
  </select>
2979
  }
2980
 
2981
  function widget ($args, $instance) {
2982
+ global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
2983
+
2984
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
2985
+ if ($debug_processing) $start_time = microtime ();
2986
 
2987
  $ai_last_check = AI_CHECK_NONE;
2988
 
2989
  $block = 0;
2990
  ai_widget_draw ($args, $instance, $block);
2991
 
2992
+ if ($debug_processing) {
2993
+ $ai_total_plugin_time += microtime () - $start_time;
2994
+ if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
2995
+ ai_log ("WIDGET END\n");
2996
+ }
2997
  }
2998
  }
2999
 
class.php CHANGED
@@ -4,10 +4,16 @@ require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
 
5
  abstract class ai_BaseCodeBlock {
6
  var $wp_options;
 
 
 
7
 
8
  function __construct () {
9
 
10
  $this->wp_options = array ();
 
 
 
11
 
12
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
13
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
@@ -300,22 +306,33 @@ abstract class ai_BaseCodeBlock {
300
  }
301
 
302
  public function ai_getCode (){
303
- $code = $this->get_ad_data();
 
 
 
 
 
 
 
 
 
 
304
 
305
- if ($this->get_process_php ()) {
306
  $global_name = 'GENERATED_CODE';
307
- if (isset ($this->wp_options [$global_name])) return $this->wp_options [$global_name];
308
 
309
  ob_start ();
310
  eval ("?>". $code . "<?php ");
311
  $code = ob_get_clean ();
312
  if (strpos ($code, __FILE__)) {
313
  if (preg_match ("/(.+) in ".str_replace ("/", "\/", __FILE__)."/", $code, $error_message))
314
- $code = "PHP error in " . AD_INSERTER_NAME . " code block ".$this->number . " - " . $this->get_ad_name() . "<br />\n" . $error_message [1];
315
  }
316
 
317
  // Cache generated code
318
- $this->wp_options [$global_name] = $code;
 
 
319
  }
320
 
321
  return $code;
@@ -358,6 +375,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
358
  $this->wp_options [AI_OPTION_AFTER_DAYS] = AD_EMPTY_DATA;
359
  $this->wp_options [AI_OPTION_START_DATE] = AD_EMPTY_DATA;
360
  $this->wp_options [AI_OPTION_END_DATE] = AD_EMPTY_DATA;
 
361
  $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_EMPTY_DATA;
362
  $this->wp_options [AI_OPTION_ID_LIST] = AD_EMPTY_DATA;
363
  $this->wp_options [AI_OPTION_ID_LIST_TYPE] = AD_BLACK_LIST;
@@ -367,6 +385,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
367
  $this->wp_options [AI_OPTION_URL_PARAMETER_LIST_TYPE] = AD_BLACK_LIST;
368
  $this->wp_options [AI_OPTION_DOMAIN_LIST] = AD_EMPTY_DATA;
369
  $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] = AD_BLACK_LIST;
 
 
370
  $this->wp_options [AI_OPTION_COUNTRY_LIST] = AD_EMPTY_DATA;
371
  $this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE] = AD_BLACK_LIST;
372
  $this->wp_options [AI_OPTION_CATEGORY_LIST] = AD_EMPTY_DATA;
@@ -824,30 +844,109 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
824
  return $counters;
825
  }
826
 
827
- public function ai_getProcessedCode ($hide_label = false){
828
- global $ai_wp_data, $ad_interter_globals;
 
 
 
 
829
 
830
- $ad_code = $this->ai_getCode ();
 
831
 
832
- if (strpos ($ad_code, AD_SEPARATOR) !== false) {
833
- $ads = explode (AD_SEPARATOR, $ad_code);
834
- $ad_code = $ads [rand (0, count ($ads) - 1)];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
835
  }
836
 
837
  $title = '';
 
 
 
 
 
 
 
 
 
 
838
  $counters = $this->ai_get_counters ($title);
839
 
840
- $ad_code = do_shortcode ($this->replace_ai_tags ($ad_code));
841
-
842
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
843
  if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
844
  $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
845
 
846
- $ad_code = '<section style="border: 1px solid red;"><section style="padding: 1px 0 1px 5px; background: #e00; color: white; font-size: 12px; text-align: left;"><a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'
847
- . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' &nbsp; ' . $this->get_ad_name () .'</a><a style="float: right; text-decoration: none; color: white; padding: 0px 10px 0 0;"><kbd title="'.$title.'">'.$counters.'</kbd><kbd style="display: none">[/AI]</kbd></a></section>' . $ad_code . '</section>';
848
  }
849
 
850
- return $ad_code;
851
  }
852
 
853
  public function get_ad_general_tag(){
@@ -883,6 +982,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
883
  return $option;
884
  }
885
 
 
 
 
 
 
886
  public function get_maximum_insertions (){
887
  $option = isset ($this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS]) ? $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] : "";
888
  return $option;
@@ -932,6 +1036,17 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
932
  return $option;
933
  }
934
 
 
 
 
 
 
 
 
 
 
 
 
935
  public function get_ad_country_list ($expand = false){
936
  $option = isset ($this->wp_options [AI_OPTION_COUNTRY_LIST]) ? $this->wp_options [AI_OPTION_COUNTRY_LIST] : "";
937
  if ($expand && function_exists ('expanded_country_list')) return expanded_country_list ($option);
@@ -1038,8 +1153,18 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1038
  $code = "<div style='border: 1px solid red;'>".$visible_blocks.$this->ai_getProcessedCode (true).'</div>';
1039
  } else $code = $this->ai_getProcessedCode ();
1040
 
1041
- if ($hidden_widgets) return $hidden_blocks; else
1042
- return $hidden_blocks . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . ($viewport_classes ? $this->get_viewport_classes () : "") . "' style='" . $this->get_alignmet_style() . "'>" . $code . "</div>";
 
 
 
 
 
 
 
 
 
 
1043
  }
1044
 
1045
  public function before_paragraph ($content, $position_preview = false) {
@@ -1752,9 +1877,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1752
 
1753
  if ($url_type == AD_BLACK_LIST) $return = false; else $return = true;
1754
 
1755
- if ($urls == AD_EMPTY_DATA) {
1756
- return !$return;
1757
- }
1758
 
1759
  $urls_listed = explode (" ", $urls);
1760
  foreach ($urls_listed as $index => $url_listed) {
@@ -1843,11 +1966,23 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1843
  break;
1844
 
1845
  case AI_SCHEDULING_BETWEEN_DATES:
 
 
1846
  $current_time = current_time ('timestamp');
1847
  $start_date = strtotime ($this->get_schedule_start_date(), $current_time);
1848
  $end_date = strtotime ($this->get_schedule_end_date(), $current_time);
1849
 
1850
- return ($current_time >= $start_date && $current_time < $end_date);
 
 
 
 
 
 
 
 
 
 
1851
  break;
1852
 
1853
  default:
@@ -1861,12 +1996,12 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1861
  $domain_list_type = $this->get_ad_domain_list_type ();
1862
 
1863
  if (isset ($_SERVER['HTTP_REFERER'])) {
1864
- $http_referer = $_SERVER['HTTP_REFERER'];
1865
- } else $http_referer = '';
1866
 
1867
  if ($domain_list_type == AD_BLACK_LIST) $return = false; else $return = true;
1868
 
1869
- $domains = trim ($this->get_ad_domain_list ());
1870
  if ($domains == AD_EMPTY_DATA) return !$return;
1871
  $domains = explode (",", $domains);
1872
 
@@ -1875,8 +2010,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1875
  if ($domain == "") continue;
1876
 
1877
  if ($domain == "#") {
1878
- if ($http_referer == "") return $return;
1879
- } elseif (preg_match ("/" . $domain . "/i", $http_referer)) return $return;
1880
  }
1881
  return !$return;
1882
  }
4
 
5
  abstract class ai_BaseCodeBlock {
6
  var $wp_options;
7
+ var $fallback;
8
+ var $client_side_ip_address_detection;
9
+ var $w3tc_code;
10
 
11
  function __construct () {
12
 
13
  $this->wp_options = array ();
14
+ $this->fallback = 0;
15
+ $this->client_side_ip_address_detection = false;
16
+ $this->w3tc_code = '';
17
 
18
  $this->wp_options [AI_OPTION_CODE] = AD_EMPTY_DATA;
19
  $this->wp_options [AI_OPTION_PROCESS_PHP] = AD_SETTINGS_NOT_CHECKED;
306
  }
307
 
308
  public function ai_getCode (){
309
+ global $block_object, $ai_total_php_time;
310
+
311
+ $obj = $this;
312
+ if ($this->fallback != 0) {
313
+ $obj = $block_object [$this->fallback];
314
+ }
315
+
316
+ $code = $obj->get_ad_data();
317
+
318
+ if ($obj->get_process_php ()) {
319
+ $start_time = microtime ();
320
 
 
321
  $global_name = 'GENERATED_CODE';
322
+ if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
323
 
324
  ob_start ();
325
  eval ("?>". $code . "<?php ");
326
  $code = ob_get_clean ();
327
  if (strpos ($code, __FILE__)) {
328
  if (preg_match ("/(.+) in ".str_replace ("/", "\/", __FILE__)."/", $code, $error_message))
329
+ $code = "PHP error in " . AD_INSERTER_NAME . " code block ".$obj->number . " - " . $obj->get_ad_name() . "<br />\n" . $error_message [1];
330
  }
331
 
332
  // Cache generated code
333
+ $obj->wp_options [$global_name] = $code;
334
+
335
+ $ai_total_php_time += microtime () - $start_time;
336
  }
337
 
338
  return $code;
375
  $this->wp_options [AI_OPTION_AFTER_DAYS] = AD_EMPTY_DATA;
376
  $this->wp_options [AI_OPTION_START_DATE] = AD_EMPTY_DATA;
377
  $this->wp_options [AI_OPTION_END_DATE] = AD_EMPTY_DATA;
378
+ $this->wp_options [AI_OPTION_FALLBACK] = AD_EMPTY_DATA;
379
  $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] = AD_EMPTY_DATA;
380
  $this->wp_options [AI_OPTION_ID_LIST] = AD_EMPTY_DATA;
381
  $this->wp_options [AI_OPTION_ID_LIST_TYPE] = AD_BLACK_LIST;
385
  $this->wp_options [AI_OPTION_URL_PARAMETER_LIST_TYPE] = AD_BLACK_LIST;
386
  $this->wp_options [AI_OPTION_DOMAIN_LIST] = AD_EMPTY_DATA;
387
  $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] = AD_BLACK_LIST;
388
+ $this->wp_options [AI_OPTION_IP_ADDRESS_LIST] = AD_EMPTY_DATA;
389
+ $this->wp_options [AI_OPTION_IP_ADDRESS_LIST_TYPE] = AD_BLACK_LIST;
390
  $this->wp_options [AI_OPTION_COUNTRY_LIST] = AD_EMPTY_DATA;
391
  $this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE] = AD_BLACK_LIST;
392
  $this->wp_options [AI_OPTION_CATEGORY_LIST] = AD_EMPTY_DATA;
844
  return $counters;
845
  }
846
 
847
+ public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false){
848
+ global $ai_wp_data, $ad_interter_globals, $block_object;
849
+
850
+ $processed_code = do_shortcode ($this->replace_ai_tags ($this->ai_getCode ()));
851
+ $dynamic_blocks = get_dynamic_blocks ();
852
+ if ($force_server_side_code || defined ('AI_NO_W3TC')) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE;
853
 
854
+ if (strpos ($processed_code, AD_ROTATE_SEPARATOR) !== false) {
855
+ $ads = explode (AD_ROTATE_SEPARATOR, $processed_code);
856
 
857
+ switch ($dynamic_blocks) {
858
+ case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
859
+ $processed_code = $ads [rand (0, count ($ads) - 1)];
860
+ break;
861
+ case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
862
+ $processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n";
863
+ foreach ($ads as $index => $ad) {
864
+ switch ($index) {
865
+ case 0:
866
+ $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'>\n".trim ($ad, "\n")."\n</div>\n";
867
+ break;
868
+ default:
869
+ $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;'>".trim ($ad, "\n")."\n</div>\n";
870
+ break;
871
+ }
872
+ }
873
+ $processed_code .= "</div>\n";
874
+ break;
875
+ case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
876
+ $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($ads)).'\')); $ai_code = $ai_code [rand (0, count ($ai_code) - 1)]; $ai_enabled = true;';
877
+ $processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
878
+ $processed_code .= $this->w3tc_code.' echo $ai_code;';
879
+ $processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
880
+ break;
881
+ }
882
+ }
883
+
884
+ if ($dynamic_blocks != AI_DYNAMIC_BLOCKS_SERVER_SIDE) {
885
+ $countries = trim (str_replace (' ', '', strtoupper ($this->get_ad_country_list (true))));
886
+ $country_list_type = $this->get_ad_country_list_type ();
887
+
888
+ $ip_addresses = trim (str_replace (' ', '', strtolower ($this->get_ad_ip_address_list ())));
889
+ $ip_address_list_type = $this->get_ad_ip_address_list_type ();
890
+
891
+ if ($countries != '' || $ip_addresses != '') {
892
+ switch ($dynamic_blocks) {
893
+ case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
894
+ if ($countries != '' || $ip_addresses != '') {
895
+ if ($country_list_type == AD_BLACK_LIST) $country_list_type = 'B'; else $country_list_type = 'W';
896
+ if ($ip_address_list_type == AD_BLACK_LIST) $ip_address_list_type = 'B'; else $ip_address_list_type = 'W';
897
+
898
+ if ($countries != '') $country_attributes = "countries='$countries' country-list='$country_list_type'"; else $country_attributes = '';
899
+ if ($ip_addresses != '') $ip_address_attributes = "ip-addresses='$ip_addresses' ip-address-list='$ip_address_list_type'"; else $ip_address_attributes = '';
900
+
901
+ $block_class_name = get_block_class_name ().'-'.$this->number;
902
+ $this->client_side_ip_address_detection = true;
903
+
904
+ $processed_code = "\n<div class='ai-ip-data' $ip_address_attributes $country_attributes class-name='$block_class_name' style='visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999;'>$processed_code</div>\n";
905
+ }
906
+ break;
907
+ case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
908
+ if ($this->w3tc_code == '') $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($processed_code)).'\')); $ai_enabled = true;';
909
+
910
+ $this->w3tc_code .= ' require_once \''.AD_INSERTER_PLUGIN_DIR.'includes/geo/Ip2Country.php\';';
911
+
912
+ if ($ip_addresses != '') {
913
+ $this->w3tc_code .= ' if ($ai_enabled) $ai_enabled = check_ip_address_list (unserialize (base64_decode (\''.base64_encode (serialize ($this->get_ad_ip_address_list (true))).'\')), '.($this->get_ad_ip_address_list_type () == AD_WHITE_LIST ? 'true':'false').');';
914
+ }
915
+
916
+ if ($countries != '') {
917
+ $this->w3tc_code .= ' if ($ai_enabled) $ai_enabled = check_country_list (unserialize (base64_decode (\''.base64_encode (serialize ($this->get_ad_country_list (true))).'\')), '.($this->get_ad_country_list_type () == AD_WHITE_LIST ? 'true':'false').');';
918
+ }
919
+
920
+ $processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
921
+ $processed_code .= $this->w3tc_code.' if ($ai_enabled) echo $ai_code;';
922
+ $processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
923
+ break;
924
+ }
925
+ }
926
  }
927
 
928
  $title = '';
929
+ $fallback_code = '';
930
+ $color = '#e00';
931
+ if ($this->fallback != 0) {
932
+ $color = '#e0e';
933
+ $fallback_block = $block_object [$this->fallback];
934
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($fallback_block->number); else $url_parameters = "";
935
+ $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $fallback_block->number;
936
+ $fallback_code = ' &nbsp;&#8678;&nbsp; '.
937
+ '<a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'. $url . '"><kbd style="display: none">[AI]</kbd>' . $this->fallback . ' &nbsp; ' . $fallback_block->get_ad_name () .'</a>';
938
+ }
939
  $counters = $this->ai_get_counters ($title);
940
 
 
 
941
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
942
  if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($this->number); else $url_parameters = "";
943
  $url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $this->number;
944
 
945
+ $processed_code = '<section style="border: 1px solid '.$color.';"><section style="padding: 1px 0 1px 5px; background: '.$color.'; color: white; font-size: 12px; text-align: left;"><a style="text-decoration: none; color: white;" title="Click to go to block settings" href="'
946
+ . $url . '"><kbd style="display: none">[AI]</kbd>' . $this->number . ' &nbsp; ' . $this->get_ad_name () .'</a>'.$fallback_code.'<a style="float: right; text-decoration: none; color: white; padding: 0px 10px 0 0;"><kbd title="'.$title.'">'.$counters.'</kbd><kbd style="display: none">[/AI]</kbd></a></section>' . $processed_code . '</section>';
947
  }
948
 
949
+ return $processed_code;
950
  }
951
 
952
  public function get_ad_general_tag(){
982
  return $option;
983
  }
984
 
985
+ public function get_fallback(){
986
+ $option = isset ($this->wp_options [AI_OPTION_FALLBACK]) ? $this->wp_options [AI_OPTION_FALLBACK] : "";
987
+ return $option;
988
+ }
989
+
990
  public function get_maximum_insertions (){
991
  $option = isset ($this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS]) ? $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] : "";
992
  return $option;
1036
  return $option;
1037
  }
1038
 
1039
+ public function get_ad_ip_address_list (){
1040
+ $option = isset ($this->wp_options [AI_OPTION_IP_ADDRESS_LIST]) ? $this->wp_options [AI_OPTION_IP_ADDRESS_LIST] : "";
1041
+ return $option;
1042
+ }
1043
+
1044
+ public function get_ad_ip_address_list_type (){
1045
+ $option = isset ($this->wp_options [AI_OPTION_IP_ADDRESS_LIST_TYPE]) ? $this->wp_options [AI_OPTION_IP_ADDRESS_LIST_TYPE] : "";
1046
+ if ($option == '') $option = AD_BLACK_LIST;
1047
+ return $option;
1048
+ }
1049
+
1050
  public function get_ad_country_list ($expand = false){
1051
  $option = isset ($this->wp_options [AI_OPTION_COUNTRY_LIST]) ? $this->wp_options [AI_OPTION_COUNTRY_LIST] : "";
1052
  if ($expand && function_exists ('expanded_country_list')) return expanded_country_list ($option);
1153
  $code = "<div style='border: 1px solid red;'>".$visible_blocks.$this->ai_getProcessedCode (true).'</div>';
1154
  } else $code = $this->ai_getProcessedCode ();
1155
 
1156
+ if ($hidden_widgets) return $hidden_blocks; else {
1157
+ if ($this->client_side_ip_address_detection) $additional_block_style = 'visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999; '; else $additional_block_style = '';
1158
+ $wrapper_before = $hidden_blocks . "<div class='" . $block_class_name . " " . $block_class_name . "-" . $this->number . ($viewport_classes ? $this->get_viewport_classes () : "") . "' style='" . $additional_block_style . $this->get_alignmet_style() . "'>";
1159
+ $wrapper_after = "</div>";
1160
+
1161
+ if ($this->w3tc_code != '' && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) {
1162
+ $code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1163
+ $code .= $this->w3tc_code.' if ($ai_enabled) echo unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_before)).'\')), $ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($wrapper_after)).'\'));';
1164
+ $code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1165
+ return $code;
1166
+ } else return $wrapper_before . $code . $wrapper_after;
1167
+ }
1168
  }
1169
 
1170
  public function before_paragraph ($content, $position_preview = false) {
1877
 
1878
  if ($url_type == AD_BLACK_LIST) $return = false; else $return = true;
1879
 
1880
+ if ($urls == AD_EMPTY_DATA) return !$return;
 
 
1881
 
1882
  $urls_listed = explode (" ", $urls);
1883
  foreach ($urls_listed as $index => $url_listed) {
1966
  break;
1967
 
1968
  case AI_SCHEDULING_BETWEEN_DATES:
1969
+ if (!function_exists ('ai_scheduling_options')) return true;
1970
+
1971
  $current_time = current_time ('timestamp');
1972
  $start_date = strtotime ($this->get_schedule_start_date(), $current_time);
1973
  $end_date = strtotime ($this->get_schedule_end_date(), $current_time);
1974
 
1975
+ $insertion_enabled = $current_time >= $start_date && $current_time < $end_date;
1976
+
1977
+ if (!$insertion_enabled) {
1978
+ $fallback = intval ($this->get_fallback());
1979
+ if ($fallback != 0 && $fallback <= AD_INSERTER_BLOCKS) {
1980
+ $this->fallback = $fallback;
1981
+ return true;
1982
+ }
1983
+ }
1984
+
1985
+ return ($insertion_enabled);
1986
  break;
1987
 
1988
  default:
1996
  $domain_list_type = $this->get_ad_domain_list_type ();
1997
 
1998
  if (isset ($_SERVER['HTTP_REFERER'])) {
1999
+ $referer_host = strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST));
2000
+ } else $referer_host = '';
2001
 
2002
  if ($domain_list_type == AD_BLACK_LIST) $return = false; else $return = true;
2003
 
2004
+ $domains = strtolower (trim ($this->get_ad_domain_list ()));
2005
  if ($domains == AD_EMPTY_DATA) return !$return;
2006
  $domains = explode (",", $domains);
2007
 
2010
  if ($domain == "") continue;
2011
 
2012
  if ($domain == "#") {
2013
+ if ($referer_host == "") return $return;
2014
+ } elseif ($domain == $referer_host) return $return;
2015
  }
2016
  return !$return;
2017
  }
constants.php CHANGED
@@ -11,7 +11,7 @@ if (!defined( 'AD_INSERTER_NAME'))
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
- define ('AD_INSERTER_VERSION', '2.0.7');
15
 
16
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
17
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -25,21 +25,6 @@ if (!defined ('AD_INSERTER_PLUGIN_URL'))
25
  if (!defined ('AD_INSERTER_PLUGIN_IMAGES_URL'))
26
  define ('AD_INSERTER_PLUGIN_IMAGES_URL', AD_INSERTER_PLUGIN_URL. 'images/');
27
 
28
- //if (!defined( 'WP_CONTENT_URL'))
29
- // define ('WP_CONTENT_URL', get_option ('siteurl') . '/wp-content');
30
-
31
- //if (!defined ('WP_ADMIN_URL'))
32
- // define ('WP_ADMIN_URL', get_option ('siteurl') . '/wp-admin');
33
-
34
- //if (!defined ('WP_CONTENT_DIR'))
35
- // define ('WP_CONTENT_DIR', ABSPATH . 'wp-content');
36
-
37
- //if (!defined ('WP_PLUGIN_URL'))
38
- // define ('WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins');
39
-
40
- //if (!defined ('WP_PLUGIN_DIR'))
41
- // define ('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
42
-
43
  define ('AD_EMPTY_DATA', '');
44
  define ('AD_ZERO', '0');
45
  define ('AD_ONE', '1');
@@ -91,6 +76,7 @@ define ('AI_OPTION_SCHEDULING', 'scheduling');
91
  define ('AI_OPTION_AFTER_DAYS', 'after_days');
92
  define ('AI_OPTION_START_DATE', 'start_date');
93
  define ('AI_OPTION_END_DATE', 'end_date');
 
94
  define ('AI_OPTION_MAXIMUM_INSERTIONS', 'maximum_insertions');
95
  define ('AI_OPTION_ID_LIST', 'id_list');
96
  define ('AI_OPTION_ID_LIST_TYPE', 'id_list_type');
@@ -100,6 +86,8 @@ define ('AI_OPTION_URL_PARAMETER_LIST', 'url_parameter_list');
100
  define ('AI_OPTION_URL_PARAMETER_LIST_TYPE', 'url_parameter_list_type');
101
  define ('AI_OPTION_DOMAIN_LIST', 'domain_list');
102
  define ('AI_OPTION_DOMAIN_LIST_TYPE', 'domain_list_type');
 
 
103
  define ('AI_OPTION_COUNTRY_LIST', 'country_list');
104
  define ('AI_OPTION_COUNTRY_LIST_TYPE', 'country_list_type');
105
  define ('AI_OPTION_CATEGORY_LIST', 'category_list');
@@ -136,7 +124,7 @@ define('AI_FORM_SAVE','ai_save');
136
  define('AI_FORM_CLEAR','ai_clear');
137
 
138
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
139
- define('AD_SEPARATOR', '|rotate|');
140
 
141
  //form select options
142
  define('AD_SELECT_SELECTED','selected');
@@ -226,13 +214,22 @@ define('AD_ABOVE_AND_THEN_BELOW','above and then below');
226
  define('AD_BELOW_AND_THEN_ABOVE','below and then above');
227
 
228
  // Scheduling
229
- define('AI_SCHEDULING_OFF', 0);
230
- define('AI_SCHEDULING_DELAY', 1);
231
- define('AI_SCHEDULING_BETWEEN_DATES', 2);
232
 
233
  define('AI_TEXT_OFF', 'Insert immediately');
234
- define('AI_TEXT_DELAY_DISPLAY', 'Delay insertion');
235
- define('AI_TEXT_DISPLAY_BETWEEN_DATES', 'Insert between dates');
 
 
 
 
 
 
 
 
 
236
 
237
  //Settings
238
  define('AD_SETTINGS_CHECKED', '1');
@@ -245,6 +242,7 @@ define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
245
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
246
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
247
  define ('DEFAULT_PLUGIN_PRIORITY', 99999);
 
248
  define ('DEFAULT_PARAGRAPH_TAGS', 'p');
249
  define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AD_SETTINGS_CHECKED);
250
  define ('DEFAULT_REMOTE_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
@@ -252,6 +250,7 @@ define ('DEFAULT_JAVASCRIPT_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
252
  define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
253
  define ('DEFAULT_MULTISITE_WIDGETS', AD_SETTINGS_CHECKED);
254
  define ('DEFAULT_MULTISITE_EXCEPTIONS', AD_SETTINGS_CHECKED);
 
255
 
256
  define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
257
  define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
@@ -320,6 +319,7 @@ define ('AI_CHECK_AD_ABOVE', 43);
320
  define ('AI_CHECK_AD_BELOW', 44);
321
  define ('AI_CHECK_SHORTCODE_ATTRIBUTES', 45);
322
  define ('AI_CHECK_COUNTRY', 46);
 
323
 
324
  define ('AI_PT_NONE', - 1);
325
  define ('AI_PT_ANY', 0);
@@ -366,6 +366,7 @@ define ('AI_URL_DEBUG_TAGS', 'ai-debug-tags');
366
  define ('AI_URL_DEBUG_POSITIONS', 'ai-debug-positions');
367
  define ('AI_URL_DEBUG_NO_INSERTION', 'ai-debug-no-insertion');
368
  define ('AI_URL_DEBUG_PHP', 'ai-debug-php');
 
369
 
370
  define ('AI_DEBUG_PROCESSING', 0x01);
371
  define ('AI_DEBUG_BLOCKS', 0x02);
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '2.0.8');
15
 
16
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
17
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
25
  if (!defined ('AD_INSERTER_PLUGIN_IMAGES_URL'))
26
  define ('AD_INSERTER_PLUGIN_IMAGES_URL', AD_INSERTER_PLUGIN_URL. 'images/');
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  define ('AD_EMPTY_DATA', '');
29
  define ('AD_ZERO', '0');
30
  define ('AD_ONE', '1');
76
  define ('AI_OPTION_AFTER_DAYS', 'after_days');
77
  define ('AI_OPTION_START_DATE', 'start_date');
78
  define ('AI_OPTION_END_DATE', 'end_date');
79
+ define ('AI_OPTION_FALLBACK', 'fallback');
80
  define ('AI_OPTION_MAXIMUM_INSERTIONS', 'maximum_insertions');
81
  define ('AI_OPTION_ID_LIST', 'id_list');
82
  define ('AI_OPTION_ID_LIST_TYPE', 'id_list_type');
86
  define ('AI_OPTION_URL_PARAMETER_LIST_TYPE', 'url_parameter_list_type');
87
  define ('AI_OPTION_DOMAIN_LIST', 'domain_list');
88
  define ('AI_OPTION_DOMAIN_LIST_TYPE', 'domain_list_type');
89
+ define ('AI_OPTION_IP_ADDRESS_LIST', 'ip_address_list');
90
+ define ('AI_OPTION_IP_ADDRESS_LIST_TYPE', 'ip_address_list_type');
91
  define ('AI_OPTION_COUNTRY_LIST', 'country_list');
92
  define ('AI_OPTION_COUNTRY_LIST_TYPE', 'country_list_type');
93
  define ('AI_OPTION_CATEGORY_LIST', 'category_list');
124
  define('AI_FORM_CLEAR','ai_clear');
125
 
126
  define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
127
+ define('AD_ROTATE_SEPARATOR', '|rotate|');
128
 
129
  //form select options
130
  define('AD_SELECT_SELECTED','selected');
214
  define('AD_BELOW_AND_THEN_ABOVE','below and then above');
215
 
216
  // Scheduling
217
+ define('AI_SCHEDULING_OFF', 0);
218
+ define('AI_SCHEDULING_DELAY', 1);
219
+ define('AI_SCHEDULING_BETWEEN_DATES', 2);
220
 
221
  define('AI_TEXT_OFF', 'Insert immediately');
222
+ define('AI_TEXT_DELAY_INSERTION', 'Delay insertion');
223
+ define('AI_TEXT_INSERT_BETWEEN_DATES', 'Insert between dates');
224
+
225
+ // Dynamic blocks
226
+ define('AI_DYNAMIC_BLOCKS_SERVER_SIDE', 0);
227
+ define('AI_DYNAMIC_BLOCKS_CLIENT_SIDE', 1);
228
+ define('AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC', 2);
229
+
230
+ define('AI_TEXT_SERVER_SIDE', 'Server-side');
231
+ define('AI_TEXT_CLIENT_SIDE', 'Client-side');
232
+ define('AI_TEXT_SERVER_SIDE_W3TC', 'Server-side using W3 Total Cache');
233
 
234
  //Settings
235
  define('AD_SETTINGS_CHECKED', '1');
242
  define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
243
  define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
244
  define ('DEFAULT_PLUGIN_PRIORITY', 99999);
245
+ define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
246
  define ('DEFAULT_PARAGRAPH_TAGS', 'p');
247
  define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AD_SETTINGS_CHECKED);
248
  define ('DEFAULT_REMOTE_DEBUGGING', AD_SETTINGS_NOT_CHECKED);
250
  define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AD_SETTINGS_CHECKED);
251
  define ('DEFAULT_MULTISITE_WIDGETS', AD_SETTINGS_CHECKED);
252
  define ('DEFAULT_MULTISITE_EXCEPTIONS', AD_SETTINGS_CHECKED);
253
+ define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AD_SETTINGS_NOT_CHECKED);
254
 
255
  define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
256
  define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
319
  define ('AI_CHECK_AD_BELOW', 44);
320
  define ('AI_CHECK_SHORTCODE_ATTRIBUTES', 45);
321
  define ('AI_CHECK_COUNTRY', 46);
322
+ define ('AI_CHECK_IP_ADDRESS', 47);
323
 
324
  define ('AI_PT_NONE', - 1);
325
  define ('AI_PT_ANY', 0);
366
  define ('AI_URL_DEBUG_POSITIONS', 'ai-debug-positions');
367
  define ('AI_URL_DEBUG_NO_INSERTION', 'ai-debug-no-insertion');
368
  define ('AI_URL_DEBUG_PHP', 'ai-debug-php');
369
+ define ('AI_URL_DEBUG_COUNTRY', 'ai-debug-country');
370
 
371
  define ('AI_DEBUG_PROCESSING', 0x01);
372
  define ('AI_DEBUG_BLOCKS', 0x02);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #data {
2
- font-family: "2.0.7"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
@@ -159,6 +159,10 @@
159
  font-size: 12px;
160
  }
161
 
 
 
 
 
162
  .ms-container .ms-selectable li.ms-elem-selectable, .ms-container .ms-selection li.ms-elem-selection {
163
  padding: 1px 10px;
164
  font-size: 12px;
@@ -175,3 +179,16 @@
175
  .ms-container div.ms-selection {
176
  margin-top: 24px;
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #data {
2
+ font-family: "2.0.8"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
159
  font-size: 12px;
160
  }
161
 
162
+ .ms-container .ms-selectable, .ms-container .ms-selection {
163
+ width: 47%;
164
+ }
165
+
166
  .ms-container .ms-selectable li.ms-elem-selectable, .ms-container .ms-selection li.ms-elem-selection {
167
  padding: 1px 10px;
168
  font-size: 12px;
179
  .ms-container div.ms-selection {
180
  margin-top: 24px;
181
  }
182
+
183
+ .country-flags .ms-container .ms-selectable li.ms-elem-selectable, .country-flags .ms-container .ms-selection li.ms-elem-selection {
184
+ padding-left: 30px;
185
+ }
186
+
187
+ .flag-icon {
188
+ display: list-item;
189
+ width: auto;
190
+ line-height: inherit;
191
+ }
192
+ .flag-icon, .flag-icon-background {
193
+ background-position: initial;
194
+ }
css/dummy.css → includes/dummy.txt RENAMED
File without changes
index.php CHANGED
@@ -22,11 +22,11 @@
22
  <h1 style="text-align: center;">Ad Inserter</h1>
23
  <p>
24
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
25
- Need more than 64 code blocks? <a href="http://tinymonitor.com/ad-inserter-pro" target="_blank" rel="nofollow">Ad Inserter Pro</a> supports
26
  64 blocks, 6 viewports, import/export settings and has additional multisite support.
27
  </p>
28
  <div>
29
- <a href="http://tinymonitor.com/ad-inserter" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="screenshot-1.jpg" /></a>
30
  </div>
31
  <p>
32
  Settings for one code block. Up to 16 blocks can be configured.
22
  <h1 style="text-align: center;">Ad Inserter</h1>
23
  <p>
24
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
25
+ Need more than 64 code blocks? <a href="http://adinserter.pro/" target="_blank" rel="nofollow">Ad Inserter Pro</a> supports
26
  64 blocks, 6 viewports, import/export settings and has additional multisite support.
27
  </p>
28
  <div>
29
+ <a href="http://adinserter.pro/documentation" target="_blank" rel="nofollow"><img style="display: block;margin: 0 auto;" src="screenshot-1.jpg" /></a>
30
  </div>
31
  <p>
32
  Settings for one code block. Up to 16 blocks can be configured.
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.0.7";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -214,33 +214,30 @@ jQuery(document).ready(function($) {
214
  var end_date_picker = $("#scheduling-off-"+block);
215
  var start_date = getDate (start_date_picker);
216
  var end_date = getDate (end_date_picker);
217
- var date_text = $("#scheduling-text-"+block);
218
 
219
- date_text.text ("");
220
- date_text.css ("color", "#222");
221
  end_date_picker.css ("border-color", "#ddd");
222
 
223
  if (start_date == null) {
224
- date_text.text ("");
225
  } else
226
  if (end_date == null) {
227
- date_text.text ("");
228
  } else
229
  if (end_date > start_date) {
230
  var now = new Date();
231
  var today_date = new Date (now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
232
  if (end_date <= today_date) {
233
  var expiration = Math.round ((today_date - end_date) / 1000 / 3600 / 24);
234
- date_text.text ("Invalid end date - insertion already expired ");
235
- date_text.css ("color", "#d00");
236
  end_date_picker.css ("border-color", "#d00");
237
  } else {
238
  var duration = Math.round ((end_date - start_date) / 1000 / 3600 / 24);
239
- date_text.text (" Duration: " + duration + " day" + (duration == 1 ? "" : "s"));
240
  }
241
  } else {
242
- date_text.text ("Invalid end date - must be after start date");
243
- date_text.css ("color", "#d00");
244
  end_date_picker.css ("border-color", "#d00");
245
  }
246
  }
@@ -416,7 +413,8 @@ jQuery(document).ready(function($) {
416
 
417
  if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
418
  var nonce = $(this).attr ('nonce');
419
- $("#export_settings_0").load ("/wp-admin/admin-ajax.php?action=ai_preview&export=0&ai_check=" + nonce, function() {
 
420
  $("#export_settings_0").attr ("name", "export_settings_0");
421
  $("#export-switch-0").addClass ("loaded");
422
  });
@@ -644,7 +642,8 @@ jQuery(document).ready(function($) {
644
 
645
  if ($("#export-container-" + block).is(':visible') && !$(this).hasClass ("loaded")) {
646
  var nonce = $(this).attr ('nonce');
647
- $("#export_settings_" + block).load ("/wp-admin/admin-ajax.php?action=ai_preview&export=" + block + "&ai_check=" + nonce, function() {
 
648
  $("#export_settings_" + block).attr ("name", "export_settings_" + block);
649
  $("#export-switch-"+block).addClass ("loaded");
650
  });
@@ -724,7 +723,8 @@ jQuery(document).ready(function($) {
724
  var window_width = 820;
725
  var window_height = 820;
726
  var nonce = $(this).attr ('nonce');
727
- var page = "/wp-admin/admin-ajax.php?action=ai_preview&preview=" + block + "&ai_check=" + nonce + "&alignment=" + encodeURI (alignment) + "&css=" + encodeURI (css) + "&name=" + encodeURI (name);
 
728
  var window_left = 120;
729
  var window_top = (screen.height / 2) - (820 / 2);
730
  var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
1
+ var javascript_version = "2.0.8";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
214
  var end_date_picker = $("#scheduling-off-"+block);
215
  var start_date = getDate (start_date_picker);
216
  var end_date = getDate (end_date_picker);
 
217
 
218
+ end_date_picker.attr ('title', '');
 
219
  end_date_picker.css ("border-color", "#ddd");
220
 
221
  if (start_date == null) {
222
+ end_date_picker.attr ('title', '');
223
  } else
224
  if (end_date == null) {
225
+ end_date_picker.attr ('title', '');
226
  } else
227
  if (end_date > start_date) {
228
  var now = new Date();
229
  var today_date = new Date (now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
230
  if (end_date <= today_date) {
231
  var expiration = Math.round ((today_date - end_date) / 1000 / 3600 / 24);
232
+ // end_date_picker.attr ('title', 'Invalid end date - insertion already expired ');
233
+ end_date_picker.attr ('title', 'Insertion expired');
234
  end_date_picker.css ("border-color", "#d00");
235
  } else {
236
  var duration = Math.round ((end_date - start_date) / 1000 / 3600 / 24);
237
+ end_date_picker.attr ('title', ' Duration: ' + duration + ' day' + (duration == 1 ? '' : 's'));
238
  }
239
  } else {
240
+ end_date_picker.attr ('title', 'Invalid end date - must be after start date');
 
241
  end_date_picker.css ("border-color", "#d00");
242
  }
243
  }
413
 
414
  if ($("#export-container-0").is(':visible') && !$(this).hasClass ("loaded")) {
415
  var nonce = $(this).attr ('nonce');
416
+ var site_url = $(this).attr ('site-url');
417
+ $("#export_settings_0").load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&export=0&ai_check=" + nonce, function() {
418
  $("#export_settings_0").attr ("name", "export_settings_0");
419
  $("#export-switch-0").addClass ("loaded");
420
  });
642
 
643
  if ($("#export-container-" + block).is(':visible') && !$(this).hasClass ("loaded")) {
644
  var nonce = $(this).attr ('nonce');
645
+ var site_url = $(this).attr ('site-url');
646
+ $("#export_settings_" + block).load (site_url+"/wp-admin/admin-ajax.php?action=ai_data&export=" + block + "&ai_check=" + nonce, function() {
647
  $("#export_settings_" + block).attr ("name", "export_settings_" + block);
648
  $("#export-switch-"+block).addClass ("loaded");
649
  });
723
  var window_width = 820;
724
  var window_height = 820;
725
  var nonce = $(this).attr ('nonce');
726
+ var site_url = $(this).attr ('site-url');
727
+ var page = site_url+"/wp-admin/admin-ajax.php?action=ai_data&preview=" + block + "&ai_check=" + nonce + "&alignment=" + encodeURI (alignment) + "&css=" + encodeURI (css) + "&name=" + encodeURI (name);
728
  var window_left = 120;
729
  var window_top = (screen.height / 2) - (820 / 2);
730
  var preview_window = window.open (page, 'preview','width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no');
preview.php CHANGED
@@ -10,19 +10,19 @@ function generate_code_preview ($block) {
10
  $custom_css = $obj->get_custom_css();
11
  $alignment_type = isset ($_GET ["alignment"]) ? $_GET ["alignment"] : $obj->get_alignment_type();
12
  $wrapper_css = isset ($_GET ["css"]) ? $_GET ["css"] : $obj->get_alignmet_style ();
13
- $block_code = $obj->ai_getProcessedCode (true);
14
 
15
  ?><html>
16
  <head>
17
  <title><?php echo AD_INSERTER_NAME; ?> Code Preview</title>
18
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
19
- <link rel='stylesheet' href='/wp-content/plugins/ad-inserter/css/ad-inserter.css?ver=<?php echo AD_INSERTER_VERSION; ?>'>
20
  <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
21
  <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
22
  <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
23
- <script src='/wp-content/plugins/ad-inserter/includes/js/jquery.mousewheel.min.js?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
24
- <script src='/wp-content/plugins/ad-inserter/includes/js/jquery.ui.spinner.js?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
25
- <link rel='stylesheet' href='/wp-content/plugins/ad-inserter/css/jquery.ui.spinner.css?ver=<?php echo AD_INSERTER_VERSION; ?>'>
26
  <script>
27
 
28
  // initialize_preview ();
10
  $custom_css = $obj->get_custom_css();
11
  $alignment_type = isset ($_GET ["alignment"]) ? $_GET ["alignment"] : $obj->get_alignment_type();
12
  $wrapper_css = isset ($_GET ["css"]) ? $_GET ["css"] : $obj->get_alignmet_style ();
13
+ $block_code = $obj->ai_getProcessedCode (true, true);
14
 
15
  ?><html>
16
  <head>
17
  <title><?php echo AD_INSERTER_NAME; ?> Code Preview</title>
18
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
19
+ <link rel='stylesheet' href='<?php echo wp_make_link_relative (get_site_url()); ?>/wp-content/plugins/ad-inserter/css/ad-inserter.css?ver=<?php echo AD_INSERTER_VERSION; ?>'>
20
  <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
21
  <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
22
  <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
23
+ <script src='<?php echo wp_make_link_relative (get_site_url()); ?>/wp-content/plugins/ad-inserter/includes/js/jquery.mousewheel.min.js?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
24
+ <script src='<?php echo wp_make_link_relative (get_site_url()); ?>/wp-content/plugins/ad-inserter/includes/js/jquery.ui.spinner.js?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
25
+ <link rel='stylesheet' href='<?php echo wp_make_link_relative (get_site_url()); ?>/wp-content/plugins/ad-inserter/css/jquery.ui.spinner.css?ver=<?php echo AD_INSERTER_VERSION; ?>'>
26
  <script>
27
 
28
  // initialize_preview ();
readme.txt CHANGED
@@ -1,17 +1,17 @@
1
  === Ad Inserter ===
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
- Tags: adsense, amazon, clickbank, advertising, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, rotation, geo targeting, countries, multisite, contextual, shortcodes, widgets, header, footer, users, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
- Stable tag: 2.0.6
8
  License: GPLv3
9
 
10
- Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
11
 
12
  == Description ==
13
 
14
- A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect for all kinds of ads.** Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
15
 
16
  > **Features**
17
  >
@@ -19,43 +19,104 @@ A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect
19
  > * Syntax highlighting editor
20
  > * Code preview with visual CSS editor
21
  > * Automatic insertion: before/after post, content, paragraph or excerpt
 
22
  > * Manual insertion: widgets, shortcodes, PHP function call
23
- > * Block alignment and style: left, center, right, float left, float right, custom CSS, no wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
24
  > * Clearance options to avoid insertion near images or headers
25
  > * PHP code processing
26
- > * Server-side and client-side device detection (3 custom viewports)
 
27
  > * Black/White-list categories, tags, post IDs, urls, url parameters, referers
28
- > * Simple troubleshooting with many debugging functions to visualize inserted code blocks, available insertion positions, HTML tags, etc.
29
- >
30
- > Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features.
31
- You can also download PDF user guide for Ad Inserter. Go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> page and below you can find button for free download of Ad Inserter User Guide.
32
 
33
- Code block is any code (for example AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress.
 
 
 
 
 
34
 
35
- > **Endorsed by Amazon**
36
- >
37
  > Amazon suggests to use Ad Inserter to add Native Shopping Ads to Wordpress posts. Native Shopping Ads provide highly relevant and dynamic product recommendations in a stylishly designed and responsive ad unit that can be placed at the end of your content or within your content to create a more compelling visitor experience and shopping opportunity.
38
  >
39
  > * Check <a href="https://affiliate-program.amazon.com/help/topic/t405" target="_blank">Wordpress Integration Guide for Native Shopping Ads</a>
40
  > * On the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page you can also find an example of contextual Amazon Shopping Ads that show items related to the post content (using post tags)
41
 
42
- **Go Pro** to get premium features
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- There is also <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> if you need more than 16 code blocks, more than 3 viewports, GEO targeting, scheduling, export/import settings or additional multisite options.
 
 
45
 
46
  **Quick Start**
47
 
48
  Few very important things you need to know in order to <a href="http://adinserter.pro/documentation#quick-start">insert code and display some ad</a>:
49
 
 
50
  * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
51
  * **Enable insertion on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
52
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
53
- * If you don't see inserted code block turn on **debuging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
54
 
55
  Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page and instructions for **Debugging**.
56
 
57
  **Settings**
58
 
 
 
 
 
59
  Each code block has 4 insertion options:
60
 
61
  * Automatic Insertion
@@ -66,7 +127,7 @@ Each code block has 4 insertion options:
66
  Normally for each code block you use only one insertion option.
67
  Of course, you can use all 4 options simultaneously taking into account that all insertion options use the same block settings (with some exceptions mentioned below).
68
 
69
- To rename code block click on the block name. To display code block (ad) at some position **you need to enable and use at least one insertion option**.
70
 
71
  Automatic Insertion Options:
72
 
@@ -83,23 +144,6 @@ For single posts or static pages insertion position Before Post usually means po
83
 
84
  For single posts or static pages insertion position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.
85
 
86
- Order of insertion positions in a typical post is the following:
87
-
88
- * [Before Post]
89
- * Post Title
90
- * [Before Content]
91
- * Paragraph 1
92
- * Paragraph 2
93
- * Paragraph ...
94
- * Paragraph n - 1
95
- * Paragraph n
96
- * [After Content]
97
- * Comments
98
- * Output of some other plugins
99
- * [After Post]
100
-
101
- Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab *).
102
-
103
  Please use **Show positions** function to see available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page).
104
 
105
  Block Alignment and Style:
@@ -130,228 +174,6 @@ No Wrapping style inserts the code as it is so margin and padding can't be set.
130
 
131
  Check <a href="https://wordpress.org/plugins/ad-inserter/screenshots/">screenshots</a> for explanation on alignment.
132
 
133
- **PLEASE NOTE:** If you are using **No Wrapping** style and need to hide code on some devices using client-side detection (CSS Media Queries) then you need to add appropriate class to your CSS code (ai-viewport-1, ai-viewport-2, ai-viewport-3).
134
- This doesn't apply to widgets as they always contain a wrapping div.
135
-
136
- For all display positions you can also define Wordpress page types where the ads will be inserted. **PLEASE NOTE:** Regardles of other settings you need to enable insertion on AT LEAST ONE PAGE TYPE:
137
-
138
- Single pages:
139
-
140
- * Posts
141
- * Static pages
142
-
143
- Blog pages:
144
-
145
- * Homepage
146
- * Category pages
147
- * Search Pages
148
- * Tag / Archive pages
149
-
150
- Insertion (located in the Misc section) is possible also for:
151
-
152
- * 404 page (Error 404: Page not found)
153
- * Feed
154
-
155
- **Please Note** For shortcodes and PHP function calls it is possible to ignore enabled page types and use them on any page. See down for details.
156
-
157
- You can also disable insertion of ads on certain posts or static pages. For each code block on posts or static pages you first define default insertion settings for posts/pages page type.
158
- Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below).
159
- Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content).
160
- For one or few exceptions it is easier to first enable ads on All Posts/Static pages page types and then either white or black-list single url or few space-separated urls (click on the Lists button).
161
-
162
- **PARAGRAPHS**
163
-
164
- Paragraph number for Automatic Insertion options Before and After Paragraph:
165
-
166
- * 0 means random paragraph position
167
- * value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
168
- * 1 or more means paragraph number
169
-
170
- **[ Counting ]**
171
-
172
- Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain/do not contain certain text or count only paragraphs that have some minimum or maximum number of words.
173
- If more than one text is defined (comma separated) and "contain" is selected then the paragraph must contain ALL texts.
174
-
175
- Paragraphs are not counted inside `<blockquote>` elements. Of course, there is an option to enable counting also inside `<blockquote>`.
176
-
177
- **Please Note** Paragraph processing works on **every** post or page according to settings. Therefore, if you enable display also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts,
178
- Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings). To enable insertion only into specific post(s) on blog pages define Filter.
179
- You can also leave Filter (click Misc button) empty (means all posts on the blog page) and define maximum number of insertions.
180
-
181
- You can also define paragraph HTML tags. Normally only `<p>` tags are used. If your post contains also `<div>` or header tags, you can define comma separated list of tags used to count paragraphs (e.g. **p, div, h2, h3**).
182
-
183
- **WARNING:** Each code block you insert in post adds one `<div>` block unelss you use **No wrapping** style. **Before Paragraph** will insert code before `<tag>`, **After Paragraph** will insert code after closing `</tag>`.
184
- **After Paragraph** will not work if you specify tag names that have no closing tags! Use # as tag if paragraphs have no tags and are separated with the `\r\n\r\n` characters.
185
-
186
- Minimum number of paragraphs / Minimum/Maximum page/post words: do not insert ad if the number of paragraphs or the number of words is below or above limit (used only for position Before or After selected paragraph).
187
-
188
- **[ Clearance ]**
189
-
190
- You can define parameters to avoid insertion at paragraph positions where above or below is some unwanted element (heading, image, title). This is useful to avoid inserting ads where they may not look good or where it is not allowed.
191
-
192
- You can define in how many paragraphs above and below should specified text be avoided. And if the text is found you can choose to either skip insertion or try to shift insertion position up or down up to the specified number of paragraphs.
193
-
194
- On every post/page there is a toolbar on the top. Ad Inserter menu item has few functions to visualize tags and positions for automatic insertion:
195
-
196
- * Show HTML tags: visualizes HTML tags
197
- * Show positions: shows available positions for automatic insertion. It uses paragraph tags for blocks configured for After or Before paragraph.
198
-
199
- **Additional Post/Static Page Options**
200
-
201
- You can define post/page minimum and maximum word length.
202
-
203
- Additional Options for code blocks:
204
-
205
- PHP processing: Enabled or Disabled - Enable processing of PHP code. If there is a non-fatal error in the PHP code, it will not break the website.
206
-
207
- * Use {category}, {short_category}, {title}, {short_title}, {tag}, {smart_tag} or {search_query} tags to insert actual post data into code blocks
208
- * Use {author} for post author username or {author_name} for post author name to insert post author data into code blocks (**works only inside posts**)
209
- * Use {country_iso2} to insert country ISO Alpha-2 code into code blocks
210
- * To rotate different ad versions separate them with `|rotate|` - Ad Inserter will randomly select one of the ads
211
-
212
- WARNING: If you are using caching ad rotation may not work as expected. It works only when the page is generated and Ad Inserter is called. In such cases please make sure you have disabled caching when you are using |rotate|.
213
-
214
- Ad Inserter is perfect for displaying any kind of ads. It can also be used to display various versions of ad, for example <a href="https://support.google.com/adsense/answer/65083?ctx=as2&rd=2&ref_topic=23389" target="_blank">AdSense ads using channels</a> to test which format or color combination performs best.
215
-
216
- **BUTTONS**
217
-
218
- **[ Misc ]**
219
-
220
- For each code block you can also limit how many times on the page the code (or ad) will be inserted. There are two settings for this:
221
-
222
- * **Max N insertions**: simple limit for the first N calls for the block
223
- * **Filter**: define which cals are wanted - single number or comma separated numbers
224
-
225
- This is **useful in many cases where you can't remove unwanted insertions** of the code with other settings:
226
-
227
- * If you need to insert ad before the first, third and fith excerpt on the homepage you simply specify `1, 3, 5` for the filter.
228
- * If your posts are divided into subpages using the `<!--nextpage-->` tag - specify Subpages as filter source and list subpage numbers, for example `2,3,4,5,6,7,8,9,10,11` for display on all subpages except the first one.
229
- * In some WP themes hooks (that call Ad Inserter insertion functions) are called more than once. In such case you might get unwanted insertions. Simply set the filter to the number of the wanted call(s). Use debugging function **Show positions** on every post/page to show available positions for automatic insertion with counters.
230
- * If you use adinserter PHP function and you don't want that for each time the functon is called on the page the code is inserted, you can simply filter calls.
231
- * If you oly need the first N calls (insertions) then leave filter to 0 and use Max N insertions instead.
232
-
233
- **Please Note** Paragraph processing works on **every** post or page according to settings. Therefore, if you enable display also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts,
234
- Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings). To enable insertion only into specific post(s) on blog pages define Filter. You can also leave Filter to 0 (means all posts on the blog page) and define maximum number of insertions.
235
-
236
- General tag: text used for {tag} and {smart_tag} if the post has no tags - useful for contextual ads - **works only inside posts/static pages!**
237
-
238
- Display Block to:
239
-
240
- * All users (default)
241
- * Logged in users
242
- * Not logged in users
243
- * Administrators (usefull for testing/debugging)
244
-
245
- **WARNING:** If you are using caching this may not work as expected. The check works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
246
-
247
- **Scheduling**
248
-
249
- You can define when the code block will be inserted:
250
-
251
- * Insert immedaitely: no scheduling
252
- * Delay insertion for N days after publishing: waits for N days after the time when the post was published (available only for before/after content and before/after paragraph)
253
- * Insert between dates START_DATE and END_DATE (Pro only): inserts code only between START_DATE (including) and END_DATE (excluding) - on START_DATE it starts inserting, on END_DATE it ends inserting
254
-
255
- **[ Lists ]**
256
-
257
- Do not insert ads in certain caregories e.g sport, news, science,... (black list) or insert ads only in certain categories (white list):
258
- leave category list empty and set it to Black list to show ads in all categories.
259
-
260
- **WARNING:** If category name contains commas or spaces, use category slug instead. Also make sure you have enabled display on **Category pages**.
261
-
262
- Do not insert ads in posts with certain tags (black list) or insert ads only in posts with certain tags (white list). Leave tag list empty and set it to Black list to show ads for all tags. Also make sure you have enabled display on **Tag / Archive pages**.
263
-
264
- Do not insert ads in posts/pages with certain post IDs (black list) or insert ads only in posts with certain IDs (white list). Leave Post ID list empty and set it to Black list to show ads for all IDs.
265
-
266
- Do not insert ads on pages with certain urls (black list) or insert ads only on pages with certain urls (white list): leave url list empty and set it to Black list to show ads for all urls.
267
- Url used here is everything starting form the `/` after the domain name. For example: if web address is `http://domain.com/lorem-ipsum`, url to white/black-list is `/lorem-ipsum`
268
- You can also use partial urls with *. To filter all urls starting with /url-start use `/url-start*`, to filter all urls that contain url-pattern use `*url-pattern*`, to filter all urls ending with url-end use `*url-end`.
269
- **WARNING:** Separate urls with SPACES.
270
-
271
- Do not insert ads on pages with certain url query parameters (black list) or insert ads only on pages with certain url parameters (white list): leave url parameter list empty and set it to Black list to show ads for all url.
272
- You can specifiy either parameters or parameters with values. For example for url `http://example.com?data=2&customer-id=22&device=0` you can define url parameters '`data, customer-id=22`' to display ad only for urls where there is `data` paramteter and `customer-id` parameter with value 22.
273
- Separate parameters with comma.
274
-
275
- Do not insert ads to users from certain referers (domains) e.g technorati.com, facebook.com,... (black list) or insert ads only for certain referrers (white list): use # for no referer (direct visit),
276
- leave referrers list empty and set it to Black list to show ads for all referrers.
277
-
278
- GEO targeting (Pro only): Do not insert ads for certain countries (black list) or insert ads only for certain countries (white list). Leave country list empty and set it to Black list to show ads for all countries.
279
- Country list should contain comma separated country ISO Alpha-2 codes. Click list to toggle country selection and then click on the countries on the left list to select countries - country codes will automatically be added to the list.
280
- You can also use 6 country groups which you can define on the Ad Inserter settings page (tab *, GEO targeting).
281
-
282
- **WARNING:** If you are using caching, referer check and GEO targeting may not work as expected. It works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.
283
-
284
- **[ Devices ]**
285
-
286
- **IMPORTANT:** There are two types of device detection: **server side** and **client-side**.
287
-
288
- **Client-side** detection
289
-
290
- * Desktop devices
291
- * Tablet devices
292
- * Phone devices
293
-
294
- **Client-side** detection of mobile/desktop devices works always as it is done in visitor's browser. CSS media queries and viewport (browser's screen) width are used to show or hide Ad Inserter code blocks:
295
-
296
- **PLEASE NOTE:** In most cases you should use **ONLY client-side** detection type. Works perfectly with responsive designs as they use CSS media queries.
297
-
298
- **BUT BE CAREFUL:** Some ad networks (like AdSense) limit ads per page. The ads are still inserted (loaded and counted) for all devices, but for unwanted devices they are hidden by the browser using CSS media queries based on viewport widths.
299
-
300
- Up to 3 viewport names and widths can be defined on the Ad Inserter Settings tab * (<a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> supports up to 6 viewports). Default values are:
301
-
302
- * Desktop: 980 pixels or more
303
- * Tablet: from 768 pixels to 979 pixels
304
- * Phone: less than 768 pixels
305
-
306
-
307
- **Server-side** detection
308
-
309
- * Desktop devices
310
- * Mobile devices (tablets and phones)
311
- * Tablet devices
312
- * Phone devices
313
- * Desktop and tablet devices
314
- * Desktop and phone devices
315
-
316
- **Server-side** detection of mobile/desktop devices works only when Ad Inserter plugin is called. It is called by Wordpress when it needs to generate a page. However, when you are using caching, it saves created page for quicker serving.
317
- In such cases **the user might get (saved) page for wrong device** (used by some previous visitor who triggered page caching). To solve this issue use themes that generate separate pages for desktop and mobile devices or use Mobile Theme Switcher plugin.
318
- Server-side detection uses User-Agent string combined with specific HTTP headers to detect the environment.
319
-
320
- **PLEASE NOTE:** Use server-side device type detection only when you need to insert (display and count) ONLY code blocks for specific device type. In all other cases switch it off.
321
-
322
- **[ Manual ]**
323
-
324
- There are 3 independent types of manual insertion of code block:
325
-
326
- * Widget - Widgets for all code blocks are enabled by default - simply drag **Ad Inserter** widget to any widget postition (e.g. Sidebar), select code block, save and you're done.
327
- * Shortcode - Insert shortcode `[adinserter block="BLOCK_NUMBER"]` or `[adinserter name="BLOCK_NAME"]` into post or page HTML code to display block with BLOCK_NAME name or BLOCK_NUMBER number at this position. **PLEASE NOTE:** Shortcodes IGNORE post/static page exception settings! You can also insert shortcode that ignores enabled page types with `[adinserter block="BLOCK_NUMBER" ignore="page_type"]`
328
- * PHP function call `<?php if (function_exists ('adinserter')) echo adinserter (BLOCK_NUMBER); ?>` - Insert code block BLOCK_NUMBER at any position in template file. You can also define Filter for PHP function - define which call(s) to the function will actually insert code. This is useful if you put a call to the `adinserter` function inside a loop in a template file (e.g. for homepage) and you need to insert ads only few times between posts. You can also use PHP function calls that ignore enabled page types `<?php if (function_exists ('adinserter')) echo adinserter (BLOCK_NUMBER, 'page_type'); ?>`
329
-
330
- **OTHER NOTES**
331
-
332
- By default code blocks will not be inserted on Error 404 page (Page Not Found) and in feeds. Check '404 Page' or 'Feed' checkbox to enable code block insertion on error 404 page or in feed.
333
-
334
- **Ad Inserter general Settings - last tab**
335
-
336
- Wrapping divs for code blocks have 'code-block' and 'code-block-N' classes which can be used for custom styles. Class name 'code-block' can be changed in Ad Inserter settings. If you are using client-side device detection (CSS media queries) then the wrapping div for the code block will have also some of the following classes: ai-viewport-1, ai-viewport-2, ai-viewport-3.
337
-
338
- You can choose between many syntax highlighting themes.
339
-
340
- By default Ad Inserter exceptions on posts/static pages are enabled only for administrators. You can define minimum user role for page/post Ad Inserter exceptions editing in Ad Inserter Settings (tab *).
341
-
342
- Default Ad Inserter plugin processing order is 99999. It is used to specify the order in which the plugin functions are executed. Lower numbers correspond with earlier execution. You can change this value if you have problems with the processing order of other plugins.
343
-
344
- Support for Special Code Blocks:
345
-
346
- * Header scripts (scripts in the `<header>` section)
347
- * Footer scripts (scripts before the `</body>` tag)
348
-
349
- **WARNING:** Text selection, Copy and Paste functions with the syntax highlighting editor do not work on mobile devices. If you need these functions you can temporarily swich to **Simple editor** using the checkbox above the code box.
350
-
351
- **WARNING:** Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button, make sure you have whitelisted Ad Inserter settings page (select "Disable on this page" or "Don't run on this page").
352
- However, since you are dealing with ads, it may make sense to temporarily disable adblockers in order to check and debug inserted ad codes.
353
- Some security plugins like WP Security or Wordfence may also detect Ad Inserter page as problematic and prevent it from loading. Please be assured that this is false positive.
354
-
355
  **CACHING**
356
 
357
  Keep in mind that just installing a caching plugin does not necessarily make your site faster. Doing a bit of optimization will get you a lot of speed increase without caching plugins.
@@ -359,95 +181,99 @@ To further combat slowness you may want to re-evaluate the performance of your h
359
 
360
  Caching on the frontend side (what visitors see) in some cases does speed up page loading but may also cause some unwanted behavior.
361
  When you are using caching and visitor visits some page, Wordpress creates that page, Ad Inseter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later.
362
- The next time the page is visited **the visitor gets cached (saved) page **. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
363
 
364
- * Block rotation with `|rotate|`
365
  * User check
366
  * Server-side device detection
367
  * Referer check
 
 
368
  * Debugging functions
369
- * GEO targeting (Pro only)
370
 
371
  When you need the functions listed above you have to switch off caching (if possible only on selected pages where needed).
372
 
373
- Caching on the backend side (Ad Inserter Settings page) may also cause some unwanted behavior if it is not done properly.
374
- The problem can occur when the plugin is updated since the new plugin also provides new javascript and CSS files.
375
- In order to prevent browsers from loading old js/css files the plugin appends version info as query parameter to js and css files needed.
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
- For example, in the source code of the settings page it should be like this:
378
 
379
- `<script type='text/javascript' src='http://example.com/wp-content/plugins/ad-inserter/js/ad-inserter.js?ver=2.0.1'></script>
380
 
381
- <link rel='stylesheet' id='ai-admin-css' href='http://example.com/wp-content/plugins/ad-inserter/css/ad-inserter.css?ver=2.0.1' type='text/css' media='all' />`
382
 
383
- However, on some websites this version parameter is removed (very likely due to aggresive caching):
 
 
384
 
385
- `<script type='text/javascript' src='http://example.com/wp-content/plugins/ad-inserter/js/ad-inserter.js'></script>
386
 
387
- <link rel='stylesheet' id='ai-admin-css' href='http://example.com/wp-content/plugins/ad-inserter/css/ad-inserter.css' type='text/css' media='all' />`
388
 
389
- Because of this the old cached files (css and js) are loaded which cause warnings and unpredicted behavior.
 
 
 
 
390
 
391
- If you are using caching make sure the caching software **DOES NOT REMOVE VERSION INFO** parameter from the url. This is needed for browsers to reload the file when the plugin is updated.
392
 
393
- **WARNING:** If you are using caching the inserted code may not appear immediately on the page. Make sure you have disabled caching when you are testing or debugging.
394
- Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
395
 
396
- **PLEASE DO NOT FORGET:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check, GEO targeting and server-side detection work only when the page is generated and Ad Inserter is called.
397
- In such cases please make sure you have disabled caching.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
 
399
  **DEBUGGING**
400
 
401
  Ad Inserter has many debugging functions that can help you to diagnose the problem when you don't see your ads at expected positions.
402
 
403
- * Code preview: click on the Preview button for each code block to see how the ad or code will look like. On the Preview window click on the Highlight button to highlight code. If you don't see display of the code here it is very likely that the code is not working properly.
404
  * Debugger Widget: Place Debugger widget in some widget area to see basic Wordpress page and Ad Inserter data (User status, Page Type, Post ID, Url, Referer, etc). With this widget you can also check saved block settings and client-side viewport name.
405
  * Debugger Shortcode: Place shortcode [adinserter block="0"] or [adinserter name="Debugger"] into post or static page to see basic Wordpress page and Ad Inserter data
406
 
407
  Each post/page has a Wordpress toolbar on the top. Ad Inserter menu (visible only to administrators and can be hidden) item has the following debugging functions:
408
 
409
- * Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the broswer to check display for other devices (or screen widths). If you see only red bar then this means that the block with your **code is inserted** but the code doesn't display anything.
410
  * Show Positions: Enable this function to show available positions for automatic insertion. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
411
  * Show HTML tags: Enable this function to see HTML tags used in the post. Use this function to determine post structure in order to configure paragraph counting.
412
  * Disable insertion: Use this function to temporarily disable insertion of code blocks - everything else on the page will look like the code blocks were processed and inserted.
413
  * Log Processing: Use this function to log insertion process in order to determine why some code block was not inserted. The log is added as HTML comment at the end of the page - check page source
414
 
415
- **WARNING:** Make sure **caching is disabled while debugging**! All debugging functions you enable will be visible only to you! Post/page debugging works by adding url parameters to the url (web address):
416
-
417
- * Label Blocks: `ai-debug-blocks=1` (use `ai-debug-blocks=0` to turn it off)
418
- * Show Positions: `ai-debug-positions=BLOCK_NUMBER`, 0 means default counting of paragraphs with p tags, numbers between 1 and 16 use paragraph counting as configured for the block (use `ai-debug-positions=` to turn it off)
419
- * Show HTML tags: `ai-debug-tags=1` (use `ai-debug-tags=0` to turn it off)
420
- * Disable insertion: `ai-debug-no-insertion=1` (use `ai-debug-no-insertion=0` to turn it off)
421
- * Log Processing: `ai-debug-processing=1` (use `ai-debug-processing=0` to turn it off)
422
 
423
- When browsing other pages on the website debuggins settings are temporarily saved (in a cookie). To disable all debugging functions click on the 'Ad Inserter' top menu item in the toolbar (or use `ai-debug=0`)
424
 
425
  If you enable **Remote debugging** you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below.
426
  **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
427
- Enable this option (and disable caching) to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in users debugging via url is always enabled.
428
-
429
- **MULTISITE**
430
-
431
- Ad Inserter supports multisite Wordpress installations. Normally, the plugin is available with settings and widgets to all the sites on the network.
432
- <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> supports options to disable Setings page, widgets and post/page exceptions for sites (except the main one).
433
-
434
- **SUPPORT**
435
-
436
- If you experience problems with the Ad Inserter plugin you can ask for help on the <a href ="https://wordpress.org/support/plugin/ad-inserter">support forum</a>.
437
- However, before you ask please use debugging functions described above. In almost all cases it is possible to determine the nature of the problem just by checking the debugging data.
438
- Check also source code of the page. Some code for ads may not display anything, either because of errors in the ad code or because of ad network issues.
439
- In order to be able to diagnose the problem and suggest actions or fix a bug, please do the following:
440
-
441
- 1. Enable Remote debugging (located on the Ad Inserter Settings tab - Debugging) and disable caching.
442
-
443
- 2. Clearly describe the problem. Describe what does not work as expected.
444
-
445
- 3. Describe the settings and code blocks used.
446
-
447
- 4. Provide web addresses (links) of the pages where the code from the settings above is not inserted properly.
448
-
449
- Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help. Once the problem is fixed you can disable Remote debugging and enable caching.
450
- Thank you very much for understanding.
451
 
452
  Please **support the plugin** if you like it:
453
 
@@ -455,57 +281,14 @@ Please **support the plugin** if you like it:
455
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
456
 
457
 
458
- == Installation ==
459
-
460
- **Automatic installation**: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
461
-
462
- **Manual installation**:
463
-
464
- 1. Download the plugin,
465
- 2. Go to Wordpress Plugins, Add New, Upload Plugin
466
- 3. Choose file, click on Install Now, activate it
467
- 3. Go to Settings / Ad Inserter to configure it
468
-
469
- **WARNING:** Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button,
470
- make sure you have whitelisted Ad Inserter settings page (select "Disable on this page" or "Don't run on this page").
471
- However, since you are dealing with ads, it may make sense to temporarily disable adblockers in order to check and debug inserted ad codes.
472
- Some security plugins like WP Security or Wordfence may also detect Ad Inserter page as problematic and prevent it from loading. Please be assured that this is false positive.
473
-
474
- **WARNING:** If you are using caching the inserted code may not appear immediately on the page. Make sure you have disabled caching when you are testing or debugging.
475
- Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
476
-
477
- **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check, country and server-side detection work only when the page is generated and Ad Inserter is called.
478
- In such cases please make sure you have disabled caching when you are using such settings.
479
-
480
- **WARNING:** Some code for ads may not display anything, either because of erros in the ad code or because of ad network issues.
481
- Before you report problem please check source code of the page and make sure the code is not inserted where it should be.
482
- The code may be inserted properly but you won't see anything. Try to add some text after the ad code to check if it appears at the expected ad position.
483
-
484
- **Ad Inserter Pro Installation**
485
-
486
- <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> is an upgraded version of the freely available Ad Inserter.
487
- In addition to all the features in the free version it offers 64 code blocks, 6 custom viewports, export and import of settings, additional multisite options and support via email.
488
-
489
- If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version.
490
- After you receive the email with download link for the Ad Inserter Pro plugin, download it, go to Wordpress Plugins, Add New, Upload Plugin, Choose file, click on Install Now,
491
- activate it and then click "Enter License Key" and enter license key you got in the email. If you need to edit license key go to Ad Inserter settings (tab *).
492
-
493
- **Uninstall**:
494
-
495
- If you deactivate and delete Ad Inserter the settings will stay in the database. To completely remove the plugin and settings do the following:
496
-
497
- 1. Go to Ad Inserter Settings (tab *) and click on Reset All Settings
498
- 2. Deactivate Ad Inserter
499
- 3. Delete Ad Inserter plugin
500
-
501
  == Frequently Asked Questions ==
502
 
503
  = I have activated Ad Inserter. How can I use it? =
504
 
505
  1. After activation, click "Settings / Ad Inserter" to access the settings page
506
  2. Put ad (or any other HTML/Javascript/PHP) code into the ad box
507
- 3. Set automatic display option
508
- 5. Enable at least one page type: Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages (some display options don't work on all page types)
509
  4. Save settings
510
 
511
 
@@ -517,14 +300,49 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
517
 
518
  = Settings for ad before the first paragraph on all posts =
519
 
520
- * Automatic Display: Before Paragraph
521
  * On all Posts checked, other page types unchecked
522
  * Paragraph number: 1
523
 
524
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  = Settings for ad before the second paragraph on all posts, but on the homepage only three ads in the first three post =
526
 
527
- * Automatic Display: Before Paragraph
528
  * On all Posts checked, Homepage checked, other page types unchecked
529
  * Paragraph number: 2
530
  * Filter: 1, 2, 3 (in some cases 2, 4, 6 - depends on the theme and needs some testing)
@@ -532,7 +350,7 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
532
 
533
  = Settings for ad wrapped with text of the third paragraph on all posts =
534
 
535
- * Automatic Display: Before Paragraph
536
  * On all Posts checked, other page types unchecked
537
  * Block Alignment and Style: Float Left
538
  * Paragraph number: 3
@@ -540,7 +358,7 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
540
 
541
  = Settings for centered ad in the middle of post paragraphs =
542
 
543
- * Automatic Display: Before Paragraph
544
  * On all Posts checked, other page types unchecked
545
  * Block Alignment and Style: Center
546
  * Paragraph number: 0.5
@@ -548,7 +366,7 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
548
 
549
  = Settings for ad above post excerpts on the Insurance category page =
550
 
551
- * Automatic Display: Before Post
552
  * Category pages checked, other page types unchecked
553
  * Click Lists button to display lists
554
  * Categories: Insurance, White List checked
@@ -556,14 +374,14 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
556
 
557
  = Settings for ad above the first and third post excerpts on the homepage =
558
 
559
- * Automatic Display: Before Excerpt
560
  * Homepage checked, other page types unchecked
561
  * Filter: 1, 3
562
 
563
 
564
  = Settings for ad above the post excerpts on the Cars tag page =
565
 
566
- * Automatic Display: Before Post
567
  * Archive pages checked, other page types unchecked
568
  * Click Lists button to display lists
569
  * Tags: Cars, White List checked
@@ -573,7 +391,7 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
573
 
574
  Configure block 1 and 2 with ads using:
575
 
576
- * Automatic Display: None
577
  * Block Alignment and Style: No Wrapping
578
  * Enable shortcode: checked
579
 
@@ -582,10 +400,10 @@ Configure block 3 with
582
  `[adinserter block="1"]
583
  [adinserter block="2"]`
584
 
585
- Use block 3 to display ads and make sure all 3 blocks are enabled for the same page types (Posts, Pages, Homepage, etc.).
586
 
587
 
588
- = I use After Content display position but the code is inserted after the stuff provided by other plugins. How can I insert directly after post content?
589
 
590
  This happens because Ad Inserter processes posts last and therefore "sees" also content added by other plugins.
591
 
@@ -610,7 +428,7 @@ Change title tag according to the theme style.
610
 
611
  = I like the plugin. How can I support it? =
612
 
613
- * Write a nice <a href="http://wordpress.org/support/view/plugin-reviews/ad-inserter">review</a>
614
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
615
 
616
 
@@ -620,16 +438,16 @@ There are two possible approaches.
620
 
621
  * Approach with page/post exceptions - use this one if there are many exceptions:
622
 
623
- 1. Go to Ad Inserter settings page and define default display options for post/page.
624
- 2. Enable automatic display on posts/pages and choose default display: **On all**, **On all except selected** or **Only on selected**.
625
  3. Go to post/page editor and open **Ad Inserter Exceptions** meta box below.
626
- 4. Check default display options for wanted code blocks.
627
  5. Set exceptions for this post or page.
628
 
629
  * Approach with code block settings only - use this one if there are only few exceptions:
630
 
631
- 1. Go to Ad Inserter settings page and define default display options for post/page.
632
- 2. Enable automatic display On all Posts/Pages.
633
  3. Click on Lists, enter url (or space separated urls) for Urls, e.g. `/permalink-url`, and white-list or black-list it.
634
 
635
 
@@ -681,25 +499,9 @@ Yes, simply create block with 4 ads separated with |rotate|: 3 times ad1 and 1 t
681
 
682
  = How can I show different ads to different visitors according to a url query parameter? =
683
 
684
- For example, use the following code for block 1 and enable PHP processing for this block:
685
-
686
- `<?php
687
- if (isset ($_GET ['src'])) {
688
- switch ($_GET ['src']) {
689
- case 'email':
690
- echo adinserter (2);
691
- break;
692
- case 'facebook':
693
- echo adinserter (3);
694
- break;
695
- case 'twitter':
696
- echo adinserter (4);
697
- break;
698
- default:
699
- echo adinserter (5);
700
- }
701
- } else echo adinserter (6); // no src parameter
702
- ?>`
703
 
704
 
705
  = How can I use PHP code for code block? =
@@ -737,7 +539,7 @@ Some HTML/Javascript code
737
 
738
  = How can I rotate few versions of the same ad? =
739
 
740
- Enter them into the ad box and separate them with |rotate| (vertical bars around text rotate). Ad Inserter will display them randomly.
741
  Example:
742
 
743
  `ad_code_1
@@ -751,7 +553,7 @@ ad_code_3`
751
 
752
  Configure ad block with the following options:
753
 
754
- * Automatic display: After Paragraph
755
  * Paragraph Number: 1
756
  * Count only paragraphs that CONTAIN: `<span id="more-`
757
 
@@ -768,31 +570,6 @@ Example for block 3:
768
  This would generate code as defined for the code block number 3.
769
 
770
 
771
- = How can I create contextual Amazon ad (to show items related to the post)? =
772
-
773
- Sign in to Amazon Associates, go to Widgets/Widget Source, choose ad type and set parameters.
774
- For titles and search terms use tags. For example, the code below would display amazon products related to the post tags - check above for all possible tags.
775
-
776
-
777
- Example for Amazon Native Shopping Ads (use your own tracking id):
778
-
779
- `<script type="text/javascript">
780
- amzn_assoc_placement = "adunit0";
781
- amzn_assoc_search_bar = "true";
782
- amzn_assoc_tracking_id = "ad-inserter-20";
783
- amzn_assoc_search_bar_position = "top";
784
- amzn_assoc_ad_mode = "search";
785
- amzn_assoc_ad_type = "smart";
786
- amzn_assoc_marketplace = "amazon";
787
- amzn_assoc_region = "US";
788
- amzn_assoc_title = "Search Results from Amazon";
789
- amzn_assoc_default_search_phrase = "{smart_tag}";
790
- amzn_assoc_default_category = "All";
791
- amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
792
- </script>
793
- <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
794
-
795
-
796
  = Center alignment does not work for some ads! =
797
 
798
  Some iframe ads can not be centered using standard approach so some additional code is needed to put them in the middle.
@@ -821,22 +598,40 @@ AD CODE RIGHT
821
  == Screenshots ==
822
 
823
  1. Settings for one code block (Before post). Up to 16 blocks can be configured (up to 64 in <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a>)
824
- 2. Complete settings for one code block (Before Paragraph)
825
- 3. Alignment **Left**, **None** - None means default (usually left) aligned ad block with thin margin around
826
- 4. Alignment **Right** - Right aligned ad block with thin margin around
827
- 5. Alignment **Center** - Center aligned ad block with thin margin around
828
- 6. Alignment **No Wrapping** - Default (usually left) aligned ad block **with no margin around**
829
- 7. Alignment **Custom CSS** - Ad block with custom CSS (no margin around). You can use it for special effects (border, background, padding, margin, floating, etc.)
830
- 8. Alignment **Float Left** - Left aligned ad block with thin margin around wrapped with text on the right
831
- 9. Alignment **Float Right** - Right aligned ad block with thin margin around wrapped with text on the left
832
- 10. Ad Inserter settings
833
- 11. Post / Page Ad Inserter Exceptions
834
- 12. Code preview with visual CSS editor
835
- 13. Code preview with visual CSS editor - highlighted code
 
 
 
 
836
 
837
 
838
  == Changelog ==
839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
840
  = 2.0.7 =
841
  - Delayed display moved to Misc group
842
  - Added option for scheduling to insert code only between specified dates (Pro only)
@@ -1107,265 +902,34 @@ AD CODE RIGHT
1107
 
1108
  == Upgrade Notice ==
1109
 
 
 
 
 
1110
  = 2.0.7 =
1111
- Delayed display moved to Misc group
1112
- Added option for scheduling to insert code only between specified dates (Pro only);
1113
- Added option for Geo targeting (Pro only);
1114
- Few minor bug fixes and cosmetic changes
1115
 
1116
  = 2.0.6 =
1117
- Added support to filter subpages created by the `<!--nextpage-->` tag;
1118
- Added option to import block name (Pro only);
1119
- Cookie deleted only when it exists and debugging is disabled;
1120
- Few minor bug fixes
1121
 
1122
  = 2.0.5 =
1123
- Cookie created only when debugging is enabled;
1124
- Few minor bug fixes
1125
 
1126
  = 2.0.4 =
1127
- Bug fix: Cursor position always at the end of block name;
1128
- State of debugging functions saved to cookie;
1129
- Few minor bug fixes
1130
 
1131
  = 2.0.3 =
1132
- Debugging functions in admin toolbar available only for administrators;
1133
- Added option to hide debugging functions in admin toolbar;
1134
- Added shortcode for debugger;
1135
- Few minor bug fixes
1136
 
1137
  = 2.0.2 =
1138
- Changed javascript version check to get plugin version from the HTML page;
1139
- Added warning if old cached version of CSS file is loaded on the settings page;
1140
- Added warning if version query parameter for js/css files is removed due to inappropriate caching
1141
 
1142
  = 2.0.1 =
1143
  Bug fix: Shortcodes called by name were not displayed
1144
 
1145
  = 2.0.0 =
1146
- Redesigned user interface;
1147
- Added many debugging tools for easier troubleshooting;
1148
- New feature: Code preview tool with visual CSS editor;
1149
- New feature: Label inserted blocks;
1150
- New feature: Show available positions for automatic insertion;
1151
- New feature: Show HTML tags in posts/static pages;
1152
- New feature: Log Ad Inserter processing;
1153
- Improved loading speed of the settings page;
1154
- Improved block insertion processing speed;
1155
- Added support to avoid inserion near images, headers and other elements;
1156
- Added option to avoid insertion in feeds;
1157
- Added option to display code blocks only to administrators;
1158
- Added option for publishig date check for display positions Before/After Content;
1159
- Added option for server-side device check for header and footer code;
1160
- Added option for maximum page/post words;
1161
- Added option for maximum paragraph words;
1162
- Added option to black/white-list post IDs;
1163
- Added option to black/white-list url query parameters;
1164
- Added warning if the settings page is blocked by ad blocker;
1165
- Added warning if old cached version of javascript is loaded on the settings page;
1166
- Added support for multisite installations to disable settings, widgets and exceptions on network sites (Pro only);
1167
- Block names can be edited by clicking on the name;
1168
- Filters now work also on posts and single pages;
1169
- CSS code for client-side detection moved to inline CSS;
1170
- Bug fix: Minimum user roles for exception editing was not calculated properly;
1171
- Bug fix: Server-side detection checkbox was not saved properly;
1172
- Many other minor bug fixes, code improvements and cosmetic changes;
1173
-
1174
- = 1.7.0 =
1175
- Bug fix: Shortcodes did not ignore post/static page exceptions;
1176
- Slightly redesigned user interface;
1177
- Excerpt/Post number(s) renamed to Filter as it now works on all display positions;
1178
- Widget setting removed from Automatic display to Manual display section;
1179
- Added support to disable widgets (standalone checkbox in Manual display);
1180
- Added call counter/filter for widgets;
1181
- Added support to edit CSS for predefined styles;
1182
- Few other minor bug fixes, code improvements and cosmetic changes;
1183
-
1184
- = 1.6.7 =
1185
- Bug fix: Block code textarea was not escaped;
1186
- Added checks for page types for shortcodes;
1187
- Added support for Before/After Post position call counter/filter;
1188
- Few minor cosmetic changes
1189
-
1190
- = 1.6.6 =
1191
- Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
1192
- Few minor cosmetic changes;
1193
- Requirements changed to WordPress 4.0 or newer;
1194
- Added initial support for Pro version
1195
-
1196
- = 1.6.5 =
1197
- Fixed bug: Wrong counting of max insertions;
1198
- Change: display position Before Title was renamed to Before Post;
1199
- Added support for display position After Post;
1200
- Added support for posts with no `<p>` tags (paragraphs separated with \r\n\r\n characters);
1201
- Added support for paragraph processing on homepage, category, archive and search pages;
1202
- Added support for custom viewports;
1203
- Added support for PHP function call counter;
1204
- Added support to disable code block on error 404 pages;
1205
- Added support to debug paragraph tags
1206
-
1207
- = 1.6.4 =
1208
- Fixed bug: For shortcodes in posts the url was not checked;
1209
- Optimizations for device detection
1210
-
1211
- = 1.6.3 =
1212
- Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type);
1213
- Added support to change plugin processing priority
1214
-
1215
- = 1.6.2 =
1216
- Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type);
1217
- Added support to change plugin processing priority
1218
-
1219
- = 1.6.1 =
1220
- Fixed bug: For shortcodes in posts the date was not checked;
1221
- Fixed error with some templates "Call to undefined method is_main_query()";
1222
- Added support for minumum number of page/post words for Before/After content display option;
1223
- Added support for {author} and {author_name} tags
1224
-
1225
- = 1.6.0 =
1226
- Added support for client-side device detection;
1227
- Many code improvements;
1228
- Improved plugin processing speed;
1229
- Removed support for deprecated tags for manual insertion {adinserter n};
1230
- Few minor bug fixes
1231
-
1232
- = 1.5.8 =
1233
- Fixed notice "Undefined index: adinserter_selected_block_" when saving page or post
1234
-
1235
- = 1.5.7 =
1236
- Fixed notice "has_cap was called with an argument that is deprecated since version 2.0!";
1237
- Few minor bug fixes and code improvements;
1238
- Added support to blacklist or whitelist url patterns: /url-start*. *url-pattern*, *url-end;
1239
- Added support to define minimum number of words in paragraphs;
1240
- Added support to define minimum user role for page/post Ad Inserter exceptions editing;
1241
- Added support to limit insertions of individual code blocks;
1242
- Added support to filter direct visits (no referer)
1243
-
1244
- = 1.5.6 =
1245
- Fixed Security Vulnerability: Plugin was vulnerable to Cross-Site Scripting (XSS);
1246
- Few bug fixes and code improvements
1247
-
1248
- = 1.5.5 =
1249
- Few bug fixes and code improvements;
1250
- Added support to export and import all Ad Inserter settings
1251
-
1252
- = 1.5.4 =
1253
- Many code optimizations and cosmetic changes;
1254
- Header and Footer code blocks moved to settings tab (*);
1255
- Added support to process shortcodes of other plugins used in Ad Inserter code blocks;
1256
- Added support to white-list or black-list individual urls;
1257
- Added support to export and import settings for code blocks;
1258
- Added support to specify excerpts for block insertion;
1259
- Added support to specify text that must be present when counting paragraphs
1260
-
1261
- = 1.5.3 =
1262
- Fixed Security Vulnerability (CSRF/XSS attacks);
1263
- Fixed bug where deprecated widgets warning reported errors;
1264
- Added support to white-list or black-list tags;
1265
- Added support for category slugs in category list;
1266
- Added support for relative paragraph positions;
1267
- Added support for individual code block exceptions on post/page editor page;
1268
- Added support for minimum number of words;
1269
- Added support to disable syntax highlighting editor (to allow using copy/paste on mobile devices)
1270
-
1271
- = 1.5.2 =
1272
- Fixed bug: Widget titles might be displayed at wrong sidebar positions;
1273
- Change: Default code block CSS class name changed to code-block;
1274
- Warning message if deprecated widgets are used;
1275
- Display blocks on desktop + tablet and desktop + phone devices
1276
-
1277
- = 1.5.1 =
1278
- Few fixes to solve plugin incompatibility issues;
1279
- Support to disable all ads on specific page
1280
-
1281
- = 1.5.0 =
1282
- Display blocks on all, desktop or mobile devices;
1283
- New widgets API - one widget for all code blocks with multiple instances - PLEASE REPLACE ALL OLD WIDGETS WITH THE NEW ONE!
1284
- Wrapping code CSS class name can be changed;
1285
- Fixed bug: Display block N days after post is published;
1286
- Fixed bug: Display block after paragraph
1287
-
1288
- = 1.4.1 =
1289
- Fixed bug: Code blocks configured as widgets were not displayed properly on widgets admin page
1290
-
1291
- = 1.4.0 =
1292
- Added support to skip paragraphs with specified text
1293
- Added position After paragraph
1294
- Added support for header and footer scripts
1295
- Added support for custom CSS styles
1296
- Added support to display blocks to all, logged in or not logged in users
1297
- Added support for syntax highlighting
1298
- Added support for shortcodes
1299
- Added classes to block wrapping divs
1300
- Few bugs fixed
1301
-
1302
- = 1.3.5 =
1303
- Fixed bug: missing echo for PHP function call example
1304
-
1305
- = 1.3.4 =
1306
- Fixed bug: in some cases Before Title display setting inserted code into RSS feed,
1307
- Selected code block position is preserved after settings are saved,
1308
- Added option for no code wrapping with div,
1309
- Added option to insert block codes from PHP code,
1310
- Changed HTML codes to disable display on specific pages,
1311
- Manual insertion can be enabled or disabled regardless of primary display setting
1312
-
1313
- = 1.3.3 =
1314
- Fixed bug: in some cases many errors reported after activating the plugin,
1315
- Added option to insert ads also before or after the excerpt,
1316
- Few minor bugs fixed,
1317
- Few minor cosmetic changes
1318
-
1319
- = 1.3.2 =
1320
- Fixed blank settings page caused by incompatibility with some themes or plugins
1321
-
1322
- = 1.3.1 =
1323
- Added option to insert ads also on pages,
1324
- Added option to process PHP code,
1325
- Few bugs fixed
1326
-
1327
- = 1.3.0 =
1328
- Number of ad slots increased to 16,
1329
- New tabbed admin interface,
1330
- Ads can be manually inserted also with {adinserter AD_NUMBER} tag,
1331
- Fixed bug: only the last ad block set to Before Title was displayed,
1332
- Few other minor bugs fixed,
1333
- Few cosmetic changes
1334
-
1335
- = 1.2.1 =
1336
- Fixed problem: || in ad code (e.g. asynchronous code for AdSense) causes only part of the code to be inserted (|| to rotate ads is replaced with |rotate|)
1337
-
1338
- = 1.2.0 =
1339
- Fixed bug: manual tags in posts lists were not removed,
1340
- Added position Before title,
1341
- Added support for minimum number of paragraphs,
1342
- Added support for page display options for Widget and Before title positions,
1343
- Alignment now works for all display positions,
1344
-
1345
- = 1.1.3 =
1346
- Fixed bug for search query tag
1347
-
1348
- = 1.1.2 =
1349
- Fixed error with multisite/network installations
1350
-
1351
- = 1.1.1 =
1352
- Fixed bug in Float Right setting display
1353
-
1354
- = 1.1.0 =
1355
- Added new features
1356
-
1357
- = 1.0.4 =
1358
- Added few minor features
1359
-
1360
- = 1.0.3 =
1361
- Fixed bug with rotating ads
1362
-
1363
- = 1.0.2 =
1364
- Support for rotating ads
1365
-
1366
- = 1.0.1 =
1367
- Support for different sidebar implementations in various themes
1368
-
1369
- = 1.0.0 =
1370
- Initial release
1371
-
1
  === Ad Inserter ===
2
  Contributors: spacetime
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
4
+ Tags: adsense, amazon, advertising, ad, advert, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, ad rotation, geo targeting, multisite, contextual, shortcodes, widgets, header, footer, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, caching support
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.0.8
8
  License: GPLv3
9
 
10
+ Insert any advert or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many insertion options and features.
11
 
12
  == Description ==
13
 
14
+ A simple yet powerful plugin to insert any ad or code into Wordpress. **Perfect for all kinds of ads.** Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to insert it.
15
 
16
  > **Features**
17
  >
19
  > * Syntax highlighting editor
20
  > * Code preview with visual CSS editor
21
  > * Automatic insertion: before/after post, content, paragraph or excerpt
22
+ > * Insertion exceptions for posts and pages
23
  > * Manual insertion: widgets, shortcodes, PHP function call
24
+ > * Custom block alignment and style
25
  > * Clearance options to avoid insertion near images or headers
26
  > * PHP code processing
27
+ > * Ad rotation (server-side and client-side - works with caching)
28
+ > * Device detection (server-side and client-side, 3 custom viewports)
29
  > * Black/White-list categories, tags, post IDs, urls, url parameters, referers
30
+ > * Simple troubleshooting with many debugging functions
31
+ > * Function to visualize inserted code blocks
32
+ > * Function to visualize available insertion positions
33
+ > * Function to visualize HTML tags
34
 
35
+ Ad Inserter plugin is simple to use but has many features. Please read user manual to get the most of it.
36
+
37
+ > * Check <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a> for detailed description of all the features
38
+ > * Download **PDF user guide** for Ad Inserter: go to <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> page and below you can find button for free download of Ad Inserter User Guide
39
+
40
+ **Endorsed by Amazon**
41
 
 
 
42
  > Amazon suggests to use Ad Inserter to add Native Shopping Ads to Wordpress posts. Native Shopping Ads provide highly relevant and dynamic product recommendations in a stylishly designed and responsive ad unit that can be placed at the end of your content or within your content to create a more compelling visitor experience and shopping opportunity.
43
  >
44
  > * Check <a href="https://affiliate-program.amazon.com/help/topic/t405" target="_blank">Wordpress Integration Guide for Native Shopping Ads</a>
45
  > * On the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page you can also find an example of contextual Amazon Shopping Ads that show items related to the post content (using post tags)
46
 
47
+ There is also <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> if you need more:
48
+
49
+ > * 64 code blocks
50
+ > * GEO targeting (works also with caching)
51
+ > * Black/White-list IP addresses or countries
52
+ > * Scheduling with fallback option
53
+ > * Export and import of settings
54
+ > * Multisite options to limit settings on the sites
55
+ > * 6 viewports
56
+ > * Support via email
57
+
58
+ **Quick Start**
59
+
60
+ Few very important things you need to know in order to <a href="http://adinserter.pro/documentation#quick-start">insert code and display some ad</a>:
61
+
62
+ * Code block is any code (for example AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress
63
+ * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
64
+ * **Enable insertion on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
65
+ * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
66
+ * If you don't see inserted code block turn on **debugging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
67
+
68
+ Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read <a href="https://wordpress.org/plugins/ad-inserter/installation/">Docs</a> page.
69
+ For more detailed instructions please read <a href="http://adinserter.pro/documentation" target="_blank">Ad Inserter documentation page</a>.
70
+
71
+ Please *support the plugin* if you like it:
72
+
73
+ * Write a nice <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
74
+ * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
75
+
76
+
77
+ == Installation ==
78
+
79
+ **Automatic installation**: Go to Wordpress Plugins menu, click Add New button, search for "Ad Inserter" and click Install Now.
80
+
81
+ **Manual installation**:
82
+
83
+ 1. Download the plugin,
84
+ 2. Go to Wordpress Plugins, Add New, Upload Plugin
85
+ 3. Choose file, click on Install Now, activate it
86
+ 3. Go to Settings / Ad Inserter to configure it
87
+
88
+ **Ad Inserter Pro Installation**
89
+
90
+ If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version.
91
+ After you receive the email with download link for the Ad Inserter Pro plugin, download it, go to Wordpress Plugins, Add New, Upload Plugin, Choose file, click on Install Now,
92
+ activate it and then click "Enter License Key" and enter license key you got in the email. If you need to edit license key go to Ad Inserter settings (tab *).
93
+
94
+ **Uninstall**
95
+
96
+ If you deactivate and delete Ad Inserter the settings will stay in the database. To completely remove the plugin and settings do the following:
97
 
98
+ 1. Go to Ad Inserter Settings (tab *) and click on Reset All Settings
99
+ 2. Deactivate Ad Inserter
100
+ 3. Delete Ad Inserter plugin
101
 
102
  **Quick Start**
103
 
104
  Few very important things you need to know in order to <a href="http://adinserter.pro/documentation#quick-start">insert code and display some ad</a>:
105
 
106
+ * Code block is any code (for example AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by Wordpress
107
  * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
108
  * **Enable insertion on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
109
  * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
110
+ * If you don't see inserted code block turn on **debugging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page)
111
 
112
  Few typical settings are described on the <a href="https://wordpress.org/plugins/ad-inserter/faq/">FAQ</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page and instructions for **Debugging**.
113
 
114
  **Settings**
115
 
116
+ Each code block has a name and settings which are divided into sections. Some settings depend also on automatic insertion used. To rename code block click on the block name.
117
+ Check **Simple editor** to switch to simple editor for mobile devices. If you have PHP code (surrounded with PHP tags `<?php � ?>`) in code block, you need to check **Process PHP** to enable PHP processing.
118
+ When you are finished with settings you need to save them by clicking on the button **Save Settings**.
119
+
120
  Each code block has 4 insertion options:
121
 
122
  * Automatic Insertion
127
  Normally for each code block you use only one insertion option.
128
  Of course, you can use all 4 options simultaneously taking into account that all insertion options use the same block settings (with some exceptions mentioned below).
129
 
130
+ To insert code block and display ad at some position **you need to enable and use at least one insertion option**.
131
 
132
  Automatic Insertion Options:
133
 
144
 
145
  For single posts or static pages insertion position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  Please use **Show positions** function to see available positions for automatic insertion (Ad Inserter menu item in the Wordpress toolbar on the top of every post/page).
148
 
149
  Block Alignment and Style:
174
 
175
  Check <a href="https://wordpress.org/plugins/ad-inserter/screenshots/">screenshots</a> for explanation on alignment.
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  **CACHING**
178
 
179
  Keep in mind that just installing a caching plugin does not necessarily make your site faster. Doing a bit of optimization will get you a lot of speed increase without caching plugins.
181
 
182
  Caching on the frontend side (what visitors see) in some cases does speed up page loading but may also cause some unwanted behavior.
183
  When you are using caching and visitor visits some page, Wordpress creates that page, Ad Inseter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later.
184
+ The next time the page is visited **the visitor gets cached (saved) page**. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:
185
 
186
+ * Server-side block rotation with |rotate|
187
  * User check
188
  * Server-side device detection
189
  * Referer check
190
+ * Server-side GEO targeting (country detection, Pro only)
191
+ * Server-side IP address detection (Pro only)
192
  * Debugging functions
 
193
 
194
  When you need the functions listed above you have to switch off caching (if possible only on selected pages where needed).
195
 
196
+ However, Ad Inserter also supports some of the functions above even when caching is enabled:
197
+
198
+ * Client-side ad rotation with |rotate|
199
+ * Client-side device detection
200
+ * Client-side GEO targeting (country detection, Pro only)
201
+ * Client-side IP address detection (Pro only)
202
+
203
+ All you have to do is to set enable and use client-side functions (executed in the visitor's browser). But you have to be careful as some adverts might not work properly or can't be used this way and you might violate their Terms of Service.
204
+
205
+ PLEASE NOTE: If you are using W3 Total Cache for caching then you can still use server-side ad rotation, IP address and country detection even when the pages are cached as Ad Inserter supports special features of this caching plugin.
206
+
207
+ **W3 Total Cache**
208
+
209
+ If you are using W3 Total Cache for caching then you can still use server-side ad rotation, IP address and country detection even when the pages are cached as Ad Inserter supports special features of this caching plugin.
210
+ To enable this mode go to Ad Inserter plugin settings tab * / tab General and set Dynamic blocks to Server-side with W3 Total Cache and configure W3 Total Cache for dynamic content.
211
 
212
+ When Dynamic blocks is set to Server-side with W3 Total Cache and you are using ad rotation, IP address or country detection, Ad Inserter inserts short PHP code with special tags in place of code block. When W3 Total Cache plugin loads cached page it executes this code before it serves the pages. So the page is stills served from the cache but the Ad Inserter blocks are dynamically created just before the page is served. Therefore, pages are served from the cache and the Ad Inserter code is still generated on the server-side.
213
 
214
+ Configure W3 Total Cache
215
 
216
+ How to fully set up W3 Total Cache is beyond the scope of this page. Check the W3 Total Cache manuals or contact it's developer for help with that if you need it.
217
 
218
+ * In General Settings set the Page Caching to Disk: Basic.
219
+ * In Page Cache under Advanced enable Late Initialization.
220
+ * If you use the Minify option add mfunc to the ignored comment stem field.
221
 
222
+ You need to flush the cache after making these changes.
223
 
224
+ Please note also the following:
225
 
226
+ * Mixing static cached and dynamic content is a tricky thing to do and often causes all kinds of issues. Ad Inserter follows the guidelines from W3 Total Cache on this. If it doesn't work it's very likely you didn't configure W3 Total Cache correctly. Alternatively, you can decide to use client-side option for dynamic blocks - your adverts will show up just fine and rotation and GEO targeting will still work.
227
+ * In order to use dynamic content with W3 Total Cache, W3TC_DYNAMIC_SECURITY PHP constant needs to be defined. Usually it is located in the wp-confing.php file. This is a security string used when generating PHP code for dynamic content. If this constant is not defined, Ad Inserter will define and use it.
228
+ * Do not use debugging functions when caching is activated.
229
+ * When you make changes in settings of the W3 Total Cache purge all caches before you check page.
230
+ * After you activate W3 Total Cache plugin go to General Settings and Save all settings.
231
 
232
+ **Ad rotation**
233
 
234
+ To use client-side rotation you have to enable it first. Go to Ad Inserter plugin settings tab * / tab General and set Dynamic blocks to Client-side.
 
235
 
236
+ Configure blocks normally and separate different versions with |rotate| tag. When the page will be created and Ad Inserter called, it will generate hidden code for all block versions. When the page will be loaded in the browser, one randomly chosen version of the code will be displayed. For example, to rotate 3 images:
237
+
238
+ `<img style='height: 400px;' src="http://malsup.github.io/images/p1.jpg">
239
+ |rotate|
240
+ <img style='height: 400px;' src="http://malsup.github.io/images/p2.jpg">
241
+ |rotate|
242
+ <img style='height: 400px;' src="http://malsup.github.io/images/p3.jpg">`
243
+
244
+ Please note the following:
245
+
246
+ * Client-side rotation works fine with banners, text ads and many ad networks including Amazon Associates. However, it should not be used with some ad networks including AdSense (hiding ad units is not allowed) because of the method used for client-side rotation: all options are present on the page but are hidden until the page is loaded and one option is made visible. Please check Terms of Service for your ad network.
247
+ * Ad Inserter reserves space for code block based on the height of the first block version. If all the versions have the same height then you won't notice anything. However, if block versions have different heights then it makes sense to define fixed block height with Custom CSS to avoid content jumping when block option with different or initially unknown height is displayed. If the first option is some Javascript based ad (e.g. Amazon widget) you should wrap it with a div and define height, for example `<div style="height: 300px;"> ... </div>`
248
+ * Since the code (block option) is displayed only when the page is loaded, you may notice a very short delay (few 100 ms) before the code (or ad) is displayed.
249
+ * Client-side rotation uses div elements to wrap the code(s). This is not important unless you use No wrapping style.
250
+
251
+ WARNING: If you are using caching, the inserted code may not appear immediately on the page. Make sure you disable caching when you are testing or debugging.
252
+ Some caching plugins like WP Super Cache and W3 Total Cache have an option to disable caching for known (logged in) users.
253
 
254
  **DEBUGGING**
255
 
256
  Ad Inserter has many debugging functions that can help you to diagnose the problem when you don't see your ads at expected positions.
257
 
258
+ * Code preview: click on the Preview button for each code block to see how the ad or code will look like. On the Preview window click on the Highlight button to highlight code. If you don't see the ad displayed here it is very likely that the code is not working properly.
259
  * Debugger Widget: Place Debugger widget in some widget area to see basic Wordpress page and Ad Inserter data (User status, Page Type, Post ID, Url, Referer, etc). With this widget you can also check saved block settings and client-side viewport name.
260
  * Debugger Shortcode: Place shortcode [adinserter block="0"] or [adinserter name="Debugger"] into post or static page to see basic Wordpress page and Ad Inserter data
261
 
262
  Each post/page has a Wordpress toolbar on the top. Ad Inserter menu (visible only to administrators and can be hidden) item has the following debugging functions:
263
 
264
+ * Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the browser to check display for other devices (or screen widths). If you see only red bar then this means that the block with your **code is inserted** but the code doesn't display anything.
265
  * Show Positions: Enable this function to show available positions for automatic insertion. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
266
  * Show HTML tags: Enable this function to see HTML tags used in the post. Use this function to determine post structure in order to configure paragraph counting.
267
  * Disable insertion: Use this function to temporarily disable insertion of code blocks - everything else on the page will look like the code blocks were processed and inserted.
268
  * Log Processing: Use this function to log insertion process in order to determine why some code block was not inserted. The log is added as HTML comment at the end of the page - check page source
269
 
270
+ **WARNING:** Make sure **caching is disabled while debugging**! All debugging functions you enable will be visible only to you!
 
 
 
 
 
 
271
 
272
+ When browsing other pages on the website debugging settings are temporarily saved (in a cookie). To disable all debugging functions click on the 'Ad Inserter' top menu item in the toolbar (or use `ai-debug=0`)
273
 
274
  If you enable **Remote debugging** you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below.
275
  **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
276
+ Enable this option (and disable caching) to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in administrators debugging via url is always enabled.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
  Please **support the plugin** if you like it:
279
 
281
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
282
 
283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  == Frequently Asked Questions ==
285
 
286
  = I have activated Ad Inserter. How can I use it? =
287
 
288
  1. After activation, click "Settings / Ad Inserter" to access the settings page
289
  2. Put ad (or any other HTML/Javascript/PHP) code into the ad box
290
+ 3. Set automatic insertion option
291
+ 5. Enable at least one page type: Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages (some insertion options don't work on all page types)
292
  4. Save settings
293
 
294
 
300
 
301
  = Settings for ad before the first paragraph on all posts =
302
 
303
+ * Automatic Insertion: Before Paragraph
304
  * On all Posts checked, other page types unchecked
305
  * Paragraph number: 1
306
 
307
 
308
+ = Settings for ad before the last paragraph on all posts =
309
+
310
+ * Automatic Insertion: Before Paragraph
311
+ * On all Posts checked, other page types unchecked
312
+ * Paragraph number: 1
313
+ * Count: From Bottom
314
+
315
+
316
+ = Settings for contextual Amazon Native Shopping Ads =
317
+
318
+ * Automatic Insertion: After Content
319
+ * On all Posts checked, other page types unchecked
320
+
321
+ Sign in to Amazon Associates, go to Widgets/Widget Source, choose ad type and set parameters.
322
+ For titles and search terms use tags. For example, the code below would display amazon products related to the post tags - check documentation for all possible tags.
323
+
324
+ `<script type="text/javascript">
325
+ amzn_assoc_placement = "adunit0";
326
+ amzn_assoc_search_bar = "true";
327
+ amzn_assoc_tracking_id = "ad-inserter-20";
328
+ amzn_assoc_search_bar_position = "top";
329
+ amzn_assoc_ad_mode = "search";
330
+ amzn_assoc_ad_type = "smart";
331
+ amzn_assoc_marketplace = "amazon";
332
+ amzn_assoc_region = "US";
333
+ amzn_assoc_title = "Search Results from Amazon";
334
+ amzn_assoc_default_search_phrase = "{smart_tag}";
335
+ amzn_assoc_default_category = "All";
336
+ amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
337
+ </script>
338
+ <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>`
339
+
340
+ Use your own tracking id! Please note `{smart_tag}` as default search phrase. This makes this widget contextual.
341
+
342
+
343
  = Settings for ad before the second paragraph on all posts, but on the homepage only three ads in the first three post =
344
 
345
+ * Automatic Insertion: Before Paragraph
346
  * On all Posts checked, Homepage checked, other page types unchecked
347
  * Paragraph number: 2
348
  * Filter: 1, 2, 3 (in some cases 2, 4, 6 - depends on the theme and needs some testing)
350
 
351
  = Settings for ad wrapped with text of the third paragraph on all posts =
352
 
353
+ * Automatic Insertion: Before Paragraph
354
  * On all Posts checked, other page types unchecked
355
  * Block Alignment and Style: Float Left
356
  * Paragraph number: 3
358
 
359
  = Settings for centered ad in the middle of post paragraphs =
360
 
361
+ * Automatic Insertion: Before Paragraph
362
  * On all Posts checked, other page types unchecked
363
  * Block Alignment and Style: Center
364
  * Paragraph number: 0.5
366
 
367
  = Settings for ad above post excerpts on the Insurance category page =
368
 
369
+ * Automatic Insertion: Before Post
370
  * Category pages checked, other page types unchecked
371
  * Click Lists button to display lists
372
  * Categories: Insurance, White List checked
374
 
375
  = Settings for ad above the first and third post excerpts on the homepage =
376
 
377
+ * Automatic Insertion: Before Excerpt
378
  * Homepage checked, other page types unchecked
379
  * Filter: 1, 3
380
 
381
 
382
  = Settings for ad above the post excerpts on the Cars tag page =
383
 
384
+ * Automatic Insertion: Before Post
385
  * Archive pages checked, other page types unchecked
386
  * Click Lists button to display lists
387
  * Tags: Cars, White List checked
391
 
392
  Configure block 1 and 2 with ads using:
393
 
394
+ * Automatic Insertion: None
395
  * Block Alignment and Style: No Wrapping
396
  * Enable shortcode: checked
397
 
400
  `[adinserter block="1"]
401
  [adinserter block="2"]`
402
 
403
+ Use block 3 to insert ads and make sure all 3 blocks are enabled for the same page types (Posts, Pages, Homepage, etc.).
404
 
405
 
406
+ = I use After Content insertion position but the code is inserted after the stuff provided by other plugins. How can I insert directly after post content?
407
 
408
  This happens because Ad Inserter processes posts last and therefore "sees" also content added by other plugins.
409
 
428
 
429
  = I like the plugin. How can I support it? =
430
 
431
+ * Write a nice <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
432
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a>
433
 
434
 
438
 
439
  * Approach with page/post exceptions - use this one if there are many exceptions:
440
 
441
+ 1. Go to Ad Inserter settings page and define default insertion options for post/page.
442
+ 2. Enable automatic insertion on posts/pages and choose default display: **On all**, **On all except selected** or **Only on selected**.
443
  3. Go to post/page editor and open **Ad Inserter Exceptions** meta box below.
444
+ 4. Check default insertion options for wanted code blocks.
445
  5. Set exceptions for this post or page.
446
 
447
  * Approach with code block settings only - use this one if there are only few exceptions:
448
 
449
+ 1. Go to Ad Inserter settings page and define default insertion options for post/page.
450
+ 2. Enable automatic insertion On all Posts/Pages.
451
  3. Click on Lists, enter url (or space separated urls) for Urls, e.g. `/permalink-url`, and white-list or black-list it.
452
 
453
 
499
 
500
  = How can I show different ads to different visitors according to a url query parameter? =
501
 
502
+ Use Url parameters List to black/white-list certain url parameters. Leave url parameter list empty and set it to Black list to show ads for all url.
503
+ You can specify either parameters or parameters with values. For example for url `http://example.com?data=2&customer-id=22&device=0` you can define url parameters '`data, customer-id=22`' to insert ad only for urls where there is `data` parameter and `customer-id` parameter with value 22.
504
+ Separate parameters with comma.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
 
506
 
507
  = How can I use PHP code for code block? =
539
 
540
  = How can I rotate few versions of the same ad? =
541
 
542
+ Enter them into the ad box and separate them with |rotate| (vertical bars around text rotate). Ad Inserter will insert them randomly.
543
  Example:
544
 
545
  `ad_code_1
553
 
554
  Configure ad block with the following options:
555
 
556
+ * Automatic Insertion: After Paragraph
557
  * Paragraph Number: 1
558
  * Count only paragraphs that CONTAIN: `<span id="more-`
559
 
570
  This would generate code as defined for the code block number 3.
571
 
572
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  = Center alignment does not work for some ads! =
574
 
575
  Some iframe ads can not be centered using standard approach so some additional code is needed to put them in the middle.
598
  == Screenshots ==
599
 
600
  1. Settings for one code block (Before post). Up to 16 blocks can be configured (up to 64 in <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a>)
601
+ 2. Code preview with visual CSS editor
602
+ 3. Code preview with visual CSS editor - highlighted code
603
+ 4. Post / Page Ad Inserter Exceptions
604
+ 5. Some <a href="http://adinserter.pro/" target="_blank">Ad Inserter Pro</a> features: IP address and country lists, Scheduling between dates with fallback
605
+ 6. Ad Inserter settings
606
+ 7. Visualization of HTML tags in post
607
+ 8. Visualization of positions for automatic insertion in post
608
+ 9. Visualization of inserted block in post
609
+ 10. Alignment **Left**, **None** - None means default (usually left) aligned ad block with thin margin around
610
+ 11. Alignment **Right** - Right aligned ad block with thin margin around
611
+ 12. Alignment **Center** - Center aligned ad block with thin margin around
612
+ 13. Alignment **No Wrapping** - Default (usually left) aligned ad block **with no margin around**
613
+ 14. Alignment **Custom CSS** - Ad block with custom CSS (no margin around). You can use it for special effects (border, background, padding, margin, floating, etc.)
614
+ 15. Alignment **Float Left** - Left aligned ad block with thin margin around wrapped with text on the right
615
+ 16. Alignment **Float Right** - Right aligned ad block with thin margin around wrapped with text on the left
616
+ 17. Complete settings for one code block (Before Paragraph)
617
 
618
 
619
  == Changelog ==
620
 
621
+ = 2.0.8 =
622
+ - Added support for client-side rotation (works with caching)
623
+ - Added support for server-side rotation with W3 Total Cache
624
+ - Added support for client-side country detection (works with caching, Pro only)
625
+ - Added support for server-side country detection with W3 Total Cache (Pro only)
626
+ - Added debugging functions to measure plugin processing time
627
+ - Added option to black/white-list IP addresses (Pro only)
628
+ - Added option for fallback code when scheduling between dates expires (Pro only)
629
+ - On multisite installations Ad Inserter debug menu item on sites is available only if settings page is enabled
630
+ - Added option for multisite installations to use Ad Inserter settings of main site for all blogs
631
+ - Added flags to country list (Pro only)
632
+ - Bug fix: Code preview did not work if Wordpress was installed in a folder
633
+ - Few minor bug fixes and cosmetic changes
634
+
635
  = 2.0.7 =
636
  - Delayed display moved to Misc group
637
  - Added option for scheduling to insert code only between specified dates (Pro only)
902
 
903
  == Upgrade Notice ==
904
 
905
+ = 2.0.8 =
906
+ Added support for client-side rotation (works with caching), added support for W3 Total Cache, client-side country detection (works with caching, Pro only),
907
+ bug fixed: Code preview did not work if Wordpress was installed in a folder, added flags to country list (Pro only)
908
+
909
  = 2.0.7 =
910
+ Delayed display moved to Misc group, added option for scheduling to insert code only between specified dates (Pro only),
911
+ added option for Geo targeting (Pro only), few minor bug fixes and cosmetic changes
 
 
912
 
913
  = 2.0.6 =
914
+ Added support to filter subpages created by the `<!--nextpage-->` tag, added option to import block name (Pro only),
915
+ cookie deleted only when it exists and debugging is disabled, few minor bug fixes
 
 
916
 
917
  = 2.0.5 =
918
+ cookie created only when debugging is enabled, few minor bug fixes
 
919
 
920
  = 2.0.4 =
921
+ Bug fix: Cursor position always at the end of block name, state of debugging functions saved to cookie, few minor bug fixes
 
 
922
 
923
  = 2.0.3 =
924
+ Debugging functions in admin toolbar available only for administrators, added option to hide debugging functions in admin toolbar,
925
+ Added shortcode for debugger, few minor bug fixes
 
 
926
 
927
  = 2.0.2 =
928
+ Changed javascript version check to get plugin version from the HTML page, added warning if old cached version of CSS file is loaded on the settings page,
929
+ added warning if version query parameter for js/css files is removed due to inappropriate caching,
 
930
 
931
  = 2.0.1 =
932
  Bug fix: Shortcodes called by name were not displayed
933
 
934
  = 2.0.0 =
935
+ Redesigned user interface, added code preview and many debugging tools for easier troubleshooting and many new features
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.jpg DELETED
Binary file
screenshot-10.jpg DELETED
Binary file
screenshot-11.jpg DELETED
Binary file
screenshot-12.jpg DELETED
Binary file
screenshot-13.jpg DELETED
Binary file
screenshot-2.jpg DELETED
Binary file
screenshot-3.jpg DELETED
Binary file
screenshot-4.jpg DELETED
Binary file
screenshot-5.jpg DELETED
Binary file
screenshot-6.jpg DELETED
Binary file
screenshot-7.jpg DELETED
Binary file
screenshot-8.jpg DELETED
Binary file
screenshot-9.jpg DELETED
Binary file
settings.php CHANGED
@@ -352,7 +352,7 @@ function generate_settings_form (){
352
  <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
353
  <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url, Referer (domain) or Country"><span style="<?php echo $lists_style; ?>">Lists</span></button>
354
  <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
355
- <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>">Preview</button>
356
  </div>
357
  <div style="float: right;">
358
  <?php if (function_exists ('ai_settings_bottom_buttons')) ai_settings_bottom_buttons ($start, $end); else { ?>
@@ -840,7 +840,7 @@ function generate_settings_form (){
840
  Filter insertions
841
  </span>
842
  <span style="display: table-cell;">
843
- <input style="border-radius: 5px; width: 100%; padding-right: 10px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_call_filter(); ?>" value="<?php echo $obj->get_call_filter(); ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, empty 0 means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="16" maxlength="20" />
844
  </span>
845
  <span style="display: table-cell;">
846
  &nbsp;&nbsp;&nbsp;Counter for filter
@@ -871,7 +871,7 @@ function generate_settings_form (){
871
  <div style="margin: 8px 0;">
872
  <select style="border-radius: 5px; margin-bottom: 0px;" id="scheduling-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_SCHEDULING, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_scheduling(); ?>">
873
  <option value="<?php echo AI_SCHEDULING_OFF; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_OFF) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_OFF; ?></option>
874
- <option value="<?php echo AI_SCHEDULING_DELAY; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_DELAY) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DELAY_DISPLAY; ?></option>
875
  <?php if (function_exists ('ai_scheduling_options')) ai_scheduling_options ($obj); ?>
876
  </select>
877
 
@@ -982,11 +982,13 @@ function generate_settings_form (){
982
 
983
  <div id="tab-general" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
984
 
 
985
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
986
-
987
- <div style="margin: 8px;">
988
- Syntax Highlighter Theme &nbsp;&nbsp;&nbsp;
989
-
 
990
  <select
991
  style="border-radius: 5px; width:220px"
992
  id="syntax-highlighter-theme"
@@ -1032,24 +1034,47 @@ function generate_settings_form (){
1032
  <option value="vibrant_ink" <?php echo ($syntax_highlighter_theme == 'vibrant_ink') ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>>Vibrant Ink</option>
1033
  </optgroup>
1034
  </select>
1035
- </div>
1036
-
1037
- <div style="margin: 8px;">
1038
- Block Class Name &nbsp;&nbsp;&nbsp;
1039
- <input style="border-radius: 5px; margin-left: 0px;" title="CSS Class Name" type="text" id="block-class-name" name="block-class-name" value="<?php echo $block_class_name; ?>" size="15" maxlength="40" />
1040
- <span style= "margin: 3px 10px 0 0; display: inline; float: right;">Example: &nbsp;&nbsp; <pre style= "display: inline; color: blue;">&lt;div class="<?php echo $block_class_name; ?> <?php echo $block_class_name; ?>-n"&gt;<span style= "color: black;">...</span>&lt;/div&gt;</pre></span>
1041
- </div>
1042
-
1043
- <div style="margin: 8px;">
1044
- Minimum User Role for Page/Post Ad Inserter Exceptions Editing
 
 
 
 
 
1045
  <select style="border-radius: 5px; margin-bottom: 3px;" id="minimum-user-role" name="minimum-user-role" selected-value="1" style="width:300px">
1046
  <?php wp_dropdown_roles (get_minimum_user_role ()); ?>
1047
  </select>
1048
- </div>
1049
-
1050
- <div style="margin: 8px;">
1051
- Plugin priority <input style="border-radius: 5px;" type="text" name="plugin_priority" value="<?php echo get_plugin_priority (); ?>" size="6" maxlength="6" />
1052
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1053
  </div>
1054
 
1055
  <div id="tab-viewports" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
@@ -1260,7 +1285,7 @@ function generate_settings_form (){
1260
 
1261
  var image = jQuery("#monitors-image");
1262
  if (image.height () < 100) {
1263
- image.hide ().after (image.clone ().attr ('class', '').attr ("id", 'monitors-image-ajax').attr ('src', '/wp-admin/admin-ajax.php?action=ai_preview&image=monitors.png&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').css ('display', 'block'));
1264
  }
1265
  }
1266
  </script>
352
  <button id="device-detection-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
353
  <button id="lists-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url, Referer (domain) or Country"><span style="<?php echo $lists_style; ?>">Lists</span></button>
354
  <button id="manual-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
355
+ <button id="preview-button-<?php echo $ad_number; ?>" type="button" style="display: none; margin-right: 4px;" title="Preview saved code above" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">Preview</button>
356
  </div>
357
  <div style="float: right;">
358
  <?php if (function_exists ('ai_settings_bottom_buttons')) ai_settings_bottom_buttons ($start, $end); else { ?>
840
  Filter insertions
841
  </span>
842
  <span style="display: table-cell;">
843
+ <input style="border-radius: 5px; width: 100%; padding-right: 10px;" type="text" name="<?php echo AI_OPTION_EXCERPT_NUMBER, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_call_filter(); ?>" value="<?php echo $obj->get_call_filter(); ?>" title= "Filter insertions by specifying wanted calls for this block - single number or comma separated numbers, empty means all / no limits. Set Counter for filter to Auto if you are using only one insertion type." size="16" maxlength="20" />
844
  </span>
845
  <span style="display: table-cell;">
846
  &nbsp;&nbsp;&nbsp;Counter for filter
871
  <div style="margin: 8px 0;">
872
  <select style="border-radius: 5px; margin-bottom: 0px;" id="scheduling-<?php echo $ad_number; ?>" name="<?php echo AI_OPTION_SCHEDULING, WP_FORM_FIELD_POSTFIX, $ad_number; ?>" default="<?php echo $default->get_scheduling(); ?>">
873
  <option value="<?php echo AI_SCHEDULING_OFF; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_OFF) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_OFF; ?></option>
874
+ <option value="<?php echo AI_SCHEDULING_DELAY; ?>" <?php echo ($obj->get_scheduling() == AI_SCHEDULING_DELAY) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DELAY_INSERTION; ?></option>
875
  <?php if (function_exists ('ai_scheduling_options')) ai_scheduling_options ($obj); ?>
876
  </select>
877
 
982
 
983
  <div id="tab-general" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
984
 
985
+ <table>
986
  <?php if (function_exists ('ai_general_settings')) ai_general_settings (); ?>
987
+ <tr>
988
+ <td>
989
+ Syntax Highlighter Theme
990
+ </td>
991
+ <td>
992
  <select
993
  style="border-radius: 5px; width:220px"
994
  id="syntax-highlighter-theme"
1034
  <option value="vibrant_ink" <?php echo ($syntax_highlighter_theme == 'vibrant_ink') ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>>Vibrant Ink</option>
1035
  </optgroup>
1036
  </select>
1037
+ </td>
1038
+ </tr>
1039
+ <tr>
1040
+ <td>
1041
+ Block Class Name
1042
+ </td>
1043
+ <td>
1044
+ <input style="border-radius: 5px; margin-left: 0px;" title="CSS Class Name for the wrapping div" type="text" id="block-class-name" name="block-class-name" value="<?php echo $block_class_name; ?>" size="15" maxlength="40" />
1045
+ </td>
1046
+ </tr>
1047
+ <tr>
1048
+ <td style="padding-right: 10px;">
1049
+ Minimum User Role for Exceptions Editing
1050
+ </td>
1051
+ <td>
1052
  <select style="border-radius: 5px; margin-bottom: 3px;" id="minimum-user-role" name="minimum-user-role" selected-value="1" style="width:300px">
1053
  <?php wp_dropdown_roles (get_minimum_user_role ()); ?>
1054
  </select>
1055
+ </td>
1056
+ </tr>
1057
+ <tr>
1058
+ <td>
1059
+ Dynamic blocks
1060
+ </td>
1061
+ <td>
1062
+ <select style="border-radius: 5px; margin-bottom: 3px;" id="dynamic_blocks" name="dynamic_blocks">
1063
+ <option value="<?php echo AI_DYNAMIC_BLOCKS_SERVER_SIDE; ?>" <?php echo get_dynamic_blocks() == AI_DYNAMIC_BLOCKS_SERVER_SIDE ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SERVER_SIDE; ?></option>
1064
+ <option value="<?php echo AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC; ?>" <?php echo get_dynamic_blocks() == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SERVER_SIDE_W3TC; ?></option>
1065
+ <option value="<?php echo AI_DYNAMIC_BLOCKS_CLIENT_SIDE; ?>" <?php echo get_dynamic_blocks() == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CLIENT_SIDE; ?></option>
1066
+ </select>
1067
+ </td>
1068
+ </tr>
1069
+ <tr>
1070
+ <td>
1071
+ Plugin priority
1072
+ </td>
1073
+ <td>
1074
+ <input style="border-radius: 5px;" type="text" name="plugin_priority" value="<?php echo get_plugin_priority (); ?>" size="6" maxlength="6" />
1075
+ </td>
1076
+ </tr>
1077
+ </table>
1078
  </div>
1079
 
1080
  <div id="tab-viewports" style="margin: 8px 0; padding: 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1285
 
1286
  var image = jQuery("#monitors-image");
1287
  if (image.height () < 100) {
1288
+ image.hide ().after (image.clone ().attr ('class', '').attr ("id", 'monitors-image-ajax').attr ('src', '<?php echo wp_make_link_relative (get_site_url()); ?>/wp-admin/admin-ajax.php?action=ai_data&image=monitors.png&ai_check=<?php echo wp_create_nonce ('adinserter_data'); ?>').css ('display', 'block'));
1289
  }
1290
  }
1291
  </script>