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

Version Description

  • Output buffering is now disabled by default (for position Above header you need to enable it)
  • Fix for min. paragraph number not processed
Download this release

Release Info

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

Code changes from version 2.2.8 to 2.2.9

Files changed (7) hide show
  1. ad-inserter.php +49 -17
  2. class.php +39 -7
  3. constants.php +6 -1
  4. css/ad-inserter.css +1 -1
  5. js/ad-inserter.js +1 -1
  6. readme.txt +9 -1
  7. settings.php +12 -1
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.2.8
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -12,6 +12,10 @@ Plugin URI: http://adinserter.pro/documentation
12
 
13
  Change Log
14
 
 
 
 
 
15
  Ad Inserter 2.2.8 - 2017-12-08
16
  - Added position for automatic insertion Above header (after `<body>` tag)
17
  - Added rotation code editor
@@ -1264,7 +1268,7 @@ function ai_wp_hook () {
1264
  (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) ||
1265
  $debug_positions) {
1266
  $ai_wp_data [AI_NUMBER_OF_COMMENTS] = 0;
1267
- add_filter ('comments_array' , 'ai_comments_array' , 10, 2);
1268
  add_filter ('wp_list_comments_args' , 'ai_wp_list_comments_args');
1269
  $ai_walker = new ai_Walker_Comment;
1270
  }
@@ -1287,20 +1291,20 @@ function ai_wp_hook () {
1287
 
1288
  if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1289
  // AMP, Accelerated Mobile Pages
1290
- add_action ('amp_post_template_head', 'ai_amp_head_hook');
1291
- add_action ('amp_post_template_css', 'ai_amp_css_hook');
1292
 
1293
  // WP AMP Ninja
1294
- add_action ('wpamp_custom_script', 'ai_amp_head_hook');
1295
  // No usable hook for custom CSS
1296
- // add_action ('wpamp_custom_style', 'ai_amp_css_hook');
1297
 
1298
  // WP AMP - Accelerated Mobile Pages for WordPress
1299
- add_action ('amphtml_template_head', 'ai_amp_head_hook');
1300
- add_action ('amphtml_template_css', 'ai_amp_css_hook');
1301
  } else
1302
  // WP
1303
- add_action ('wp_head', 'ai_wp_head_hook');
1304
 
1305
  $automatic_insertion_footer_hook = isset ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions;
1306
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
@@ -2116,8 +2120,10 @@ function ai_wp_head_hook () {
2116
  }
2117
 
2118
  if (defined ('AI_BUFFERING')) {
2119
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2120
- ai_buffering_start ();
 
 
2121
  }
2122
  }
2123
 
@@ -2180,8 +2186,10 @@ function ai_amp_head_hook () {
2180
  // }
2181
 
2182
  if (defined ('AI_BUFFERING')) {
2183
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2184
- ai_buffering_start ();
 
 
2185
  }
2186
  }
2187
 
@@ -2212,8 +2220,10 @@ function ai_wp_footer_hook () {
2212
  }
2213
 
2214
  if (defined ('AI_BUFFERING')) {
2215
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2216
- ai_buffering_end ();
 
 
2217
  }
2218
  }
2219
 
@@ -2260,8 +2270,10 @@ function ai_amp_footer_hook () {
2260
  }
2261
 
2262
  if (defined ('AI_BUFFERING')) {
2263
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2264
- ai_buffering_end ();
 
 
2265
  }
2266
  }
2267
 
@@ -2482,6 +2494,16 @@ function ai_write_debug_info ($write_processing_log = false) {
2482
  break;
2483
  }
2484
  echo "\n";
 
 
 
 
 
 
 
 
 
 
2485
  echo 'PLUGIN PRIORITY: ', get_plugin_priority (), "\n";
2486
  echo 'HEADER CODE: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2487
  echo 'FOOTER CODE: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
