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

Version Description

  • Added display of header and footer code in Label blocks debugging function
  • Added AdSense ad overlays in Label blocks debugging function (experimental)
  • Fixed bug for removed square brackets in HTML element selectors
  • Fixed preview of AdSense ad units
  • Few minor bug fixes
Download this release

Release Info

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

Code changes from version 2.3.4 to 2.3.5

ad-inserter.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /*
4
  Plugin Name: Ad Inserter
5
- Version: 2.3.4
6
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
7
  Author: Igor Funa
8
  Author URI: http://igorfuna.com/
@@ -13,6 +13,13 @@ Plugin URI: http://adinserter.pro/documentation
13
 
14
  Change Log
15
 
 
 
 
 
 
 
 
16
  Ad Inserter 2.3.4 - 2018-03-05
17
  - Added support for author:author-username items in taxonomy list
18
  - Fixed errors when downgrading from Pro
@@ -1859,7 +1866,8 @@ function ai_replace_js_data ($js) {
1859
  $js = str_replace ('AI_ADB_MESSAGE_WINDOW', "jQuery ('<div>', {attr: {'style': jQuery.base64Decode ('" . base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_MESSAGE_CSS) . get_message_css ()) . "')}, 'html': jQuery.base64Decode ('" .
1860
  base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), do_shortcode ($adb->ai_getCode ()))) . "')})", $js);
1861
 
1862
- $js = str_replace ('AI_ADB_SELECTORS', str_replace (' ', '', get_adb_selectors ()), $js);
 
1863
 
1864
  $redirection_page = get_redirection_page ();
1865
  if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ());
@@ -2333,6 +2341,25 @@ function get_adb_status_debug_info () {
2333
  }
2334
 
2335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2336
  function ai_http_header () {
2337
  global $block_object, $ai_wp_data;
2338
 
@@ -2370,6 +2397,7 @@ function ai_wp_head_hook () {
2370
  add_head_inline_styles_and_scripts ();
2371
 
2372
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
 
2373
 
2374
  $obj = $block_object [AI_HEADER_OPTION_NAME];
2375
  // $obj->clear_code_cache (); // cleared at ai_http_header
@@ -2377,6 +2405,8 @@ function ai_wp_head_hook () {
2377
  if ($obj->get_enable_manual ()) {
2378
  if ($obj->check_server_side_detection ()) {
2379
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
 
 
2380
  $processed_code = do_shortcode ($obj->ai_getCode ());
2381
 
2382
  if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
@@ -2389,6 +2419,8 @@ function ai_wp_head_hook () {
2389
  $processed_code = $codes [0];
2390
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2391
 
 
 
2392
  echo $processed_code;
2393
  }
2394
  }
@@ -2415,6 +2447,17 @@ function ai_wp_head_hook () {
2415
  </script>\n";
2416
  }
2417
 
 
 
 
 
 
 
 
 
 
 
 
2418
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2419
  echo "<script>
2420
  jQuery(document).ready(function($) {
@@ -2543,6 +2586,7 @@ function ai_wp_footer_hook () {
2543
  if ($ai_wp_data [AI_DISABLE_CACHING]) ai_disable_caching ();
2544
 
2545
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
 
2546
 
2547
  $footer = $block_object [AI_FOOTER_OPTION_NAME];
2548
  $footer->clear_code_cache ();
@@ -2550,6 +2594,7 @@ function ai_wp_footer_hook () {
2550
  if ($footer->get_enable_manual ()) {
2551
  if ($footer->check_server_side_detection ()) {
2552
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
 
2553
  $processed_code = do_shortcode ($footer->ai_getCode ());
2554
 
2555
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
@@ -2557,6 +2602,8 @@ function ai_wp_footer_hook () {
2557
  $processed_code = $codes [0];
2558
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2559
 
 
 
2560
  echo $processed_code;
2561
  }
2562
  }
@@ -2570,6 +2617,10 @@ function ai_wp_footer_hook () {
2570
  echo get_page_type_debug_info () , "\n";
2571
  }
2572
 
 
 
 
 
2573
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2574
  $ai_total_plugin_time += microtime (true) - $start_time;
2575
  ai_log ("FOOTER HOOK END\n");
@@ -2845,7 +2896,7 @@ function ai_write_debug_info ($write_processing_log = false) {
2845
  echo "\n";
2846
  echo 'ADB DELAY ACTION: ', get_delay_action (), "\n";
2847
  echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2848
- echo 'ADB SELECTORS: ', get_adb_selectors (), "\n";
2849
  $redirection_page = get_redirection_page ();
2850
  echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : 'Custom Url', "\n";
2851
  echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
@@ -2920,6 +2971,7 @@ function ai_write_debug_info ($write_processing_log = false) {
2920
  case AI_OPTION_PARAGRAPH_TEXT:
2921
  case AI_OPTION_AVOID_TEXT_ABOVE:
2922
  case AI_OPTION_AVOID_TEXT_BELOW:
 
2923
  if ($write_processing_log)
2924
  $settings .= "[" . $key . ": " . ai_log_filter_content (html_entity_decode ($obj->wp_options [$key])) . ']'; else
2925
  $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
@@ -3674,12 +3726,14 @@ function get_no_action_period ($return_number = false) {
3674
  return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']);
3675
  }
3676
 
3677
- function get_adb_selectors () {
3678
  global $ai_db_options;
3679
 
3680
  if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'] = '';
3681
 
3682
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS']);
 
 
3683
  }
3684
 
3685
  function get_redirection_page ($return_number = false) {
@@ -3759,10 +3813,14 @@ function filter_option ($option, $value, $delete_escaped_backslashes = true){
3759
  if ($delete_escaped_backslashes)
3760
  $value = str_replace (array ("\\\""), array ("\""), $value);
3761
 
3762
- if ($option == AI_OPTION_DOMAIN_LIST ||
 
 
 
 
 
 
3763
  $option == 'NO_PARAGRAPH_COUNTING_INSIDE' ||
3764
- $option == 'ADB_SELECTORS' ||
3765
- $option == AI_OPTION_HTML_SELECTOR ||
3766
  $option == AI_OPTION_PARAGRAPH_TAGS ||
3767
  $option == AI_OPTION_IP_ADDRESS_LIST ||
3768
  $option == AI_OPTION_COUNTRY_LIST) {
@@ -3835,7 +3893,13 @@ function ai_ajax () {
3835
  // check_ajax_referer ("adinserter_data", "ai_check");
3836
  // check_admin_referer ("adinserter_data", "ai_check");
3837
 
3838
- if (function_exists ('ai_ajax_processing_2')) {
 
 
 
 
 
 
3839
  ai_ajax_processing_2 ();
3840
  }
3841
 
@@ -3854,21 +3918,13 @@ function ai_ajax_backend () {
3854
  require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php';
3855
  generate_code_preview (
3856
  $block,
3857
- // wp_unslash (urldecode ($_POST ["name"])),
3858
  isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : null,
3859
- // urldecode ($_POST ["alignment"]),
3860
  isset ($_POST ["alignment"]) ? base64_decode ($_POST ["alignment"]) : null,
3861
-
3862
  isset ($_POST ["horizontal"]) ? base64_decode ($_POST ["horizontal"]) : null,
3863
  isset ($_POST ["vertical"]) ? base64_decode ($_POST ["vertical"]) : null,
3864
-
3865
- // wp_unslash (urldecode ($_POST ["alignment_css"])),
3866
  isset ($_POST ["alignment_css"]) ? base64_decode ($_POST ["alignment_css"]) : null,
3867
- // wp_unslash (urldecode ($_POST ["custom_css"])),
3868
  isset ($_POST ["custom_css"]) ? base64_decode ($_POST ["custom_css"]) : null,
3869
- // wp_unslash (urldecode (base64_decode ($_POST ["code"]))), // base64_decode after wp_unslash / urldecode ?
3870
  isset ($_POST ["code"]) ? base64_decode ($_POST ["code"]) : null,
3871
- // urldecode ($_POST ["php"]) == 1);
3872
  isset ($_POST ["php"]) ? $_POST ["php"] == 1 : null,
3873
  isset ($_POST ["close"]) ? $_POST ["close"] : null,
3874
  isset ($_POST ["read_only"]) ? true : false
@@ -3898,6 +3954,8 @@ function ai_ajax_backend () {
3898
  '',
3899
  '',
3900
  '',
 
 
3901
  $adsense_error == '' ? $adsense_code : '<div style="color: red;">'.$adsense_error.'</div>',
3902
  false,
3903
  AI_CLOSE_NONE,
@@ -3996,7 +4054,7 @@ function ai_ajax_backend () {
3996
 
3997
  elseif (isset ($_GET ["adsense-code"])) {
3998
  if (defined ('AI_ADSENSE_API')) {
3999
- adsense_code ($_GET ["adsense-code"]);
4000
  }
4001
  }
4002
 
@@ -4468,6 +4526,16 @@ a.ai-debug-center {text-align: center; font-size: 10px; text-decoration: none; c
4468
  .ai-debug-pre {background: #222;}
4469
  .ai-debug-special {background: #fb0; color: #000;}
4470
 
 
 
 
 
 
 
 
 
 
 
4471
  .ai-debug-block {border: 1px solid;}
4472
 
4473
  .ai-debug-block.ai-debug-default {border-color: #e00;}
2
 
3
  /*
4
  Plugin Name: Ad Inserter
5
+ Version: 2.3.5
6
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
7
  Author: Igor Funa
8
  Author URI: http://igorfuna.com/
13
 
14
  Change Log
15
 
16
+ Ad Inserter 2.3.5 - 2018-03-10
17
+ - Added display of header and footer code in Label blocks debugging function
18
+ - Added AdSense ad overlays in Label blocks debugging function (experimental)
19
+ - Fixed bug for removed square brackets in HTML element selectors
20
+ - Fixed preview of AdSense ad units
21
+ - Few minor bug fixes
22
+
23
  Ad Inserter 2.3.4 - 2018-03-05
24
  - Added support for author:author-username items in taxonomy list
25
  - Fixed errors when downgrading from Pro
1866
  $js = str_replace ('AI_ADB_MESSAGE_WINDOW', "jQuery ('<div>', {attr: {'style': jQuery.base64Decode ('" . base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_MESSAGE_CSS) . get_message_css ()) . "')}, 'html': jQuery.base64Decode ('" .
1867
  base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), do_shortcode ($adb->ai_getCode ()))) . "')})", $js);
1868
 
1869
+ // $js = str_replace ('AI_ADB_SELECTORS', str_replace (' ', '', get_adb_selectors (true)), $js);
1870
+ $js = str_replace ('AI_ADB_SELECTORS', get_adb_selectors (true), $js);
1871
 
1872
  $redirection_page = get_redirection_page ();
1873
  if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ());
2341
  }
2342
 
2343
 
2344
+ function get_header_footer_debug_block ($name, $title, $code, $javascript = false) {
2345
+ $message = '';
2346
+ if (strpos ($code, 'enable_page_level_ads') !== false)
2347
+ $message = 'Code for <a style="text-decoration: none; color: #fff; font-weight: bold; box-shadow: none;" href="https://adinserter.pro/adsense-ads#auto-ads" target="_blank">AdSense Auto Ads</a> detected - Code will automatically insert AdSense ads at optimal positions ';
2348
+
2349
+ $debug_script = new ai_block_labels ('ai-debug-script');
2350
+ $debug_block_start = $debug_script->block_start ();
2351
+ $debug_block_start .= $debug_script->bar ($name, '', $message, $title);
2352
+ if ($javascript) $debug_block_start = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_start);
2353
+
2354
+ $debug_block_end = $debug_script->block_end ();
2355
+ if ($javascript) $debug_block_end = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_end);
2356
+
2357
+ $html_code = htmlspecialchars ($code);
2358
+ if ($javascript) $html_code = str_replace (array ("\n", "\r"), array ("\\n", ''), $html_code);
2359
+
2360
+ return $debug_block_start . "<pre class='ai-debug-code'>". $html_code . "</pre>" . $debug_block_end;
2361
+ }
2362
+
2363
  function ai_http_header () {
2364
  global $block_object, $ai_wp_data;
2365
 
2397
  add_head_inline_styles_and_scripts ();
2398
 
2399
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2400
+ $header_code = null;
2401
 
2402
  $obj = $block_object [AI_HEADER_OPTION_NAME];
2403
  // $obj->clear_code_cache (); // cleared at ai_http_header
2405
  if ($obj->get_enable_manual ()) {
2406
  if ($obj->check_server_side_detection ()) {
2407
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2408
+ $header_code = '';
2409
+
2410
  $processed_code = do_shortcode ($obj->ai_getCode ());
2411
 
2412
  if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2419
  $processed_code = $codes [0];
2420
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2421
 
2422
+ $header_code = $processed_code;
2423
+
2424
  echo $processed_code;
2425
  }
2426
  }
2447
  </script>\n";
2448
  }
2449
 
2450
+ if ($header_code !== null && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2451
+ echo "<script>\n";
2452
+ if (defined ('AI_ADSENSE_OVERLAY')) {
2453
+ echo ai_get_js ('ai-ads');
2454
+ }
2455
+ echo " jQuery(document).ready(function($) {
2456
+ $('body').prepend (\"" . get_header_footer_debug_block (' Header code ', '&lt;head&gt;...&lt;/head&gt;', $header_code, true) . "\");
2457
+ });
2458
+ </script>\n";
2459
+ }
2460
+
2461
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2462
  echo "<script>
2463
  jQuery(document).ready(function($) {
2586
  if ($ai_wp_data [AI_DISABLE_CACHING]) ai_disable_caching ();
2587
 
2588
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
2589
+ $footer_code = null;
2590
 
2591
  $footer = $block_object [AI_FOOTER_OPTION_NAME];
2592
  $footer->clear_code_cache ();
2594
  if ($footer->get_enable_manual ()) {
2595
  if ($footer->check_server_side_detection ()) {
2596
  if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
2597
+ $footer_code = '';
2598
  $processed_code = do_shortcode ($footer->ai_getCode ());
2599
 
2600
  if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2602
  $processed_code = $codes [0];
2603
  } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2604
 
2605
+ $footer_code = $processed_code;
2606
+
2607
  echo $processed_code;
2608
  }
2609
  }
2617
  echo get_page_type_debug_info () , "\n";
2618
  }
2619
 
2620
+ if ($footer_code !== null && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2621
+ echo get_header_footer_debug_block (' Footer code ', '...&lt;/body&gt;', $footer_code);
2622
+ }
2623
+
2624
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2625
  $ai_total_plugin_time += microtime (true) - $start_time;
2626
  ai_log ("FOOTER HOOK END\n");
2896
  echo "\n";
2897
  echo 'ADB DELAY ACTION: ', get_delay_action (), "\n";
2898
  echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2899
+ echo 'ADB SELECTORS: ', get_adb_selectors (true), "\n";
2900
  $redirection_page = get_redirection_page ();
2901
  echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : 'Custom Url', "\n";
2902
  echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
2971
  case AI_OPTION_PARAGRAPH_TEXT:
2972
  case AI_OPTION_AVOID_TEXT_ABOVE:
2973
  case AI_OPTION_AVOID_TEXT_BELOW:
2974
+ case AI_OPTION_HTML_SELECTOR:
2975
  if ($write_processing_log)
2976
  $settings .= "[" . $key . ": " . ai_log_filter_content (html_entity_decode ($obj->wp_options [$key])) . ']'; else
2977
  $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
3726
  return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']);
3727
  }
3728
 
3729
+ function get_adb_selectors ($decode = false) {
3730
  global $ai_db_options;
3731
 
3732
  if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'] = '';
3733
 
3734
+ if ($decode)
3735
+ return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])); else
3736
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS']);
3737
  }
3738
 
3739
  function get_redirection_page ($return_number = false) {
3813
  if ($delete_escaped_backslashes)
3814
  $value = str_replace (array ("\\\""), array ("\""), $value);
3815
 
3816
+ if ($option == 'ADB_SELECTORS' ||
3817
+ $option == AI_OPTION_HTML_SELECTOR) {
3818
+ // $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "'", '"'), "", $value);
3819
+ $value = str_replace (array ("\\", "/", "?", "\"", "'", "'", '"'), "", $value);
3820
+ $value = esc_html ($value);
3821
+ }
3822
+ elseif ($option == AI_OPTION_DOMAIN_LIST ||
3823
  $option == 'NO_PARAGRAPH_COUNTING_INSIDE' ||
 
 
3824
  $option == AI_OPTION_PARAGRAPH_TAGS ||
3825
  $option == AI_OPTION_IP_ADDRESS_LIST ||
3826
  $option == AI_OPTION_COUNTRY_LIST) {
3893
  // check_ajax_referer ("adinserter_data", "ai_check");
3894
  // check_admin_referer ("adinserter_data", "ai_check");
3895
 
3896
+ if (isset ($_POST ["adsense-ad-units"])) {
3897
+ if (defined ('AI_ADSENSE_API')) {
3898
+ adsense_ad_name ($_POST ["adsense-ad-units"]);
3899
+ }
3900
+ }
3901
+
3902
+ elseif (function_exists ('ai_ajax_processing_2')) {
3903
  ai_ajax_processing_2 ();
3904
  }
3905
 
3918
  require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php';
3919
  generate_code_preview (
3920
  $block,
 
3921
  isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : null,
 
3922
  isset ($_POST ["alignment"]) ? base64_decode ($_POST ["alignment"]) : null,
 
3923
  isset ($_POST ["horizontal"]) ? base64_decode ($_POST ["horizontal"]) : null,
3924
  isset ($_POST ["vertical"]) ? base64_decode ($_POST ["vertical"]) : null,
 
 
3925
  isset ($_POST ["alignment_css"]) ? base64_decode ($_POST ["alignment_css"]) : null,
 
3926
  isset ($_POST ["custom_css"]) ? base64_decode ($_POST ["custom_css"]) : null,
 
3927
  isset ($_POST ["code"]) ? base64_decode ($_POST ["code"]) : null,
 
3928
  isset ($_POST ["php"]) ? $_POST ["php"] == 1 : null,
3929
  isset ($_POST ["close"]) ? $_POST ["close"] : null,
3930
  isset ($_POST ["read_only"]) ? true : false
3954
  '',
3955
  '',
3956
  '',
3957
+ '',
3958
+ '',
3959
  $adsense_error == '' ? $adsense_code : '<div style="color: red;">'.$adsense_error.'</div>',
3960
  false,
3961
  AI_CLOSE_NONE,
4054
 
4055
  elseif (isset ($_GET ["adsense-code"])) {
4056
  if (defined ('AI_ADSENSE_API')) {
4057
+ ai_adsense_code ($_GET ["adsense-code"]);
4058
  }
4059
  }
4060
 
4526
  .ai-debug-pre {background: #222;}
4527
  .ai-debug-special {background: #fb0; color: #000;}
4528
 
4529
+ .ai-debug-ad-overlay {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #8f8; opacity: 0.6; z-index': '999999990}
4530
+ .ai-auto-ads {background-color: #84f;}
4531
+ .ai-no-slot {background-color: #48f;}
4532
+ .ai-debug-ad-info {position: absolute; top: 0; left: 0; overflow: hidden; width: auto; height: auto; font-size: 11px; line-height: 11px; text-align: left; z-index: 999999991;}
4533
+ .ai-info {display: inline-block; padding: 2px 4px;}
4534
+ .ai-info-1 {background: #000; color: #fff;}
4535
+ .ai-info-2 {background: #fff; color: #000;}
4536
+
4537
+ .ai-debug-code {margin: 0; padding: 0; border: 0; font-family: monospace; font-size: 12px; line-height: 13px;}
4538
+
4539
  .ai-debug-block {border: 1px solid;}
4540
 
4541
  .ai-debug-block.ai-debug-default {border-color: #e00;}
changelog.txt ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ = Changelog archive =
2
+
3
+ This is an archive of older changelog entries. Most recent entries are maintained in readme.txt
4
+
5
+ = 2.2.9 =
6
+ - Output buffering is now disabled by default (for position Above header you need to enable it)
7
+ - Fix for min. paragraph number not processed
8
+
9
+ = 2.2.8 =
10
+ - Added position for automatic insertion Above header (after `<body>` tag)
11
+ - Added rotation code editor
12
+ - Added support to name rotation options
13
+ - Added code generator for banners
14
+ - Added code generator for AdSense
15
+ - Added support to rearrange code blocks
16
+ - Added support to copy any block settings
17
+ - Added support for clipboard to copy/paste block settings
18
+ - Added option to select ad blocking detection mode (Pro only)
19
+ - Delayed insertion on posts now available for all insertion positions
20
+ - Few minor bug fixes, cosmetic changes and code improvements
21
+
22
+ = 2.2.7 =
23
+ - Fix for duplicate amp-custom tag on AMP pages
24
+
25
+ = 2.2.6 =
26
+ - Fix for posts filter counter not counting
27
+ - Added list with short overview of all code blocks
28
+ - Added support for word count on blog pages
29
+ - Added support for client code preview (no need to save it for preview)
30
+ - Improved compatibility on AMP pages
31
+ - Few minor bug fixes, cosmetic changes and code improvements
32
+
33
+ = 2.2.5 =
34
+ - Fix for issue with Ajax requests
35
+
36
+ = 2.2.4 =
37
+ - Added support to insert raw HTTP response header lines
38
+ - Added support to check for individual exceptions for shortcodes
39
+ - Added support to trigger ad blocking detection action only on individual pages
40
+ - Added support for automatic insertion position Footer
41
+ - Added support for custom hooks
42
+ - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE)
43
+ - Fix for |count| separator not processed
44
+
45
+ = 2.2.3 =
46
+ - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
47
+ - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
48
+ - Added support for post-type:POST_TYPE taxonomy list items
49
+ - Added support for JavaScript based sticky widgets
50
+ - Added support for ad blocking statistics (Pro only)
51
+ - Added support for WP AMP and WP AMP Ninja plugins
52
+ - Post/Page Word Count moved to Misc section (now works also on widgets)
53
+ - Few minor bug fixes, cosmetic changes and code improvements
54
+
55
+ = 2.2.2 =
56
+ - Fix for mobile admin layout
57
+ - Few other minor bug fixes
58
+
59
+ = 2.2.1 =
60
+ - Fix for header/footer scripts on AMP pages
61
+
62
+ = 2.2.0 =
63
+ - Added support for ad blocking detection (experimental)
64
+ - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
65
+ - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
66
+ - Added syntax highlighting for shortcodes and separators
67
+ - Added option to define minimum number of words in paragraphs above
68
+ - Added support for %N filter item to filter every N-th insertion
69
+ - Added filter support when inserting for all paragraphs
70
+ - Added style `clear: both;` to Default, Left, Right and Center alignments
71
+ - Bug fix for errors when loading tracking charts (Pro only)
72
+ - Many minor bug fixes, cosmetic changes and code improvements
73
+
74
+ = 2.1.14 =
75
+ - Fix for error when using older PHP versions (prior to 5.5)
76
+
77
+ = 2.1.13 =
78
+ - Fix for Fatal error: Can't use method return value in write context
79
+
80
+ = 2.1.12 =
81
+ - Added option to define tags inside which paragraphs are not counted
82
+ - Added max insertions check when inserting for all paragraphs
83
+ - Added support for inverted filter
84
+ - Increased nonce lifespan to 48 hours when using tracking (Pro only)
85
+ - Fixed wrong urls in debug menu when behind proxy
86
+ - Few other bug fixes, cosmetic changes and code improvements
87
+
88
+ = 2.1.11 =
89
+ - Improved support for sticky widgets (works with most themes)
90
+ - Added support for ad counting (|count| separator)
91
+ - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
92
+ - Added support for automatic insertion before, between and after comments
93
+ - Added processing of shortcodes in the header and footer code
94
+ - Debugging function Show positions shows also page type
95
+ - Fixed page type detection when Post page was set to static page and it was not homepage
96
+ - Few minor bug fixes, cosmetic changes and code improvements
97
+
98
+ = 2.1.10 =
99
+ - Fix for shifted sidebars in some themes
100
+
101
+ = 2.1.9 =
102
+ - Added support for sticky widgets
103
+ - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
104
+ - Impression and click tracking (beta, Pro only)
105
+ - Few minor bug fixes, cosmetic changes and code improvements
106
+
107
+ = 2.1.8 =
108
+ - Fixed error when using server-side device detection
109
+
110
+ = 2.1.7 =
111
+ - Fixed error when using PHP 5.4 or earlier
112
+
113
+ = 2.1.6 =
114
+ - Added support for insertion before/after multiple paragraphs
115
+ - Added initial support for impression and click tracking (Pro only)
116
+ - Few bug fixes and cosmetic changes
117
+
118
+ = 2.1.5 =
119
+ - Added support to avoid insertion inside `<figure>` and `<li>` elements (image captions, lists)
120
+ - Added support for exceptions for custom post types
121
+ - Few minor bug fixes and code improvements
122
+
123
+ = 2.1.4 =
124
+ - Paragraph counting restored to standard functions
125
+ - Added option to select paragraph counting functions with multibyte support (unicode characters)
126
+ - Fixed bug for wrong paragraph counting in posts with blockquote sections in some cases
127
+ - Fixed bug for wrong measuring of plugin processing time in some cases
128
+ - Fixed bug for "Empty delimiter" warning
129
+
130
+ = 2.1.3 =
131
+ - Added support for counting paragraphs with multibyte (unicode) characters
132
+ - Fixed bug for class name not saved
133
+ - Few minor bug fixes and cosmetic changes
134
+
135
+ = 2.1.2 =
136
+ - Fixed bug for disabled settings page on multisite blogs
137
+
138
+ = 2.1.1 =
139
+ - Changes for compatibility with PHP 7.1
140
+ - Automatic rename of old pro plugin slug (Pro only)
141
+ - Added support for additional Pro features (Pro only)
142
+ - Few bug fixes and cosmetic changes
143
+
144
+ = 2.1.0 =
145
+ - Added support to insert ads in Ajax requests (e.g. in infinite scroll)
146
+ - Added support to not include block classes when class name is empty
147
+ - Added sticky positions (Pro only)
148
+ - Bug fix for minimum user role not taken into account for exceptions list
149
+ - Bug fix for IP database update cron event (Pro only)
150
+
class.php CHANGED
@@ -886,8 +886,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
886
  return $this->alignment_style ($this->get_alignment_type());
887
  }
888
 
889
- public function get_html_selector (){
890
  $option = isset ($this->wp_options [AI_OPTION_HTML_SELECTOR]) ? $this->wp_options [AI_OPTION_HTML_SELECTOR] : "";
 
891
  return $option;
892
  }
893
 
@@ -1866,7 +1867,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1866
  }
1867
  elseif ($viewports_insertion && $html_element_insertion) {
1868
  $this->counters = '<span class="ai-selector-counter"></span>';
1869
- $selector = $this->get_html_selector ();
1870
  $viewport_classes = trim ($this->get_viewport_classes ());
1871
 
1872
  $serverside_insertion_code = "<div class='ai-viewports $viewport_classes' data-insertion='$insertion' data-selector='$selector' data-code='[#AI_CODE#]' data-block='{$this->number}'></div>\n";
@@ -1876,7 +1877,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1876
  }
1877
  else { // only HTML element insertion
1878
  $this->counters = '<span class="ai-selector-counter"></span>';
1879
- $selector = $this->get_html_selector ();
1880
 
1881
  $code_before = '';
1882
  $code_after = '';
886
  return $this->alignment_style ($this->get_alignment_type());
887
  }
888
 
889
+ public function get_html_selector ($decode = false){
890
  $option = isset ($this->wp_options [AI_OPTION_HTML_SELECTOR]) ? $this->wp_options [AI_OPTION_HTML_SELECTOR] : "";
891
+ if ($decode) $option = html_entity_decode ($option);
892
  return $option;
893
  }
894
 
1867
  }
1868
  elseif ($viewports_insertion && $html_element_insertion) {
1869
  $this->counters = '<span class="ai-selector-counter"></span>';
1870
+ $selector = $this->get_html_selector (true);
1871
  $viewport_classes = trim ($this->get_viewport_classes ());
1872
 
1873
  $serverside_insertion_code = "<div class='ai-viewports $viewport_classes' data-insertion='$insertion' data-selector='$selector' data-code='[#AI_CODE#]' data-block='{$this->number}'></div>\n";
1877
  }
1878
  else { // only HTML element insertion
1879
  $this->counters = '<span class="ai-selector-counter"></span>';
1880
+ $selector = $this->get_html_selector (true);
1881
 
1882
  $code_before = '';
1883
  $code_after = '';
constants.php CHANGED
@@ -24,7 +24,7 @@ if (!defined( 'AD_INSERTER_NAME'))
24
  define ('AD_INSERTER_NAME', 'Ad Inserter');
25
 
26
  if (!defined( 'AD_INSERTER_VERSION'))
27
- define ('AD_INSERTER_VERSION', '2.3.4');
28
 
29
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
30
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -595,6 +595,7 @@ define ('AI_AMP_HEADER_STYLES', true);
595
  define ('AI_CODE_GENERATOR', true);
596
  define ('AI_BUFFERING', true);
597
  define ('AI_ADSENSE_API', true);
 
598
  //define ('AI_STICKY_SETTINGS', true);
599
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
600
  define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
24
  define ('AD_INSERTER_NAME', 'Ad Inserter');
25
 
26
  if (!defined( 'AD_INSERTER_VERSION'))
27
+ define ('AD_INSERTER_VERSION', '2.3.5');
28
 
29
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
30
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
595
  define ('AI_CODE_GENERATOR', true);
596
  define ('AI_BUFFERING', true);
597
  define ('AI_ADSENSE_API', true);
598
+ define ('AI_ADSENSE_OVERLAY', true);
599
  //define ('AI_STICKY_SETTINGS', true);
600
  define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
601
  define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.3.4"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #ai-data {
2
+ font-family: "2.3.5"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
includes/js/ai-ads.js ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var adsense_ad_names = [];
2
+ var ai_preview_window = typeof ai_preview !== 'undefined';
3
+
4
+ function ai_process_adsense_ads ($) {
5
+ var ai_debug = typeof ai_debugging !== 'undefined';
6
+ $('ins ins iframe').each (function () {
7
+ var adsense_iframe = $(this);
8
+ var adsense_width = adsense_iframe.attr ('width');
9
+ var adsense_height = adsense_iframe.attr ('height');
10
+ var adsense_iframe2 = adsense_iframe.contents().find ('iframe[allowtransparency]');
11
+ var url_parameters = getAllUrlParams (adsense_iframe2.attr ('src'))
12
+
13
+ if (typeof url_parameters ['client'] !== 'undefined') {
14
+ var adsense_ad_client = url_parameters ['client'];
15
+ var adsense_publisher_id = adsense_ad_client.replace ('ca-', '');
16
+ var adsense_ad_slot = url_parameters ['slotname'];
17
+ var adsense_index = url_parameters ['ifi'];
18
+
19
+ if (ai_debug) console.log ('AI ADSENSE', adsense_index, adsense_ad_client, adsense_ad_slot, url_parameters ['format'], url_parameters ['w'], url_parameters ['h']);
20
+
21
+ var adsense_overlay = $('<div class="ai-debug-ad-overlay"></div>');
22
+
23
+ var adsense_ad_info = '';
24
+ if (typeof adsense_ad_slot !== 'undefined') {
25
+ var adsense_ad_name = '';
26
+ if (typeof adsense_ad_names ['publisher_id'] !== 'undefined' &&
27
+ adsense_ad_names ['publisher_id'] == adsense_publisher_id &&
28
+ typeof adsense_ad_names [adsense_ad_slot] !== 'undefined') {
29
+ adsense_ad_name = '<div class="ai-info ai-info-2">' + adsense_ad_names [adsense_ad_slot] + '</div>';
30
+ }
31
+ adsense_ad_info = '<div class="ai-info ai-info-1">' + adsense_ad_slot + '</div>' + adsense_ad_name;
32
+ } else {
33
+ var adsense_auto_ads = adsense_iframe.closest ('div.google-auto-placed').length != 0;
34
+ if (adsense_auto_ads) {
35
+ adsense_overlay.addClass ('ai-auto-ads');
36
+ adsense_ad_info = '<div class="ai-info ai-info-1">Auto ads</div>';
37
+ } else adsense_overlay.addClass ('ai-no-slot');
38
+ }
39
+
40
+ var adsense_info = $('<div class="ai-debug-ad-info"><div class="ai-info ai-info-1">AdSense #' + adsense_index + '</div><div class="ai-info ai-info-2">' + adsense_width + 'x' + adsense_height + '</div>' + adsense_ad_info + '</div>');
41
+
42
+ adsense_iframe.after (adsense_info);
43
+
44
+ if (!ai_preview_window) {
45
+ adsense_iframe.after (adsense_overlay);
46
+ }
47
+ }
48
+ });
49
+ }
50
+
51
+ jQuery(document).ready(function($) {
52
+ var ai_debug = typeof ai_debugging !== 'undefined';
53
+ var nonce = 'AI_NONCE';
54
+ var adsense_data = {'ai': 1}; // dummy
55
+
56
+ $.post (ajaxurl, {'action': 'ai_ajax', 'ai_check': nonce, 'adsense-ad-units': adsense_data}
57
+ ).done (function (data) {
58
+ if (data != '') {
59
+ try {
60
+ adsense_ad_names = JSON.parse (data);
61
+
62
+ if (ai_debug) console.log ("AI ADSENSE DATA:", Object.keys (adsense_ad_names).length - 1, 'ad units');
63
+
64
+ } catch (error) {
65
+ if (ai_debug) console.log ("AI ADSENSE DATA ERROR:", data);
66
+ }
67
+ }
68
+ }).fail (function (xhr, status, error) {
69
+ if (ai_debug) console.log ("AI ADSENSE DATA ERROR:", xhr.status, xhr.statusText);
70
+ }).always (function (data) {
71
+ if (ai_debug) console.log ('AI ADSENSE DATA', 'END');
72
+ });
73
+
74
+ if (!ai_preview_window) setTimeout (function() {ai_process_adsense_ads (jQuery);}, 2000);
75
+ });
76
+
77
+ function getAllUrlParams (url) {
78
+
79
+ // get query string from url (optional) or window
80
+ var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
81
+
82
+ // we'll store the parameters here
83
+ var obj = {};
84
+
85
+ // if query string exists
86
+ if (queryString) {
87
+
88
+ // stuff after # is not part of query string, so get rid of it
89
+ queryString = queryString.split('#')[0];
90
+
91
+ // split our query string into its component parts
92
+ var arr = queryString.split('&');
93
+
94
+ for (var i=0; i<arr.length; i++) {
95
+ // separate the keys and the values
96
+ var a = arr[i].split('=');
97
+
98
+ // in case params look like: list[]=thing1&list[]=thing2
99
+ var paramNum = undefined;
100
+ var paramName = a[0].replace(/\[\d*\]/, function(v) {
101
+ paramNum = v.slice(1,-1);
102
+ return '';
103
+ });
104
+
105
+ // set parameter value (use 'true' if empty)
106
+ var paramValue = typeof(a[1])==='undefined' ? true : a[1];
107
+
108
+ // (optional) keep case consistent
109
+ paramName = paramName.toLowerCase();
110
+ paramValue = paramValue.toLowerCase();
111
+
112
+ // if parameter name already exists
113
+ if (obj[paramName]) {
114
+ // convert value to array (if still string)
115
+ if (typeof obj[paramName] === 'string') {
116
+ obj[paramName] = [obj[paramName]];
117
+ }
118
+ // if no array index number specified...
119
+ if (typeof paramNum === 'undefined') {
120
+ // put the value on the end of the array
121
+ obj[paramName].push(paramValue);
122
+ }
123
+ // if array index number specified...
124
+ else {
125
+ // put the value at that index number
126
+ obj[paramName][paramNum] = paramValue;
127
+ }
128
+ }
129
+ // if param name doesn't exist yet, set it
130
+ else {
131
+ obj[paramName] = paramValue;
132
+ }
133
+ }
134
+ }
135
+
136
+ return obj;
137
+ }
138
+
includes/js/ai-ads.min.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ var adsense_ad_names=[];var ai_preview_window=typeof ai_preview!=="undefined";
2
+ function ai_process_adsense_ads($){var ai_debug=typeof ai_debugging!=="undefined";$("ins ins iframe").each(function(){var adsense_iframe=$(this);var adsense_width=adsense_iframe.attr("width");var adsense_height=adsense_iframe.attr("height");var adsense_iframe2=adsense_iframe.contents().find("iframe[allowtransparency]");var url_parameters=getAllUrlParams(adsense_iframe2.attr("src"));if(typeof url_parameters["client"]!=="undefined"){var adsense_ad_client=url_parameters["client"];var adsense_publisher_id=
3
+ adsense_ad_client.replace("ca-","");var adsense_ad_slot=url_parameters["slotname"];var adsense_index=url_parameters["ifi"];if(ai_debug)console.log("AI ADSENSE",adsense_index,adsense_ad_client,adsense_ad_slot,url_parameters["format"],url_parameters["w"],url_parameters["h"]);var adsense_overlay=$('<div class="ai-debug-ad-overlay"></div>');var adsense_ad_info="";if(typeof adsense_ad_slot!=="undefined"){var adsense_ad_name="";if(typeof adsense_ad_names["publisher_id"]!=="undefined"&&adsense_ad_names["publisher_id"]==
4
+ adsense_publisher_id&&typeof adsense_ad_names[adsense_ad_slot]!=="undefined")adsense_ad_name='<div class="ai-info ai-info-2">'+adsense_ad_names[adsense_ad_slot]+"</div>";adsense_ad_info='<div class="ai-info ai-info-1">'+adsense_ad_slot+"</div>"+adsense_ad_name}else{var adsense_auto_ads=adsense_iframe.closest("div.google-auto-placed").length!=0;if(adsense_auto_ads){adsense_overlay.addClass("ai-auto-ads");adsense_ad_info='<div class="ai-info ai-info-1">Auto ads</div>'}else adsense_overlay.addClass("ai-no-slot")}var adsense_info=
5
+ $('<div class="ai-debug-ad-info"><div class="ai-info ai-info-1">AdSense #'+adsense_index+'</div><div class="ai-info ai-info-2">'+adsense_width+"x"+adsense_height+"</div>"+adsense_ad_info+"</div>");adsense_iframe.after(adsense_info);if(!ai_preview_window)adsense_iframe.after(adsense_overlay)}})}
6
+ jQuery(document).ready(function($){var ai_debug=typeof ai_debugging!=="undefined";var nonce="AI_NONCE";var adsense_data={"ai":1};$.post(ajaxurl,{"action":"ai_ajax","ai_check":nonce,"adsense-ad-units":adsense_data}).done(function(data){if(data!="")try{adsense_ad_names=JSON.parse(data);if(ai_debug)console.log("AI ADSENSE DATA:",Object.keys(adsense_ad_names).length-1,"ad units")}catch(error){if(ai_debug)console.log("AI ADSENSE DATA ERROR:",data)}}).fail(function(xhr,status,error){if(ai_debug)console.log("AI ADSENSE DATA ERROR:",
7
+ xhr.status,xhr.statusText)}).always(function(data){if(ai_debug)console.log("AI ADSENSE DATA","END")});if(!ai_preview_window)setTimeout(function(){ai_process_adsense_ads(jQuery)},2E3)});
8
+ function getAllUrlParams(url){var queryString=url?url.split("?")[1]:window.location.search.slice(1);var obj={};if(queryString){queryString=queryString.split("#")[0];var arr=queryString.split("&");for(var i=0;i<arr.length;i++){var a=arr[i].split("=");var paramNum=undefined;var paramName=a[0].replace(/\[\d*\]/,function(v){paramNum=v.slice(1,-1);return""});var paramValue=typeof a[1]==="undefined"?true:a[1];paramName=paramName.toLowerCase();paramValue=paramValue.toLowerCase();if(obj[paramName]){if(typeof obj[paramName]===
9
+ "string")obj[paramName]=[obj[paramName]];if(typeof paramNum==="undefined")obj[paramName].push(paramValue);else obj[paramName][paramNum]=paramValue}else obj[paramName]=paramValue}}return obj};
includes/preview.php CHANGED
@@ -27,6 +27,8 @@ function padding_margin_code ($close_button, $class, $wrapper_css, $block_code)
27
  <!-- IE bug: use inline CSS: position: absolute;-->
28
  <div id='code-background-white' class= "code-background-white" style="position: absolute;"></div>
29
  <div id='code-overlay' class="code-overlay" style="position: absolute;"></div>
 
 
30
  <?php
31
  }
32
 
@@ -88,7 +90,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
88
  // Disable AdSense Auto ads (page level ads)
89
  $head_code = str_replace ('enable_page_level_ads', 'disabled_page_level_ads', $head_code);
90
 
91
- $block_code = $obj->ai_getProcessedCode (true, true, $client_code, $process_php);
92
 
93
  // Fix for relative urls
94
  $block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
@@ -113,7 +115,9 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
113
  <script>
114
 
115
  // initialize_preview ();
116
- <?php echo get_frontend_javascript_debugging () ? 'ai_debugging = true;' : ''; ?>;
 
 
117
  var sticky = <?php echo $sticky ? 'true' : 'false'; ?>;
118
  if (sticky) window.resizeTo (screen.width, screen.height);
119
 
@@ -125,7 +129,8 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
125
 
126
  function initialize_preview () {
127
 
128
- var debug = <?php echo get_backend_javascript_debugging () ? 'true' : 'false'; ?>;
 
129
  var block = <?php echo $block; ?>;
130
  var code_blocks;
131
  var spinning = false;
@@ -247,7 +252,8 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
247
  // document.write = oldDocumentWrite
248
  // }, 1000);
249
 
250
- console.log (settings.find ("select#block-alignment-" + block + " option:selected").attr('value'));
 
251
  $("select#block-alignment").val (settings.find ("select#block-alignment-" + block + " option:selected").attr('value')).change();
252
  $("select#block-alignment option:selected").data ('alt-style', '1');
253
  $("#custom-css").val (settings.find ("#custom-css-" + block).val ());
@@ -341,7 +347,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
341
 
342
  function process_display_elements () {
343
 
344
- console.log ('process_display_elements');
345
 
346
  var style = "";
347
  $("#css-label").css('display', 'inline-block');
@@ -445,7 +451,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
445
 
446
  $("#wrapper").attr ("style", style);
447
 
448
- console.log ('process_display_elements');
449
 
450
  if (wrapping) update_margin_padding ();
451
 
@@ -455,7 +461,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
455
 
456
  function update_custom_css () {
457
 
458
- console.log ('update_custom_css');
459
 
460
  $("#custom-css").val ($("#wrapper").attr ("style"));
461
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
@@ -516,7 +522,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
516
 
517
  function update_sticky_css (context) {
518
 
519
- console.log ('update_sticky_css', context, 'sticky_context', sticky_context);
520
 
521
  if (sticky_context != context) return;
522
 
@@ -539,7 +545,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
539
 
540
  $('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css').text (vertical_position_css + horizontal_position_css);
541
 
542
- console.log ('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css', vertical_position_css + horizontal_position_css);
543
 
544
 
545
  $('#wrapper').removeClass ('ai-sticky-content').removeClass ('ai-sticky-left').removeClass ('ai-sticky-right').removeClass ('ai-sticky-scroll');
@@ -577,7 +583,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
577
 
578
  function update_sticky_elements (context) {
579
 
580
- console.log ('update_sticky_elements', context, 'sticky_context', sticky_context);
581
 
582
  if (sticky_context != context) return;
583
 
@@ -599,14 +605,14 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
599
 
600
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_BLOCK_ALIGNMENT;
601
 
602
- console.log ('select#block-alignment change', $("select#block-alignment option:selected").attr ('value'));
603
 
604
  if (sticky) update_sticky_css (STICKY_CONTEXT_BLOCK_ALIGNMENT);
605
 
606
  process_display_elements ();
607
  update_close_button ();
608
 
609
- console.log ('select#block-alignment');
610
 
611
  if (sticky) update_sticky_elements (STICKY_CONTEXT_BLOCK_ALIGNMENT);
612
 
@@ -621,14 +627,14 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
621
  $("select#horizontal-position").change (function() {
622
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_HORIZONTAL_POSITION;
623
 
624
- console.log ('select#horizontal-position change');
625
 
626
  if (sticky_context == STICKY_CONTEXT_HORIZONTAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
627
  update_sticky_css (STICKY_CONTEXT_HORIZONTAL_POSITION);
628
  process_display_elements ();
629
  update_close_button ();
630
 
631
- console.log ('select#horizontal-position');
632
 
633
  update_sticky_elements (STICKY_CONTEXT_HORIZONTAL_POSITION);
634
  update_highlighting ();
@@ -639,14 +645,14 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
639
  $("select#vertical-position").change (function() {
640
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_VERTICAL_POSITION;
641
 
642
- console.log ('select#vertical-position change');
643
 
644
  if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
645
  update_sticky_css (STICKY_CONTEXT_VERTICAL_POSITION);
646
  process_display_elements ();
647
  update_close_button ();
648
 
649
- console.log ('select#vertical-position');
650
 
651
  update_sticky_elements (STICKY_CONTEXT_VERTICAL_POSITION);
652
  update_highlighting ();
@@ -736,12 +742,12 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
736
  $("#custom-css").on ('input', function() {
737
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_CUSTOM_CSS;
738
 
739
- console.log ('#custom-css input');
740
 
741
  if (wrapping) $("#wrapper").attr ("style", $("#custom-css").val ());
742
  if (sticky) update_sticky_css (STICKY_CONTEXT_CUSTOM_CSS);
743
 
744
- console.log ('#custom-css');
745
 
746
  if (sticky) update_sticky_elements (STICKY_CONTEXT_CUSTOM_CSS);
747
  update_margin_padding ();
@@ -758,9 +764,26 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
758
 
759
  if (!$('body').hasClass ("highlighted")) {
760
  $(".highlighting").remove ();
 
761
  return;
762
  }
763
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
764
  if (wrapping) {
765
 
766
  var overlay_position = '';
@@ -868,6 +891,7 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
868
  code_index ++;
869
  var element_offset = $(this).offset ();
870
 
 
871
  var element_left = element_offset.left;
872
  var element_top = element_offset.top;
873
  var element_outer_width = $(this).outerWidth ();
@@ -876,13 +900,15 @@ function generate_code_preview ($block, $name = null, $alignment = null, $horizo
876
  if (debug) {
877
  console.log ("");
878
  console.log ("element " + code_index + ": " + element_tag);
879
-
880
  console.log ("element_left: " + element_left);
881
  console.log ("element_top: " + element_top);
882
  console.log ("element_outer_width: " + element_outer_width);
883
  console.log ("element_outer_height: " + element_outer_height);
884
  }
885
 
 
 
886
  var overlay_div_position = overlay_div.css ('position');
887
  var overlay_background_div_position = overlay_background_div.css ('position');
888
  var fixed_offset_top = 0;
@@ -1111,6 +1137,9 @@ body.sticky {
1111
  background: rgba(50, 140, 220, 0.5);
1112
  display: block;
1113
  }
 
 
 
1114
 
1115
  table.screen td {
1116
  padding: 0;
@@ -1222,6 +1251,12 @@ select {
1222
  .ai-close-hidden {
1223
  visibility: hidden;
1224
  }
 
 
 
 
 
 
1225
  </style>
1226
  <?php echo $head_code; ?>
1227
  </head>
@@ -1599,7 +1634,12 @@ Single pages (posts and static pages) have also additional setting for individua
1599
  <?php ai_wp_footer_hook (); ?>
1600
  <script>
1601
  <?php if (function_exists ('ai_load_settings_2')) echo ai_get_js ('ai-close'); ?>
1602
- <?php if ($sticky) echo ai_get_js ('ai-sticky'); ?>
 
 
 
 
 
1603
  </script>
1604
  </body>
1605
  </html>
27
  <!-- IE bug: use inline CSS: position: absolute;-->
28
  <div id='code-background-white' class= "code-background-white" style="position: absolute;"></div>
29
  <div id='code-overlay' class="code-overlay" style="position: absolute;"></div>
30
+ <div id='ad-info-overlay'></div>
31
+
32
  <?php
33
  }
34
 
90
  // Disable AdSense Auto ads (page level ads)
91
  $head_code = str_replace ('enable_page_level_ads', 'disabled_page_level_ads', $head_code);
92
 
93
+ $block_code = $obj->ai_getProcessedCode (true, true, $client_code, $process_php);
94
 
95
  // Fix for relative urls
96
  $block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
115
  <script>
116
 
117
  // initialize_preview ();
118
+ ajaxurl = "<?php echo admin_url ('admin-ajax.php'); ?>";
119
+ var ai_preview = true;
120
+ <?php echo get_frontend_javascript_debugging () ? 'ai_debugging = true;' : ''; ?>
121
  var sticky = <?php echo $sticky ? 'true' : 'false'; ?>;
122
  if (sticky) window.resizeTo (screen.width, screen.height);
123
 
129
 
130
  function initialize_preview () {
131
 
132
+ // var debug = <?php echo get_backend_javascript_debugging () ? 'true' : 'false'; ?>;
133
+ var debug = typeof ai_debugging !== 'undefined';
134
  var block = <?php echo $block; ?>;
135
  var code_blocks;
136
  var spinning = false;
252
  // document.write = oldDocumentWrite
253
  // }, 1000);
254
 
255
+ // console.log (settings.find ("select#block-alignment-" + block + " option:selected").attr('value'));
256
+
257
  $("select#block-alignment").val (settings.find ("select#block-alignment-" + block + " option:selected").attr('value')).change();
258
  $("select#block-alignment option:selected").data ('alt-style', '1');
259
  $("#custom-css").val (settings.find ("#custom-css-" + block).val ());
347
 
348
  function process_display_elements () {
349
 
350
+ // console.log ('process_display_elements');
351
 
352
  var style = "";
353
  $("#css-label").css('display', 'inline-block');
451
 
452
  $("#wrapper").attr ("style", style);
453
 
454
+ // console.log ('process_display_elements');
455
 
456
  if (wrapping) update_margin_padding ();
457
 
461
 
462
  function update_custom_css () {
463
 
464
+ // console.log ('update_custom_css');
465
 
466
  $("#custom-css").val ($("#wrapper").attr ("style"));
467
  $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
522
 
523
  function update_sticky_css (context) {
524
 
525
+ // console.log ('update_sticky_css', context, 'sticky_context', sticky_context);
526
 
527
  if (sticky_context != context) return;
528
 
545
 
546
  $('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css').text (vertical_position_css + horizontal_position_css);
547
 
548
+ // console.log ('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css', vertical_position_css + horizontal_position_css);
549
 
550
 
551
  $('#wrapper').removeClass ('ai-sticky-content').removeClass ('ai-sticky-left').removeClass ('ai-sticky-right').removeClass ('ai-sticky-scroll');
583
 
584
  function update_sticky_elements (context) {
585
 
586
+ // console.log ('update_sticky_elements', context, 'sticky_context', sticky_context);
587
 
588
  if (sticky_context != context) return;
589
 
605
 
606
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_BLOCK_ALIGNMENT;
607
 
608
+ // console.log ('select#block-alignment change', $("select#block-alignment option:selected").attr ('value'));
609
 
610
  if (sticky) update_sticky_css (STICKY_CONTEXT_BLOCK_ALIGNMENT);
611
 
612
  process_display_elements ();
613
  update_close_button ();
614
 
615
+ // console.log ('select#block-alignment');
616
 
617
  if (sticky) update_sticky_elements (STICKY_CONTEXT_BLOCK_ALIGNMENT);
618
 
627
  $("select#horizontal-position").change (function() {
628
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_HORIZONTAL_POSITION;
629
 
630
+ // console.log ('select#horizontal-position change');
631
 
632
  if (sticky_context == STICKY_CONTEXT_HORIZONTAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
633
  update_sticky_css (STICKY_CONTEXT_HORIZONTAL_POSITION);
634
  process_display_elements ();
635
  update_close_button ();
636
 
637
+ // console.log ('select#horizontal-position');
638
 
639
  update_sticky_elements (STICKY_CONTEXT_HORIZONTAL_POSITION);
640
  update_highlighting ();
645
  $("select#vertical-position").change (function() {
646
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_VERTICAL_POSITION;
647
 
648
+ // console.log ('select#vertical-position change');
649
 
650
  if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
651
  update_sticky_css (STICKY_CONTEXT_VERTICAL_POSITION);
652
  process_display_elements ();
653
  update_close_button ();
654
 
655
+ // console.log ('select#vertical-position');
656
 
657
  update_sticky_elements (STICKY_CONTEXT_VERTICAL_POSITION);
658
  update_highlighting ();
742
  $("#custom-css").on ('input', function() {
743
  if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_CUSTOM_CSS;
744
 
745
+ // console.log ('#custom-css input');
746
 
747
  if (wrapping) $("#wrapper").attr ("style", $("#custom-css").val ());
748
  if (sticky) update_sticky_css (STICKY_CONTEXT_CUSTOM_CSS);
749
 
750
+ // console.log ('#custom-css');
751
 
752
  if (sticky) update_sticky_elements (STICKY_CONTEXT_CUSTOM_CSS);
753
  update_margin_padding ();
764
 
765
  if (!$('body').hasClass ("highlighted")) {
766
  $(".highlighting").remove ();
767
+ $('.ai-debug-ad-info').remove();
768
  return;
769
  }
770
 
771
+ <?php
772
+ if (defined ('AI_ADSENSE_OVERLAY')) {
773
+ echo "
774
+ ai_process_adsense_ads (jQuery);
775
+ $('.ai-debug-ad-info').each (function () {
776
+ var info_top = $(this).offset ().top;
777
+ var info_left = $(this).offset ().left;
778
+ var ad_width = $(this).parent ().width ();
779
+ $(this).css ({top: info_top, left: info_left, width: ad_width});
780
+ if ($('#wrapper').css ('position') == 'fixed') $(this).css ('position', 'fixed');
781
+ $('#ad-info-overlay').append ($(this));
782
+ });
783
+ ";
784
+ }
785
+ ?>
786
+
787
  if (wrapping) {
788
 
789
  var overlay_position = '';
891
  code_index ++;
892
  var element_offset = $(this).offset ();
893
 
894
+ var element_display = $(this).css ('display');
895
  var element_left = element_offset.left;
896
  var element_top = element_offset.top;
897
  var element_outer_width = $(this).outerWidth ();
900
  if (debug) {
901
  console.log ("");
902
  console.log ("element " + code_index + ": " + element_tag);
903
+ console.log ("element_display: " + element_display);
904
  console.log ("element_left: " + element_left);
905
  console.log ("element_top: " + element_top);
906
  console.log ("element_outer_width: " + element_outer_width);
907
  console.log ("element_outer_height: " + element_outer_height);
908
  }
909
 
910
+ if (element_display == 'none') return; // continue
911
+
912
  var overlay_div_position = overlay_div.css ('position');
913
  var overlay_background_div_position = overlay_background_div.css ('position');
914
  var fixed_offset_top = 0;
1137
  background: rgba(50, 140, 220, 0.5);
1138
  display: block;
1139
  }
1140
+ .ad-info-overlay {
1141
+ position: absolute;
1142
+ }
1143
 
1144
  table.screen td {
1145
  padding: 0;
1251
  .ai-close-hidden {
1252
  visibility: hidden;
1253
  }
1254
+
1255
+ .ai-debug-ad-info {position: absolute; top: 0; left: 0; overflow: hidden; width: auto; height: auto; font-size: 11px; line-height: 11px; text-align: left; z-index: 999999991;}
1256
+ .ai-info {display: inline-block; padding: 2px 4px;}
1257
+ .ai-info-1 {background: #000; color: #fff;}
1258
+ .ai-info-2 {background: #fff; color: #000;}
1259
+
1260
  </style>
1261
  <?php echo $head_code; ?>
1262
  </head>
1634
  <?php ai_wp_footer_hook (); ?>
1635
  <script>
1636
  <?php if (function_exists ('ai_load_settings_2')) echo ai_get_js ('ai-close'); ?>
1637
+ <?php
1638
+ if ($sticky) echo ai_get_js ('ai-sticky');
1639
+ if (defined ('AI_ADSENSE_OVERLAY')) {
1640
+ echo ai_get_js ('ai-ads');
1641
+ }
1642
+ ?>
1643
  </script>
1644
  </body>
1645
  </html>
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.3.4";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
1
+ var javascript_version = "2.3.5";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
readme.txt CHANGED
@@ -34,7 +34,7 @@ Google lists Ad Inserter plugin as possible solution to place AdSense ad code in
34
 
35
  > If you're new to AdSense, one of your first tasks is to connect your site to AdSense. This requires you to copy the code on your AdSense homepage and paste it into the HTML of your page, between the `<head>` and `</head>` tags.
36
 
37
- Check [How to insert ad code in your WordPress site](https://support.google.com/adsense/answer/7527509). Advanced users can enable **AdSense integration**: get <a href="https://adinserter.pro/adsense-ads#integration">AdSense ad codes</a> from the plugin settings page - no need to copy ad codes from the AdSense admin pages and paste them to code blocks. List ad units, preview AdSense ads and get ad codes where you need them.
38
 
39
  **Endorsed by Amazon**
40
 
@@ -250,185 +250,20 @@ If you deactivate and delete Ad Inserter, the settings will stay in the database
250
  3. Delete Ad Inserter plugin
251
 
252
 
253
- **Quick Start**
254
-
255
- 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>:
256
-
257
- * 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
258
- * **Enable and use at least one insertion option** (Automatic insertion, Widget, Shortcode, PHP function call)
259
- * **Enable insertion on at least one Wordpress page type** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
260
- * For Posts and static pages **select default value On all Posts / On all Static pages** unless you really know what are you doing
261
- * 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)
262
-
263
- Few examples for automatic insertion are described on the <a href="http://adinserter.pro/settings">Common settings</a> page. Please make sure you have also read **WARNINGS** on the bottom of this page and instructions for **Debugging**.
264
-
265
- **Settings**
266
-
267
- 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.
268
- 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.
269
- When you are finished with settings you need to save them by clicking on the button **Save Settings**.
270
-
271
- Each code block has 4 insertion options:
272
-
273
- * Automatic Insertion
274
- * Widget
275
- * Shortcode
276
- * PHP function call
277
-
278
- Normally for each code block you use only one insertion option.
279
- 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).
280
-
281
- To insert code block and display ad at some position **you need to enable and use at least one insertion option**.
282
-
283
- Automatic Insertion Options:
284
-
285
- * Insert Before Post (before post or posts on blog pages, previously named Before Title)
286
- * Insert Before Content (before post or static page text)
287
- * Insert Before Paragraph (on posts, static pages and blog pages)
288
- * Insert After Paragraph (on posts, static pages and blog pages)
289
- * Insert After Content (after post or static page text)
290
- * Insert After Post (after post or posts on blog pages)
291
- * Insert Before Excerpt (on blog pages)
292
- * Insert After Excerpt (on blog pages)
293
- * Insert Between Posts (on blog pages)
294
- * Insert Before Comments (on posts)
295
- * Insert Between Comments (on posts)
296
- * Insert After Comments (on posts)
297
- * Insert into HTML Footer (before `</body>` tag)
298
- * Insert at custom hook positions (define them on the tab * / tab Hooks)
299
-
300
- For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.
301
-
302
- 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.
303
-
304
- 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).
305
-
306
- Block Alignment and Style:
307
-
308
- * No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
309
- * Custom CSS (You can enter custom CSS code for wrapping div)
310
- * Default (simple div with thin margin)
311
- * Align Left
312
- * Align Right
313
- * Center
314
- * Float Left (ad on left with wrapped text on right)
315
- * Float Right (ad on right with wrapped text on left)
316
-
317
- **[ Preview ]**
318
-
319
- Ad Inserter has a very useful function that can help you to check if the ad code is working and to see how it will look like when it will be inserted. Click on the **Preview** button to open Preview window.
320
- WARNING: Some adblockers may block code on the Ad Inserter preview window. If you see warning PAGE BLOCKED or you don't see your code and the widow elements are distorted, make sure you have disabled ad blockers.
321
- On the top of the window there is visual CSS editor and four buttons and below there is CSS code of the wrapping div (which can be edited manually) and 'Alignment and Style' selection.
322
-
323
- Below the settings there is a preview of the code between two dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div or write CSS code directly
324
- and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.
325
- You can resize the window (and refresh the page to reload ads) to check display with different screen widths. Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.
326
- No Wrapping style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.
327
-
328
- **Please note** that Preview window uses also Header and Footer code.
329
-
330
- Check <a href="https://adinserter.pro/alignments-and-styles">Ad Inserter Alignments and Styles</a> for explanation on available alignments and styles of code blocks.
331
-
332
- **CACHING**
333
-
334
- 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.
335
- To further combat slowness you may want to re-evaluate the performance of your hosting package. Maybe you've outgrown it. In that case, upgrade to a better hosting solution.
336
-
337
- Caching on the frontend side (what visitors see) in some cases does speed up page loading but may also cause some unwanted behavior.
338
- 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.
339
- 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:
340
-
341
- * Server-side block rotation with [ADINSERTER ROTATE] (or old separator |rotate|)
342
- * User check
343
- * Server-side device detection
344
- * Referer check
345
- * Server-side GEO targeting (country detection, Pro only)
346
- * Server-side IP address detection (Pro only)
347
- * Debugging functions
348
-
349
- When you need the functions listed above you have to switch off caching (if possible only on selected pages where needed).
350
-
351
- However, Ad Inserter also supports some of the functions above even when caching is enabled:
352
-
353
- * Client-side ad rotation with [ADINSERTER ROTATE] (or old separator |rotate|)
354
- * Client-side device detection
355
- * Client-side GEO targeting (country detection, Pro only)
356
- * Client-side IP address detection (Pro only)
357
-
358
- 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.
359
-
360
- 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.
361
-
362
- **W3 Total Cache**
363
-
364
- 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.
365
- 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.
366
-
367
- 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.
368
-
369
- Configure W3 Total Cache
370
-
371
- How to fully set up W3 Total Cache is beyond the scope of this page. Check the W3 Total Cache manuals or contact its developer for help with that if you need it.
372
-
373
- * In General Settings set the Page Caching to Disk: Basic.
374
- * In Page Cache under Advanced enable Late Initialization.
375
- * If you use the Minify option add mfunc to the ignored comment stem field.
376
-
377
- You need to flush the cache after making these changes.
378
-
379
- Please note also the following:
380
-
381
- * 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.
382
- * 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.
383
- * Do not use debugging functions when caching is activated.
384
- * When you make changes in settings of the W3 Total Cache purge all caches before you check page.
385
- * After you activate W3 Total Cache plugin go to General Settings and Save all settings.
386
-
387
- **Ad rotation**
388
-
389
- 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.
390
-
391
- Configure blocks normally and separate different versions with [ADINSERTER ROTATE] shortcode. When the page will be created and Ad Inserter called, it will generate hidden code for all block versions. When the page will be loaded in the browser, one randomly chosen version of the code will be displayed. For example, to rotate 3 images:
392
-
393
- `<img style='height: 400px;' src="http://malsup.github.io/images/p1.jpg">
394
- [ADINSERTER ROTATE]
395
- <img style='height: 400px;' src="http://malsup.github.io/images/p2.jpg">
396
- [ADINSERTER ROTATE]
397
- <img style='height: 400px;' src="http://malsup.github.io/images/p3.jpg">`
398
-
399
- Please note the following:
400
-
401
- * 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.
402
- * 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>`
403
- * 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.
404
- * Client-side rotation uses div elements to wrap the code(s). This is not important unless you use No wrapping style.
405
-
406
- 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.
407
- Some caching plugins like WP Super Cache and W3 Total Cache have an option to disable caching for known (logged in) users.
408
-
409
- **DEBUGGING**
410
-
411
- Ad Inserter has many debugging functions that can help you to diagnose the problem when you don't see your ads at expected positions.
412
-
413
- * 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.
414
- * 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.
415
- * 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
416
-
417
- 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:
418
 
419
- * 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.
420
- * 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.
421
- * 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.
422
- * 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.
423
- * 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
 
 
 
 
 
 
424
 
425
- **WARNING:** Make sure **caching is disabled while debugging**! All debugging functions you enable will be visible only to you!
426
-
427
- 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`)
428
-
429
- 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.
430
- **Remote debugging** enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing).
431
- 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.
432
 
433
  **Please support plugin development**
434
 
@@ -448,7 +283,7 @@ Support the advancement of this plugin:
448
  = I have activated Ad Inserter. How can I use it? =
449
 
450
  1. After activation, click "Settings / Ad Inserter" to access the settings page
451
- 2. Put ad (or any other HTML/Javascript/PHP) code into the ad box
452
  3. Set automatic insertion option (for example: Before Post)
453
  4. Enable at least one page type (for example: Posts, some insertion options don't work on all page types)
454
  5. Save settings
@@ -469,10 +304,29 @@ The easiest way to check Ad Inserter code blocks is to use **Label blocks** debu
469
  [https://adinserter.pro/documentation#debugging](https://adinserter.pro/documentation#debugging)
470
 
471
 
 
 
 
 
 
 
 
 
 
472
  = I have installed code for AdSense ads but the ad blocks are blank. =
473
 
474
- If you get blank ads then this might be because there is some error in the code (wrong IDs), your AdSense account is not fully approved yet, your website was not accepted or your AdSense account is banned.
475
- In such case you can try other ad networks for contextual ads. Check <a href="https://adinserter.pro/documentation#ads-not-displayed">Ads Not Displayed</a> for more information.
 
 
 
 
 
 
 
 
 
 
476
 
477
  = Settings for widget =
478
 
@@ -549,11 +403,6 @@ This happens because Ad Inserter processes posts last and therefore "sees" also
549
  Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab * / tab General).
550
 
551
 
552
- = How can I replace deprecated tags {adinserter n} for manual insertion with new ones [adinserter block="n"] in all posts? =
553
-
554
- Use <a href="https://wordpress.org/plugins/search-regex/" target="_blank">Search Regex</a> plugin to replace tags in all posts with few clicks. If you are not familiar with regular expressions simply use search and replace text for each code block. Use **Replace** to test replacements and when it works as expected use **Replace & Save**.
555
-
556
-
557
  = How can I add some text or title (e.g. Advertisement) above the ad? =
558
 
559
  If this is a sidebar widget then you can simply name the widget. In other cases you can add title HTML code above ad code. For example:
@@ -608,34 +457,6 @@ Select device types (desktop, tablet or phone) for which you need to show ads an
608
  In most cases you should use ONLY client-side detection. All code blocks are generated, however, they are displayed according to settings and browser's screen width using CSS Media Queries. This works perfectly in responsive designs.
609
 
610
 
611
- = How can I disable ads for direct visitors? =
612
-
613
- Blacklist `#` as referer for visitors that enter web address directly into browser (no referer).
614
- Blacklist `yourdomain.com` as referer for visitors that browse your website yourdomain.com.
615
- To blacklist both enter `yourdomain.com, #`
616
-
617
-
618
- = How can I disable ads on error 404 page? =
619
-
620
- This is disabled by default. Uncheck Error 404 Page checkbox (button Misc).
621
-
622
-
623
- = Is there a way to display country flag of the visitor? =
624
-
625
- Possible if you are using Ad Inserter Pro. In the header put the following code:
626
-
627
- `<link rel='stylesheet' href='/wp-content/plugins/ad-inserter/css/flags.css' type='text/css' media='all' />`
628
-
629
- In the code block use the following code for flag
630
-
631
- `<span class="flag-icon flag-icon-[adinserter data='country-iso2']" style="width: 400px; height: 300px;"></span>`
632
-
633
- Adjust width and height according to your needs. Please not that `[adinserter data='country_iso2']` tag works only server-side - it won't work on cached pages.
634
- Of course, you can also use static code for flags. For example, for United States:
635
-
636
- `<span class="flag-icon flag-icon-us" style="width: 400px; height: 300px;"></span>`
637
-
638
-
639
  = How can I enable or disable ads on group of similar pages? =
640
 
641
  If those pages have something in common in the url (page address) then you can block them with url patterns.
@@ -802,6 +623,13 @@ AD CODE RIGHT
802
 
803
  == Changelog ==
804
 
 
 
 
 
 
 
 
805
  = 2.3.4 =
806
  - Added support for author:author-username items in taxonomy list
807
  - Fixed errors when downgrading from Pro
@@ -866,154 +694,19 @@ AD CODE RIGHT
866
  - Fix for errors when using old |rotate| separator
867
  - Few minor bug fixes, cosmetic changes and code improvements
868
 
869
- = 2.2.9 =
870
- - Output buffering is now disabled by default (for position Above header you need to enable it)
871
- - Fix for min. paragraph number not processed
872
-
873
- = 2.2.8 =
874
- - Added position for automatic insertion Above header (after `<body>` tag)
875
- - Added rotation code editor
876
- - Added support to name rotation options
877
- - Added code generator for banners
878
- - Added code generator for AdSense
879
- - Added support to rearrange code blocks
880
- - Added support to copy any block settings
881
- - Added support for clipboard to copy/paste block settings
882
- - Added option to select ad blocking detection mode (Pro only)
883
- - Delayed insertion on posts now available for all insertion positions
884
- - Few minor bug fixes, cosmetic changes and code improvements
885
-
886
- = 2.2.7 =
887
- - Fix for duplicate amp-custom tag on AMP pages
888
-
889
- = 2.2.6 =
890
- - Fix for posts filter counter not counting
891
- - Added list with short overview of all code blocks
892
- - Added support for word count on blog pages
893
- - Added support for client code preview (no need to save it for preview)
894
- - Improved compatibility on AMP pages
895
- - Few minor bug fixes, cosmetic changes and code improvements
896
-
897
- = 2.2.5 =
898
- - Fix for issue with Ajax requests
899
-
900
- = 2.2.4 =
901
- - Added support to insert raw HTTP response header lines
902
- - Added support to check for individual exceptions for shortcodes
903
- - Added support to trigger ad blocking detection action only on individual pages
904
- - Added support for automatic insertion position Footer
905
- - Added support for custom hooks
906
- - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE)
907
- - Fix for |count| separator not processed
908
-
909
- = 2.2.3 =
910
- - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
911
- - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
912
- - Added support for post-type:POST_TYPE taxonomy list items
913
- - Added support for JavaScript based sticky widgets
914
- - Added support for ad blocking statistics (Pro only)
915
- - Added support for WP AMP and WP AMP Ninja plugins
916
- - Post/Page Word Count moved to Misc section (now works also on widgets)
917
- - Few minor bug fixes, cosmetic changes and code improvements
918
-
919
- = 2.2.2 =
920
- - Fix for mobile admin layout
921
- - Few other minor bug fixes
922
-
923
- = 2.2.1 =
924
- - Fix for header/footer scripts on AMP pages
925
-
926
- = 2.2.0 =
927
- - Added support for ad blocking detection (experimental)
928
- - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
929
- - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
930
- - Added syntax highlighting for shortcodes and separators
931
- - Added option to define minimum number of words in paragraphs above
932
- - Added support for %N filter item to filter every N-th insertion
933
- - Added filter support when inserting for all paragraphs
934
- - Added style `clear: both;` to Default, Left, Right and Center alignments
935
- - Bug fix for errors when loading tracking charts (Pro only)
936
- - Many minor bug fixes, cosmetic changes and code improvements
937
-
938
- = 2.1.14 =
939
- - Fix for error when using older PHP versions (prior to 5.5)
940
-
941
- = 2.1.13 =
942
- - Fix for Fatal error: Can't use method return value in write context
943
-
944
- = 2.1.12 =
945
- - Added option to define tags inside which paragraphs are not counted
946
- - Added max insertions check when inserting for all paragraphs
947
- - Added support for inverted filter
948
- - Increased nonce lifespan to 48 hours when using tracking (Pro only)
949
- - Fixed wrong urls in debug menu when behind proxy
950
- - Few other bug fixes, cosmetic changes and code improvements
951
-
952
- = 2.1.11 =
953
- - Improved support for sticky widgets (works with most themes)
954
- - Added support for ad counting (|count| separator)
955
- - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
956
- - Added support for automatic insertion before, between and after comments
957
- - Added processing of shortcodes in the header and footer code
958
- - Debugging function Show positions shows also page type
959
- - Fixed page type detection when Post page was set to static page and it was not homepage
960
- - Few minor bug fixes, cosmetic changes and code improvements
961
-
962
- = 2.1.10 =
963
- - Fix for shifted sidebars in some themes
964
-
965
- = 2.1.9 =
966
- - Added support for sticky widgets
967
- - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
968
- - Impression and click tracking (beta, Pro only)
969
- - Few minor bug fixes, cosmetic changes and code improvements
970
 
971
- = 2.1.8 =
972
- - Fixed error when using server-side device detection
973
-
974
- = 2.1.7 =
975
- - Fixed error when using PHP 5.4 or earlier
976
-
977
- = 2.1.6 =
978
- - Added support for insertion before/after multiple paragraphs
979
- - Added initial support for impression and click tracking (Pro only)
980
- - Few bug fixes and cosmetic changes
981
-
982
- = 2.1.5 =
983
- - Added support to avoid insertion inside `<figure>` and `<li>` elements (image captions, lists)
984
- - Added support for exceptions for custom post types
985
- - Few minor bug fixes and code improvements
986
-
987
- = 2.1.4 =
988
- - Paragraph counting restored to standard functions
989
- - Added option to select paragraph counting functions with multibyte support (unicode characters)
990
- - Fixed bug for wrong paragraph counting in posts with blockquote sections in some cases
991
- - Fixed bug for wrong measuring of plugin processing time in some cases
992
- - Fixed bug for "Empty delimiter" warning
993
-
994
- = 2.1.3 =
995
- - Added support for counting paragraphs with multibyte (unicode) characters
996
- - Fixed bug for class name not saved
997
- - Few minor bug fixes and cosmetic changes
998
-
999
- = 2.1.2 =
1000
- - Fixed bug for disabled settings page on multisite blogs
1001
-
1002
- = 2.1.1 =
1003
- - Changes for compatibility with PHP 7.1
1004
- - Automatic rename of old pro plugin slug (Pro only)
1005
- - Added support for additional Pro features (Pro only)
1006
- - Few bug fixes and cosmetic changes
1007
-
1008
- = 2.1.0 =
1009
- - Added support to insert ads in Ajax requests (e.g. in infinite scroll)
1010
- - Added support to not include block classes when class name is empty
1011
- - Added sticky positions (Pro only)
1012
- - Bug fix for minimum user role not taken into account for exceptions list
1013
- - Bug fix for IP database update cron event (Pro only)
1014
 
1015
  == Upgrade Notice ==
1016
 
 
 
 
 
 
 
 
1017
  = 2.3.4 =
1018
  Added support for author:author-username items in taxonomy list;
1019
  Fixed errors when downgrading from Pro;
@@ -1076,128 +769,3 @@ Fix for ad blocking detection when using https (Pro only)
1076
  Fix for rotation editor code import/export;
1077
  Fix for errors when using old |rotate| separator
1078
 
1079
- = 2.2.9 =
1080
- Output buffering is now disabled by default (for position Above header you need to enable it);
1081
- Fix for min. paragraph number not processed
1082
-
1083
- = 2.2.8 =
1084
- Added position for automatic insertion Above header (after `<body>` tag);
1085
- Added rotation code editor;
1086
- Added support to name rotation options;
1087
- Added code generator for banners and AdSense;
1088
- Added support to rearrange code blocks;
1089
- Added support for clipboard to copy/paste block settings;
1090
- Added option to select ad blocking detection mode (Pro only);
1091
-
1092
- = 2.2.7 =
1093
- Fix for duplicate amp-custom tag on AMP pages
1094
-
1095
- = 2.2.6 =
1096
- Fix for posts filter counter not counting;
1097
- Added list with short overview of all code blocks;
1098
- Added support for word count on blog pages;
1099
- Added support for client code preview (no need to save it for preview);
1100
- Improved compatibility on AMP pages;
1101
- Few minor bug fixes, cosmetic changes and code improvements
1102
-
1103
- = 2.2.5 =
1104
- Fix for issue with Ajax requests
1105
-
1106
- = 2.2.4 =
1107
- Added support to insert raw HTTP response header lines;
1108
- Added support to check for individual exceptions for shortcodes;
1109
- Added support to trigger ad blocking detection action only on individual pages;
1110
- Added support for automatic insertion position Footer;
1111
- Added support for custom hooks;
1112
- Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE);
1113
- Fix for |count| separator not processed;
1114
-
1115
- = 2.2.3 =
1116
- Added support to insert custom fields via shortcode;
1117
- Added support for user:USERNAME, user-role:USER_ROLE and post-type:POST_TYPE taxonomy list items;
1118
- Added support for JavaScript based sticky widgets;
1119
- Added support for ad blocking statistics (Pro only);
1120
- Added support for WP AMP and WP AMP Ninja plugins;
1121
- Post/Page Word Count moved to Misc section (now works also on widgets)
1122
-
1123
- = 2.2.2 =
1124
- Fix for mobile admin layout;
1125
- Few other minor bug fixes
1126
-
1127
- = 2.2.1 =
1128
- Fix for header/footer scripts on AMP pages
1129
-
1130
- = 2.2.0 =
1131
- Added support for ad blocking detection (experimental);
1132
- Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages;
1133
- Added syntax highlighting for shortcodes and separators
1134
- Added option to define minimum number of words in paragraphs above;
1135
- Added support for %N filter item to filter every N-th insertion;
1136
- Added style `clear: both;` to Default, Left, Right and Center alignments;
1137
- Added filter support when inserting for all paragraphs;
1138
- Bug fix for errors when loading tracking charts (Pro only);
1139
-
1140
- = 2.1.14 =
1141
- Fix for error when using older PHP versions (prior to 5.5)
1142
-
1143
- = 2.1.13 =
1144
- Fix for Fatal error: Can't use method return value in write context
1145
-
1146
- = 2.1.12 =
1147
- Added option to define tags inside which paragraphs are not counted;
1148
- Added max insertions check when inserting for all paragraphs;
1149
- Added support for inverted filter;
1150
- Few minor bug fixes, cosmetic changes and code improvements
1151
-
1152
- = 2.1.11 =
1153
- Improved support for sticky widgets (works with most themes);
1154
- Added support for ad counting (|count| separator);
1155
- Added support to black/white-list arbitrary taxonomies;
1156
- Added support for automatic insertion before, between and after comments;
1157
- Added processing of shortcodes in the header and footer code;
1158
- Fixed page type detection on blog pages in some cases;
1159
-
1160
- = 2.1.10 =
1161
- Fix for shifted sidebars in some themes
1162
-
1163
- = 2.1.9 =
1164
- Added support for sticky widgets;
1165
- Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img);
1166
- Impression and click tracking (beta, Pro only);
1167
- Few minor bug fixes, cosmetic changes and code improvements
1168
-
1169
- = 2.1.8 =
1170
- Fixed error when using server-side device detection
1171
-
1172
- = 2.1.7 =
1173
- Fixed error when using PHP 5.4 or earlier
1174
-
1175
- = 2.1.6 =
1176
- Added support for insertion before/after multiple paragraphs;
1177
- Few bug fixes and cosmetic changes
1178
-
1179
- = 2.1.5 =
1180
- Added support to avoid insertion inside `<figure>` and `<li>` elements;
1181
- Added support for exceptions for custom post types;
1182
- Few minor bug fixes and code improvements
1183
-
1184
- = 2.1.4 =
1185
- Paragraph counting restored to standard functions;
1186
- Added option to select paragraph counting functions with multibyte support (unicode characters);
1187
- Few bugs fixed including for "Empty delimiter" warning
1188
-
1189
- = 2.1.3 =
1190
- Added support for counting paragraphs with multibyte (unicode) characters;
1191
- Fixed bug for class name not saved;
1192
- Few minor bug fixes and cosmetic changes
1193
-
1194
- = 2.1.2 =
1195
- Fixed bug for disabled settings page on multisite blogs
1196
-
1197
- = 2.1.1 =
1198
- Changes for compatibility with PHP 7.1;
1199
- Few bug fixes and cosmetic changes
1200
-
1201
- = 2.1.0 =
1202
- Support for ads in Ajax requests (e.g. in infinite scroll); Added sticky positions (Pro only);
1203
- Bug fix for minimum user role for exceptions list; Bug fix for IP database update cron event (Pro only)
34
 
35
  > If you're new to AdSense, one of your first tasks is to connect your site to AdSense. This requires you to copy the code on your AdSense homepage and paste it into the HTML of your page, between the `<head>` and `</head>` tags.
36
 
37
+ Check [How to insert ad code in your WordPress site](https://support.google.com/adsense/answer/7527509). Advanced users can enable [AdSense integration](https://adinserter.pro/adsense-ads#integration): get AdSense ad codes from the plugin settings page - no need to copy ad codes from the AdSense admin pages and paste them to code blocks. List ad units, preview AdSense ads and get ad codes where you need them.
38
 
39
  **Endorsed by Amazon**
40
 
250
  3. Delete Ad Inserter plugin
251
 
252
 
253
+ **Online Documentation**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ * [Code Editing](https://adinserter.pro/code-editing)
256
+ * [Common Settings](https://adinserter.pro/settings)
257
+ * [Ad Inserter Documentation](https://adinserter.pro/documentation)
258
+ * [Automatic Insertion](https://adinserter.pro/documentation#automatic-insertion)
259
+ * [Block Alignment and Style](https://adinserter.pro/alignments-and-styles)
260
+ * [AdSense Ads](https://adinserter.pro/adsense-ads)
261
+ * [WordPress Page Types](https://adinserter.pro/page-types)
262
+ * [Black and White Lists](https://adinserter.pro/lists)
263
+ * [Post and Page Exceptions](https://adinserter.pro/exceptions)
264
+ * [Debugging](https://adinserter.pro/documentation#debugging)
265
+ * [Ads not displayed](https://adinserter.pro/documentation#ads-not-displayed)
266
 
 
 
 
 
 
 
 
267
 
268
  **Please support plugin development**
269
 
283
  = I have activated Ad Inserter. How can I use it? =
284
 
285
  1. After activation, click "Settings / Ad Inserter" to access the settings page
286
+ 2. Put ad (or any other HTML/Javascript/PHP) code into the code window
287
  3. Set automatic insertion option (for example: Before Post)
288
  4. Enable at least one page type (for example: Posts, some insertion options don't work on all page types)
289
  5. Save settings
304
  [https://adinserter.pro/documentation#debugging](https://adinserter.pro/documentation#debugging)
305
 
306
 
307
+ = I have installed code for AdSense ads and I see ads placed at random positions. =
308
+
309
+ You are probably using code for [AdSense Auto ads](https://adinserter.pro/adsense-ads#auto-ads).
310
+
311
+ AdSense Auto ads (known also as Page Level Ads) is a code that you insert on every page once and it will automatically display AdSense ads on positions chosen by the code.
312
+ Auto ads use Google's machine learning to pick the best placements on your pages to show ads. You only need to add one piece of code to all your pages, and let Google take care of the rest.
313
+
314
+ Auto ads may not be suitable for some WordPress themes or layouts. In such cases it is easier to place ads at wanted locations by using [normal AdSense code](https://adinserter.pro/adsense-ads#ad-unit) and specifying exact locations where the code should be inserted.
315
+
316
  = I have installed code for AdSense ads but the ad blocks are blank. =
317
 
318
+ Blank AdSense ad block means that the code is inserted properly only the ad code doesn't display anything. Typical reasons for this are the following:
319
+
320
+ * After the ad code is inserted Google needs some time (hours) to check the pages before it starts to serve ads.
321
+ * AdSense account is not fully approved yet - if your account is new you need to wait until Google checks ad codes on your website and and confirms your account. Usually this takes few days.
322
+ * Your website or page is not approved yet - you need to wait until Google web crawlers check your pages.
323
+ * Your website or page was not approved for AdSense ads
324
+ * Your AdSense account is banned
325
+ * No ads available for your website
326
+ * Errors in ad code - check or regenerate ad code
327
+ * You are using ad blocker
328
+
329
+ See [AdSense ads not displayed](https://adinserter.pro/adsense-ads#ads-not-displayed) for details. In such case you can try other ad networks for contextual ads. Check <a href="https://adinserter.pro/documentation#ads-not-displayed">Ads Not Displayed</a> for more information.
330
 
331
  = Settings for widget =
332
 
403
  Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab * / tab General).
404
 
405
 
 
 
 
 
 
406
  = How can I add some text or title (e.g. Advertisement) above the ad? =
407
 
408
  If this is a sidebar widget then you can simply name the widget. In other cases you can add title HTML code above ad code. For example:
457
  In most cases you should use ONLY client-side detection. All code blocks are generated, however, they are displayed according to settings and browser's screen width using CSS Media Queries. This works perfectly in responsive designs.
458
 
459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  = How can I enable or disable ads on group of similar pages? =
461
 
462
  If those pages have something in common in the url (page address) then you can block them with url patterns.
623
 
624
  == Changelog ==
625
 
626
+ = 2.3.5 =
627
+ - Added display of header and footer code in Label blocks debugging function
628
+ - Added AdSense ad overlays in Label blocks debugging function (experimental)
629
+ - Fixed bug for removed square brackets in HTML element selectors
630
+ - Fixed preview of AdSense ad units
631
+ - Few minor bug fixes
632
+
633
  = 2.3.4 =
634
  - Added support for author:author-username items in taxonomy list
635
  - Fixed errors when downgrading from Pro
694
  - Fix for errors when using old |rotate| separator
695
  - Few minor bug fixes, cosmetic changes and code improvements
696
 
697
+ = Earlier versions =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
 
699
+ For the changelog of earlier versions, please refer to the separate changelog.txt file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
700
 
701
  == Upgrade Notice ==
702
 
703
+ = 2.3.5 =
704
+ Added display of header and footer code in Label blocks debugging function;
705
+ Added AdSense ad overlays in Label blocks debugging function (experimental);
706
+ Fixed bug for removed square brackets in HTML element selectors;
707
+ Fixed preview of AdSense ad units;
708
+ Few minor bug fixes
709
+
710
  = 2.3.4 =
711
  Added support for author:author-username items in taxonomy list;
712
  Fixed errors when downgrading from Pro;
769
  Fix for rotation editor code import/export;
770
  Fix for errors when using old |rotate| separator
771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
settings.php CHANGED
@@ -333,15 +333,17 @@ function generate_settings_form (){
333
 
334
  }
335
 
336
- $title_hfa = "";
337
- if ($adH->get_enable_manual () && $adH->get_ad_data() != "") $title_hfa .= ", Header code";
338
- if ($adF->get_enable_manual () && $adF->get_ad_data() != "") $title_hfa .= ", Footer code";
339
-
340
  $enabled_k = count ($ai_custom_hooks) != 0;
341
  $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
342
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
343
  if ($enabled_h || $enabled_f) $class_hfa = " on"; else $class_hfa = "";
344
 
 
 
 
 
 
 
345
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
346
  $enabled_a = $ai_wp_data [AI_ADB_DETECTION];
347
  if ($enabled_a) $title_hfa .= ", Ad blocking detection code";
@@ -1786,8 +1788,8 @@ function generate_settings_form (){
1786
  if (function_exists ('ai_global_settings')) ai_global_settings ();
1787
 
1788
  if ($enabled_k) $style_k = "font-weight: bold; color: #66f;"; else $style_k = "";
1789
- if ($enabled_h) $style_h = "font-weight: bold; color: #66f;"; else $style_h = "";
1790
- if ($enabled_f) $style_f = "font-weight: bold; color: #66f;"; else $style_f = "";
1791
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1792
  $adb_action = get_adb_action (true);
1793
  if ($enabled_a) $style_a = "font-weight: bold; color: " . ($adb_action == AI_ADB_ACTION_NONE ? "#66f;" : "#c0f;"); else $style_a = "";
@@ -2066,6 +2068,7 @@ function generate_settings_form (){
2066
  <div style="margin: 8px 0; width: 100%;">
2067
  <div style="float: left;">
2068
  Code in the <pre style="display: inline; color: blue;">&lt;head&gt;&lt;/head&gt;</pre> section of the HTML page
 
2069
  </div>
2070
 
2071
  <div style="clear: both;"></div>
@@ -2122,6 +2125,7 @@ function generate_settings_form (){
2122
  <div style="margin: 8px 0; width: 100%;">
2123
  <div style="float: left;">
2124
  Code before the <pre style="display: inline; color: blue;">&lt;/body&gt;</pre> tag of the the HTML page
 
2125
  </div>
2126
 
2127
  <div style="clear: both;"></div>
@@ -2823,13 +2827,13 @@ function code_block_list () {
2823
 
2824
  if (defined ('AI_ADSENSE_API')) {
2825
 
2826
- function adsense_list () {
2827
  require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
2828
 
2829
- if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
 
2830
 
2831
- $publisher_id = '';
2832
- $ad_units = array ();
2833
  $error = '';
2834
 
2835
  $update_ad_units = isset ($_GET ["update_ad_units"]) ? $_GET ["update_ad_units"] == 1 : false;
@@ -2846,6 +2850,21 @@ function adsense_list () {
2846
  set_transient (AI_TRANSIENT_ADSENSE_ADS, $ad_data, AI_TRANSIENT_ADSENSE_ADS_EXPIRATION);
2847
  }
2848
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2849
 
2850
  if ($error == '') {
2851
 
@@ -3038,7 +3057,7 @@ function adsense_list () {
3038
 
3039
  }
3040
 
3041
- function adsense_code ($ad_slot_id) {
3042
  if (defined ('AI_ADSENSE_API')) {
3043
  require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
3044
 
@@ -3050,6 +3069,29 @@ function adsense_code ($ad_slot_id) {
3050
  }
3051
  }
3052
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3053
  function generate_list_options ($options) {
3054
  $max_items = 2000;
3055
 
333
 
334
  }
335
 
 
 
 
 
336
  $enabled_k = count ($ai_custom_hooks) != 0;
337
  $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
338
  $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
339
  if ($enabled_h || $enabled_f) $class_hfa = " on"; else $class_hfa = "";
340
 
341
+ $title_hfa = "";
342
+ if ($enabled_h) $title_hfa .= ", Header code";
343
+ if ($enabled_f) $title_hfa .= ", Footer code";
344
+ $header_code_disabled = !$adH->get_enable_manual () && $adH->get_ad_data() != "";
345
+ $footer_code_disabled = !$adF->get_enable_manual () && $adF->get_ad_data() != "";
346
+
347
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
348
  $enabled_a = $ai_wp_data [AI_ADB_DETECTION];
349
  if ($enabled_a) $title_hfa .= ", Ad blocking detection code";
1788
  if (function_exists ('ai_global_settings')) ai_global_settings ();
1789
 
1790
  if ($enabled_k) $style_k = "font-weight: bold; color: #66f;"; else $style_k = "";
1791
+ if ($enabled_h) $style_h = "font-weight: bold; color: #66f;"; else if ($header_code_disabled) $style_h = "font-weight: bold; color: #f66;"; else $style_h = "";
1792
+ if ($enabled_f) $style_f = "font-weight: bold; color: #66f;"; else if ($footer_code_disabled) $style_f = "font-weight: bold; color: #f66;"; else $style_f = "";
1793
  if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1794
  $adb_action = get_adb_action (true);
1795
  if ($enabled_a) $style_a = "font-weight: bold; color: " . ($adb_action == AI_ADB_ACTION_NONE ? "#66f;" : "#c0f;"); else $style_a = "";
2068
  <div style="margin: 8px 0; width: 100%;">
2069
  <div style="float: left;">
2070
  Code in the <pre style="display: inline; color: blue;">&lt;head&gt;&lt;/head&gt;</pre> section of the HTML page
2071
+ <?php if ($header_code_disabled) echo '<span style="color: #f00;">DISABLED</span>'; ?>
2072
  </div>
2073
 
2074
  <div style="clear: both;"></div>
2125
  <div style="margin: 8px 0; width: 100%;">
2126
  <div style="float: left;">
2127
  Code before the <pre style="display: inline; color: blue;">&lt;/body&gt;</pre> tag of the the HTML page
2128
+ <?php if ($footer_code_disabled) echo '<span style="color: #f00;">DISABLED</span>'; ?>
2129
  </div>
2130
 
2131
  <div style="clear: both;"></div>
2827
 
2828
  if (defined ('AI_ADSENSE_API')) {
2829
 
2830
+ function ai_adsense_data (&$error) {
2831
  require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
2832
 
2833
+ $error = 'AdSense not authorized';
2834
+ $ad_data = false;
2835
 
2836
+ if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
 
2837
  $error = '';
2838
 
2839
  $update_ad_units = isset ($_GET ["update_ad_units"]) ? $_GET ["update_ad_units"] == 1 : false;
2850
  set_transient (AI_TRANSIENT_ADSENSE_ADS, $ad_data, AI_TRANSIENT_ADSENSE_ADS_EXPIRATION);
2851
  }
2852
  }
2853
+ }
2854
+
2855
+ return $ad_data;
2856
+ }
2857
+
2858
+ function adsense_list () {
2859
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
2860
+
2861
+ if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
2862
+
2863
+ $publisher_id = '';
2864
+ $ad_units = array ();
2865
+ $error = '';
2866
+
2867
+ $ad_data = ai_adsense_data ($error);
2868
 
2869
  if ($error == '') {
2870
 
3057
 
3058
  }
3059
 
3060
+ function ai_adsense_code ($ad_slot_id) {
3061
  if (defined ('AI_ADSENSE_API')) {
3062
  require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
3063
 
3069
  }
3070
  }
3071
 
3072
+ function adsense_ad_name ($adsense_data) {
3073
+ if (defined ('AI_ADSENSE_API')) {
3074
+ $publisher_id = '';
3075
+ $ad_units = array ();
3076
+ $error = '';
3077
+
3078
+ $ad_data = ai_adsense_data ($error);
3079
+
3080
+ if ($error == '') {
3081
+ $publisher_id = $ad_data [0];
3082
+ $ad_units = $ad_data [1];
3083
+ $ad_slot_names = array ('publisher_id' => $publisher_id);
3084
+
3085
+ foreach ($ad_units as $ad_unit) {
3086
+ if ($ad_unit ['active'])
3087
+ $ad_slot_names [$ad_unit ['code']] = $ad_unit ['name'];
3088
+
3089
+ }
3090
+ echo json_encode ($ad_slot_names);
3091
+ }
3092
+ }
3093
+ }
3094
+
3095
  function generate_list_options ($options) {
3096
  $max_items = 2000;
3097