@@ -2834,6 +2856,7 @@ function ai_check_plugin_options ($plugin_options = array ()) {
2834
 
2835
  if (!isset ($plugin_options ['DYNAMIC_BLOCKS'])) $plugin_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
2836
  if (!isset ($plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'])) $plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS;
 
2837
  if (!isset ($plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'])) $plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'] = DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE;
2838
  if (!isset ($plugin_options ['ADB_ACTION'])) $plugin_options ['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
2839
  if (!isset ($plugin_options ['ADB_DELAY_ACTION'])) $plugin_options ['ADB_DELAY_ACTION'] = '';
@@ -3027,6 +3050,14 @@ function get_paragraph_counting_functions(){
3027
  return ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS']);
3028
  }
3029
 
 
 
 
 
 
 
 
 
3030
  function get_no_paragraph_counting_inside () {
3031
  global $ai_db_options;
3032
 
@@ -4029,6 +4060,7 @@ function ai_settings () {
4029
  if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']);
4030
  if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']);
4031
  if (isset ($_POST ['paragraph_counting_functions'])) $options ['PARAGRAPH_COUNTING_FUNCTIONS'] = filter_option ('PARAGRAPH_COUNTING_FUNCTIONS', $_POST ['paragraph_counting_functions']);
 
4032
  if (isset ($_POST ['no-paragraph-counting-inside'])) $options ['NO_PARAGRAPH_COUNTING_INSIDE'] = filter_option ('NO_PARAGRAPH_COUNTING_INSIDE', $_POST ['no-paragraph-counting-inside']);
4033
  if (isset ($_POST [AI_OPTION_ADB_ACTION])) $options ['ADB_ACTION'] = filter_option ('ADB_ACTION', $_POST [AI_OPTION_ADB_ACTION]);
4034
  if (isset ($_POST [AI_OPTION_ADB_DELAY_ACTION])) $options ['ADB_DELAY_ACTION'] = filter_option ('ADB_DELAY_ACTION', $_POST [AI_OPTION_ADB_DELAY_ACTION]);
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.2.9
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
12
 
13
  Change Log
14
 
15
+ Ad Inserter 2.2.9 - 2017-12-09
16
+ - Output buffering is now disabled by default (for position Above header you need to enable it)
17
+ - Fix for min. paragraph number not processed
18
+
19
  Ad Inserter 2.2.8 - 2017-12-08
20
  - Added position for automatic insertion Above header (after `<body>` tag)
21
  - Added rotation code editor
1268
  (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) ||
1269
  $debug_positions) {
1270
  $ai_wp_data [AI_NUMBER_OF_COMMENTS] = 0;
1271
+ add_filter ('comments_array' , 'ai_comments_array', 10, 2);
1272
  add_filter ('wp_list_comments_args' , 'ai_wp_list_comments_args');
1273
  $ai_walker = new ai_Walker_Comment;
1274
  }
1291
 
1292
  if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1293
  // AMP, Accelerated Mobile Pages
1294
+ add_action ('amp_post_template_head', 'ai_amp_head_hook', 99999);
1295
+ add_action ('amp_post_template_css', 'ai_amp_css_hook', 99999);
1296
 
1297
  // WP AMP Ninja
1298
+ add_action ('wpamp_custom_script', 'ai_amp_head_hook', 99999);
1299
  // No usable hook for custom CSS
1300
+ // add_action ('wpamp_custom_style', 'ai_amp_css_hook', 99999);
1301
 
1302
  // WP AMP - Accelerated Mobile Pages for WordPress
1303
+ add_action ('amphtml_template_head', 'ai_amp_head_hook', 99999);
1304
+ add_action ('amphtml_template_css', 'ai_amp_css_hook', 99999);
1305
  } else
1306
  // WP
1307
+ add_action ('wp_head', 'ai_wp_head_hook', 99999);
1308
 
1309
  $automatic_insertion_footer_hook = isset ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions;
1310
  if ($ai_wp_data [AI_WP_AMP_PAGE]) {
2120
  }
2121
 
2122
  if (defined ('AI_BUFFERING')) {
2123
+ if (get_output_buffering ()) {
2124
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2125
+ ai_buffering_start ();
2126
+ }
2127
  }
2128
  }
2129
 
2186
  // }
2187
 
2188
  if (defined ('AI_BUFFERING')) {
2189
+ if (get_output_buffering ()) {
2190
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2191
+ ai_buffering_start ();
2192
+ }
2193
  }
2194
  }
2195
 
2220
  }
2221
 
2222
  if (defined ('AI_BUFFERING')) {
2223
+ if (get_output_buffering ()) {
2224
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2225
+ ai_buffering_end ();
2226
+ }
2227
  }
2228
  }
2229
 
2270
  }
2271
 
2272
  if (defined ('AI_BUFFERING')) {
2273
+ if (get_output_buffering ()) {
2274
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2275
+ ai_buffering_end ();
2276
+ }
2277
  }
2278
  }
2279
 
2494
  break;
2495
  }
2496
  echo "\n";
2497
+ echo 'OUTPUT BUFFERING: ';
2498
+ switch (get_output_buffering()) {
2499
+ case AI_OUTPUT_BUFFERING_DISABLED:
2500
+ echo AI_TEXT_DISABLED;
2501
+ break;
2502
+ case AI_OUTPUT_BUFFERING_ENABLED:
2503
+ echo AI_TEXT_ENABLED;
2504
+ break;
2505
+ }
2506
+ echo "\n";
2507
  echo 'PLUGIN PRIORITY: ', get_plugin_priority (), "\n";
2508
  echo 'HEADER CODE: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2509
  echo 'FOOTER CODE: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2856
 
2857
  if (!isset ($plugin_options ['DYNAMIC_BLOCKS'])) $plugin_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
2858
  if (!isset ($plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'])) $plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS;
2859
+ if (!isset ($plugin_options ['OUTPUT_BUFFERING'])) $plugin_options ['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING;
2860
  if (!isset ($plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'])) $plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'] = DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE;
2861
  if (!isset ($plugin_options ['ADB_ACTION'])) $plugin_options ['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
2862
  if (!isset ($plugin_options ['ADB_DELAY_ACTION'])) $plugin_options ['ADB_DELAY_ACTION'] = '';
3050
  return ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS']);
3051
  }
3052
 
3053
+ function get_output_buffering(){
3054
+ global $ai_db_options;
3055
+
3056
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'])) $ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING;
3057
+
3058
+ return ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING']);
3059
+ }
3060
+
3061
  function get_no_paragraph_counting_inside () {
3062
  global $ai_db_options;
3063
 
4060
  if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']);
4061
  if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']);
4062
  if (isset ($_POST ['paragraph_counting_functions'])) $options ['PARAGRAPH_COUNTING_FUNCTIONS'] = filter_option ('PARAGRAPH_COUNTING_FUNCTIONS', $_POST ['paragraph_counting_functions']);
4063
+ if (isset ($_POST ['output-buffering'])) $options ['OUTPUT_BUFFERING'] = filter_option ('OUTPUT_BUFFERING', $_POST ['output-buffering']);
4064
  if (isset ($_POST ['no-paragraph-counting-inside'])) $options ['NO_PARAGRAPH_COUNTING_INSIDE'] = filter_option ('NO_PARAGRAPH_COUNTING_INSIDE', $_POST ['no-paragraph-counting-inside']);
4065
  if (isset ($_POST [AI_OPTION_ADB_ACTION])) $options ['ADB_ACTION'] = filter_option ('ADB_ACTION', $_POST [AI_OPTION_ADB_ACTION]);
4066
  if (isset ($_POST [AI_OPTION_ADB_DELAY_ACTION])) $options ['ADB_DELAY_ACTION'] = filter_option ('ADB_DELAY_ACTION', $_POST [AI_OPTION_ADB_DELAY_ACTION]);
class.php CHANGED
@@ -2183,14 +2183,30 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2183
  foreach ($positions as $position_index) $real_positions []= $position_index >= 0 ? $position_index + 1 : '*';
2184
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' INSERTION POSITIONS: ' . implode (', ', $real_positions));
2185
 
 
 
2186
  foreach ($paragraph_positions as $counter => $paragraph_position) {
2187
  if ($position_preview) $inserted_code = "[[AI_BP".($counter + 1)."]]";
2188
  // elseif (!empty ($positions) && in_array ($counter + 1, $positions) && $this->check_block_counter ()) {
2189
  elseif (!empty ($positions) && in_array ($counter, $positions) && $this->check_block_counter ()) {
2190
- $this->increment_block_counter ();
2191
- $inserted_code = $this->get_code_for_insertion ();
 
 
 
 
 
 
 
 
 
 
 
 
2192
  // $ai_last_check = AI_CHECK_INSERTED;
2193
- if ($debug_processing) ai_log (ai_log_block_status ($this->number, AI_CHECK_INSERTED));
 
 
2194
  }
2195
  // else continue;
2196
  else {
@@ -2740,14 +2756,30 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2740
  foreach ($positions as $position_index) $real_positions []= $position_index >= 0 ? $position_index + 1 : '*';
2741
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' INSERTION POSITIONS: ' . implode (', ', $real_positions));
2742
 
 
 
2743
  foreach ($paragraph_positions as $counter => $paragraph_position) {
2744
  if ($position_preview) $inserted_code = "[[AI_AP".($counter + 1)."]]";
2745
  // elseif (!empty ($positions) && in_array ($counter + 1, $positions) && $this->check_block_counter ()) {
2746
  elseif (!empty ($positions) && in_array ($counter, $positions) && $this->check_block_counter ()) {
2747
- $this->increment_block_counter ();
2748
- $inserted_code = $this->get_code_for_insertion ();
2749
- // $ai_last_check = AI_CHECK_INSERTED;
2750
- if ($debug_processing) ai_log (ai_log_block_status ($this->number, AI_CHECK_INSERTED));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2751
  }
2752
  // else continue;
2753
  else {
2183
  foreach ($positions as $position_index) $real_positions []= $position_index >= 0 ? $position_index + 1 : '*';
2184
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' INSERTION POSITIONS: ' . implode (', ', $real_positions));
2185
 
2186
+ $min_paragraphs = intval ($this->get_paragraph_number_minimum());
2187
+
2188
  foreach ($paragraph_positions as $counter => $paragraph_position) {
2189
  if ($position_preview) $inserted_code = "[[AI_BP".($counter + 1)."]]";
2190
  // elseif (!empty ($positions) && in_array ($counter + 1, $positions) && $this->check_block_counter ()) {
2191
  elseif (!empty ($positions) && in_array ($counter, $positions) && $this->check_block_counter ()) {
2192
+
2193
+ $inserted = false;
2194
+
2195
+ $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER;
2196
+ if (count ($paragraph_positions) >= $min_paragraphs) {
2197
+ $this->increment_block_counter ();
2198
+
2199
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
2200
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
2201
+ $ai_last_check = AI_CHECK_INSERTED;
2202
+ $inserted_code = $this->get_code_for_insertion ();
2203
+ $inserted = true;
2204
+ }
2205
+ }
2206
  // $ai_last_check = AI_CHECK_INSERTED;
2207
+ if ($debug_processing) ai_log (ai_log_block_status ($this->number, $ai_last_check));
2208
+
2209
+ if (!$inserted) continue;
2210
  }
2211
  // else continue;
2212
  else {
2756
  foreach ($positions as $position_index) $real_positions []= $position_index >= 0 ? $position_index + 1 : '*';
2757
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' INSERTION POSITIONS: ' . implode (', ', $real_positions));
2758
 
2759
+ $min_paragraphs = intval ($this->get_paragraph_number_minimum());
2760
+
2761
  foreach ($paragraph_positions as $counter => $paragraph_position) {
2762
  if ($position_preview) $inserted_code = "[[AI_AP".($counter + 1)."]]";
2763
  // elseif (!empty ($positions) && in_array ($counter + 1, $positions) && $this->check_block_counter ()) {
2764
  elseif (!empty ($positions) && in_array ($counter, $positions) && $this->check_block_counter ()) {
2765
+
2766
+ $inserted = false;
2767
+
2768
+ $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER;
2769
+ if (count ($paragraph_positions) >= $min_paragraphs) {
2770
+ $this->increment_block_counter ();
2771
+
2772
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
2773
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
2774
+ $ai_last_check = AI_CHECK_INSERTED;
2775
+ $inserted_code = $this->get_code_for_insertion ();
2776
+ $inserted = true;
2777
+ }
2778
+ }
2779
+
2780
+ if ($debug_processing) ai_log (ai_log_block_status ($this->number, $ai_last_check));
2781
+
2782
+ if (!$inserted) continue;
2783
  }
2784
  // else continue;
2785
  else {
constants.php CHANGED
@@ -19,7 +19,7 @@ if (!defined( 'AD_INSERTER_NAME'))
19
  define ('AD_INSERTER_NAME', 'Ad Inserter');
20
 
21
  if (!defined( 'AD_INSERTER_VERSION'))
22
- define ('AD_INSERTER_VERSION', '2.2.8');
23
 
24
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
25
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -413,6 +413,10 @@ define ('AI_TEXT_HIDE', 'Hide');
413
  define ('AI_ADB_DETECTION_STANDARD', 0);
414
  define ('AI_ADB_DETECTION_ADVANCED', 1);
415
 
 
 
 
 
416
  // Click detection
417
  define ('AI_CLICK_DETECTION_STANDARD', 0);
418
  define ('AI_CLICK_DETECTION_ADVANCED', 1);
@@ -474,6 +478,7 @@ define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
474
  define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
475
  define ('DEFAULT_ADB_DETECTION', AI_ADB_DETECTION_ADVANCED);
476
  define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
 
477
 
478
  define ('AI_ADBLOCKING_DETECTION', true);
479
  define ('AI_AMP_HEADER_STYLES', true);
19
  define ('AD_INSERTER_NAME', 'Ad Inserter');
20
 
21
  if (!defined( 'AD_INSERTER_VERSION'))
22
+ define ('AD_INSERTER_VERSION', '2.2.9');
23
 
24
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
25
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
413
  define ('AI_ADB_DETECTION_STANDARD', 0);
414
  define ('AI_ADB_DETECTION_ADVANCED', 1);
415
 
416
+ // Output buffering
417
+ define ('AI_OUTPUT_BUFFERING_DISABLED', 0);
418
+ define ('AI_OUTPUT_BUFFERING_ENABLED', 1);
419
+
420
  // Click detection
421
  define ('AI_CLICK_DETECTION_STANDARD', 0);
422
  define ('AI_CLICK_DETECTION_ADVANCED', 1);
478
  define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
479
  define ('DEFAULT_ADB_DETECTION', AI_ADB_DETECTION_ADVANCED);
480
  define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
481
+ define ('DEFAULT_OUTPUT_BUFFERING', AI_OUTPUT_BUFFERING_DISABLED);
482
 
483
  define ('AI_ADBLOCKING_DETECTION', true);
484
  define ('AI_AMP_HEADER_STYLES', true);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.2.8"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #ai-data {
2
+ font-family: "2.2.9"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.2.8";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
1
+ var javascript_version = "2.2.9";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: ads, adsense, ad management, advertising manager, advanced contextual ads,
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.2.4
9
- Stable tag: 2.2.7
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
@@ -754,6 +754,10 @@ AD CODE RIGHT
754
 
755
  == Changelog ==
756
 
 
 
 
 
757
  = 2.2.8 =
758
  - Added position for automatic insertion Above header (after `<body>` tag)
759
  - Added rotation code editor
@@ -898,6 +902,10 @@ AD CODE RIGHT
898
 
899
  == Upgrade Notice ==
900
 
 
 
 
 
901
  = 2.2.8 =
902
  Added position for automatic insertion Above header (after `<body>` tag);
903
  Added rotation code editor;
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.2.4
9
+ Stable tag: 2.2.8
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
754
 
755
  == Changelog ==
756
 
757
+ = 2.2.9 =
758
+ - Output buffering is now disabled by default (for position Above header you need to enable it)
759
+ - Fix for min. paragraph number not processed
760
+
761
  = 2.2.8 =
762
  - Added position for automatic insertion Above header (after `<body>` tag)
763
  - Added rotation code editor
902
 
903
  == Upgrade Notice ==
904
 
905
+ = 2.2.9 =
906
+ Output buffering is now disabled by default (for position Above header you need to enable it);
907
+ Fix for min. paragraph number not processed
908
+
909
  = 2.2.8 =
910
  Added position for automatic insertion Above header (after `<body>` tag);
911
  Added rotation code editor;
settings.php CHANGED
@@ -724,7 +724,7 @@ function generate_settings_form (){
724
  Automatic Insertion:
725
  <select class="ai-image-selection" style="margin-bottom: 3px;" id="display-type-<?php echo $block; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_automatic_insertion(); ?>" style="width:200px;">
726
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion disabled" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" data-title="<?php echo AI_TEXT_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
727
- <?php if (defined ('AI_BUFFERING')) : ?>
728
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion above-header" value="<?php echo AI_AUTOMATIC_INSERTION_ABOVE_HEADER; ?>" data-title="<?php echo AI_TEXT_ABOVE_HEADER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_ABOVE_HEADER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ABOVE_HEADER; ?></option>
729
  <?php endif; ?>
730
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-post" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" data-title="<?php echo AI_TEXT_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
@@ -1624,6 +1624,17 @@ function generate_settings_form (){
1624
  </select>
1625
  </td>
1626
  </tr>
 
 
 
 
 
 
 
 
 
 
 
1627
  <tr>
1628
  <td>
1629
  No paragraph counting inside
724
  Automatic Insertion:
725
  <select class="ai-image-selection" style="margin-bottom: 3px;" id="display-type-<?php echo $block; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_automatic_insertion(); ?>" style="width:200px;">
726
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion disabled" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" data-title="<?php echo AI_TEXT_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
727
+ <?php if (defined ('AI_BUFFERING') && get_output_buffering ()) : ?>
728
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion above-header" value="<?php echo AI_AUTOMATIC_INSERTION_ABOVE_HEADER; ?>" data-title="<?php echo AI_TEXT_ABOVE_HEADER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_ABOVE_HEADER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ABOVE_HEADER; ?></option>
729
  <?php endif; ?>
730
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion before-post" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" data-title="<?php echo AI_TEXT_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
1624
  </select>
1625
  </td>
1626
  </tr>
1627
+ <tr>
1628
+ <td>
1629
+ Output buffering
1630
+ </td>
1631
+ <td>
1632
+ <select id="output-buffering" name="output-buffering" default="<?php echo DEFAULT_OUTPUT_BUFFERING; ?>" title="Needed for position Above header but may not work with all themes">
1633
+ <option value="<?php echo AI_OUTPUT_BUFFERING_DISABLED; ?>" <?php echo get_output_buffering() == AI_OUTPUT_BUFFERING_DISABLED ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
1634
+ <option value="<?php echo AI_OUTPUT_BUFFERING_ENABLED; ?>" <?php echo get_output_buffering() == AI_OUTPUT_BUFFERING_ENABLED ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ENABLED; ?></option>
1635
+ </select>
1636
+ </td>
1637
+ </tr>
1638
  <tr>
1639
  <td>
1640
  No paragraph counting inside