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

Version Description

  • Added option to insert into HTML element (prepend, append, replace content)
  • Added option to remove HTML element
  • Added option to not show deactivation feedback form
  • Added support for negative relative positions for paragraph counting
  • Few minor bug fixes, cosmetic changes and code improvements
Download this release

Release Info

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

Code changes from version 2.4.0 to 2.4.1

ad-inserter.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /*
4
  Plugin Name: Ad Inserter
5
- Version: 2.4.0
6
  Description: Ad management plugin with many advanced advertising features to insert ads at optimal positions
7
  Author: Igor Funa
8
  Author URI: http://igorfuna.com/
@@ -13,6 +13,13 @@ Plugin URI: https://adinserter.pro/documentation
13
 
14
  Change Log
15
 
 
 
 
 
 
 
 
16
  Ad Inserter 2.4.0 - 2018-09-26
17
  - Improved code for client-side insertion
18
  - Added support for usage tracking
@@ -632,63 +639,268 @@ function ai_buffering_end () {
632
  $obj = $block_object [$block];
633
  $obj->clear_code_cache ();
634
 
635
- $insert_after = $obj->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT;
636
- $selector = $obj->get_html_selector ();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
 
638
  libxml_use_internal_errors (true);
639
  $content = phpQuery::newDocumentHTML ($body);
640
  libxml_use_internal_errors (false);
641
- foreach (pq ($selector) as $element){
642
- if ($insert_after)
643
- pq ($element)->after (AI_MARKER_START.$element->tagName.AI_MARKER_END); else
 
 
 
 
 
 
 
 
 
 
 
 
644
  pq ($element)->before (AI_MARKER_START.$element->tagName.AI_MARKER_END);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  }
646
 
647
- $markers = preg_split ('/('.AI_MARKER_START.'.*?'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
 
 
 
 
 
 
 
 
 
648
 
649
  $content_before = '';
650
  $insertions = array ();
651
  foreach ($markers as $marker) {
652
  if (strpos ($marker, AI_MARKER_START) === 0) {
653
- $tag = str_replace (array (AI_MARKER_START, AI_MARKER_END), '', $marker);
 
 
 
 
 
 
 
 
654
 
655
- if ($insert_after && in_array ($tag, $no_closing_tag)) $tag_string = '>'; else
656
- $tag_string = $insert_after ? "</{$tag}>" : "<{$tag}";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
 
658
  preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches);
659
- $insertions []= array ($tag_string, $insert_after ? count ($tag_matches [0]) : count ($tag_matches [0]) + 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
660
  continue;
661
  }
662
  $content_before .= $marker;
663
  }
664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665
  $insertion_offsets = array ();
666
  foreach ($insertions as $insertion) {
667
  $tag = $insertion [0];
668
  $tag_counter = $insertion [1];
669
  preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE);
670
  if (isset ($org_tag_matches [0][$tag_counter - 1])) {
671
- if ($insert_after)
672
- $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag); else
 
 
 
 
 
 
 
 
 
 
 
 
673
  $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1];
 
 
674
  }
675
  }
676
 
677
  sort ($insertion_offsets);
678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
  $new_content = '';
680
  $current_offset = 0;
681
- foreach ($insertion_offsets as $insertion_offset) {
682
  if ($multibyte)
683
  $new_content .= mb_substr ($body, $current_offset, $insertion_offset - $current_offset);
684
  $new_content .= substr ($body, $current_offset, $insertion_offset - $current_offset);
685
 
686
- $current_offset = $insertion_offset;
 
 
 
 
 
 
 
 
 
 
687
 
688
  ob_start ();
689
 
690
- $action = ($insert_after ? 'after' : 'before') . '_html_element';
691
- $action_name = ($insert_after ? 'After ' : 'Before ') . $selector;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
 
693
  $ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] = array ($block);
694
  ai_custom_hook ($action, $action_name);
@@ -1561,8 +1773,6 @@ function add_footer_inline_scripts () {
1561
  if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1562
  echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: -1px;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
1563
  echo '<!--noptimize-->', "\n";
1564
- // echo "<script type='text/javascript' src='", plugins_url ('js/ads.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1565
- // echo "<script type='text/javascript' src='", plugins_url ('js/sponsors.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1566
  echo "<script type='text/javascript' src='", plugins_url ('js/ads.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1567
  echo "<script type='text/javascript' src='", plugins_url ('js/sponsors.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1568
  echo '<!--/noptimize-->', "\n";
@@ -1711,7 +1921,7 @@ function ai_admin_notice_hook () {
1711
  <div class="ai-notice-element ai-notice-buttons last">
1712
  <div class="ai-notice-text-button ai-notice-dismiss" data-notice="yes">
1713
  <button class="button-primary ai-notice-dismiss" data-notice="yes">
1714
- <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" class="ai-notice-dismiss" target="_blank" data-notice="yes">Rate Ad Inserter</a>
1715
  </button>
1716
  </div>
1717
 
@@ -4053,6 +4263,7 @@ function ai_generate_extract (&$settings) {
4053
  // Change insertion position to actual server-side insertion position
4054
  switch ($automatic_insertion) {
4055
  case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
 
4056
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
4057
  switch ($obj->get_html_element_insertion ()) {
4058
  case AI_HTML_INSERTION_SEREVR_SIDE:
@@ -4953,8 +5164,9 @@ function ai_adinserter ($ad_number = '', $ignore = ''){
4953
  if ($obj->get_disable_insertion ()) return "";
4954
 
4955
  // Last check before counter check before insertion
4956
- $ai_last_check = AI_CHECK_CODE;
4957
- if ($obj->ai_getCode () == '') return "";
 
4958
 
4959
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
4960
 
@@ -5078,8 +5290,9 @@ function ai_content_hook ($content = '') {
5078
  if ($obj->get_disable_insertion ()) continue;
5079
 
5080
  // Last check before counter check before insertion
5081
- $ai_last_check = AI_CHECK_CODE;
5082
- if ($obj->ai_getCode () == '') continue;
 
5083
 
5084
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5085
  if ($max_page_blocks_enabled) {
@@ -5246,8 +5459,9 @@ function ai_excerpt_hook ($content = '') {
5246
  if ($obj->get_disable_insertion ()) continue;
5247
 
5248
  // Last check before counter check before insertion
5249
- $ai_last_check = AI_CHECK_CODE;
5250
- if ($obj->ai_getCode () == '') continue;
 
5251
 
5252
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5253
  if ($max_page_blocks_enabled) {
@@ -5392,8 +5606,9 @@ function ai_comment_callback ($comment, $args, $depth) {
5392
  if ($obj->get_disable_insertion ()) continue;
5393
 
5394
  // Last check before counter check before insertion
5395
- $ai_last_check = AI_CHECK_CODE;
5396
- if ($obj->ai_getCode () == '') continue;
 
5397
 
5398
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5399
  if ($max_page_blocks_enabled) {
@@ -5498,8 +5713,9 @@ function ai_comment_end_callback ($comment, $args, $depth) {
5498
  if ($obj->get_disable_insertion ()) continue;
5499
 
5500
  // Last check before counter check before insertion
5501
- $ai_last_check = AI_CHECK_CODE;
5502
- if ($obj->ai_getCode () == '') continue;
 
5503
 
5504
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5505
  if ($max_page_blocks_enabled) {
@@ -5561,8 +5777,9 @@ function ai_comment_end_callback ($comment, $args, $depth) {
5561
  if ($obj->get_disable_insertion ()) continue;
5562
 
5563
  // Last check before counter check before insertion
5564
- $ai_last_check = AI_CHECK_CODE;
5565
- if ($obj->ai_getCode () == '') continue;
 
5566
 
5567
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5568
  if ($max_page_blocks_enabled) {
@@ -5664,8 +5881,9 @@ function ai_custom_hook ($action, $name, $hook_parameter = null, $hook_check = n
5664
  if ($obj->get_disable_insertion ()) continue;
5665
 
5666
  // Last check before counter check before insertion
5667
- $ai_last_check = AI_CHECK_CODE;
5668
- if ($obj->ai_getCode () == '') continue;
 
5669
 
5670
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5671
  if ($max_page_blocks_enabled) {
@@ -5893,8 +6111,9 @@ function ai_process_shortcode (&$block, $atts) {
5893
  if ($obj->get_disable_insertion ()) return "";
5894
 
5895
  // Last check before counter check before insertion
5896
- $ai_last_check = AI_CHECK_CODE;
5897
- if ($obj->ai_getCode () == '') return "";
 
5898
 
5899
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5900
  if ($max_page_blocks_enabled) {
@@ -6683,9 +6902,8 @@ if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) {
6683
 
6684
  $ai_dst = new DST_Client ($dst_settings);
6685
  }
6686
-
6687
  function ai_notice_text ($text) {
6688
- $text = __('Thank you for installing [STRONG][NAME][/STRONG]. We would like to track its usage on your site. This is completely optional and can be disabled at any time.[P]
6689
  We don\'t record any sensitive data, only information regarding the WordPress environment and %1$s usage, which will help us to make improvements to the %1$s.', 'ad-inserter');
6690
 
6691
  return $text;
@@ -6700,11 +6918,11 @@ if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) {
6700
 
6701
  $install_timestamp = get_option (AI_INSTALL_NAME);
6702
  if ($install_timestamp) {
6703
- $install_date = date ("Y-m-d", $install_timestamp + get_option ('gmt_offset') * 3600);
6704
  } else $install_date = '';
6705
 
6706
  if (isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'])) {
6707
- $settings_date = date ("Y-m-d", $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'] + get_option ('gmt_offset') * 3600);
6708
  } else $settings_date = '';
6709
 
6710
  $count_posts = wp_count_posts ();
@@ -6719,8 +6937,20 @@ if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) {
6719
  return ($options);
6720
  }
6721
 
 
 
 
 
 
 
 
 
 
 
 
6722
  add_filter (DST_Client::DST_FILTER_OPTIN_NOTICE_TEXT . AD_INSERTER_SLUG, 'ai_notice_text');
6723
- add_filter (DST_Client::DST_FILTER_OPTIONS . AD_INSERTER_SLUG, 'ai_dst_options');
 
6724
 
6725
  ai_start_dst ();
6726
  }
2
 
3
  /*
4
  Plugin Name: Ad Inserter
5
+ Version: 2.4.1
6
  Description: Ad management plugin with many advanced advertising features to insert ads at optimal positions
7
  Author: Igor Funa
8
  Author URI: http://igorfuna.com/
13
 
14
  Change Log
15
 
16
+ Ad Inserter 2.4.1 - 2018-10-05
17
+ - Added option to insert into HTML element (prepend, append, replace content)
18
+ - Added option to remove HTML element
19
+ - Added option to not show deactivation feedback form
20
+ - Added support for negative relative positions for paragraph counting
21
+ - Few minor bug fixes, cosmetic changes and code improvements
22
+
23
  Ad Inserter 2.4.0 - 2018-09-26
24
  - Improved code for client-side insertion
25
  - Added support for usage tracking
639
  $obj = $block_object [$block];
640
  $obj->clear_code_cache ();
641
 
642
+ switch ($obj->get_automatic_insertion ()) {
643
+ case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
644
+ $insertion_position = 'before';
645
+ break;
646
+ case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
647
+ $insertion_position = 'after';
648
+ break;
649
+ case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT:
650
+ switch ($obj->get_inside_element ()) {
651
+ case AI_HTML_PREPEND_CONTENT:
652
+ $insertion_position = 'prepend';
653
+ break;
654
+ case AI_HTML_APPEND_CONTENT:
655
+ $insertion_position = 'append';
656
+ break;
657
+ case AI_HTML_REPLACE_CONTENT:
658
+ $insertion_position = 'replace-content';
659
+ break;
660
+ case AI_HTML_REPLACE_ELEMENT:
661
+ $insertion_position = 'replace-element';
662
+ break;
663
+ }
664
+ break;
665
+ }
666
+
667
+ $selector = $obj->get_html_selector ();
668
 
669
  libxml_use_internal_errors (true);
670
  $content = phpQuery::newDocumentHTML ($body);
671
  libxml_use_internal_errors (false);
672
+
673
+ foreach (pq ($selector) as $element) {
674
+
675
+ if (in_array ($element->tagName, $no_closing_tag)) {
676
+ switch ($insertion_position) {
677
+ case 'replace-content':
678
+ case 'prepend':
679
+ case 'append':
680
+ $insertion_position = 'after';
681
+ break;
682
+ }
683
+ }
684
+
685
+ switch ($insertion_position) {
686
+ case 'before':
687
  pq ($element)->before (AI_MARKER_START.$element->tagName.AI_MARKER_END);
688
+ break;
689
+ case 'after':
690
+ pq ($element)->after (AI_MARKER_START.$element->tagName.AI_MARKER_END);
691
+ break;
692
+ case 'prepend':
693
+ pq ($element)->prepend (AI_MARKER_START.$element->tagName.AI_MARKER_END);
694
+ break;
695
+ case 'append':
696
+ pq ($element)->append (AI_MARKER_START.$element->tagName.AI_MARKER_END);
697
+ break;
698
+ case 'replace-content':
699
+ pq ($element)->prepend (AI_MARKER_START.'-'.$element->tagName.'-'.AI_MARKER_END);
700
+ pq ($element)->append (AI_MARKER_START.'='.$element->tagName.'='.AI_MARKER_END);
701
+ break;
702
+ case 'replace-element':
703
+ pq ($element)->before (AI_MARKER_START.'-'.$element->tagName.'-'.AI_MARKER_END);
704
+ pq ($element)->after (AI_MARKER_START.'='.$element->tagName.'='.AI_MARKER_END);
705
+ break;
706
+ }
707
  }
708
 
709
+ switch ($insertion_position) {
710
+ case 'replace-content':
711
+ case 'replace-element':
712
+ $markers = preg_split ('/('.AI_MARKER_START.'-.*?-'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
713
+ $markers2 = preg_split ('/('.AI_MARKER_START.'=.*?='.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
714
+ break;
715
+ default:
716
+ $markers = preg_split ('/('.AI_MARKER_START.'.*?'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
717
+ break;
718
+ }
719
 
720
  $content_before = '';
721
  $insertions = array ();
722
  foreach ($markers as $marker) {
723
  if (strpos ($marker, AI_MARKER_START) === 0) {
724
+ switch ($insertion_position) {
725
+ case 'replace-content':
726
+ case 'replace-element':
727
+ $tag = str_replace (array (AI_MARKER_START.'-', '-'.AI_MARKER_END), '', $marker);
728
+ break;
729
+ default:
730
+ $tag = str_replace (array (AI_MARKER_START, AI_MARKER_END), '', $marker);
731
+ break;
732
+ }
733
 
734
+ switch ($insertion_position) {
735
+ case 'before':
736
+ case 'replace-element':
737
+ $tag_string = "<{$tag}";
738
+ break;
739
+ case 'after':
740
+ if (in_array ($tag, $no_closing_tag)) $tag_string = '>'; else $tag_string = "</{$tag}>";
741
+ break;
742
+ case 'prepend':
743
+ case 'replace-content':
744
+ $tag_string = "<{$tag}[^>]*>";
745
+ break;
746
+ case 'append':
747
+ $tag_string = "</{$tag}>";
748
+ break;
749
+ }
750
 
751
  preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches);
752
+
753
+ switch ($insertion_position) {
754
+ case 'before':
755
+ case 'replace-element':
756
+ $insertions []= array ($tag_string, count ($tag_matches [0]) + 1);
757
+ break;
758
+ case 'after':
759
+ $insertions []= array ($tag_string, count ($tag_matches [0]));
760
+ break;
761
+ case 'replace-content':
762
+ case 'prepend':
763
+ $insertions []= array ($tag_string, count ($tag_matches [0]));
764
+ break;
765
+ case 'append':
766
+ $insertions []= array ($tag_string, count ($tag_matches [0]) + 1);
767
+ break;
768
+ }
769
+
770
  continue;
771
  }
772
  $content_before .= $marker;
773
  }
774
 
775
+ switch ($insertion_position) {
776
+ case 'replace-content':
777
+ case 'replace-element':
778
+ $content_before = '';
779
+ $insertions2 = array ();
780
+ foreach ($markers2 as $marker) {
781
+ if (strpos ($marker, AI_MARKER_START) === 0) {
782
+ $tag = str_replace (array (AI_MARKER_START.'=', '='.AI_MARKER_END), '', $marker);
783
+ $tag_string = "</{$tag}>";
784
+
785
+ preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches);
786
+
787
+ switch ($insertion_position) {
788
+ case 'replace-content':
789
+ $insertions2 []= array ($tag_string, count ($tag_matches [0]) + 1);
790
+ break;
791
+ case 'replace-element':
792
+ $insertions2 []= array ($tag_string, count ($tag_matches [0]));
793
+ break;
794
+ }
795
+
796
+ continue;
797
+ }
798
+ $content_before .= $marker;
799
+ }
800
+ break;
801
+ }
802
+
803
  $insertion_offsets = array ();
804
  foreach ($insertions as $insertion) {
805
  $tag = $insertion [0];
806
  $tag_counter = $insertion [1];
807
  preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE);
808
  if (isset ($org_tag_matches [0][$tag_counter - 1])) {
809
+
810
+ switch ($insertion_position) {
811
+ case 'before':
812
+ case 'replace-element':
813
+ $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1];
814
+ break;
815
+ case 'after':
816
+ $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag);
817
+ break;
818
+ case 'prepend':
819
+ case 'replace-content':
820
+ $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($org_tag_matches [0][$tag_counter - 1][0]);
821
+ break;
822
+ case 'append':
823
  $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1];
824
+ break;
825
+ }
826
  }
827
  }
828
 
829
  sort ($insertion_offsets);
830
 
831
+ switch ($insertion_position) {
832
+ case 'replace-content':
833
+ case 'replace-element':
834
+ $insertion_offsets2 = array ();
835
+ foreach ($insertions2 as $insertion) {
836
+ $tag = $insertion [0];
837
+ $tag_counter = $insertion [1];
838
+ preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE);
839
+ if (isset ($org_tag_matches [0][$tag_counter - 1])) {
840
+
841
+ switch ($insertion_position) {
842
+ case 'replace-content':
843
+ $insertion_offsets2 []= $org_tag_matches [0][$tag_counter - 1][1];
844
+ break;
845
+ case 'replace-element':
846
+ $insertion_offsets2 []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag);
847
+ break;
848
+ }
849
+ }
850
+ }
851
+
852
+ sort ($insertion_offsets2);
853
+
854
+ break;
855
+ }
856
+
857
  $new_content = '';
858
  $current_offset = 0;
859
+ foreach ($insertion_offsets as $index => $insertion_offset) {
860
  if ($multibyte)
861
  $new_content .= mb_substr ($body, $current_offset, $insertion_offset - $current_offset);
862
  $new_content .= substr ($body, $current_offset, $insertion_offset - $current_offset);
863
 
864
+ switch ($insertion_position) {
865
+ case 'replace-content':
866
+ case 'replace-element':
867
+ if (isset ($insertion_offsets2 [$index])) {
868
+ $current_offset = $insertion_offsets2 [$index];
869
+ } else $current_offset = $insertion_offset;
870
+ break;
871
+ default:
872
+ $current_offset = $insertion_offset;
873
+ break;
874
+ }
875
 
876
  ob_start ();
877
 
878
+ switch ($insertion_position) {
879
+ case 'before':
880
+ $action = 'before_html_element';
881
+ $action_name = 'Before ' . $selector;
882
+ break;
883
+ case 'after':
884
+ $action = 'after_html_element';
885
+ $action_name = 'After ' . $selector;
886
+ break;
887
+ case 'prepend':
888
+ $action = 'prepend_html_element';
889
+ $action_name = 'Prepend ' . $selector;
890
+ break;
891
+ case 'append':
892
+ $action = 'append_html_element';
893
+ $action_name = 'Append ' . $selector;
894
+ break;
895
+ case 'replace-content':
896
+ $action = 'replace_content_html_element';
897
+ $action_name = 'Replace content' . $selector;
898
+ break;
899
+ case 'replace-element':
900
+ $action = 'replace_html_element';
901
+ $action_name = 'Replace ' . $selector;
902
+ break;
903
+ }
904
 
905
  $ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] = array ($block);
906
  ai_custom_hook ($action, $action_name);
1773
  if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1774
  echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: -1px;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
1775
  echo '<!--noptimize-->', "\n";
 
 
1776
  echo "<script type='text/javascript' src='", plugins_url ('js/ads.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1777
  echo "<script type='text/javascript' src='", plugins_url ('js/sponsors.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1778
  echo '<!--/noptimize-->', "\n";
1921
  <div class="ai-notice-element ai-notice-buttons last">
1922
  <div class="ai-notice-text-button ai-notice-dismiss" data-notice="yes">
1923
  <button class="button-primary ai-notice-dismiss" data-notice="yes">
1924
+ <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post" class="ai-notice-dismiss" target="_blank" data-notice="yes">Rate Ad Inserter</a>
1925
  </button>
1926
  </div>
1927
 
4263
  // Change insertion position to actual server-side insertion position
4264
  switch ($automatic_insertion) {
4265
  case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
4266
+ case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT:
4267
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
4268
  switch ($obj->get_html_element_insertion ()) {
4269
  case AI_HTML_INSERTION_SEREVR_SIDE:
5164
  if ($obj->get_disable_insertion ()) return "";
5165
 
5166
  // Last check before counter check before insertion
5167
+ // $ai_last_check = AI_CHECK_CODE;
5168
+ // if ($obj->ai_getCode () == '') return "";
5169
+ if ($obj->empty_code ()) return "";
5170
 
5171
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5172
 
5290
  if ($obj->get_disable_insertion ()) continue;
5291
 
5292
  // Last check before counter check before insertion
5293
+ // $ai_last_check = AI_CHECK_CODE;
5294
+ // if ($obj->ai_getCode () == '') continue;
5295
+ if ($obj->empty_code ()) continue;
5296
 
5297
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5298
  if ($max_page_blocks_enabled) {
5459
  if ($obj->get_disable_insertion ()) continue;
5460
 
5461
  // Last check before counter check before insertion
5462
+ // $ai_last_check = AI_CHECK_CODE;
5463
+ // if ($obj->ai_getCode () == '') continue;
5464
+ if ($obj->empty_code ()) continue;
5465
 
5466
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5467
  if ($max_page_blocks_enabled) {
5606
  if ($obj->get_disable_insertion ()) continue;
5607
 
5608
  // Last check before counter check before insertion
5609
+ // $ai_last_check = AI_CHECK_CODE;
5610
+ // if ($obj->ai_getCode () == '') continue;
5611
+ if ($obj->empty_code ()) continue;
5612
 
5613
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5614
  if ($max_page_blocks_enabled) {
5713
  if ($obj->get_disable_insertion ()) continue;
5714
 
5715
  // Last check before counter check before insertion
5716
+ // $ai_last_check = AI_CHECK_CODE;
5717
+ // if ($obj->ai_getCode () == '') continue;
5718
+ if ($obj->empty_code ()) continue;
5719
 
5720
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5721
  if ($max_page_blocks_enabled) {
5777
  if ($obj->get_disable_insertion ()) continue;
5778
 
5779
  // Last check before counter check before insertion
5780
+ // $ai_last_check = AI_CHECK_CODE;
5781
+ // if ($obj->ai_getCode () == '') continue;
5782
+ if ($obj->empty_code ()) continue;
5783
 
5784
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5785
  if ($max_page_blocks_enabled) {
5881
  if ($obj->get_disable_insertion ()) continue;
5882
 
5883
  // Last check before counter check before insertion
5884
+ // $ai_last_check = AI_CHECK_CODE;
5885
+ // if ($obj->ai_getCode () == '') continue;
5886
+ if ($obj->empty_code ()) continue;
5887
 
5888
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
5889
  if ($max_page_blocks_enabled) {
6111
  if ($obj->get_disable_insertion ()) return "";
6112
 
6113
  // Last check before counter check before insertion
6114
+ // $ai_last_check = AI_CHECK_CODE;
6115
+ // if ($obj->ai_getCode () == '') return "";
6116
+ if ($obj->empty_code ()) return "";
6117
 
6118
  $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled ();
6119
  if ($max_page_blocks_enabled) {
6902
 
6903
  $ai_dst = new DST_Client ($dst_settings);
6904
  }
 
6905
  function ai_notice_text ($text) {
6906
+ $text = __('Thank you for installing [STRONG][NAME][/STRONG]. We would like to <a href="https://wordpress.org/plugins/ad-inserter/#what%%20is%%20usage%%20tracking%%3F" target=_blank" style="text-decoration: none; box-shadow: 0 0 0;">track its usage</a> on your site. This is completely optional and can be disabled at any time.[P]
6907
  We don\'t record any sensitive data, only information regarding the WordPress environment and %1$s usage, which will help us to make improvements to the %1$s.', 'ad-inserter');
6908
 
6909
  return $text;
6918
 
6919
  $install_timestamp = get_option (AI_INSTALL_NAME);
6920
  if ($install_timestamp) {
6921
+ $install_date = $install_timestamp;
6922
  } else $install_date = '';
6923
 
6924
  if (isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'])) {
6925
+ $settings_date = $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'];
6926
  } else $settings_date = '';
6927
 
6928
  $count_posts = wp_count_posts ();
6937
  return ($options);
6938
  }
6939
 
6940
+ function ai_dst_form_text ($form) {
6941
+ $form ['body'] =
6942
+ '</p>' .
6943
+ 'Looking for <a href="https://adinserter.pro/documentation" target="_blank" style="text-decoration: none; box-shadow: 0 0 0;">Documentation</a>, ' .
6944
+ '<a href="https://adinserter.pro/documentation/common-settings" target="_blank" style="text-decoration: none; box-shadow: 0 0 0;">Common Settings</a>, <a href="https://adinserter.pro/documentation/quick-start" target="_blank" style="text-decoration: none; box-shadow: 0 0 0;">Quick Start</a> or help for <a href="https://adinserter.pro/documentation/adsense-ads" target="_blank" style="text-decoration: none; box-shadow: 0 0 0;">AdSense ads</a>? ' .
6945
+ 'The plugin doesn\\\'t work with your theme? <a href="https://adinserter.pro/contact#help" target="_blank" style="text-decoration: none; box-shadow: 0 0 0;">Let us know</a> and we\\\'ll try to help you.' .
6946
+ '<hr /><p>' .
6947
+ $form ['body'];
6948
+ return ($form);
6949
+ }
6950
+
6951
  add_filter (DST_Client::DST_FILTER_OPTIN_NOTICE_TEXT . AD_INSERTER_SLUG, 'ai_notice_text');
6952
+ add_filter (DST_Client::DST_FILTER_OPTIONS . AD_INSERTER_SLUG, 'ai_dst_options');
6953
+ add_filter (DST_Client::DST_FILTER_FORM_TEXT . AD_INSERTER_SLUG, 'ai_dst_form_text');
6954
 
6955
  ai_start_dst ();
6956
  }
class.php CHANGED
@@ -369,6 +369,21 @@ abstract class ai_BaseCodeBlock {
369
  unset ($this->wp_options ['GENERATED_CODE']);
370
  }
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  public function ai_getCode (){
373
  global $block_object, $ai_total_php_time, $ai_wp_data;
374
 
@@ -431,6 +446,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
431
  $this->wp_options [AI_OPTION_HTML_SELECTOR] = AD_EMPTY_DATA;
432
  $this->wp_options [AI_OPTION_SERVER_SIDE_INSERTION] = DEFAULT_SERVER_SIDE_INSERTION;
433
  $this->wp_options [AI_OPTION_HTML_ELEMENT_INSERTION] = DEFAULT_HTML_ELEMENT_INSERTION;
 
434
  $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] = AD_ONE;
435
  $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] = AD_EMPTY_DATA;
436
  $this->wp_options [AI_OPTION_MIN_WORDS_ABOVE] = AD_EMPTY_DATA;
@@ -616,6 +632,9 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
616
  case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
617
  return AI_TEXT_BEFORE_HTML_ELEMENT;
618
  break;
 
 
 
619
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
620
  return AI_TEXT_AFTER_HTML_ELEMENT;
621
  break;
@@ -1167,6 +1186,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1167
  return $option;
1168
  }
1169
 
 
 
 
 
 
1170
  public function get_paragraph_number(){
1171
  $option = isset ($this->wp_options [AI_OPTION_PARAGRAPH_NUMBER]) ? $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] : "";
1172
  return $option;
@@ -2334,6 +2358,27 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2334
  if ($server_side_html_insertion && !$viewports_insertion) return $this->get_code_for_insertion ($include_viewport_classes, $hidden_widgets, $code_only);
2335
  $html_element_insertion = true;
2336
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2337
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
2338
  $insertion = 'after';
2339
  if ($server_side_html_insertion && !$viewports_insertion) return $this->get_code_for_insertion ($include_viewport_classes, $hidden_widgets, $code_only);
@@ -2801,50 +2846,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2801
 
2802
  get_paragraph_start_positions ($content, $multibyte, $dummy, $paragraph_start_strings, $paragraph_positions, $active_paragraph_positions);
2803
 
2804
- // foreach ($paragraph_start_strings as $paragraph_start_string) {
2805
- // if (trim ($paragraph_start_string) == '') continue;
2806
-
2807
- // $last_position = - 1;
2808
-
2809
- // $paragraph_start_string = trim ($paragraph_start_string);
2810
- // if ($paragraph_start_string == "#") {
2811
- // $paragraph_start = "\r\n\r\n";
2812
- // if (!in_array (0, $paragraph_positions)) {
2813
- // $paragraph_positions [] = 0;
2814
- // $active_paragraph_positions [0] = 1;
2815
- // }
2816
- // } else $paragraph_start = '<' . $paragraph_start_string;
2817
-
2818
- // if ($multibyte) {
2819
- // $paragraph_start_len = mb_strlen ($paragraph_start);
2820
- // while (mb_stripos ($content, $paragraph_start, $last_position + 1) !== false) {
2821
- // $last_position = mb_stripos ($content, $paragraph_start, $last_position + 1);
2822
- // if ($paragraph_start_string == "#") {
2823
- // $paragraph_positions [] = $last_position + 4;
2824
- // $active_paragraph_positions [$last_position + 4] = 1;
2825
- // } elseif (mb_substr ($content, $last_position + $paragraph_start_len, 1) == ">" || mb_substr ($content, $last_position + $paragraph_start_len, 1) == " ") {
2826
- // $paragraph_positions [] = $last_position;
2827
- // $active_paragraph_positions [$last_position] = 1;
2828
- // }
2829
- // }
2830
- // } else {
2831
- // $paragraph_start_len = strlen ($paragraph_start);
2832
- // while (stripos ($content, $paragraph_start, $last_position + 1) !== false) {
2833
- // $last_position = stripos ($content, $paragraph_start, $last_position + 1);
2834
- // if ($paragraph_start_string == "#") {
2835
- // $paragraph_positions [] = $last_position + 4;
2836
- // $active_paragraph_positions [$last_position + 4] = 1;
2837
- // } elseif ($content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ") {
2838
- // $paragraph_positions [] = $last_position;
2839
- // $active_paragraph_positions [$last_position] = 1;
2840
- // }
2841
- // }
2842
- // }
2843
- // }
2844
-
2845
  // Nothing to do
2846
  $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS;
2847
- // if (count ($paragraph_positions) == 0) return $content;
2848
  if (array_sum ($active_paragraph_positions) == 0) return $content;
2849
 
2850
  sort ($paragraph_positions);
@@ -2903,7 +2906,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2903
 
2904
  if (count ($special_element_offsets) != 0) {
2905
 
2906
- // $filtered_paragraph_positions = array ();
2907
  $inside_special_element = array ();
2908
 
2909
  foreach ($special_element_offsets as $special_element_offset) {
@@ -2913,15 +2915,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2913
  }
2914
 
2915
  foreach ($paragraph_positions as $index => $paragraph_position) {
2916
- // if (!in_array ($paragraph_position, $inside_special_element)) $filtered_paragraph_positions []= $paragraph_position;
2917
  if (in_array ($paragraph_position, $inside_special_element)) $active_paragraph_positions [$index] = 0;
2918
  }
2919
-
2920
- // $paragraph_positions = $filtered_paragraph_positions;
2921
  }
2922
 
2923
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE;
2924
- // if (count ($paragraph_positions) == 0) return $content;
2925
  if (array_sum ($active_paragraph_positions) == 0) return $content;
2926
  }
2927
 
@@ -2936,28 +2934,22 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2936
  get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy);
2937
  }
2938
 
2939
- // $filtered_paragraph_positions = array ();
2940
  foreach ($paragraph_positions as $index => $paragraph_position) {
2941
 
2942
  if ($active_paragraph_positions [$index] == 0) continue;
2943
 
2944
  if ($multibyte) {
2945
- // $paragraph_code = $index == count ($paragraph_positions) - 1 ? mb_substr ($content, $paragraph_position) : mb_substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
2946
  $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2947
  } else {
2948
- // $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
2949
  $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2950
  }
2951
 
2952
- // if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
2953
  if (!$this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $active_paragraph_positions [$index] = 0;
2954
  }
2955
- // $paragraph_positions = $filtered_paragraph_positions;
2956
  }
2957
 
2958
  // Nothing to do
2959
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS;
2960
- // if (count ($paragraph_positions) == 0) return $content;
2961
  if (array_sum ($active_paragraph_positions) == 0) return $content;
2962
 
2963
 
@@ -2969,7 +2961,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2969
  get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy);
2970
  }
2971
 
2972
- // $filtered_paragraph_positions = array ();
2973
  $paragraph_text_type = $this->get_paragraph_text_type ();
2974
 
2975
  foreach ($paragraph_positions as $index => $paragraph_position) {
@@ -2977,10 +2968,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2977
  if ($active_paragraph_positions [$index] == 0) continue;
2978
 
2979
  if ($multibyte) {
2980
- // $paragraph_code = $index == count ($paragraph_positions) - 1 ? mb_substr ($content, $paragraph_position) : mb_substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
2981
  $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2982
  } else {
2983
- // $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
2984
  $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2985
  }
2986
 
@@ -3001,7 +2990,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3001
  }
3002
  }
3003
  }
3004
- // if ($found) $filtered_paragraph_positions [] = $paragraph_position;
3005
  if (!$found) $active_paragraph_positions [$index] = 0;
3006
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
3007
  $found = false;
@@ -3020,24 +3008,19 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3020
  }
3021
  }
3022
  }
3023
- // if (!$found) $filtered_paragraph_positions [] = $paragraph_position;
3024
  if ($found) $active_paragraph_positions [$index] = 0;
3025
  }
3026
  }
3027
-
3028
- // $paragraph_positions = $filtered_paragraph_positions;
3029
  }
3030
 
3031
  // Nothing to do
3032
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT;
3033
- // if (count ($paragraph_positions) == 0) return $content;
3034
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3035
 
3036
  $position_text = trim ($this->get_paragraph_number());
3037
 
3038
 
3039
  // Prepare $paragraph_end_positions
3040
- // if (!$position_preview && $position_text == '') {
3041
  if ($position_preview || $position_text == '') {
3042
  if (!isset ($paragraph_end_positions)) {
3043
  $paragraph_end_positions = array ();
@@ -3080,7 +3063,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3080
  if ($position > 0 && $position < 1) {
3081
  $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3082
  }
3083
- elseif ($position < 0) {
 
 
 
3084
  $position = count ($paragraph_positions) + $position;
3085
  }
3086
  elseif ($position == 0) {
@@ -3096,7 +3082,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3096
  if ($position > 0 && $position < 1) {
3097
  $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3098
  }
3099
- elseif ($position < 0) {
 
 
 
3100
  $positions [$index] = count ($paragraph_positions) + $position;
3101
  }
3102
  elseif ($position == 0) {
@@ -3115,7 +3104,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3115
 
3116
  if ($this->get_direction_type() != AD_DIRECTION_FROM_BOTTOM) {
3117
  if ($words_above >= $min_words_above) {
3118
- // $positions []= $index + 1;
3119
  $positions []= $index;
3120
  $words_above = 0;
3121
  }
@@ -3123,10 +3111,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3123
 
3124
 
3125
  if ($multibyte) {
3126
- // $paragraph_code = $index == count ($paragraph_positions) - 1 ? mb_substr ($content, $paragraph_position) : mb_substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
3127
  $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
3128
  } else {
3129
- // $paragraph_code = $index == count ($paragraph_positions) - 1 ? substr ($content, $paragraph_position) : substr ($content, $paragraph_position, $paragraph_positions [$index + 1] - $paragraph_position);
3130
  $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
3131
  }
3132
 
@@ -3134,7 +3120,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3134
 
3135
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
3136
  if ($words_above >= $min_words_above) {
3137
- // $positions []= $index + 1;
3138
  $positions []= $index;
3139
  $words_above = 0;
3140
  }
@@ -3143,7 +3128,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3143
  }
3144
  } else
3145
  foreach ($paragraph_positions as $index => $paragraph_position) {
3146
- // $positions []= $index + 1;
3147
  $positions []= $index;
3148
  }
3149
 
@@ -3187,7 +3171,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3187
 
3188
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
3189
 
3190
- // if (empty ($positions)) {
3191
  if (!empty ($positions)) {
3192
  $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
3193
  $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
@@ -3286,7 +3269,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3286
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' FAILED');
3287
 
3288
  $ai_last_check = AI_CHECK_DO_NOT_INSERT;
3289
- // if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
3290
  if ($this->get_avoid_action() == AD_DO_NOT_INSERT) {
3291
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3292
  $positions [$position_index] = - 1;
@@ -3296,7 +3278,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3296
  switch ($direction) {
3297
  case AD_ABOVE: // Try above
3298
  $ai_last_check = AI_CHECK_AD_ABOVE;
3299
- // if ($position == 0) return $content; // Already at the top - do not insert
3300
  if ($position == 0) {
3301
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3302
  $positions [$position_index] = - 1;
@@ -3307,7 +3289,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3307
  break;
3308
  case AD_BELOW: // Try below
3309
  $ai_last_check = AI_CHECK_AD_BELOW;
3310
- // if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
3311
  if ($position >= count ($paragraph_positions) - 1) {
3312
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3313
  $positions [$position_index] = - 1;
@@ -3323,7 +3305,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3323
  $checks = $max_checks;
3324
  $position = $saved_position;
3325
  $ai_last_check = AI_CHECK_AD_BELOW;
3326
- // if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
3327
  if ($position >= count ($paragraph_positions) - 1) {
3328
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3329
  $positions [$position_index] = - 1;
@@ -3340,7 +3322,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3340
  $checks = $max_checks;
3341
  $position = $saved_position;
3342
  $ai_last_check = AI_CHECK_AD_ABOVE;
3343
- // if ($position == 0) return $content; // Already at the top - do not insert
3344
  if ($position == 0) {
3345
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3346
  $positions [$position_index] = - 1;
@@ -3358,7 +3340,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3358
  }
3359
 
3360
  // Try next position
3361
- // if ($checks <= 0) return $content; // Suitable position not found - do not insert
3362
  if ($checks <= 0) {
3363
  // Suitable position not found - do not insert
3364
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
@@ -3415,7 +3396,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3415
  if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++;
3416
 
3417
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3418
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3419
  if (!$this->get_debug_disable_insertion ()) {
3420
  $inserted_code = $this->get_code_for_serverside_insertion ();
3421
  $ai_last_check = AI_CHECK_INSERTED;
@@ -3456,40 +3436,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3456
 
3457
  // empty $positions
3458
  return $content;
3459
-
3460
-
3461
- // // Deprecated since $postion is now in array $positions
3462
- // $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER;
3463
- // if (count ($paragraph_positions) >= intval ($this->get_paragraph_number_minimum())) {
3464
- // $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER;
3465
- // if (count ($paragraph_positions) > $position) {
3466
- // $this->increment_block_counter ();
3467
-
3468
- // $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3469
- // //if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3470
- // if (!$this->get_debug_disable_insertion ()) {
3471
- // $content_position = $paragraph_positions [$position];
3472
-
3473
- // if ($multibyte) {
3474
- // $content = mb_substr ($content, 0, $content_position) . $this->get_code_for_serverside_insertion () . mb_substr ($content, $content_position);
3475
- // } else {
3476
- // $content = substr_replace ($content, $this->get_code_for_serverside_insertion (), $content_position, 0);
3477
- // }
3478
- // $this->clear_code_cache ();
3479
-
3480
- // $ai_last_check = AI_CHECK_INSERTED;
3481
- // }
3482
- // }
3483
- // }
3484
-
3485
- // return $content;
3486
  }
3487
 
3488
  public function after_paragraph ($content, $position_preview = false) {
3489
  global $ai_wp_data, $ai_last_check, $special_element_tags;
3490
 
3491
- // $no_closing_tag = array ('img', 'hr', 'br');
3492
-
3493
  $multibyte = get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS;
3494
 
3495
  $paragraph_positions = array ();
@@ -3513,66 +3464,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3513
 
3514
  get_paragraph_end_positions ($content, $multibyte, $dummy, $paragraph_end_strings, $paragraph_positions, $active_paragraph_positions);
3515
 
3516
-
3517
- // foreach ($paragraph_end_strings as $paragraph_end_string) {
3518
-
3519
- // $last_position = - 1;
3520
-
3521
- // $paragraph_end_string = trim ($paragraph_end_string);
3522
- // if ($paragraph_end_string == '') continue;
3523
-
3524
- // if (in_array ($paragraph_end_string, $no_closing_tag)) {
3525
- // if (preg_match_all ("/<$paragraph_end_string(.*?)>/", $content, $images)) {
3526
- // foreach ($images [0] as $paragraph_end) {
3527
- // if ($multibyte) {
3528
- // $last_position = mb_stripos ($content, $paragraph_end, $last_position + 1) + mb_strlen ($paragraph_end) - 1;
3529
- // $paragraph_positions [] = $last_position;
3530
- // $active_paragraph_positions [$last_position] = 1;
3531
- // } else {
3532
- // $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
3533
- // $paragraph_positions [] = $last_position;
3534
- // $active_paragraph_positions [$last_position] = 1;
3535
- // }
3536
- // }
3537
- // }
3538
- // continue;
3539
- // }
3540
- // elseif ($paragraph_end_string == "#") {
3541
- // $paragraph_end = "\r\n\r\n";
3542
- // if (!in_array ($last_content_position, $paragraph_positions)) {
3543
- // $paragraph_positions [] = $last_content_position;
3544
- // $active_paragraph_positions [$last_content_position] = 1;
3545
- // }
3546
- // } else $paragraph_end = '</' . $paragraph_end_string . '>';
3547
-
3548
- // if ($multibyte) {
3549
- // while (mb_stripos ($content, $paragraph_end, $last_position + 1) !== false) {
3550
- // $last_position = mb_stripos ($content, $paragraph_end, $last_position + 1) + mb_strlen ($paragraph_end) - 1;
3551
- // if ($paragraph_end_string == "#") {
3552
- // $paragraph_positions [] = $last_position - 4;
3553
- // $active_paragraph_positions [$last_position - 4] = 1;
3554
- // } else {
3555
- // $paragraph_positions [] = $last_position;
3556
- // $active_paragraph_positions [$last_position] = 1;
3557
- // }
3558
- // }
3559
- // } else {
3560
- // while (stripos ($content, $paragraph_end, $last_position + 1) !== false) {
3561
- // $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1;
3562
- // if ($paragraph_end_string == "#") {
3563
- // $paragraph_positions [] = $last_position - 4;
3564
- // $active_paragraph_positions [$last_position - 4] = 1;
3565
- // } else {
3566
- // $paragraph_positions [] = $last_position;
3567
- // $active_paragraph_positions [$last_position] = 1;
3568
- // }
3569
- // }
3570
- // }
3571
- // }
3572
-
3573
  // Nothing to do
3574
  $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS;
3575
- // if (count ($paragraph_positions) == 0) return $content;
3576
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3577
 
3578
 
@@ -3632,7 +3525,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3632
 
3633
  if (count ($special_element_offsets) != 0) {
3634
 
3635
- // $filtered_paragraph_positions = array ();
3636
  $inside_special_element = array ();
3637
 
3638
  foreach ($special_element_offsets as $special_element_offset) {
@@ -3642,15 +3534,11 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3642
  }
3643
 
3644
  foreach ($paragraph_positions as $index => $paragraph_position) {
3645
- // if (!in_array ($paragraph_position, $inside_special_element)) $filtered_paragraph_positions []= $paragraph_position;
3646
  if (in_array ($paragraph_position, $inside_special_element)) $active_paragraph_positions [$index] = 0;
3647
  }
3648
-
3649
- // $paragraph_positions = $filtered_paragraph_positions;
3650
  }
3651
 
3652
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE;
3653
- // if (count ($paragraph_positions) == 0) return $content;
3654
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3655
  }
3656
 
@@ -3665,29 +3553,23 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3665
  get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy);
3666
  }
3667
 
3668
- // $filtered_paragraph_positions = array ();
3669
  foreach ($paragraph_positions as $index => $paragraph_position) {
3670
 
3671
  if ($active_paragraph_positions [$index] == 0) continue;
3672
 
3673
  if ($multibyte) {
3674
- // $paragraph_code = $index == 0 ? mb_substr ($content, 0, $paragraph_position + 1) : mb_substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
3675
  $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3676
  } else {
3677
- // $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
3678
  $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3679
  }
3680
 
3681
- // if ($this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $filtered_paragraph_positions [] = $paragraph_position;
3682
  if (!$this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $active_paragraph_positions [$index] = 0;
3683
  }
3684
- // $paragraph_positions = $filtered_paragraph_positions;
3685
  }
3686
 
3687
 
3688
  // Nothing to do
3689
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS;
3690
- // if (count ($paragraph_positions) == 0) return $content;
3691
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3692
 
3693
 
@@ -3699,7 +3581,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3699
  get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy);
3700
  }
3701
 
3702
- // $filtered_paragraph_positions = array ();
3703
  $paragraph_text_type = $this->get_paragraph_text_type ();
3704
 
3705
  foreach ($paragraph_positions as $index => $paragraph_position) {
@@ -3707,10 +3588,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3707
  if ($active_paragraph_positions [$index] == 0) continue;
3708
 
3709
  if ($multibyte) {
3710
- // $paragraph_code = $index == 0 ? mb_substr ($content, 0, $paragraph_position + 1) : mb_substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
3711
  $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3712
  } else {
3713
- // $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
3714
  $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3715
  }
3716
 
@@ -3732,7 +3611,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3732
  }
3733
 
3734
  }
3735
- // if ($found) $filtered_paragraph_positions [] = $paragraph_position;
3736
  if (!$found) $filtered_paragraph_positions [] = $active_paragraph_positions [$index] = 0;
3737
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
3738
  $found = false;
@@ -3752,18 +3630,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3752
  }
3753
 
3754
  }
3755
- // if (!$found) $filtered_paragraph_positions [] = $paragraph_position;
3756
  if ($found) $active_paragraph_positions [$index] = 0;
3757
  }
3758
  }
3759
-
3760
- // $paragraph_positions = $filtered_paragraph_positions;
3761
  }
3762
 
3763
 
3764
  // Nothing to do
3765
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT;
3766
- // if (count ($paragraph_positions) == 0) return $content;
3767
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3768
 
3769
  $position_text = trim ($this->get_paragraph_number());
@@ -3811,7 +3685,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3811
  if ($position > 0 && $position < 1) {
3812
  $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3813
  }
3814
- elseif ($position < 0) {
 
 
 
3815
  $position = count ($paragraph_positions) + $position;
3816
  }
3817
  elseif ($position == 0) {
@@ -3825,7 +3702,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3825
  if ($position > 0 && $position < 1) {
3826
  $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3827
  }
3828
- elseif ($position < 0) {
 
 
 
3829
  $positions [$index] = count ($paragraph_positions) + $position;
3830
  }
3831
  elseif ($position == 0) {
@@ -3844,17 +3724,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3844
 
3845
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
3846
  if ($words_above >= $min_words_above) {
3847
- // $positions []= $index + 1;
3848
  $positions []= $index;
3849
  $words_above = 0;
3850
  }
3851
  }
3852
 
3853
  if ($multibyte) {
3854
- // $paragraph_code = $index == 0 ? mb_substr ($content, 0, $paragraph_position + 1) : mb_substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
3855
  $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3856
  } else {
3857
- // $paragraph_code = $index == 0 ? substr ($content, 0, $paragraph_position + 1) : substr ($content, $paragraph_positions [$index - 1] + 1, $paragraph_position - $paragraph_positions [$index - 1]);
3858
  $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3859
  }
3860
 
@@ -3862,7 +3739,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3862
 
3863
  if ($this->get_direction_type() != AD_DIRECTION_FROM_BOTTOM) {
3864
  if ($words_above >= $min_words_above) {
3865
- // $positions []= $index + 1;
3866
  $positions []= $index;
3867
  $words_above = 0;
3868
  }
@@ -3871,7 +3747,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3871
  }
3872
  } else
3873
  foreach ($paragraph_positions as $index => $paragraph_position) {
3874
- // $positions []= $index + 1;
3875
  $positions []= $index;
3876
  }
3877
 
@@ -3911,7 +3786,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3911
 
3912
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
3913
 
3914
- // if (empty ($positions)) {
3915
  if (!empty ($positions)) {
3916
  $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
3917
  $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
@@ -4011,7 +3885,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4011
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' FAILED');
4012
 
4013
  $ai_last_check = AI_CHECK_DO_NOT_INSERT;
4014
- // if ($this->get_avoid_action() == AD_DO_NOT_INSERT) return $content;
4015
  if ($this->get_avoid_action() == AD_DO_NOT_INSERT) {
4016
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
4017
  $positions [$position_index] = - 1;
@@ -4022,7 +3895,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4022
  case AD_ABOVE: // Try above
4023
  $ai_last_check = AI_CHECK_AD_ABOVE;
4024
  // Already at the top - do not insert
4025
- // if ($position == 0) return $content;
4026
  if ($position == 0) {
4027
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
4028
  $positions [$position_index] = - 1;
@@ -4034,7 +3906,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4034
  case AD_BELOW: // Try below
4035
  $ai_last_check = AI_CHECK_AD_BELOW;
4036
  // Already at the bottom - do not insert
4037
- // if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
4038
  if ($position >= count ($paragraph_positions) - 1) {
4039
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
4040
  $positions [$position_index] = - 1;
@@ -4051,7 +3922,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4051
  $position = $saved_position;
4052
  $ai_last_check = AI_CHECK_AD_BELOW;
4053
  // Already at the bottom - do not insert
4054
- // if ($position >= count ($paragraph_positions) - 1) return $content; // Already at the bottom - do not insert
4055
  if ($position >= count ($paragraph_positions) - 1) {
4056
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
4057
  $positions [$position_index] = - 1;
@@ -4069,7 +3939,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4069
  $position = $saved_position;
4070
  $ai_last_check = AI_CHECK_AD_ABOVE;
4071
  // Already at the top - do not insert
4072
- // if ($position == 0) return $content; // Already at the top - do not insert
4073
  if ($position == 0) {
4074
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
4075
  $positions [$position_index] = - 1;
@@ -4087,7 +3956,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4087
  }
4088
 
4089
  // Try next position
4090
- // if ($checks <= 0) return $content; // Suitable position not found - do not insert
4091
  if ($checks <= 0) {
4092
  // Suitable position not found - do not insert
4093
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
@@ -4134,7 +4002,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4134
  if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++;
4135
 
4136
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
4137
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
4138
  if (!$this->get_debug_disable_insertion ()) {
4139
  $inserted_code = $this->get_code_for_serverside_insertion ();
4140
  $ai_last_check = AI_CHECK_INSERTED;
@@ -4176,37 +4043,6 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
4176
 
4177
  // empty $positions
4178
  return $content;
4179
-
4180
-
4181
- // // Deprecated since $postion is now in array $positions
4182
- // $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER;
4183
- // if (count ($paragraph_positions) >= intval ($this->get_paragraph_number_minimum())) {
4184
- // $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER;
4185
- // if (count ($paragraph_positions) > $position) {
4186
- // $this->increment_block_counter ();
4187
-
4188
- // $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
4189
- // //if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
4190
- // if (!$this->get_debug_disable_insertion ()) {
4191
- // $content_position = $paragraph_positions [$position];
4192
-
4193
- // if ($multibyte) {
4194
- // if ($content_position >= mb_strlen ($content) - 1)
4195
- // $content = $content . $this->get_code_for_serverside_insertion (); else
4196
- // $content = mb_substr ($content, 0, $content_position + 1) . $this->get_code_for_serverside_insertion () . mb_substr ($content, $content_position + 1);
4197
- // } else {
4198
- // if ($content_position >= strlen ($content) - 1)
4199
- // $content = $content . $this->get_code_for_serverside_insertion (); else
4200
- // $content = substr_replace ($content, $this->get_code_for_serverside_insertion (), $content_position + 1, 0);
4201
- // }
4202
- // $this->clear_code_cache ();
4203
-
4204
- // $ai_last_check = AI_CHECK_INSERTED;
4205
- // }
4206
- // }
4207
- // }
4208
-
4209
- // return $content;
4210
  }
4211
 
4212
 
@@ -5181,6 +5017,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
5181
 
5182
  switch ($this->get_automatic_insertion()) {
5183
  case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
 
5184
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
5185
  if ($this->get_html_element_insertion () != AI_HTML_INSERTION_SEREVR_SIDE) $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true;
5186
  break;
369
  unset ($this->wp_options ['GENERATED_CODE']);
370
  }
371
 
372
+ public function empty_code () {
373
+ global $ai_last_check;
374
+
375
+ $ai_last_check = AI_CHECK_CODE;
376
+ $empty = $this->ai_getCode () == '';
377
+
378
+ if ($this->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT &&
379
+ ($this->get_inside_element () == AI_HTML_REPLACE_CONTENT ||
380
+ $this->get_inside_element () == AI_HTML_REPLACE_ELEMENT)) {
381
+ return false;
382
+ }
383
+
384
+ return $empty;
385
+ }
386
+
387
  public function ai_getCode (){
388
  global $block_object, $ai_total_php_time, $ai_wp_data;
389
 
446
  $this->wp_options [AI_OPTION_HTML_SELECTOR] = AD_EMPTY_DATA;
447
  $this->wp_options [AI_OPTION_SERVER_SIDE_INSERTION] = DEFAULT_SERVER_SIDE_INSERTION;
448
  $this->wp_options [AI_OPTION_HTML_ELEMENT_INSERTION] = DEFAULT_HTML_ELEMENT_INSERTION;
449
+ $this->wp_options [AI_OPTION_INSIDE_ELEMENT] = DEFAULT_INSIDE_ELEMENT;
450
  $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] = AD_ONE;
451
  $this->wp_options [AI_OPTION_MIN_PARAGRAPHS] = AD_EMPTY_DATA;
452
  $this->wp_options [AI_OPTION_MIN_WORDS_ABOVE] = AD_EMPTY_DATA;
632
  case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
633
  return AI_TEXT_BEFORE_HTML_ELEMENT;
634
  break;
635
+ case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT:
636
+ return AI_TEXT_INSIDE_HTML_ELEMENT;
637
+ break;
638
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
639
  return AI_TEXT_AFTER_HTML_ELEMENT;
640
  break;
1186
  return $option;
1187
  }
1188
 
1189
+ public function get_inside_element (){
1190
+ $option = isset ($this->wp_options [AI_OPTION_INSIDE_ELEMENT]) ? $this->wp_options [AI_OPTION_INSIDE_ELEMENT] : DEFAULT_INSIDE_ELEMENT;
1191
+ return $option;
1192
+ }
1193
+
1194
  public function get_paragraph_number(){
1195
  $option = isset ($this->wp_options [AI_OPTION_PARAGRAPH_NUMBER]) ? $this->wp_options [AI_OPTION_PARAGRAPH_NUMBER] : "";
1196
  return $option;
2358
  if ($server_side_html_insertion && !$viewports_insertion) return $this->get_code_for_insertion ($include_viewport_classes, $hidden_widgets, $code_only);
2359
  $html_element_insertion = true;
2360
  break;
2361
+ case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT:
2362
+ switch ($this->get_inside_element ()) {
2363
+ case AI_HTML_PREPEND_CONTENT:
2364
+ $insertion = 'prepend';
2365
+ break;
2366
+ case AI_HTML_APPEND_CONTENT:
2367
+ $insertion = 'append';
2368
+ break;
2369
+ case AI_HTML_REPLACE_CONTENT:
2370
+ $insertion = 'replace-content';
2371
+ break;
2372
+ case AI_HTML_REPLACE_ELEMENT:
2373
+ $insertion = 'replace-element';
2374
+ break;
2375
+ default:
2376
+ $insertion = '';
2377
+ break;
2378
+ }
2379
+ if ($server_side_html_insertion && !$viewports_insertion) return $this->get_code_for_insertion ($include_viewport_classes, $hidden_widgets, $code_only);
2380
+ $html_element_insertion = true;
2381
+ break;
2382
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
2383
  $insertion = 'after';
2384
  if ($server_side_html_insertion && !$viewports_insertion) return $this->get_code_for_insertion ($include_viewport_classes, $hidden_widgets, $code_only);
2846
 
2847
  get_paragraph_start_positions ($content, $multibyte, $dummy, $paragraph_start_strings, $paragraph_positions, $active_paragraph_positions);
2848
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2849
  // Nothing to do
2850
  $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS;
 
2851
  if (array_sum ($active_paragraph_positions) == 0) return $content;
2852
 
2853
  sort ($paragraph_positions);
2906
 
2907
  if (count ($special_element_offsets) != 0) {
2908
 
 
2909
  $inside_special_element = array ();
2910
 
2911
  foreach ($special_element_offsets as $special_element_offset) {
2915
  }
2916
 
2917
  foreach ($paragraph_positions as $index => $paragraph_position) {
 
2918
  if (in_array ($paragraph_position, $inside_special_element)) $active_paragraph_positions [$index] = 0;
2919
  }
 
 
2920
  }
2921
 
2922
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE;
 
2923
  if (array_sum ($active_paragraph_positions) == 0) return $content;
2924
  }
2925
 
2934
  get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy);
2935
  }
2936
 
 
2937
  foreach ($paragraph_positions as $index => $paragraph_position) {
2938
 
2939
  if ($active_paragraph_positions [$index] == 0) continue;
2940
 
2941
  if ($multibyte) {
 
2942
  $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2943
  } else {
 
2944
  $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2945
  }
2946
 
 
2947
  if (!$this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $active_paragraph_positions [$index] = 0;
2948
  }
 
2949
  }
2950
 
2951
  // Nothing to do
2952
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS;
 
2953
  if (array_sum ($active_paragraph_positions) == 0) return $content;
2954
 
2955
 
2961
  get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy);
2962
  }
2963
 
 
2964
  $paragraph_text_type = $this->get_paragraph_text_type ();
2965
 
2966
  foreach ($paragraph_positions as $index => $paragraph_position) {
2968
  if ($active_paragraph_positions [$index] == 0) continue;
2969
 
2970
  if ($multibyte) {
 
2971
  $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2972
  } else {
 
2973
  $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
2974
  }
2975
 
2990
  }
2991
  }
2992
  }
 
2993
  if (!$found) $active_paragraph_positions [$index] = 0;
2994
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
2995
  $found = false;
3008
  }
3009
  }
3010
  }
 
3011
  if ($found) $active_paragraph_positions [$index] = 0;
3012
  }
3013
  }
 
 
3014
  }
3015
 
3016
  // Nothing to do
3017
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT;
 
3018
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3019
 
3020
  $position_text = trim ($this->get_paragraph_number());
3021
 
3022
 
3023
  // Prepare $paragraph_end_positions
 
3024
  if ($position_preview || $position_text == '') {
3025
  if (!isset ($paragraph_end_positions)) {
3026
  $paragraph_end_positions = array ();
3063
  if ($position > 0 && $position < 1) {
3064
  $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3065
  }
3066
+ elseif ($position > - 1 && $position < 0) {
3067
+ $position = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5);
3068
+ }
3069
+ elseif ($position <= - 1) {
3070
  $position = count ($paragraph_positions) + $position;
3071
  }
3072
  elseif ($position == 0) {
3082
  if ($position > 0 && $position < 1) {
3083
  $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3084
  }
3085
+ elseif ($position > - 1 && $position < 0) {
3086
+ $positions [$index] = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5);
3087
+ }
3088
+ elseif ($position <= - 1) {
3089
  $positions [$index] = count ($paragraph_positions) + $position;
3090
  }
3091
  elseif ($position == 0) {
3104
 
3105
  if ($this->get_direction_type() != AD_DIRECTION_FROM_BOTTOM) {
3106
  if ($words_above >= $min_words_above) {
 
3107
  $positions []= $index;
3108
  $words_above = 0;
3109
  }
3111
 
3112
 
3113
  if ($multibyte) {
 
3114
  $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
3115
  } else {
 
3116
  $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1);
3117
  }
3118
 
3120
 
3121
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
3122
  if ($words_above >= $min_words_above) {
 
3123
  $positions []= $index;
3124
  $words_above = 0;
3125
  }
3128
  }
3129
  } else
3130
  foreach ($paragraph_positions as $index => $paragraph_position) {
 
3131
  $positions []= $index;
3132
  }
3133
 
3171
 
3172
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
3173
 
 
3174
  if (!empty ($positions)) {
3175
  $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
3176
  $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
3269
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' FAILED');
3270
 
3271
  $ai_last_check = AI_CHECK_DO_NOT_INSERT;
 
3272
  if ($this->get_avoid_action() == AD_DO_NOT_INSERT) {
3273
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3274
  $positions [$position_index] = - 1;
3278
  switch ($direction) {
3279
  case AD_ABOVE: // Try above
3280
  $ai_last_check = AI_CHECK_AD_ABOVE;
3281
+ // Already at the top - do not insert
3282
  if ($position == 0) {
3283
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3284
  $positions [$position_index] = - 1;
3289
  break;
3290
  case AD_BELOW: // Try below
3291
  $ai_last_check = AI_CHECK_AD_BELOW;
3292
+ // Already at the bottom - do not insert
3293
  if ($position >= count ($paragraph_positions) - 1) {
3294
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3295
  $positions [$position_index] = - 1;
3305
  $checks = $max_checks;
3306
  $position = $saved_position;
3307
  $ai_last_check = AI_CHECK_AD_BELOW;
3308
+ // Already at the bottom - do not insert
3309
  if ($position >= count ($paragraph_positions) - 1) {
3310
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3311
  $positions [$position_index] = - 1;
3322
  $checks = $max_checks;
3323
  $position = $saved_position;
3324
  $ai_last_check = AI_CHECK_AD_ABOVE;
3325
+ // Already at the top - do not insert
3326
  if ($position == 0) {
3327
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3328
  $positions [$position_index] = - 1;
3340
  }
3341
 
3342
  // Try next position
 
3343
  if ($checks <= 0) {
3344
  // Suitable position not found - do not insert
3345
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3396
  if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++;
3397
 
3398
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
 
3399
  if (!$this->get_debug_disable_insertion ()) {
3400
  $inserted_code = $this->get_code_for_serverside_insertion ();
3401
  $ai_last_check = AI_CHECK_INSERTED;
3436
 
3437
  // empty $positions
3438
  return $content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3439
  }
3440
 
3441
  public function after_paragraph ($content, $position_preview = false) {
3442
  global $ai_wp_data, $ai_last_check, $special_element_tags;
3443
 
 
 
3444
  $multibyte = get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS;
3445
 
3446
  $paragraph_positions = array ();
3464
 
3465
  get_paragraph_end_positions ($content, $multibyte, $dummy, $paragraph_end_strings, $paragraph_positions, $active_paragraph_positions);
3466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3467
  // Nothing to do
3468
  $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS;
 
3469
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3470
 
3471
 
3525
 
3526
  if (count ($special_element_offsets) != 0) {
3527
 
 
3528
  $inside_special_element = array ();
3529
 
3530
  foreach ($special_element_offsets as $special_element_offset) {
3534
  }
3535
 
3536
  foreach ($paragraph_positions as $index => $paragraph_position) {
 
3537
  if (in_array ($paragraph_position, $inside_special_element)) $active_paragraph_positions [$index] = 0;
3538
  }
 
 
3539
  }
3540
 
3541
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE;
 
3542
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3543
  }
3544
 
3553
  get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy);
3554
  }
3555
 
 
3556
  foreach ($paragraph_positions as $index => $paragraph_position) {
3557
 
3558
  if ($active_paragraph_positions [$index] == 0) continue;
3559
 
3560
  if ($multibyte) {
 
3561
  $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3562
  } else {
 
3563
  $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3564
  }
3565
 
 
3566
  if (!$this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $active_paragraph_positions [$index] = 0;
3567
  }
 
3568
  }
3569
 
3570
 
3571
  // Nothing to do
3572
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS;
 
3573
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3574
 
3575
 
3581
  get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy);
3582
  }
3583
 
 
3584
  $paragraph_text_type = $this->get_paragraph_text_type ();
3585
 
3586
  foreach ($paragraph_positions as $index => $paragraph_position) {
3588
  if ($active_paragraph_positions [$index] == 0) continue;
3589
 
3590
  if ($multibyte) {
 
3591
  $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3592
  } else {
 
3593
  $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3594
  }
3595
 
3611
  }
3612
 
3613
  }
 
3614
  if (!$found) $filtered_paragraph_positions [] = $active_paragraph_positions [$index] = 0;
3615
  } elseif ($paragraph_text_type == AD_DO_NOT_CONTAIN) {
3616
  $found = false;
3630
  }
3631
 
3632
  }
 
3633
  if ($found) $active_paragraph_positions [$index] = 0;
3634
  }
3635
  }
 
 
3636
  }
3637
 
3638
 
3639
  // Nothing to do
3640
  $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT;
 
3641
  if (array_sum ($active_paragraph_positions) == 0) return $content;
3642
 
3643
  $position_text = trim ($this->get_paragraph_number());
3685
  if ($position > 0 && $position < 1) {
3686
  $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3687
  }
3688
+ elseif ($position > - 1 && $position < 0) {
3689
+ $position = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5);
3690
+ }
3691
+ elseif ($position <= - 1) {
3692
  $position = count ($paragraph_positions) + $position;
3693
  }
3694
  elseif ($position == 0) {
3702
  if ($position > 0 && $position < 1) {
3703
  $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5);
3704
  }
3705
+ elseif ($position > - 1 && $position < 0) {
3706
+ $positions [$index] = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5);
3707
+ }
3708
+ elseif ($position <= - 1) {
3709
  $positions [$index] = count ($paragraph_positions) + $position;
3710
  }
3711
  elseif ($position == 0) {
3724
 
3725
  if ($this->get_direction_type() == AD_DIRECTION_FROM_BOTTOM) {
3726
  if ($words_above >= $min_words_above) {
 
3727
  $positions []= $index;
3728
  $words_above = 0;
3729
  }
3730
  }
3731
 
3732
  if ($multibyte) {
 
3733
  $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3734
  } else {
 
3735
  $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1);
3736
  }
3737
 
3739
 
3740
  if ($this->get_direction_type() != AD_DIRECTION_FROM_BOTTOM) {
3741
  if ($words_above >= $min_words_above) {
 
3742
  $positions []= $index;
3743
  $words_above = 0;
3744
  }
3747
  }
3748
  } else
3749
  foreach ($paragraph_positions as $index => $paragraph_position) {
 
3750
  $positions []= $index;
3751
  }
3752
 
3786
 
3787
  $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
3788
 
 
3789
  if (!empty ($positions)) {
3790
  $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above());
3791
  $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below());
3885
  if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' FAILED');
3886
 
3887
  $ai_last_check = AI_CHECK_DO_NOT_INSERT;
 
3888
  if ($this->get_avoid_action() == AD_DO_NOT_INSERT) {
3889
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3890
  $positions [$position_index] = - 1;
3895
  case AD_ABOVE: // Try above
3896
  $ai_last_check = AI_CHECK_AD_ABOVE;
3897
  // Already at the top - do not insert
 
3898
  if ($position == 0) {
3899
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3900
  $positions [$position_index] = - 1;
3906
  case AD_BELOW: // Try below
3907
  $ai_last_check = AI_CHECK_AD_BELOW;
3908
  // Already at the bottom - do not insert
 
3909
  if ($position >= count ($paragraph_positions) - 1) {
3910
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3911
  $positions [$position_index] = - 1;
3922
  $position = $saved_position;
3923
  $ai_last_check = AI_CHECK_AD_BELOW;
3924
  // Already at the bottom - do not insert
 
3925
  if ($position >= count ($paragraph_positions) - 1) {
3926
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3927
  $positions [$position_index] = - 1;
3939
  $position = $saved_position;
3940
  $ai_last_check = AI_CHECK_AD_ABOVE;
3941
  // Already at the top - do not insert
 
3942
  if ($position == 0) {
3943
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
3944
  $positions [$position_index] = - 1;
3956
  }
3957
 
3958
  // Try next position
 
3959
  if ($checks <= 0) {
3960
  // Suitable position not found - do not insert
3961
  $failed_clearance_positions [$positions [$position_index]] = $ai_last_check;
4002
  if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++;
4003
 
4004
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
 
4005
  if (!$this->get_debug_disable_insertion ()) {
4006
  $inserted_code = $this->get_code_for_serverside_insertion ();
4007
  $ai_last_check = AI_CHECK_INSERTED;
4043
 
4044
  // empty $positions
4045
  return $content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4046
  }
4047
 
4048
 
5017
 
5018
  switch ($this->get_automatic_insertion()) {
5019
  case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
5020
+ case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT:
5021
  case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
5022
  if ($this->get_html_element_insertion () != AI_HTML_INSERTION_SEREVR_SIDE) $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true;
5023
  break;
constants.php CHANGED
@@ -29,7 +29,7 @@ if (!defined( 'AD_INSERTER_NAME'))
29
  define ('AD_INSERTER_NAME', 'Ad Inserter');
30
 
31
  if (!defined( 'AD_INSERTER_VERSION'))
32
- define ('AD_INSERTER_VERSION', '2.4.0');
33
 
34
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
35
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
@@ -95,6 +95,7 @@ define ('AI_OPTION_AVOID_TRY_LIMIT', 'avoid_try_limit');
95
  define ('AI_OPTION_AVOID_DIRECTION', 'avoid_direction');
96
  define ('AI_OPTION_HTML_SELECTOR', 'html_selector');
97
  define ('AI_OPTION_SERVER_SIDE_INSERTION', 'server_side_insertion');
 
98
  define ('AI_OPTION_HTML_ELEMENT_INSERTION', 'html_insertion');
99
  define ('AI_OPTION_EXCERPT_NUMBER', 'excerpt_number'); // needs to be renamed
100
  define ('AI_OPTION_FILTER_TYPE', 'filter_type');
@@ -225,6 +226,7 @@ define('AI_AUTOMATIC_INSERTION_FOOTER', 13);
225
  define('AI_AUTOMATIC_INSERTION_ABOVE_HEADER', 14);
226
  define('AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT', 15);
227
  define('AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT', 16);
 
228
 
229
  define('AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING', 99);
230
  define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
@@ -246,6 +248,7 @@ define('AI_TEXT_ABOVE_HEADER', 'Above Header');
246
  define('AI_TEXT_FOOTER', 'Footer');
247
  define('AI_TEXT_BEFORE_HTML_ELEMENT', 'Before HTML element');
248
  define('AI_TEXT_AFTER_HTML_ELEMENT', 'After HTML element');
 
249
 
250
  //Display options
251
  define('AD_DISPLAY_ALL_USERS','all users');
@@ -588,6 +591,16 @@ define ('AI_HTML_INSERTION_SEREVR_SIDE', 2);
588
 
589
  define('AI_TEXT_CLIENT_SIDE_DOM_READY', 'Client-side when DOM ready');
590
 
 
 
 
 
 
 
 
 
 
 
591
  //Settings
592
  define ('AI_ENABLED', '1');
593
  define ('AI_DISABLED', '0');
@@ -655,6 +668,7 @@ define ('DEFAULT_GEO_DB_UPDATES', AI_DISABLED);
655
  define ('DEFAULT_CLOSE_BUTTON', AI_CLOSE_NONE);
656
  define ('DEFAULT_SERVER_SIDE_INSERTION', AI_AUTOMATIC_INSERTION_FOOTER);
657
  define ('DEFAULT_HTML_ELEMENT_INSERTION', AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY);
 
658
  define ('DEFAULT_CLIENT_SIDE_ACTION', AI_CLIENT_SIDE_ACTION_SHOW);
659
  define ('DEFAULT_HORIZONTAL_POSITION', AI_STICK_TO_THE_LEFT);
660
  define ('DEFAULT_VERTICAL_POSITION', AI_STICK_TO_THE_TOP);
29
  define ('AD_INSERTER_NAME', 'Ad Inserter');
30
 
31
  if (!defined( 'AD_INSERTER_VERSION'))
32
+ define ('AD_INSERTER_VERSION', '2.4.1');
33
 
34
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
35
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
95
  define ('AI_OPTION_AVOID_DIRECTION', 'avoid_direction');
96
  define ('AI_OPTION_HTML_SELECTOR', 'html_selector');
97
  define ('AI_OPTION_SERVER_SIDE_INSERTION', 'server_side_insertion');
98
+ define ('AI_OPTION_INSIDE_ELEMENT', 'inside_element');
99
  define ('AI_OPTION_HTML_ELEMENT_INSERTION', 'html_insertion');
100
  define ('AI_OPTION_EXCERPT_NUMBER', 'excerpt_number'); // needs to be renamed
101
  define ('AI_OPTION_FILTER_TYPE', 'filter_type');
226
  define('AI_AUTOMATIC_INSERTION_ABOVE_HEADER', 14);
227
  define('AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT', 15);
228
  define('AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT', 16);
229
+ define('AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT', 17);
230
 
231
  define('AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING', 99);
232
  define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
248
  define('AI_TEXT_FOOTER', 'Footer');
249
  define('AI_TEXT_BEFORE_HTML_ELEMENT', 'Before HTML element');
250
  define('AI_TEXT_AFTER_HTML_ELEMENT', 'After HTML element');
251
+ define('AI_TEXT_INSIDE_HTML_ELEMENT', 'Inside HTML element');
252
 
253
  //Display options
254
  define('AD_DISPLAY_ALL_USERS','all users');
591
 
592
  define('AI_TEXT_CLIENT_SIDE_DOM_READY', 'Client-side when DOM ready');
593
 
594
+ define ('AI_HTML_PREPEND_CONTENT', 1);
595
+ define ('AI_HTML_APPEND_CONTENT', 2);
596
+ define ('AI_HTML_REPLACE_CONTENT', 3);
597
+ define ('AI_HTML_REPLACE_ELEMENT', 4);
598
+
599
+ define('AI_TEXT_PREPEND_CONTENT', 'Prepend content');
600
+ define('AI_TEXT_APPEND_CONTENT', 'Append content');
601
+ define('AI_TEXT_REPLACE_CONTENT', 'Replace content');
602
+ define('AI_TEXT_REPLACE_ELEMENT', 'Replace element');
603
+
604
  //Settings
605
  define ('AI_ENABLED', '1');
606
  define ('AI_DISABLED', '0');
668
  define ('DEFAULT_CLOSE_BUTTON', AI_CLOSE_NONE);
669
  define ('DEFAULT_SERVER_SIDE_INSERTION', AI_AUTOMATIC_INSERTION_FOOTER);
670
  define ('DEFAULT_HTML_ELEMENT_INSERTION', AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY);
671
+ define ('DEFAULT_INSIDE_ELEMENT', AI_HTML_PREPEND_CONTENT);
672
  define ('DEFAULT_CLIENT_SIDE_ACTION', AI_CLIENT_SIDE_ACTION_SHOW);
673
  define ('DEFAULT_HORIZONTAL_POSITION', AI_STICK_TO_THE_LEFT);
674
  define ('DEFAULT_VERTICAL_POSITION', AI_STICK_TO_THE_TOP);
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.4.0"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #ai-data {
2
+ font-family: "2.4.1"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
includes/dst/dst.php CHANGED
@@ -4,7 +4,7 @@
4
  * DST - WP theme and plugin usage tracking client
5
  * Experimental
6
  *
7
- * @version 1.0.2
8
  * @author Igor Funa <igor.funa/gmail.com>
9
  */
10
 
@@ -12,6 +12,11 @@
12
 
13
  Change Log
14
 
 
 
 
 
 
15
  DST 1.0.2 - 2018-09-23
16
  - Added transient for last action
17
  - Added last action check for update when admin IP address is sent
@@ -83,6 +88,7 @@ class DST_Client {
83
  const DST_NOTIFICATION_TIMES = 'dst_notification_times';
84
  const DST_OPTION_DEACTIVATION_REASON = 'dst_deactivation_reason';
85
  const DST_OPTION_DEACTIVATION_DETAILS = 'dst_deactivation_details';
 
86
 
87
  const DST_FILTER_IS_LOCAL = 'dst_is_local_';
88
  const DST_FILTER_OPTIN_NOTICE_TEXT = 'dst_optin_notice_text_';
@@ -128,9 +134,10 @@ class DST_Client {
128
  self::DST_NOTIFICATION_TIMES,
129
  self::DST_OPTION_DEACTIVATION_REASON,
130
  self::DST_OPTION_DEACTIVATION_DETAILS,
 
131
  );
132
 
133
- private $version = '1.0.2';
134
  private $tracking_url;
135
  private $main_file;
136
  private $slug;
@@ -253,7 +260,7 @@ class DST_Client {
253
 
254
  // Deactivation
255
  add_filter ('plugin_action_links_' . plugin_basename ($this->main_file), array ($this, 'filter_action_links'));
256
- add_action ('admin_footer-plugins.php', array ($this, 'deactivation_form'));
257
  add_action ('wp_ajax_dst_ajax_' . $this->slug, array ($this, 'process_ajax'));
258
 
259
  $this->check_schedule ();
@@ -383,9 +390,6 @@ class DST_Client {
383
  }
384
  elseif ($options ['type'] == 'theme' && array_key_exists ('themes', $options) && is_array ($options ['themes']) && !empty ($options ['themes'])) {
385
  foreach ($options ['themes'] as $theme) {
386
-
387
- // if ($theme == 'dynamic-news-lite') $theme = 'dynamic-news-lite-child';
388
-
389
  if ($theme == $this->slug) {
390
  $this->action = self::DST_ACTION_UPGRADE;
391
  $this->update (true);
@@ -664,6 +668,30 @@ class DST_Client {
664
  }
665
  }
666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
  public function is_time_to_track () {
668
  if (defined ('DST_DEBUG_TIME_TO_TRACK')) {
669
  $this->log_event ('DST_DEBUG_TIME_TO_TRACK: ' . ((bool) DST_DEBUG_TIME_TO_TRACK));
@@ -845,7 +873,7 @@ class DST_Client {
845
  ?>
846
  <div class="dst-notice-element" style="width: 100%; padding: 0 10px 0;">
847
  <?php
848
- $notice = str_replace (array ('[BR]', '[STRONG]', '[/STRONG]', '[NAME]'), array ("<br />", '<strong>', '</strong>', esc_html ($name)), esc_html ($notice_text));
849
  $paragraphs = explode ('[P]', $notice);
850
  foreach ($paragraphs as $paragraph) {
851
  echo '<p>',$paragraph, '</p>';
@@ -1100,7 +1128,7 @@ jQuery (document).ready (function ($) {
1100
  public function filter_action_links ($links) {
1101
  if (!$this->get_tracking ()) return $links;
1102
 
1103
- if (isset ($links ['deactivate']) && $this->deactivation_form) {
1104
  $deactivation_link = $links ['deactivate'];
1105
  $deactivation_link = str_replace ( '<a ', '<span class="dst-deactivation-form-wrapper"><span class="dst-deactivation-form" id="dst-deactivation-form-' . esc_attr ($this->slug) . '"></span></span><a onclick="javascript:event.preventDefault();" id="dst-deactivation-link-' . esc_attr ($this->slug) . '" ', $deactivation_link);
1106
  $links ['deactivate'] = $deactivation_link;
@@ -1114,17 +1142,19 @@ jQuery (document).ready (function ($) {
1114
  $form ['heading'] = __( 'Sorry to see you go', 'dst');
1115
  $form ['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'dst');
1116
  $form ['options'] = array (
1117
- __( 'Set up is too difficult', 'dst'),
1118
- __( 'Lack of documentation', 'dst'),
1119
- __( 'Not the features I wanted', 'dst'),
1120
- __( 'Found a better plugin', 'dst'),
1121
- __( 'Installed by mistake', 'dst'),
1122
- __( 'Didn\'t work', 'dst'),
1123
- __( 'Just testing', 'dst'),
1124
- __( 'Only required temporarily', 'dst'),
 
1125
  );
1126
  $form ['details'] = __('Details (optional)', 'dst' );
1127
  $form ['info'] = __('This information will greatly help us to improve the plugin.', 'dst');
 
1128
 
1129
  return $form;
1130
  }
@@ -1134,21 +1164,33 @@ jQuery (document).ready (function ($) {
1134
  return apply_filters (self::DST_FILTER_FORM_TEXT . esc_attr ($this->slug), $form);
1135
  }
1136
 
1137
- public function deactivation_form () {
1138
 
1139
  if ($this->product_type == self::DST_PRODUCT_TYPE_THEME) return;
1140
 
 
 
1141
  $form = $this->filtered_deactivation_form_text ();
1142
  if (!isset ($form ['heading']) || !isset( $form ['body']) || !isset ($form ['options']) || !is_array ($form ['options']) || !isset ($form ['info']) || !isset ($form ['details'])) {
1143
  $form = $this->default_deactivation_form_text ();
1144
  }
1145
 
1146
  $html = '<div class="dst-deactivation-form-head"><strong>' . esc_html ($form ['heading']) . '</strong></div>';
1147
- $html .= '<div class="dst-deactivation-form-body"><p>' . esc_html ($form['body']) . '</p>';
1148
  if (is_array ($form ['options'])) {
1149
  $html .= '<div class="dst-deactivation-options"><p>';
1150
  foreach ($form ['options'] as $option) {
1151
- $html .= '<input type="checkbox" name="dst-deactivation-options[]" id="' . str_replace( " ", "", esc_attr ($option )) . '" value="' . esc_attr ($option) . '"> <label for="' . str_replace (" ", "", esc_attr ($option)) . '">' . esc_attr ($option) . '</label><br>';
 
 
 
 
 
 
 
 
 
 
1152
  }
1153
  $html .= '</p><label for="dst-deactivation-reasons">' . esc_html ($form ['details'] ) .'</label><textarea name="dst-deactivation-reasons" id="dst-deactivation-reasons" rows="3" style="width:100%"></textarea><p>' . esc_html ($form['info']) . '</p>';
1154
  $html .= '</div>';
@@ -1196,6 +1238,13 @@ jQuery (document).ready (function ($) {
1196
  .dst-deactivation-form-body {
1197
  padding: 8px 18px;
1198
  color: #444;
 
 
 
 
 
 
 
1199
  }
1200
  .deactivating-spinner {
1201
  width: 200px;
@@ -1215,12 +1264,24 @@ jQuery (document).ready (function ($) {
1215
  float: left;
1216
  background: #fff;
1217
  color: #000;
 
1218
  }
1219
  .dst-deactivation-form-footer .button.primary {
1220
  float: right;
1221
  background: #716eef;
1222
  color: #fff;
1223
  }
 
 
 
 
 
 
 
 
 
 
 
1224
  @media (max-width: 500px) {
1225
  .dst-form-active .dst-deactivation-form {
1226
  width: 100%;
@@ -1233,6 +1294,7 @@ jQuery (document).ready (function ($) {
1233
  <script>
1234
  jQuery(document).ready (function ($){
1235
  var dst_debugging = <?php echo defined ('DST_DEBUG_JS') && DST_DEBUG_JS ? 'true' : 'false'; ?>;
 
1236
 
1237
  $("#dst-deactivation-link-<?php echo esc_attr ($this->slug); ?>").on ("click",function() {
1238
  var url = $("#dst-deactivation-link-<?php echo esc_attr ($this->slug); ?>").attr ('href');
@@ -1242,17 +1304,28 @@ jQuery (document).ready (function ($) {
1242
  $('body').toggleClass ('dst-form-active');
1243
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?>").fadeIn();
1244
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?>").html ('<?php echo $html; ?>' +
1245
- '<div class="dst-deactivation-form-footer"><p><a id="dst-just-deactivate" class="button secondary" href="'+url+'"><?php _e('Just Deactivate', 'dst'); ?></a>&nbsp;<a id="dst-submit-form" class="button primary" href="#"><?php _e( 'Submit and Deactivate', 'dst' ); ?></a></p></div>');
1246
  $('#dst-submit-form').on ('click', function (e){
 
1247
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .dst-deactivation-form-body").hide();
1248
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .dst-deactivation-form-footer").hide();
1249
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .deactivating-spinner").show();
1250
  e.preventDefault();
1251
 
1252
  var values = new Array();
1253
- $.each ($("input[name='dst-deactivation-options[]']:checked"), function(){
 
 
 
 
 
 
 
 
 
1254
  values.push ($(this).val ());
1255
  });
 
1256
  var details = $('#dst-deactivation-reasons').val();
1257
  var data = {
1258
  'action': 'dst_ajax_<?php echo $this->slug; ?>',
@@ -1263,6 +1336,10 @@ jQuery (document).ready (function ($) {
1263
  'dataType': "json"
1264
  }
1265
 
 
 
 
 
1266
  if (dst_debugging) console.log ('DST DEACTIVATION SUBMIT', data);
1267
 
1268
  $.post(
@@ -1280,11 +1357,28 @@ jQuery (document).ready (function ($) {
1280
  window.location.href = $('#dst-just-deactivate').attr ('href');
1281
  });
1282
 
 
 
 
 
 
1283
  $('.dst-deactivation-form-bg').on ('click', function (){
1284
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?>").fadeOut();
1285
  $('body').removeClass ('dst-form-active');
1286
  });
1287
 
 
 
 
 
 
 
 
 
 
 
 
 
1288
  window.onkeydown = function( event ) {
1289
  if (event.keyCode === 27 ) {
1290
  $('.dst-deactivation-form-bg').click ();
@@ -1333,6 +1427,10 @@ jQuery (document).ready (function ($) {
1333
 
1334
  $details = sanitize_text_field ($_POST ['details']);
1335
  $this->set_deactivation_details ($details);
 
 
 
 
1336
  }
1337
 
1338
  wp_die();
4
  * DST - WP theme and plugin usage tracking client
5
  * Experimental
6
  *
7
+ * @version 1.0.3
8
  * @author Igor Funa <igor.funa/gmail.com>
9
  */
10
 
12
 
13
  Change Log
14
 
15
+ DST 1.0.3 - 2018-10-02
16
+ - Added option to not show deactivation form again
17
+ - Fix to support notice HTML
18
+ - No deactivation form code if form not enabled
19
+
20
  DST 1.0.2 - 2018-09-23
21
  - Added transient for last action
22
  - Added last action check for update when admin IP address is sent
88
  const DST_NOTIFICATION_TIMES = 'dst_notification_times';
89
  const DST_OPTION_DEACTIVATION_REASON = 'dst_deactivation_reason';
90
  const DST_OPTION_DEACTIVATION_DETAILS = 'dst_deactivation_details';
91
+ const DST_OPTION_HIDE_DEACTIVATION_FORM = 'dst_hide_deactivation_form';
92
 
93
  const DST_FILTER_IS_LOCAL = 'dst_is_local_';
94
  const DST_FILTER_OPTIN_NOTICE_TEXT = 'dst_optin_notice_text_';
134
  self::DST_NOTIFICATION_TIMES,
135
  self::DST_OPTION_DEACTIVATION_REASON,
136
  self::DST_OPTION_DEACTIVATION_DETAILS,
137
+ self::DST_OPTION_HIDE_DEACTIVATION_FORM,
138
  );
139
 
140
+ private $version = '1.0.3';
141
  private $tracking_url;
142
  private $main_file;
143
  private $slug;
260
 
261
  // Deactivation
262
  add_filter ('plugin_action_links_' . plugin_basename ($this->main_file), array ($this, 'filter_action_links'));
263
+ add_action ('admin_footer-plugins.php', array ($this, 'generate_deactivation_form'));
264
  add_action ('wp_ajax_dst_ajax_' . $this->slug, array ($this, 'process_ajax'));
265
 
266
  $this->check_schedule ();
390
  }
391
  elseif ($options ['type'] == 'theme' && array_key_exists ('themes', $options) && is_array ($options ['themes']) && !empty ($options ['themes'])) {
392
  foreach ($options ['themes'] as $theme) {
 
 
 
393
  if ($theme == $this->slug) {
394
  $this->action = self::DST_ACTION_UPGRADE;
395
  $this->update (true);
668
  }
669
  }
670
 
671
+ public function get_hide_deactivation_form () {
672
+ if ($this->product_type != self::DST_PRODUCT_TYPE_PLUGIN) {
673
+ return false;
674
+ } else {
675
+ $hide_deactivation_form = get_option (self::DST_OPTION_HIDE_DEACTIVATION_FORM);
676
+ if (!isset ($hide_deactivation_form [$this->slug])) return false;
677
+ return $hide_deactivation_form [$this->slug];
678
+ }
679
+ }
680
+
681
+ public function set_hide_deactivation_form ($hide) {
682
+ if ($this->product_type != self::DST_PRODUCT_TYPE_PLUGIN) return;
683
+
684
+ $hide_deactivation_form = get_option (self::DST_OPTION_HIDE_DEACTIVATION_FORM);
685
+ if (!isset ($hide_deactivation_form [$this->slug]) || $hide != $this->get_hide_deactivation_form ()) {
686
+ if (empty ($hide_deactivation_form) || !is_array ($hide_deactivation_form)) {
687
+ $hide_deactivation_form = array ($this->slug => (int) $hide);
688
+ } else {
689
+ $hide_deactivation_form [$this->slug] = (int) $hide;
690
+ }
691
+ update_option (self::DST_OPTION_HIDE_DEACTIVATION_FORM, $hide_deactivation_form);
692
+ }
693
+ }
694
+
695
  public function is_time_to_track () {
696
  if (defined ('DST_DEBUG_TIME_TO_TRACK')) {
697
  $this->log_event ('DST_DEBUG_TIME_TO_TRACK: ' . ((bool) DST_DEBUG_TIME_TO_TRACK));
873
  ?>
874
  <div class="dst-notice-element" style="width: 100%; padding: 0 10px 0;">
875
  <?php
876
+ $notice = str_replace (array ('[BR]', '[STRONG]', '[/STRONG]', '[NAME]'), array ("<br />", '<strong>', '</strong>', esc_html ($name)), $notice_text);
877
  $paragraphs = explode ('[P]', $notice);
878
  foreach ($paragraphs as $paragraph) {
879
  echo '<p>',$paragraph, '</p>';
1128
  public function filter_action_links ($links) {
1129
  if (!$this->get_tracking ()) return $links;
1130
 
1131
+ if (isset ($links ['deactivate']) && $this->deactivation_form && !$this->get_hide_deactivation_form ()) {
1132
  $deactivation_link = $links ['deactivate'];
1133
  $deactivation_link = str_replace ( '<a ', '<span class="dst-deactivation-form-wrapper"><span class="dst-deactivation-form" id="dst-deactivation-form-' . esc_attr ($this->slug) . '"></span></span><a onclick="javascript:event.preventDefault();" id="dst-deactivation-link-' . esc_attr ($this->slug) . '" ', $deactivation_link);
1134
  $links ['deactivate'] = $deactivation_link;
1142
  $form ['heading'] = __( 'Sorry to see you go', 'dst');
1143
  $form ['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'dst');
1144
  $form ['options'] = array (
1145
+ __('Set up is too difficult', 'dst'),
1146
+ __('Lack of documentation', 'dst'),
1147
+ __('Not the features I wanted', 'dst'),
1148
+ __('Doesn\'t work', 'dst'),
1149
+ __('Found a better plugin', 'dst'),
1150
+ __('Installed by mistake', 'dst'),
1151
+ __('Just testing', 'dst') . '#2',
1152
+ __('Only required temporarily', 'dst') . '#2',
1153
+ __('Don\'t show this form again', 'dst') . '#1',
1154
  );
1155
  $form ['details'] = __('Details (optional)', 'dst' );
1156
  $form ['info'] = __('This information will greatly help us to improve the plugin.', 'dst');
1157
+ $form ['leaving'] = __( 'Goodbye!', 'dst');
1158
 
1159
  return $form;
1160
  }
1164
  return apply_filters (self::DST_FILTER_FORM_TEXT . esc_attr ($this->slug), $form);
1165
  }
1166
 
1167
+ public function generate_deactivation_form () {
1168
 
1169
  if ($this->product_type == self::DST_PRODUCT_TYPE_THEME) return;
1170
 
1171
+ if (!$this->deactivation_form || $this->get_hide_deactivation_form ()) return;
1172
+
1173
  $form = $this->filtered_deactivation_form_text ();
1174
  if (!isset ($form ['heading']) || !isset( $form ['body']) || !isset ($form ['options']) || !is_array ($form ['options']) || !isset ($form ['info']) || !isset ($form ['details'])) {
1175
  $form = $this->default_deactivation_form_text ();
1176
  }
1177
 
1178
  $html = '<div class="dst-deactivation-form-head"><strong>' . esc_html ($form ['heading']) . '</strong></div>';
1179
+ $html .= '<div class="dst-deactivation-form-body"><p>' . ($form['body']) . '</p>';
1180
  if (is_array ($form ['options'])) {
1181
  $html .= '<div class="dst-deactivation-options"><p>';
1182
  foreach ($form ['options'] as $option) {
1183
+ $option_data = explode ('#', $option);
1184
+ $attributes = '';
1185
+ if (isset ($option_data [1])) {
1186
+ $attributes = 'data-option="' . $option_data [1] .'"';
1187
+ if ($option_data [1] == 1) {
1188
+ $attributes .= ' style="visibility: hidden;"';
1189
+ }
1190
+ }
1191
+ $option = $option_data [0];
1192
+ $id = strtolower (str_replace (array (" ", "&#039;"), "", esc_attr ($option)));
1193
+ $html .= '<input type="checkbox" name="dst-deactivation-options[]" id="' . $id . '" value="' . esc_attr ($option) . '"' . $attributes . '> <label for="' . $id . '"' . $attributes . '>' . esc_attr ($option) . '</label><br>';
1194
  }
1195
  $html .= '</p><label for="dst-deactivation-reasons">' . esc_html ($form ['details'] ) .'</label><textarea name="dst-deactivation-reasons" id="dst-deactivation-reasons" rows="3" style="width:100%"></textarea><p>' . esc_html ($form['info']) . '</p>';
1196
  $html .= '</div>';
1238
  .dst-deactivation-form-body {
1239
  padding: 8px 18px;
1240
  color: #444;
1241
+ text-align: justify;
1242
+ }
1243
+ div.dst-deactivation-form-body strong {
1244
+ display: inline;
1245
+ }
1246
+ .dst-deactivation-options {
1247
+ margin-top: 20px;
1248
  }
1249
  .deactivating-spinner {
1250
  width: 200px;
1264
  float: left;
1265
  background: #fff;
1266
  color: #000;
1267
+ margin: 0 10px 0 0;
1268
  }
1269
  .dst-deactivation-form-footer .button.primary {
1270
  float: right;
1271
  background: #716eef;
1272
  color: #fff;
1273
  }
1274
+ @media (max-width: 768px) {
1275
+ .dst-deactivation-form-footer .button.secondary {
1276
+ padding: 6px 6px;
1277
+ }
1278
+ .row-actions span .dst-deactivation-form {
1279
+ padding-top: 0;
1280
+ }
1281
+ .dst-deactivation-form-body {
1282
+ text-align: left;
1283
+ }
1284
+ }
1285
  @media (max-width: 500px) {
1286
  .dst-form-active .dst-deactivation-form {
1287
  width: 100%;
1294
  <script>
1295
  jQuery(document).ready (function ($){
1296
  var dst_debugging = <?php echo defined ('DST_DEBUG_JS') && DST_DEBUG_JS ? 'true' : 'false'; ?>;
1297
+ var hide_form_visible = 0;
1298
 
1299
  $("#dst-deactivation-link-<?php echo esc_attr ($this->slug); ?>").on ("click",function() {
1300
  var url = $("#dst-deactivation-link-<?php echo esc_attr ($this->slug); ?>").attr ('href');
1304
  $('body').toggleClass ('dst-form-active');
1305
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?>").fadeIn();
1306
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?>").html ('<?php echo $html; ?>' +
1307
+ '<div class="dst-deactivation-form-footer"><p><a id="dst-cancel" class="button secondary" href="'+url+'"><?php _e('Cancel', 'dst'); ?></a>&nbsp;<a id="dst-just-deactivate" class="button secondary" href="'+url+'"><?php _e('Just Deactivate', 'dst'); ?></a>&nbsp;<a id="dst-submit-form" class="button primary" href="#"><?php _e( 'Submit and Deactivate', 'dst' ); ?></a></p></div>');
1308
  $('#dst-submit-form').on ('click', function (e){
1309
+ $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .dst-deactivation-form-head").html('<strong><?php echo esc_html ($form ['leaving']); ?></strong>');
1310
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .dst-deactivation-form-body").hide();
1311
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .dst-deactivation-form-footer").hide();
1312
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?> .deactivating-spinner").show();
1313
  e.preventDefault();
1314
 
1315
  var values = new Array();
1316
+ var hide_form = false;
1317
+ $.each ($("input[name='dst-deactivation-options[]']:checked"), function (x){
1318
+ var data = $(this).data ('option');
1319
+ if (typeof data != 'undefined') {
1320
+ switch (data) {
1321
+ case 1:
1322
+ hide_form = true;
1323
+ break;
1324
+ }
1325
+ }
1326
  values.push ($(this).val ());
1327
  });
1328
+
1329
  var details = $('#dst-deactivation-reasons').val();
1330
  var data = {
1331
  'action': 'dst_ajax_<?php echo $this->slug; ?>',
1336
  'dataType': "json"
1337
  }
1338
 
1339
+ if (hide_form) {
1340
+ data ['hide_form'] = 1;
1341
+ }
1342
+
1343
  if (dst_debugging) console.log ('DST DEACTIVATION SUBMIT', data);
1344
 
1345
  $.post(
1357
  window.location.href = $('#dst-just-deactivate').attr ('href');
1358
  });
1359
 
1360
+ $('#dst-cancel').on ('click', function (e){
1361
+ e.preventDefault();
1362
+ $('.dst-deactivation-form-bg').click ();
1363
+ });
1364
+
1365
  $('.dst-deactivation-form-bg').on ('click', function (){
1366
  $("#dst-deactivation-form-<?php echo esc_attr ($this->slug); ?>").fadeOut();
1367
  $('body').removeClass ('dst-form-active');
1368
  });
1369
 
1370
+ $("input[data-option='2']").on ('click', function (){
1371
+ if ($(this).is (":checked"))
1372
+ hide_form_visible ++; else
1373
+ hide_form_visible --;
1374
+
1375
+ if (hide_form_visible) {
1376
+ $("[data-option=1]").css ('visibility', '');
1377
+ } else {
1378
+ $("[data-option=1]").css ('visibility', 'hidden');
1379
+ }
1380
+ });
1381
+
1382
  window.onkeydown = function( event ) {
1383
  if (event.keyCode === 27 ) {
1384
  $('.dst-deactivation-form-bg').click ();
1427
 
1428
  $details = sanitize_text_field ($_POST ['details']);
1429
  $this->set_deactivation_details ($details);
1430
+
1431
+ if (isset ($_POST ["hide_form"])) {
1432
+ $this->set_hide_deactivation_form ($_POST ["hide_form"]);
1433
+ }
1434
  }
1435
 
1436
  wp_die();
includes/js/ai-rotate.js CHANGED
@@ -194,10 +194,11 @@ jQuery (function ($) {
194
  // if (ai_debug) console.log ('adb_show_wrapping_div.data ("ai-tracking")', adb_show_wrapping_div.data ("ai-tracking"));
195
 
196
  if (adb_show_wrapping_div.data ("ai-tracking")) {
197
- var data = JSON.parse (atob (adb_show_wrapping_div.data ("ai-tracking")));
 
198
  if (typeof data !== "undefined" && data.constructor === Array) {
199
  data [1] = random_index + 1;
200
- data [3] = option_name;
201
  // adb_show_wrapping_div.data ("ai-tracking", btoa (JSON.stringify (data)))
202
  adb_show_wrapping_div.data ("ai-tracking", b64e (JSON.stringify (data)))
203
  tracking_updated = true;
@@ -208,8 +209,8 @@ jQuery (function ($) {
208
  if (!tracking_updated) {
209
  var wrapping_div = $(rotation_block).closest ('div[data-ai]');
210
  if (typeof wrapping_div.data ("ai") != "undefined") {
211
- var data = JSON.parse (atob (wrapping_div.data ("ai")));
212
-
213
  if (typeof data !== "undefined" && data.constructor === Array) {
214
  data [1] = random_index + 1;
215
  data [3] = option_name;
194
  // if (ai_debug) console.log ('adb_show_wrapping_div.data ("ai-tracking")', adb_show_wrapping_div.data ("ai-tracking"));
195
 
196
  if (adb_show_wrapping_div.data ("ai-tracking")) {
197
+ // var data = JSON.parse (atob (adb_show_wrapping_div.data ("ai-tracking")));
198
+ var data = JSON.parse (b64d (adb_show_wrapping_div.data ("ai-tracking")));
199
  if (typeof data !== "undefined" && data.constructor === Array) {
200
  data [1] = random_index + 1;
201
+ data [3] = option_name ;
202
  // adb_show_wrapping_div.data ("ai-tracking", btoa (JSON.stringify (data)))
203
  adb_show_wrapping_div.data ("ai-tracking", b64e (JSON.stringify (data)))
204
  tracking_updated = true;
209
  if (!tracking_updated) {
210
  var wrapping_div = $(rotation_block).closest ('div[data-ai]');
211
  if (typeof wrapping_div.data ("ai") != "undefined") {
212
+ // var data = JSON.parse (atob (wrapping_div.data ("ai")));
213
+ var data = JSON.parse (b64d (wrapping_div.data ("ai")));
214
  if (typeof data !== "undefined" && data.constructor === Array) {
215
  data [1] = random_index + 1;
216
  data [3] = option_name;
includes/js/ai-rotate.min.js CHANGED
@@ -7,6 +7,6 @@ option=$(rotate_options[random_index]);rotation_time=0;if(ai_debug)console.log("
7
  random_index,"time:",rotation_time)}if(rotation_time>0){var next_random_index=random_index+1;if(next_random_index>=rotate_options.length)next_random_index=0;if(typeof $(rotation_block).data("info")!="undefined"){var block_info=JSON.parse(atob($(rotation_block).data("info")));var rotation_id=block_info[0];$(rotation_block).attr("data-next",next_random_index);if(trigger_rotation)setTimeout(function(){ai_process_rotation($("div.ai-rotate.ai-"+rotation_id))},rotation_time*1E3);option_time_text=" ("+rotation_time+
8
  " s)"}}}else{if(!ai_debug)rotate_options.each(function(index){if(index!=random_index)$(this).remove()});if(ai_debug)console.log("AI ROTATE no time");if(ai_debug)console.log("AI ROTATE index:",random_index)}option.css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""}).removeClass("ai-rotate-hidden").removeClass("ai-rotate-hidden-2");$(rotation_block).css({"position":""});if(typeof option.data("code")!="undefined"){rotate_options.empty();var option_code=b64d(option.data("code"));
9
  option.append(option_code)}var option_name="";var debug_block_frame=$(rotation_block).closest(".ai-debug-block");if(debug_block_frame.length!=0){var option_name=b64d(option.data("name"));var name_tag=debug_block_frame.find("kbd.ai-option-name");var nested_debug_block=debug_block_frame.find(".ai-debug-block");if(typeof nested_debug_block!="undefined"){var name_tag2=nested_debug_block.find("kbd.ai-option-name");name_tag=name_tag.slice(0,name_tag.length-name_tag2.length)}if(typeof name_tag!="undefined"){var separator=
10
- name_tag.first().data("separator");if(typeof separator=="undefined")separator="";name_tag.html(separator+option_name+option_time_text)}}var tracking_updated=false;var adb_show_wrapping_div=$(rotation_block).closest(".ai-adb-show");if(adb_show_wrapping_div.length!=0)if(adb_show_wrapping_div.data("ai-tracking")){var data=JSON.parse(atob(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;adb_show_wrapping_div.data("ai-tracking",
11
- b64e(JSON.stringify(data)));tracking_updated=true}}if(!tracking_updated){var wrapping_div=$(rotation_block).closest("div[data-ai]");if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;wrapping_div.data("ai",b64e(JSON.stringify(data)))}}}};function ai_process_rotations(){$("div.ai-rotate").each(function(index,element){ai_process_rotation(this)})}ai_process_rotations_in_element=
12
  function(el){$("div.ai-rotate",el).each(function(index,element){ai_process_rotation(this)})};$(document).ready(function($){setTimeout(function(){ai_process_rotations()},10)})});
7
  random_index,"time:",rotation_time)}if(rotation_time>0){var next_random_index=random_index+1;if(next_random_index>=rotate_options.length)next_random_index=0;if(typeof $(rotation_block).data("info")!="undefined"){var block_info=JSON.parse(atob($(rotation_block).data("info")));var rotation_id=block_info[0];$(rotation_block).attr("data-next",next_random_index);if(trigger_rotation)setTimeout(function(){ai_process_rotation($("div.ai-rotate.ai-"+rotation_id))},rotation_time*1E3);option_time_text=" ("+rotation_time+
8
  " s)"}}}else{if(!ai_debug)rotate_options.each(function(index){if(index!=random_index)$(this).remove()});if(ai_debug)console.log("AI ROTATE no time");if(ai_debug)console.log("AI ROTATE index:",random_index)}option.css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""}).removeClass("ai-rotate-hidden").removeClass("ai-rotate-hidden-2");$(rotation_block).css({"position":""});if(typeof option.data("code")!="undefined"){rotate_options.empty();var option_code=b64d(option.data("code"));
9
  option.append(option_code)}var option_name="";var debug_block_frame=$(rotation_block).closest(".ai-debug-block");if(debug_block_frame.length!=0){var option_name=b64d(option.data("name"));var name_tag=debug_block_frame.find("kbd.ai-option-name");var nested_debug_block=debug_block_frame.find(".ai-debug-block");if(typeof nested_debug_block!="undefined"){var name_tag2=nested_debug_block.find("kbd.ai-option-name");name_tag=name_tag.slice(0,name_tag.length-name_tag2.length)}if(typeof name_tag!="undefined"){var separator=
10
+ name_tag.first().data("separator");if(typeof separator=="undefined")separator="";name_tag.html(separator+option_name+option_time_text)}}var tracking_updated=false;var adb_show_wrapping_div=$(rotation_block).closest(".ai-adb-show");if(adb_show_wrapping_div.length!=0)if(adb_show_wrapping_div.data("ai-tracking")){var data=JSON.parse(b64d(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;adb_show_wrapping_div.data("ai-tracking",
11
+ b64e(JSON.stringify(data)));tracking_updated=true}}if(!tracking_updated){var wrapping_div=$(rotation_block).closest("div[data-ai]");if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(b64d(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;wrapping_div.data("ai",b64e(JSON.stringify(data)))}}}};function ai_process_rotations(){$("div.ai-rotate").each(function(index,element){ai_process_rotation(this)})}ai_process_rotations_in_element=
12
  function(el){$("div.ai-rotate",el).each(function(index,element){ai_process_rotation(this)})};$(document).ready(function($){setTimeout(function(){ai_process_rotations()},10)})});
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.4.0";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -35,6 +35,7 @@ var AI_FOOTER = 13;
35
  var AI_ABOVE_HEADER = 14;
36
  var AI_BEFORE_HTML_ELEMENT = 15;
37
  var AI_AFTER_HTML_ELEMENT = 16;
 
38
 
39
 
40
  var AI_ALIGNMENT_DEFAULT = 0;
@@ -1037,6 +1038,8 @@ jQuery(document).ready(function($) {
1037
 
1038
  $("#html-element-settings-"+block).hide();
1039
 
 
 
1040
  var automatic_insertion = $("select#display-type-"+block+" option:selected").attr('value');
1041
 
1042
  if (automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH) {
@@ -1046,8 +1049,12 @@ jQuery(document).ready(function($) {
1046
  $("#paragraph-clearance-"+block).hide();
1047
  }
1048
 
1049
- if (automatic_insertion == AI_BEFORE_HTML_ELEMENT || automatic_insertion == AI_AFTER_HTML_ELEMENT) {
1050
  $("#html-element-settings-"+block).show();
 
 
 
 
1051
  }
1052
 
1053
  var content_settings = automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH || automatic_insertion == AI_BEFORE_CONTENT || automatic_insertion == AI_AFTER_CONTENT;
1
+ var javascript_version = "2.4.1";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
35
  var AI_ABOVE_HEADER = 14;
36
  var AI_BEFORE_HTML_ELEMENT = 15;
37
  var AI_AFTER_HTML_ELEMENT = 16;
38
+ var AI_INSIDE_HTML_ELEMENT = 17;
39
 
40
 
41
  var AI_ALIGNMENT_DEFAULT = 0;
1038
 
1039
  $("#html-element-settings-"+block).hide();
1040
 
1041
+ $("#inside-element-"+block).hide();
1042
+
1043
  var automatic_insertion = $("select#display-type-"+block+" option:selected").attr('value');
1044
 
1045
  if (automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH) {
1049
  $("#paragraph-clearance-"+block).hide();
1050
  }
1051
 
1052
+ if (automatic_insertion == AI_BEFORE_HTML_ELEMENT || automatic_insertion == AI_AFTER_HTML_ELEMENT || automatic_insertion == AI_INSIDE_HTML_ELEMENT) {
1053
  $("#html-element-settings-"+block).show();
1054
+
1055
+ if (automatic_insertion == AI_INSIDE_HTML_ELEMENT) {
1056
+ $("#inside-element-"+block).css ('display', 'table-cell');
1057
+ }
1058
  }
1059
 
1060
  var content_settings = automatic_insertion == AI_BEFORE_PARAGRAPH || automatic_insertion == AI_AFTER_PARAGRAPH || automatic_insertion == AI_BEFORE_CONTENT || automatic_insertion == AI_AFTER_CONTENT;
readme.txt CHANGED
@@ -4,9 +4,9 @@ Contributors: spacetime
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
5
  Tags: ads, adsense, header footer code, ad management, sticky fixed widgets, advanced geo targeting ads, amp adverts ad rotation, advertising manager, amazon banners ad injection, ad blocking detection, PHP Javascript HTML insertion, custom fields posts
6
  Requires at least: 4.0
7
- Tested up to: 4.9
8
  Requires PHP: 5.6
9
- Stable tag: 2.4.0
10
  License: GPLv3
11
 
12
  Insert and manage ads: Amazon, Google AdSense ads, banner rotation, sticky widget ads, AMP, PHP, HTML, CSS, Javascript, tracking, footer, header code
@@ -68,6 +68,7 @@ Looking for AdSense plugin with simple setup for ads at best positions? A plugin
68
  * Insert ads between excerpts on blog pages
69
  * Insert ads between comments
70
  * Insert ads at custom hook positions (`do_action ()` WP function)
 
71
  * Avoid inserting ads near images or headers (AdSense TOS)
72
  * Disable ads on individual posts or pages
73
  * Insert header (`<head>` section) and footer code
@@ -95,6 +96,7 @@ Looking for AdSense plugin with simple setup for ads at best positions? A plugin
95
  * Easy copying and pasting ads or settings using internal clipboard
96
  * Simple troubleshooting with many debugging functions
97
  * Function to visualize inserted code blocks and ads
 
98
  * Function to visualize available insertion positions
99
  * Function to visualize HTML tags
100
  * You name it :)
@@ -133,7 +135,7 @@ And if you need more ads with page/category specific settings, ad statistics and
133
  * Ad impression and click statistics (works also with `<iframe>` Javascript ads like Google AdSense)
134
  * External tracking via Google Analytics or Matomo (Piwik)
135
  * A/B testing - discover ads and settings that perform best
136
- * Lazy loading ads
137
  * [Sticky ads](https://adinserter.pro/documentation/alignments-and-styles#sticky-ads) with optional close button
138
  * Sticky sidebar ads (stick to the screen or to the content)
139
  * Floating slide-in banner ads
@@ -150,11 +152,11 @@ And if you need more ads with page/category specific settings, ad statistics and
150
  * No ads on the settings page
151
  * Support via email
152
 
153
- Run a WordPress related blog? Have experience with AdSense ads? Interested in reviewing Ad Inserter Pro? <a href="https://adinserter.pro/contact" target="_blank">Introduce yourself</a>.
154
 
155
- Ad Inserter Wordpress plugin is an advanced advertising manager for all kind of ads - it has many features and options to automate placing ads in order to optimally monetize your website on desktop, tablet and phone displays. It provides many simple ways to insert any kind of ads, Javascript, HTML, PHP or advert code anywhere on the page. For best placement of ads please read the user manual to get the most of the plugin.
156
 
157
- Check <a href="https://adinserter.pro/documentation" target="_blank">Ad Inserter documentation pages</a> for detailed description of all the features and some <a href="https://adinserter.pro/documentation/common-settings" target="_blank">common settings</a> for quick start
158
 
159
  You can also use shortcodes from other plugins (for example, to insert ads from other ad plugins like AdRotate, Advanced Ads, Quick Adsense, AdSense Plugin WP QUADS, Insert Post Ads).
160
 
@@ -199,18 +201,20 @@ Maintaining several plugins (often from different vendors) is not easy. And each
199
 
200
  **Quick Start**
201
 
202
- To become familiar with the plugin check [Quick Start](https://adinserter.pro/documentation/quick-start) to display ads on your website. Few important steps:
203
 
204
- * Completely **disable AdBlocker!** You don't need it when working with ads! Ad blockers prevent displaying ads and also block all AdSense pages!
205
- * [Code block](https://adinserter.pro/documentation/code-editing) is any code (for example for Google AdSense ads) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code (or ads) at almost any position supported by Wordpress
206
- * To rename block click on the name
207
- * If you are using AdSense ads check available tools and code generator for [AdSense ads](https://adinserter.pro/documentation/adsense-ads)
208
- * Paste ad code into the code window or use <a href="https://adinserter.pro/documentation/code-editing" target="_blank">code generator</a> to generate code for banners, AdSense ads or any other HTML advert
209
- * **Enable and use at least one insertion option** (<a href="https://adinserter.pro/documentation/automatic-insertion" target="_blank">Automatic insertion</a>, Widget, <a href="https://adinserter.pro/documentation/manual-insertion" target="_blank">Shortcode</a>, PHP function call)
210
- * **Enable insertion on at least one <a href="https://adinserter.pro/documentation/wordpress-page-types">Wordpress page type</a>** (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
211
- * For Posts and Static pages **leave default BLANK selection value** after the checkbox unless you really know what are you doing (using individual exceptions)
212
- * If you don't see inserted blocks or ads, turn on **debugging functions**: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the Wordpress admin toolbar on the top of every post/page when you are logged in). Check [Troubleshooting](https://adinserter.pro/documentation/troubleshooting) documentation for details.
213
- * If you are using <a href="https://adinserter.pro/documentation/adsense-ads" target="_blank">AdSense ads</a> you may get blank (empty) ad blocks - no ads are displayed. This might happen because there is some error in the code (wrong IDs), your Google AdSense account is not fully approved yet, your website was not accepted or your Google AdSense account is banned. In such case you can try other ad networks for contextual ads. Check <a href="https://adinserter.pro/documentation/adsense-ads#ads-not-displayed">Ads Not Displayed</a> for more information.
 
 
214
 
215
  Few typical settings are described on the <a href="https://adinserter.pro/documentation/common-settings" target="_blank">Common Settings</a> page. Please make sure you have also read <a href="https://adinserter.pro/documentation/plugin-installation">plugin installation</a> documentation. For more detailed instructions please read <a href="https://adinserter.pro/documentation" target="_blank">Ad Inserter documentation pages</a>.
216
 
@@ -233,69 +237,19 @@ Please note that **Output buffering** may not work with all themes - in such cas
233
 
234
  **Please support plugin development**
235
 
236
- If you are using Ad Inserter and you like it, then please write about it and spread the word on the <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review page</a>.
237
 
238
  Positive reviews are a great way to show your appreciation for my work. Besides being an incredible boost to my morale, they are also a great incentive to fix any bug found in the software and to add new features for better monetization of your website.
239
 
240
  Support the advancement of this plugin:
241
 
242
- * Write a short <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">review</a>
243
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a> if Ad Inserter helps you to make money with ads
244
  * Buy license for [Ad Inserter Pro](https://adinserter.pro/) - Top WordPress plugin for ads
245
 
246
  == Installation ==
247
 
248
- = Using The WordPress Dashboard =
249
-
250
- 1. Go to Wordpress Plugins menu, click Add New button
251
- 2. Search for `ad inserter`
252
- 3. Click 'Install Now'
253
- 4. Activate Ad Inserter on the Plugins dashboard
254
-
255
- = Uploading plugin file =
256
-
257
- 1. Go to Wordpress Plugins menu, click Add New button
258
- 2. Click Upload Plugin
259
- 3. Select `ad-inserter.zip` from your computer
260
- 4. Click 'Install Now'
261
- 5. Activate Ad Inserter on the Plugins dashboard
262
-
263
- = Using FTP =
264
-
265
- 1. Download `ad-inserter.zip`
266
- 2. Extract `ad-inserter` directory to your computer
267
- 3. Make sure `ad-inserter` directory contains plugin files and not another `ad-inserter` directory inside
268
- 4. Upload `ad-inserter` directory to the `/wp-content/plugins/` directory
269
- 5. Activate Ad Inserter on the Plugins dashboard
270
-
271
- **Ad Inserter Pro Installation**
272
-
273
- If you are using free Ad Inserter then first uninstall it. The Pro version will automatically import existing settings from the free version.
274
- After you receive the email with download link for the Ad Inserter Pro plugin, download it, go to Wordpress Plugins, Add New, Upload Plugin, Choose file, click on Install Now,
275
- activate it and then click "Enter License Key" and enter license key you got in the email.
276
-
277
- **Uninstall**
278
-
279
- If you deactivate and delete Ad Inserter, the settings will stay in the database. To completely remove the plugin and settings do the following:
280
-
281
- 1. Go to Ad Inserter general settings (tab &#9881;) and click on Reset All Settings
282
- 1. Go to Ad Inserter general settings (tab &#9881;) and click on Clear All Statistics Data (Pro only)
283
- 2. Deactivate Ad Inserter
284
- 3. Delete Ad Inserter plugin
285
-
286
- *Please Note*
287
-
288
- Ad Inserter inserts only the code you configure (blocks 1 - 16, Header, Footer). The code you see is the code that will be inserted (+ some internal scripts for plugin features).
289
- When you deactivate Ad Inserter it can't insert anything as WordPress doesn't call it. If you still see ads please clear all the caches and check page source code before you make any conclusion.
290
- Of course, if you configure code block with some javacript ad code, then this code may generate ads. But please, don't blame the plugin for this.
291
- You can also use Ad Inserter to insert code for AdSense Auto ads on each page (usually in the header). However, **the exact placement of ads will be done by the ad code, not Ad Inserter!**
292
- [https://adinserter.pro/documentation/adsense-ads#auto-ads](https://adinserter.pro/documentation/adsense-ads#auto-ads)
293
-
294
- The easiest way to check Ad Inserter code blocks or ads is to use **Label blocks** debugging function:
295
- [https://adinserter.pro/documentation/debugging](https://adinserter.pro/documentation/debugging)
296
-
297
- When you deactivate Ad Inserter it can't insert anything - WordPress doesn't call it. If you still see some ads that were inserted by Ad Inserter, make sure you have cleared all the caches.
298
- If you still see those ads after you have disabled Ad Inserter and cleared all the caches, then the ads were not inserted by Ad Inserter.
299
 
300
 
301
  **Online Documentation**
@@ -324,10 +278,13 @@ If you still see those ads after you have disabled Ad Inserter and cleared all t
324
  4. Set automatic insertion option (for example: Before Post)
325
  5. Enable at least one page type (for example: Posts, some insertion options don't work on all page types)
326
  6. Save settings
327
- 7. Check also <a href="https://adinserter.pro/documentation/common-settings" target="_blank">common Ad Inserter settings</a>
328
  8. Check inserted code on the posts
329
- 9. Ads are not showing? Check <a href="https://adinserter.pro/documentation/troubleshooting#ads-not-displayed" target="_blank">troubleshooting guide</a> to find out what to check to fix the problem.
330
 
 
 
 
331
 
332
  = Does Ad Inserter insert any internal ads? =
333
 
@@ -345,10 +302,10 @@ The easiest way to check Ad Inserter code blocks is to use **Label blocks** debu
345
 
346
  You are probably using code for [AdSense Auto ads](https://adinserter.pro/documentation/adsense-ads#auto-ads).
347
 
348
- 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.
349
- 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.
350
 
351
- 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/documentation/adsense-ads#ad-unit) and specifying exact locations where the code should be inserted.
352
 
353
  = I have installed code for AdSense ads but the ad blocks are blank. =
354
 
@@ -414,13 +371,14 @@ There are two modes for sticky widgets (or sticky sidebars) available as **Stick
414
  * CSS mode - This mode is the best approach but may not work with all themes. CSS mode works by changing sidebar CSS to `position: sticky`. This works with most themes but not all. If your widgets and sidebar aren't sticking as expected you can use **JavaScript mode** described below.
415
  * JavaScript mode - This mode should work with practically all themes but may reload ads on page load when sticky sidebar is initialized.
416
 
417
- = What is usage tracking? =
 
418
 
419
  When enabled, the information regarding WordPress environment and Ad Inserter usage will be collected and sent to plugin developers (once per month and on events like plugin activation/deactivation).
420
 
421
  This is completely optional and can be disabled at any time. So if you have opted in (by clicking Allow when asked for permission) and now you would like to disable tracking, you should go to tab &#9881; / tab General, select **Disable** for Plugin usage tracking and save settings.
422
 
423
- If this setting is not available then you have not selected any option yet - **tracking is disabled unless explicitly enabled** by clicking Allow when asked for permission (or when this setiing is set to Enable).
424
 
425
  What data is collected: Ad Inserter version, activation status, number of active blocks, date of installation, date of last saved settings, status of review notice and remote debugging, block class name, location, website url and name, WordPress version, language, text direction, charset, number of posts, active theme and version, list of installed plugins, PHP version, server name, IP address (used to determine country), site count for multisite installations, deactivation reasons and details (if provided).
426
 
@@ -432,6 +390,7 @@ If you are not happy to reveal this information and you have opted in, simply di
432
 
433
  **Your decision will be respected.**
434
 
 
435
  = Settings for contextual Amazon Native Shopping Ads =
436
 
437
  * Automatic Insertion: After Content
@@ -463,17 +422,6 @@ You can also use <a href="https://codex.wordpress.org/Custom_Fields" target="_bl
463
  You can also try with `[adinserter data='tag']', `[adinserter data='short-title']`, `[adinserter data='category']` or `[adinserter data='short-category']`. For more options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
464
 
465
 
466
- = Settings for ads ... =
467
-
468
- Check <a href="https://adinserter.pro/documentation/common-settings" target="_blank">common Ad Inserter settings</a>
469
-
470
-
471
- = What PHP versions are supported? =
472
-
473
- Officially PHP 5.6 and higher versions up to PHP 7.2 are supported. However, Ad Inserter should work also with older PHP versions supported by WordPress.
474
- Some plugins like PHP Compatibility Checker may report warnings with PHP 7.2 because they check also files that are loaded only for older PHP versions.
475
-
476
-
477
  = I wish to show ads side by side but not in the same block. How do I do this? =
478
 
479
  Configure block 1 and 2 with ads using:
@@ -484,10 +432,10 @@ Configure block 1 and 2 with ads using:
484
 
485
  Configure block 3 with
486
 
487
- `[adinserter block="1"]
488
- [adinserter block="2"]`
489
 
490
- Use block 3 to insert ads and make sure all 3 blocks are enabled for the same page types (Posts, Pages, Homepage, etc.).
491
 
492
 
493
  = I use After Content insertion position but the ads are inserted after the stuff provided by other plugins. How can I insert ads directly after post content?
@@ -497,7 +445,7 @@ This happens because Ad Inserter processes posts last and therefore "sees" also
497
  Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab &#9881; / tab General).
498
 
499
 
500
- = How can I add some title or label (e.g. Advertisements) above the ads? =
501
 
502
  If this is a sidebar widget then you can simply name the widget.
503
 
@@ -513,122 +461,7 @@ In case you need a different label for some ad you can simply add label HTML cod
513
 
514
  AD_CODE`
515
 
516
-
517
- = How can I enable/disable ads on specific posts/pages? =
518
-
519
- There are two possible approaches.
520
-
521
- * Approach with page/post exceptions - use this one if there are many exceptions (more than two):
522
-
523
- 1. Go to Ad Inserter settings page and define default insertion options for post/page.
524
- 2. Enable automatic insertion on posts/pages and choose default insertion: **Individually disabled** or **Individually enabled**.
525
- 3. Save settings.
526
- 4. Go to post/page editor and open **Ad Inserter Individual Exceptions** meta box below.
527
- 5. define insertion exceptions for this post or page.
528
- 6. Save post/page.
529
-
530
- **Individually disabled** means that insertion will be by default enabled on all posts (according to the settings for this code block), but you will be able to disable insertion on individual posts or pages (in post/page editor).
531
-
532
- **Individually enabled** means that insertion will be by default disabled on all posts, but you will be able to enable insertion on individual posts or pages (in post/page editor) - of course, other settings (e.g. lists) for this code block will also apply.
533
-
534
- * Approach with code block settings only - use this one if there are only few exceptions:
535
-
536
- 1. Go to Ad Inserter settings page and define default insertion options for post/page.
537
- 2. Enable automatic insertion for Posts/Pages (use default value after checkbox - blank selection means no individual exceptions).
538
- 3a. Click on Lists, enter post IDs (click on the button left of the list) and white-list or black-list them.
539
- 3b. Click on Lists, enter url (or comma separated urls) for Urls, e.g. `/permalink-url`, and white-list or black-list it.
540
-
541
- For details check <a href="https://adinserter.pro/documentation/individual-post-and-page-exceptions" target="_blank">Individual Post/Page Exceptions</a>.
542
-
543
-
544
- = I'm using responsive theme. How can I show or hide some ads on mobile devices? =
545
-
546
- Select device types (desktop, tablet or phone) for which you need to show ads and enable **only client-side** device detection.
547
-
548
-
549
- = How can I enable or disable ads on group of similar pages? =
550
-
551
- If those pages have something in common in the url (page address) then you can block them with url patterns.
552
- Use `*` to define url pattern to whitelist (enable) or blacklist (disable).
553
-
554
- 1. To filter all urls starting with **/url-start** use `/url-start*`
555
- 2. To filter all urls that contain **url-pattern** use `*url-pattern*`
556
- 3. To filter all urls ending with **url-end** use `*url-end`
557
-
558
- For example, to exclude ads on pages that have /shop/ in url (page address) blacklist the following url: `*/shop/*`
559
-
560
-
561
- = How can I put ads in the middle of the post regardless of the number of paragraphs? =
562
-
563
- Use Before paragraph automatic insertion and put 0.5 as paragraph number. Value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
564
-
565
-
566
- = How can I put ads before the second paragraph and also in the middle of post with single ad block? =
567
-
568
- Use Before paragraph automatic insertion and put `2, 0.5` as paragraph number. You can specify multiple paragraphs as comma separated paragraph numbers (or relative postions).
569
-
570
-
571
- = I'd like to rotate my ads based on percentage, for example show one ad 75% of the time and another one 25% of the time. Is that possible? =
572
-
573
- Yes. Either use rotation code generator and define shares in percents or create code using `ROTATE` separator with attribute *share* where you define percentage of the rotation share:
574
-
575
- `[ADINSERTER ROTATE share="75"]
576
- ad_code_1
577
- [ADINSERTER ROTATE share="25"]
578
- ad_code_2`
579
-
580
- If you omit one share value it will be automatically calculated:
581
-
582
- `ad_code_1
583
- [ADINSERTER ROTATE share="25"]
584
- ad_code_2`
585
-
586
-
587
- = How can I show different ads to different visitors according to a url query parameter? =
588
-
589
- Use Url parameters List to black/white-list certain url parameters. Leave url parameter list empty and set it to Black list to show ads for all url.
590
- You can specify either parameters or parameters with values. For example for url `http://example.com?data=2&customer-id=22&device=0` you can define url parameters '`data, customer-id=22`' to insert ad only for urls where there is `data` parameter and `customer-id` parameter with value 22.
591
- Separate parameters with comma.
592
-
593
-
594
- = How can I use PHP code for code block? =
595
-
596
- Enter PHP code surrounded by PHP tags and check Process PHP.
597
- Example:
598
-
599
- `<div style="width: 100%;">
600
- Some HTML/Javascript code
601
- </div>
602
- <?php echo "PHP code by Ad Inserter"; ?>`
603
-
604
-
605
- = How can I rotate few versions of the same ad? =
606
-
607
- Enter them into the ad box and separate them with `[ADINSERTER ROTATE]`. Ad Inserter will insert them randomly.
608
- Example:
609
-
610
- `ad_code_1
611
- [ADINSERTER ROTATE]
612
- ad_code_2
613
- [ADINSERTER ROTATE]
614
- ad_code_3`
615
-
616
-
617
- = What settings should I use for ads on AMP pages? =
618
-
619
- Normally the code will not be inserted on AMP pages. There are two settings that can be used to insert code on AMP pages:
620
-
621
- 1. **AMP pages** checkbox in **Misc / Insertion** section - If checked it enables insertion also on AMP pages. **Use this approach only if you need to insert the same code on normal and AMP pages.** To insert different codes on AMP pages use **[ADINSERTER AMP]** separator as described below.
622
- 2. Separate the codes with **[ADINSERTER AMP]** separator - the code above the separator will be inserted on normal pages, the code below the separator will be inserted on AMP pages. This separator can be used also for **Header** and **Footer** code.
623
-
624
- The following AMP plugins have been tested with Ad Inserter:
625
- * <a href="https://wordpress.org/plugins/accelerated-mobile-pages/" target="_blank">AMP for WP - Accelerated Mobile Pages</a> (free)
626
- * <a href="https://wordpress.org/plugins/amp/" target="_blank">AMP</a> (free)
627
- * <a href="https://wordpress.org/plugins/wp-amp-ninja/" target="_blank">WP AMP Ninja</a> (free)
628
- * WP AMP - Accelerated Mobile Pages for WordPress (paid - you need to uncheck *Remove third-party the_content hooks for better compatibility*)
629
-
630
- For details check <a href="https://adinserter.pro/documentation/amp-pages" target="_blank">settings for ads on AMP pages</a>.
631
-
632
 
633
  = How can place ads below Read More tag? =
634
 
@@ -641,23 +474,6 @@ Configure ad block with the following options:
641
  Check source code of your website for proper "read more" tag.
642
 
643
 
644
- = How can I insert ads or code block directly into template php file? =
645
-
646
- Enable PHP function adinserter for code block and call adinserter function with code block number as parameter.
647
- Example for block 3:
648
-
649
- `<?php if (function_exists ('adinserter')) echo adinserter (3); ?>`
650
-
651
- This would generate code as defined for the code block number 3. Before you modifu theme files it makes sense to create a <a href="https://codex.wordpress.org/Child_Themes" target="_blank">child theme</a> first.
652
-
653
-
654
- = Center alignment does not work for some ads! =
655
-
656
- Some ads can not be centered using the standard approach so some different CSS code is needed to put them in the middle.
657
-
658
- In Preview window you can try alternative CSS code for centering the ad. Double-click on the icon for Center alignment and the code will toggle. The current code version is displayed next to Alignment and Style selection.
659
-
660
-
661
  = How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left? =
662
 
663
  Set Block Alignment and Style to "No Wrapping" and create manual wrapping around both ads separated with [ADINSERTER ROTATE]:
@@ -672,6 +488,7 @@ AD CODE LEFT
672
  AD CODE RIGHT
673
  </div>`
674
 
 
675
 
676
  == Screenshots ==
677
 
@@ -696,6 +513,13 @@ AD CODE RIGHT
696
 
697
  == Changelog ==
698
 
 
 
 
 
 
 
 
699
  = 2.4.0 =
700
  - Improved code for client-side insertion
701
  - Added support for usage tracking
@@ -731,103 +555,6 @@ AD CODE RIGHT
731
  - Added shortcode for ad blocking detection action
732
  - Few minor bug fixes, cosmetic changes and code improvements
733
 
734
- = 2.3.16 =
735
- - Added option to insert block only when WP loop is currently active
736
- - Added support for Better AMP plugin
737
- - Code generator for placeholders on https sites now generates https urls
738
- - Optimized loading of plugin settings
739
- - Few minor bug fixes, cosmetic changes and code improvements
740
-
741
- = 2.3.15 =
742
- - Fix for insertion on AMP pages
743
-
744
- = 2.3.14 =
745
- - Simplified AdSense integration
746
- - Added setting to define maximum number of blocks (ads) per page
747
- - Optimized the_content filter processing
748
- - Added setting for lazy loading offset (Pro only)
749
- - Fix for url parameter list when using client-side dynamic blocks
750
- - Few minor bug fixes, cosmetic changes and code improvements
751
-
752
- = 2.3.13 =
753
- - Added support for lazy loading (Pro only)
754
- - Fix for unwanted insertions with some paragraph settings
755
- - Few minor bug fixes, cosmetic changes and code improvements
756
-
757
- = 2.3.12 =
758
- - Fix for urlencode error
759
- - Few other minor bug fixes
760
-
761
- = 2.3.11 =
762
- - Added support for W3TC/client-side check for cookies (in url parameter list) to support showing ads based on visitor's cookie consent
763
- - Added support for W3TC/client-side check for referers
764
- - Improved paragraph processing
765
- - Few minor bug fixes, cosmetic changes and code improvements
766
-
767
- = 2.3.10 =
768
- - Added support for timed rotation
769
- - Added support for client-side insertion of dynamic blocks
770
- - Improved word count function
771
- - Few minor bug fixes, cosmetic changes and code improvements
772
-
773
- = 2.3.9 =
774
- - Added option to easily disable insertion of individual code block
775
- - Changes for compatibility with PHP 7.2
776
- - Added non-interaction parameter to external tracking (Pro only)
777
- - Few minor bug fixes, cosmetic changes and code improvements
778
-
779
- = 2.3.8 =
780
- - Added support for rotation option shares
781
- - Added support for sticky ad settings and animations (Pro only)
782
- - Few minor bug fixes, cosmetic changes and code improvements
783
-
784
- = 2.3.7 =
785
- - Added support for ad labels
786
- - Blocked search indexing while debugging
787
- - Close button setting moved to tab Display (Pro only)
788
- - Few minor bug fixes, cosmetic changes and code improvements
789
-
790
- = 2.3.6 =
791
- - Added widget for debugging tools
792
- - Fix for AdSense ad overlays not displayed with some themes
793
- - Few minor bug fixes, cosmetic changes and code improvements
794
-
795
- = 2.3.5 =
796
- - Added display of header and footer code in Label blocks debugging function
797
- - Added AdSense ad overlays in Label blocks debugging function (experimental)
798
- - Fixed bug for removed square brackets in HTML element selectors
799
- - Fixed preview of AdSense ad units
800
- - Few minor bug fixes
801
-
802
- = 2.3.4 =
803
- - Added support for author:author-username items in taxonomy list
804
- - Fixed errors when downgrading from Pro
805
- - Few minor bug fixes
806
-
807
- = 2.3.3 =
808
- - Added list editors
809
- - Added Label blocks debugging function for AdSense Auto ads
810
-
811
- = 2.3.2 =
812
- - Added AdSense code generator for ad sizes using CSS media queries
813
- - Fix for slow updates caused by changed user agent (Pro only, credits Olivier Langlois)
814
- - Fix for client-side insertion of non-English characters before/after HTML element
815
-
816
- = 2.3.1 =
817
- - Added support for server-side insertion before/after any HTML element
818
- - Few minor bug fixes
819
-
820
- = 2.3.0 =
821
- - Added support for client-side insertion before/after any HTML element
822
- - Inplemented AdSense integration
823
- - Added option to define close button position
824
- - Fix for code generator import and code preview error with non ASCII characters
825
- - Fix for post/page exceptions and page types not processed in the header
826
- - Fix for close button in preview window
827
- - Fix for errors when rearranging blocks
828
- - Fix for errors when importing code
829
- - Few minor bug fixes, cosmetic changes and code improvements
830
-
831
 
832
  = Earlier versions =
833
 
@@ -835,6 +562,13 @@ For the changelog of earlier versions, please refer to the separate changelog.tx
835
 
836
  == Upgrade Notice ==
837
 
 
 
 
 
 
 
 
838
  = 2.4.0 =
839
  Improved code for client-side insertion;
840
  Added support for usage tracking;
@@ -870,100 +604,4 @@ Few minor bug fixes, cosmetic changes and code improvements
870
  Added shortcode for ad blocking detection action;
871
  Few minor bug fixes, cosmetic changes and code improvements
872
 
873
- = 2.3.16 =
874
- Added option to insert block only when WP loop is currently active;
875
- Added support for Better AMP plugin;
876
- Code generator for placeholders on https sites now generates https urls;
877
- Optimized loading of plugin settings;
878
- Few minor bug fixes, cosmetic changes and code improvements;
879
-
880
- = 2.3.15 =
881
- Fix for insertion on AMP pages
882
-
883
- = 2.3.14 =
884
- Simplified AdSense integration;
885
- Added setting to define maximum number of blocks (ads) per page;
886
- Optimized the_content filter processing;
887
- Added setting for lazy loading offset (Pro only);
888
- Fix for url parameter list when using client-side dynamic blocks;
889
- Few minor bug fixes, cosmetic changes and code improvements
890
-
891
- = 2.3.13 =
892
- Added support for lazy loading (Pro only);
893
- Fix for unwanted insertions with some paragraph settings;
894
- Few minor bug fixes, cosmetic changes and code improvements
895
-
896
- = 2.3.12 =
897
- Fix for urlencode error;
898
- Few other minor bug fixes
899
-
900
- = 2.3.11 =
901
- Added support for W3TC/client-side check for cookies (in url parameter list) to support showing ads based on visitor's cookie consent;
902
- Added support for W3TC/client-side check for referers;
903
- Improved paragraph processing;
904
- Few minor bug fixes, cosmetic changes and code improvements
905
-
906
- = 2.3.10 =
907
- Added support for timed rotation;
908
- Added support for client-side insertion of dynamic blocks;
909
- Improved word count function;
910
- Few minor bug fixes, cosmetic changes and code improvements
911
-
912
- = 2.3.9 =
913
- Added option to easily disable insertion of individual code block;
914
- Changes for compatibility with PHP 7.2;
915
- Added non-interaction parameter to external tracking (Pro only);
916
- Few minor bug fixes, cosmetic changes and code improvements
917
-
918
- = 2.3.8 =
919
- Added support for rotation option shares;
920
- Added support for sticky ad settings and animations (Pro only);
921
- Few minor bug fixes, cosmetic changes and code improvements
922
-
923
- = 2.3.7 =
924
- Added support for ad labels;
925
- Blocked search indexing while debugging;
926
- Close button setting moved to tab Display (Pro only);
927
- Few minor bug fixes, cosmetic changes and code improvements;
928
-
929
- = 2.3.6 =
930
- Added widget for debugging tools;
931
- Fix for AdSense ad overlays not displayed with some themes;
932
- Few minor bug fixes, cosmetic changes and code improvements;
933
-
934
- = 2.3.5 =
935
- Added display of header and footer code in Label blocks debugging function;
936
- Added AdSense ad overlays in Label blocks debugging function (experimental);
937
- Fixed bug for removed square brackets in HTML element selectors;
938
- Fixed preview of AdSense ad units;
939
- Few minor bug fixes
940
-
941
- = 2.3.4 =
942
- Added support for author:author-username items in taxonomy list;
943
- Fixed errors when downgrading from Pro;
944
- Few minor bug fixes
945
-
946
- = 2.3.3 =
947
- Added list editors;
948
- Added Label blocks debugging function for AdSense Auto ads
949
-
950
- = 2.3.2 =
951
- Added AdSense code generator for ad sizes using CSS media queries;
952
- Fix for slow updates caused by changed user agent (Pro only, credits Olivier Langlois);
953
- Fix for client-side insertion of non-English characters before/after HTML element
954
-
955
- = 2.3.1 =
956
- Added support for server-side insertion before/after any HTML element;
957
- Few minor bug fixes
958
-
959
- = 2.3.0 =
960
- Added support for client-side insertion before/after any HTML element;
961
- Inplemented AdSense integration;
962
- Added option to define close button position;
963
- Fix for code generator import and code preview error with non ASCII characters;
964
- Fix for post/page exceptions and page types not processed in the header;
965
- Fix for close button in preview window;
966
- Fix for errors when rearranging blocks;
967
- Fix for errors when importing code;
968
- Few minor bug fixes, cosmetic changes and code improvements;
969
 
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4
5
  Tags: ads, adsense, header footer code, ad management, sticky fixed widgets, advanced geo targeting ads, amp adverts ad rotation, advertising manager, amazon banners ad injection, ad blocking detection, PHP Javascript HTML insertion, custom fields posts
6
  Requires at least: 4.0
7
+ Tested up to: 5.0
8
  Requires PHP: 5.6
9
+ Stable tag: 2.4.1
10
  License: GPLv3
11
 
12
  Insert and manage ads: Amazon, Google AdSense ads, banner rotation, sticky widget ads, AMP, PHP, HTML, CSS, Javascript, tracking, footer, header code
68
  * Insert ads between excerpts on blog pages
69
  * Insert ads between comments
70
  * Insert ads at custom hook positions (`do_action ()` WP function)
71
+ * Insert ads before or after any HTML element using CSS selectors
72
  * Avoid inserting ads near images or headers (AdSense TOS)
73
  * Disable ads on individual posts or pages
74
  * Insert header (`<head>` section) and footer code
96
  * Easy copying and pasting ads or settings using internal clipboard
97
  * Simple troubleshooting with many debugging functions
98
  * Function to visualize inserted code blocks and ads
99
+ * Function to visualize AdSense ads with ad names and IDs
100
  * Function to visualize available insertion positions
101
  * Function to visualize HTML tags
102
  * You name it :)
135
  * Ad impression and click statistics (works also with `<iframe>` Javascript ads like Google AdSense)
136
  * External tracking via Google Analytics or Matomo (Piwik)
137
  * A/B testing - discover ads and settings that perform best
138
+ * Lazy loading ads (works with AdSense ads)
139
  * [Sticky ads](https://adinserter.pro/documentation/alignments-and-styles#sticky-ads) with optional close button
140
  * Sticky sidebar ads (stick to the screen or to the content)
141
  * Floating slide-in banner ads
152
  * No ads on the settings page
153
  * Support via email
154
 
155
+ Run a WordPress related blog? Have experience with AdSense ads? Interested in reviewing Ad Inserter Pro? [Introduce yourself](https://adinserter.pro/contact).
156
 
157
+ Ad Inserter WordPress plugin is an advanced advertising manager for all kind of ads - it has many features and options to automate placing ads in order to optimally monetize your website on desktop, tablet and phone displays. It provides many simple ways to insert any kind of ads, Javascript, HTML, PHP or advert code anywhere on the page. For best placement of ads please read the user manual to get the most of the plugin.
158
 
159
+ Check [Ad Inserter documentation pages](https://adinserter.pro/documentation) for detailed description of all the features and some [common settings](https://adinserter.pro/documentation/common-settings) for quick start
160
 
161
  You can also use shortcodes from other plugins (for example, to insert ads from other ad plugins like AdRotate, Advanced Ads, Quick Adsense, AdSense Plugin WP QUADS, Insert Post Ads).
162
 
201
 
202
  **Quick Start**
203
 
204
+ To become familiar with the plugin check [Quick Start](https://adinserter.pro/documentation/quick-start) to display ads on your website.
205
 
206
+ To learn how to configure the most advanced WordPress AdSense plugin check documentation for [AdSense ads](https://adinserter.pro/documentation/adsense-ads): AdSense ad units, AdSense Auto ads, AdSense in-feed ads, AdSense in-article ads, AdSense AMP ads,...
207
+
208
+ **Main AdSense Features**
209
+
210
+ * Get code for AdSense ads directly from your [AdSense account](https://adinserter.pro/documentation/adsense-ads#integration)
211
+ * Create code for AdSense AMP ads from normal AdSense ad code
212
+ * Create responsive AdSense code from fixed size AdSense ads
213
+ * Create responsive AdSense code with [fixed ad sizes for differrent devices](https://adinserter.pro/documentation/adsense-ads#responsive)
214
+ * Optionally limit insertion to 3 AdSense ads per page
215
+ * Disable insertion of AdSense ads on Error 404 pages
216
+ * Insert AdSense In-feed or In-article ads between posts or comments
217
+ * Debugging function to label AdSense ad blocks to mark [blank AdSense ads](https://adinserter.pro/documentation/adsense-ads#ads-not-displayed)
218
 
219
  Few typical settings are described on the <a href="https://adinserter.pro/documentation/common-settings" target="_blank">Common Settings</a> page. Please make sure you have also read <a href="https://adinserter.pro/documentation/plugin-installation">plugin installation</a> documentation. For more detailed instructions please read <a href="https://adinserter.pro/documentation" target="_blank">Ad Inserter documentation pages</a>.
220
 
237
 
238
  **Please support plugin development**
239
 
240
+ If you are using Ad Inserter and you like it, then please write about it and spread the word on the <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post">review page</a>.
241
 
242
  Positive reviews are a great way to show your appreciation for my work. Besides being an incredible boost to my morale, they are also a great incentive to fix any bug found in the software and to add new features for better monetization of your website.
243
 
244
  Support the advancement of this plugin:
245
 
246
+ * Write a short <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post">review</a>
247
  * <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4">Donate</a> if Ad Inserter helps you to make money with ads
248
  * Buy license for [Ad Inserter Pro](https://adinserter.pro/) - Top WordPress plugin for ads
249
 
250
  == Installation ==
251
 
252
+ [Ad Inserter installation](https://adinserter.pro/documentation/plugin-installation)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
 
255
  **Online Documentation**
278
  4. Set automatic insertion option (for example: Before Post)
279
  5. Enable at least one page type (for example: Posts, some insertion options don't work on all page types)
280
  6. Save settings
281
+ 7. Check also [common Ad Inserter settings](https://adinserter.pro/documentation/common-settings)
282
  8. Check inserted code on the posts
283
+ 9. Ads are not showing? Check [Blank AdSense ads](https://adinserter.pro/documentation/adsense-ads#ads-not-displayed) and [troubleshooting guide](https://adinserter.pro/documentation/troubleshooting#ads-not-displayed) to find out what to check.
284
 
285
+ = Settings for ads ... =
286
+
287
+ Check <a href="https://adinserter.pro/documentation/common-settings" target="_blank">common Ad Inserter settings</a>
288
 
289
  = Does Ad Inserter insert any internal ads? =
290
 
302
 
303
  You are probably using code for [AdSense Auto ads](https://adinserter.pro/documentation/adsense-ads#auto-ads).
304
 
305
+ AdSense Auto ads (known also as AdSense 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.
306
+ AdSense 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.
307
 
308
+ AdSense 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/documentation/adsense-ads#ad-unit) and specifying exact locations where the code should be inserted.
309
 
310
  = I have installed code for AdSense ads but the ad blocks are blank. =
311
 
371
  * CSS mode - This mode is the best approach but may not work with all themes. CSS mode works by changing sidebar CSS to `position: sticky`. This works with most themes but not all. If your widgets and sidebar aren't sticking as expected you can use **JavaScript mode** described below.
372
  * JavaScript mode - This mode should work with practically all themes but may reload ads on page load when sticky sidebar is initialized.
373
 
374
+
375
+ = What is plugin usage tracking? =
376
 
377
  When enabled, the information regarding WordPress environment and Ad Inserter usage will be collected and sent to plugin developers (once per month and on events like plugin activation/deactivation).
378
 
379
  This is completely optional and can be disabled at any time. So if you have opted in (by clicking Allow when asked for permission) and now you would like to disable tracking, you should go to tab &#9881; / tab General, select **Disable** for Plugin usage tracking and save settings.
380
 
381
+ If this setting is not available then you have not selected any option yet - **tracking is disabled unless explicitly enabled** by clicking Allow when asked for permission (or when this setting is set to Enable).
382
 
383
  What data is collected: Ad Inserter version, activation status, number of active blocks, date of installation, date of last saved settings, status of review notice and remote debugging, block class name, location, website url and name, WordPress version, language, text direction, charset, number of posts, active theme and version, list of installed plugins, PHP version, server name, IP address (used to determine country), site count for multisite installations, deactivation reasons and details (if provided).
384
 
390
 
391
  **Your decision will be respected.**
392
 
393
+
394
  = Settings for contextual Amazon Native Shopping Ads =
395
 
396
  * Automatic Insertion: After Content
422
  You can also try with `[adinserter data='tag']', `[adinserter data='short-title']`, `[adinserter data='category']` or `[adinserter data='short-category']`. For more options check <a href="http://adinserter.pro/documentation#code-block-options" target="_blank">Ad Inserter documentation page</a>.
423
 
424
 
 
 
 
 
 
 
 
 
 
 
 
425
  = I wish to show ads side by side but not in the same block. How do I do this? =
426
 
427
  Configure block 1 and 2 with ads using:
432
 
433
  Configure block 3 with
434
 
435
+ `[adinserter code="1" ignore="page-type"]
436
+ [adinserter code="2" ignore="page-type"]`
437
 
438
+ and use block 3 to insert ads.
439
 
440
 
441
  = I use After Content insertion position but the ads are inserted after the stuff provided by other plugins. How can I insert ads directly after post content?
445
  Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab &#9881; / tab General).
446
 
447
 
448
+ = How can I add some title or label (e.g. Advertisements) above AdSense ads? =
449
 
450
  If this is a sidebar widget then you can simply name the widget.
451
 
461
 
462
  AD_CODE`
463
 
464
+ Ad lables can be inserted only above ads (blocks) inserted by Ad Inserter - AdSense Auto ads are automatically inseted by AdSense Auto ads code.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
 
466
  = How can place ads below Read More tag? =
467
 
474
  Check source code of your website for proper "read more" tag.
475
 
476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  = How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left? =
478
 
479
  Set Block Alignment and Style to "No Wrapping" and create manual wrapping around both ads separated with [ADINSERTER ROTATE]:
488
  AD CODE RIGHT
489
  </div>`
490
 
491
+ Please note that responsive AdSense ads can not work with floating alignments (ad container width is not known) - either use AdSense code with fixed ad sizes or don't use floating alignment.
492
 
493
  == Screenshots ==
494
 
513
 
514
  == Changelog ==
515
 
516
+ = 2.4.1 =
517
+ - Added option to insert into HTML element (prepend, append, replace content)
518
+ - Added option to remove HTML element
519
+ - Added option to not show deactivation feedback form
520
+ - Added support for negative relative positions for paragraph counting
521
+ - Few minor bug fixes, cosmetic changes and code improvements
522
+
523
  = 2.4.0 =
524
  - Improved code for client-side insertion
525
  - Added support for usage tracking
555
  - Added shortcode for ad blocking detection action
556
  - Few minor bug fixes, cosmetic changes and code improvements
557
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
 
559
  = Earlier versions =
560
 
562
 
563
  == Upgrade Notice ==
564
 
565
+ = 2.4.1 =
566
+ Added option to insert into HTML element (prepend, append, replace content);
567
+ Added option to remove HTML element;
568
+ Added option to not show deactivation feedback form;
569
+ Added support for negative relative positions for paragraph counting;
570
+ Few minor bug fixes, cosmetic changes and code improvements
571
+
572
  = 2.4.0 =
573
  Improved code for client-side insertion;
574
  Added support for usage tracking;
604
  Added shortcode for ad blocking detection action;
605
  Few minor bug fixes, cosmetic changes and code improvements
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
 
settings.php CHANGED
@@ -111,6 +111,7 @@ function generate_settings_form (){
111
  }
112
  }
113
 
 
114
  if ($rating_string = get_transient (AI_TRANSIENT_RATING)) {
115
  if ($rating_string < 1 && $rating_string > 5) $rating_string = '';
116
  }
@@ -146,10 +147,10 @@ function generate_settings_form (){
146
  </div>
147
  <div id="header-buttons">
148
  <img id="ai-loading" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>loading.gif" style="width: 24px; height: 24px; vertical-align: middle; margin-right: 20px; display: none;" />
149
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://adinserter.pro/documentation')" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button>
150
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter')" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button>
151
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
152
- <!-- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>-->
153
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://adinserter.pro/')" title="Need more code blocks, sticky ads, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go&nbsp;Pro</button>
154
  <button id="ai-list" type="button" class="ai-top-button" style="width: 62px; display: none; margin-right: 0px; outline-color: transparent;" title="Show list of all code blocks"><span>Blocks</span></button>
155
  </div>
@@ -505,10 +506,12 @@ function generate_settings_form (){
505
 
506
  $html_settings =
507
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT ||
508
- $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT;
 
509
 
510
  $html_element_insertion = $obj->get_html_element_insertion ();
511
  $server_side_insertion = $obj->get_server_side_insertion ();
 
512
 
513
  $filter_type = $obj->get_filter_type();
514
 
@@ -925,6 +928,7 @@ function generate_settings_form (){
925
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-comments" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_COMMENTS; ?>" data-title="<?php echo AI_TEXT_AFTER_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_COMMENTS; ?></option>
926
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-footer" value="<?php echo AI_AUTOMATIC_INSERTION_FOOTER; ?>" data-title="<?php echo AI_TEXT_FOOTER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_FOOTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FOOTER; ?></option>
927
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-html" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_BEFORE_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_HTML_ELEMENT; ?></option>
 
928
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-html" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?></option>
929
  <?php foreach ($ai_custom_hooks as $hook_index => $custom_hook) { ?>
930
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-custom-hook" value="<?php echo AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1; ?>" data-title="<?php echo $custom_hook ['name']; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo $custom_hook ['name']; ?></option>
@@ -1096,6 +1100,16 @@ function generate_settings_form (){
1096
  style="width: 100%;"
1097
  maxlength="80" />
1098
  </span>
 
 
 
 
 
 
 
 
 
 
1099
  </div>
1100
  <div class="max-input" style="margin: 8px 0 0 0;">
1101
  <span style="display: table-cell; width: 1px; white-space: nowrap;">
@@ -1565,8 +1579,8 @@ function generate_settings_form (){
1565
  <li id="ai-server-side-detection<?php echo $block; ?>"><a href="#tab-server-side-<?php echo $block; ?>"><span style="<?php echo $server_side_style; ?>">Server-side device detection</span></a></li>
1566
  </ul>
1567
 
1568
- <div id="tab-client-side-<?php echo $block; ?>" class="rounded">
1569
- <div style="float: left; margin-top: 0px;">
1570
  <input type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1571
  <input id="client-side-detection-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
1572
  <label for="client-side-detection-<?php echo $block; ?>" style="vertical-align: baseline;">Use client-side detection to </label>
@@ -1579,7 +1593,7 @@ function generate_settings_form (){
1579
  <label style="vertical-align: baseline;"> only on</label>
1580
  </div>
1581
 
1582
- <div style="float: left; margin: -5px 0 -2px 0;">
1583
  <?php
1584
 
1585
  $viewports = array ();
@@ -1603,7 +1617,7 @@ function generate_settings_form (){
1603
  <?php
1604
  }
1605
  ?>
1606
- <td style='padding: 2px 0 0 20px;'>
1607
  <input type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1608
  <input type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $block; ?>" id="viewport-<?php echo $viewport, "-", $block; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
1609
  <label for="viewport-<?php echo $viewport, "-", $block; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
@@ -2059,7 +2073,7 @@ function generate_settings_form (){
2059
  Plugin usage tracking
2060
  </td>
2061
  <td>
2062
- <select id="plugin-usage-tracking" name="plugin-usage-tracking" default="#" title="Enable tracking of <?php echo AD_INSERTER_NAME; ?> usage and help us to make improvements to the plugin. Only information regarding the WordPress environment and <?php echo AD_INSERTER_NAME; ?> usage is recorded.">
2063
  <option value="<?php echo AI_PLUGIN_TRACKING_DISABLED; ?>" <?php echo $plugin_tracking == AI_PLUGIN_TRACKING_DISABLED ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
2064
  <option value="<?php echo AI_PLUGIN_TRACKING_ENABLED; ?>" <?php echo $plugin_tracking == AI_PLUGIN_TRACKING_ENABLED ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ENABLED; ?></option>
2065
  </select>
@@ -2521,7 +2535,7 @@ function generate_settings_form (){
2521
  Used blocks
2522
  </td>
2523
  <td>
2524
- <?php if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) echo count ($used_blocks), ' (', implode (', ', array_slice ($used_blocks, 0, 24)), count ($used_blocks) > 24 ? ',...' : '', ')'; ?>
2525
  </td>
2526
  </tr>
2527
  <?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
@@ -2610,22 +2624,22 @@ function generate_settings_form (){
2610
  sidebar_pro ();
2611
  break;
2612
  case 1:
2613
- sidebar_support_plugin ();
2614
  sidebar_help ();
2615
  sidebar_pro ();
2616
  break;
2617
  case 2:
2618
- sidebar_support_plugin ();
2619
  sidebar_help ();
2620
  sidebar_pro ();
2621
  break;
2622
  case 3:
2623
- sidebar_support_plugin ();
2624
  sidebar_help ();
2625
  sidebar_pro ();
2626
  break;
2627
  case 4:
2628
- sidebar_support_plugin ();
2629
  sidebar_support_review ();
2630
  sidebar_help ();
2631
  sidebar_pro ();
@@ -3476,14 +3490,39 @@ function sidebar_addense_alternative () { ?>
3476
  <?php
3477
  }
3478
 
 
3479
  function sidebar_support_review () {
 
 
3480
  if (!wp_is_mobile () && is_super_admin ()) {
3481
  ?>
3482
  <div class="ai-form header no-select rounded" style="position: relative; text-align: justify;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3483
  You've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.
3484
- Positive <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">reviews</a> are a great way to show your appreciation for my work.
3485
  Besides being an incredible boost to my morale, they are also a great incentive to fix bugs and to add new features for better monetization of your website.
3486
- Thank you, Igor <img draggable="false" class="emoji" alt="happy" src="https://s.w.org/images/core/emoji/2.3/svg/1f642.svg" style="margin-left: 5px!important;">
3487
  </div>
3488
 
3489
  <?php
@@ -3493,11 +3532,10 @@ function sidebar_support_review () {
3493
  function sidebar_support_plugin () {
3494
  global $rating_value, $rating_string, $rating_css;
3495
  ?>
3496
-
3497
  <div class="ai-form header rounded no-select">
3498
  <div style="float: left;">
3499
  <h2 style="display: inline-block; margin: 7px 0;">Support plugin development</h2>
3500
- <button type="button" class="ai-top-button" style="display: none; margin: -5px 0px 0px 15px; min-width; 62px; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
3501
  </div>
3502
 
3503
  <div style="float: right;">
@@ -3513,7 +3551,7 @@ function sidebar_support_plugin () {
3513
 
3514
  <div id="ai-rating-bar" class="header" style="float: right; cursor: pointer; margin: 3px 0 0 0; width: 148px; display: none;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">
3515
  <div class="header" style="background: #ccc;" title="Average rating of the plugin - Thank you!">
3516
- <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">
3517
  <div id="rating-value" style="text-align: center; font-size: 11px; line-height: 12px; border-radius: 2px; background: #fddf87; height: 100%; <?php echo $rating_css; ?>"><span style=""><?php echo $rating_string; ?></span></div>
3518
  </a>
3519
  </div>
111
  }
112
  }
113
 
114
+ $rating_string = '';
115
  if ($rating_string = get_transient (AI_TRANSIENT_RATING)) {
116
  if ($rating_string < 1 && $rating_string > 5) $rating_string = '';
117
  }
147
  </div>
148
  <div id="header-buttons">
149
  <img id="ai-loading" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>loading.gif" style="width: 24px; height: 24px; vertical-align: middle; margin-right: 20px; display: none;" />
150
+ <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 104px; outline-color: transparent;" onclick="window.open('https://adinserter.pro/documentation')" title="<?php echo AD_INSERTER_NAME; ?> Online Documentation">Documentation</button>
151
+ <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 104px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter')" title="<?php echo AD_INSERTER_NAME; ?> support forum - if you have issues using the plugin go here, check existing threads and open a new one if you don't find answers for your issue.">Support Forum</button>
152
+ <!-- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>-->
153
+ <!-- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>-->
154
  <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://adinserter.pro/')" title="Need more code blocks, sticky ads, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go&nbsp;Pro</button>
155
  <button id="ai-list" type="button" class="ai-top-button" style="width: 62px; display: none; margin-right: 0px; outline-color: transparent;" title="Show list of all code blocks"><span>Blocks</span></button>
156
  </div>
506
 
507
  $html_settings =
508
  $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT ||
509
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT ||
510
+ $automatic_insertion == AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT;
511
 
512
  $html_element_insertion = $obj->get_html_element_insertion ();
513
  $server_side_insertion = $obj->get_server_side_insertion ();
514
+ $inside_element = $obj->get_inside_element ();
515
 
516
  $filter_type = $obj->get_filter_type();
517
 
928
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-comments" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_COMMENTS; ?>" data-title="<?php echo AI_TEXT_AFTER_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_COMMENTS; ?></option>
929
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-footer" value="<?php echo AI_AUTOMATIC_INSERTION_FOOTER; ?>" data-title="<?php echo AI_TEXT_FOOTER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_FOOTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FOOTER; ?></option>
930
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-html" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_BEFORE_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_HTML_ELEMENT; ?></option>
931
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-html" value="<?php echo AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INSIDE_HTML_ELEMENT; ?></option>
932
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-html" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?></option>
933
  <?php foreach ($ai_custom_hooks as $hook_index => $custom_hook) { ?>
934
  <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-custom-hook" value="<?php echo AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1; ?>" data-title="<?php echo $custom_hook ['name']; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo $custom_hook ['name']; ?></option>
1100
  style="width: 100%;"
1101
  maxlength="80" />
1102
  </span>
1103
+ <span id="inside-element-<?php echo $block; ?>" style="display: table-cell; white-space: nowrap; width: 20%;<?php if ($automatic_insertion != AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT) echo ' display: none;'; ?>">
1104
+ &nbsp;
1105
+ Action
1106
+ <select style="margin-bottom: 3px;" name="<?php echo AI_OPTION_INSIDE_ELEMENT, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_inside_element (); ?>">
1107
+ <option value="<?php echo AI_HTML_PREPEND_CONTENT; ?>" <?php echo ($inside_element == AI_HTML_PREPEND_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_PREPEND_CONTENT; ?></option>
1108
+ <option value="<?php echo AI_HTML_APPEND_CONTENT; ?>" <?php echo ($inside_element == AI_HTML_APPEND_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_APPEND_CONTENT; ?></option>
1109
+ <option value="<?php echo AI_HTML_REPLACE_CONTENT; ?>" <?php echo ($inside_element == AI_HTML_REPLACE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_REPLACE_CONTENT; ?></option>
1110
+ <option value="<?php echo AI_HTML_REPLACE_ELEMENT; ?>" <?php echo ($inside_element == AI_HTML_REPLACE_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_REPLACE_ELEMENT; ?></option>
1111
+ </select>
1112
+ </span>
1113
  </div>
1114
  <div class="max-input" style="margin: 8px 0 0 0;">
1115
  <span style="display: table-cell; width: 1px; white-space: nowrap;">
1579
  <li id="ai-server-side-detection<?php echo $block; ?>"><a href="#tab-server-side-<?php echo $block; ?>"><span style="<?php echo $server_side_style; ?>">Server-side device detection</span></a></li>
1580
  </ul>
1581
 
1582
+ <div id="tab-client-side-<?php echo $block; ?>" class="rounded" style="padding-top: 0;">
1583
+ <div style="float: left; margin-top: 10px;">
1584
  <input type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1585
  <input id="client-side-detection-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
1586
  <label for="client-side-detection-<?php echo $block; ?>" style="vertical-align: baseline;">Use client-side detection to </label>
1593
  <label style="vertical-align: baseline;"> only on</label>
1594
  </div>
1595
 
1596
+ <div style="float: left; margin: 7px 0 -2px 0;">
1597
  <?php
1598
 
1599
  $viewports = array ();
1617
  <?php
1618
  }
1619
  ?>
1620
+ <td style='padding: 0 0 0 20px;'>
1621
  <input type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1622
  <input type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $block; ?>" id="viewport-<?php echo $viewport, "-", $block; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
1623
  <label for="viewport-<?php echo $viewport, "-", $block; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
2073
  Plugin usage tracking
2074
  </td>
2075
  <td>
2076
+ <select id="plugin-usage-tracking" name="plugin-usage-tracking" default="#" title="Enable tracking of <?php echo AD_INSERTER_NAME; ?> usage and help us to make improvements to the plugin. Only information regarding the WordPress environment and <?php echo AD_INSERTER_NAME; ?> usage is recorded (once per month and on events like plugin activation/deactivation).">
2077
  <option value="<?php echo AI_PLUGIN_TRACKING_DISABLED; ?>" <?php echo $plugin_tracking == AI_PLUGIN_TRACKING_DISABLED ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
2078
  <option value="<?php echo AI_PLUGIN_TRACKING_ENABLED; ?>" <?php echo $plugin_tracking == AI_PLUGIN_TRACKING_ENABLED ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ENABLED; ?></option>
2079
  </select>
2535
  Used blocks
2536
  </td>
2537
  <td>
2538
+ <?php if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) echo count ($used_blocks), ' (', implode (', ', array_slice ($used_blocks, 0, 22)), count ($used_blocks) > 22 ? ',...' : '', ')'; ?>
2539
  </td>
2540
  </tr>
2541
  <?php if (function_exists ('ai_system_debugging')) ai_system_debugging (); ?>
2624
  sidebar_pro ();
2625
  break;
2626
  case 1:
2627
+ // sidebar_support_plugin ();
2628
  sidebar_help ();
2629
  sidebar_pro ();
2630
  break;
2631
  case 2:
2632
+ // sidebar_support_plugin ();
2633
  sidebar_help ();
2634
  sidebar_pro ();
2635
  break;
2636
  case 3:
2637
+ // sidebar_support_plugin ();
2638
  sidebar_help ();
2639
  sidebar_pro ();
2640
  break;
2641
  case 4:
2642
+ // sidebar_support_plugin ();
2643
  sidebar_support_review ();
2644
  sidebar_help ();
2645
  sidebar_pro ();
3490
  <?php
3491
  }
3492
 
3493
+
3494
  function sidebar_support_review () {
3495
+ global $rating_value, $rating_string, $rating_css;
3496
+
3497
  if (!wp_is_mobile () && is_super_admin ()) {
3498
  ?>
3499
  <div class="ai-form header no-select rounded" style="position: relative; text-align: justify;">
3500
+
3501
+ <div style="float: left;">
3502
+ <h2 style="display: inline-block; margin: 7px 0;">Support plugin development</h2>
3503
+ <button type="button" class="ai-top-button" style="display: none; margin: -5px 0px 0px 15px; min-width; 124px; width: 124px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review <?php echo AD_INSERTER_NAME; ?></button>
3504
+ <button type="button" class="ai-top-button" style="display: none; margin: -5px 0px 0px 15px; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
3505
+ </div>
3506
+
3507
+ <div style="float: right; margin: 7px 10px 0 0;">
3508
+ <div id="ai-stars" style="float: right; margin: 0 0 -3px 0; cursor: pointer; font-size: 11px;"><span><?php //echo $rating_value; ?></span><img id="ai-stars-img" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>stars.png" style="margin: 0 0 -3px 10px;"/></div>
3509
+
3510
+ <div id="ai-rating-bar" class="header" style="float: right; cursor: pointer; margin: 3px 0 0 0; width: 148px; display: none;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">
3511
+ <div class="header" style="background: #ccc;" title="Average rating of the plugin &mdash; Thank you!">
3512
+ <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">
3513
+ <div id="rating-value" style="text-align: center; font-size: 11px; line-height: 12px; border-radius: 2px; background: #fddf87; height: 100%; <?php echo $rating_css; ?>"><span style=""><?php echo $rating_string; ?></span></div>
3514
+ </a>
3515
+ </div>
3516
+ </div>
3517
+ </div>
3518
+
3519
+ <div style="clear: both;"></div>
3520
+ <hr />
3521
+
3522
  You've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.
3523
+ Positive <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">reviews</a> are a great way to show your appreciation for my work.
3524
  Besides being an incredible boost to my morale, they are also a great incentive to fix bugs and to add new features for better monetization of your website.
3525
+ <img draggable="false" class="emoji" alt="happy" src="https://s.w.org/images/core/emoji/2.3/svg/1f642.svg" style="margin-left: 5px!important;"> Thank you! Igor
3526
  </div>
3527
 
3528
  <?php
3532
  function sidebar_support_plugin () {
3533
  global $rating_value, $rating_string, $rating_css;
3534
  ?>
 
3535
  <div class="ai-form header rounded no-select">
3536
  <div style="float: left;">
3537
  <h2 style="display: inline-block; margin: 7px 0;">Support plugin development</h2>
3538
+ <button type="button" class="ai-top-button" style="display: none; margin: -5px 0px 0px 15px; min-width; 62px; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
3539
  </div>
3540
 
3541
  <div style="float: right;">
3551
 
3552
  <div id="ai-rating-bar" class="header" style="float: right; cursor: pointer; margin: 3px 0 0 0; width: 148px; display: none;" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">
3553
  <div class="header" style="background: #ccc;" title="Average rating of the plugin - Thank you!">
3554
+ <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/#new-post" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">
3555
  <div id="rating-value" style="text-align: center; font-size: 11px; line-height: 12px; border-radius: 2px; background: #fddf87; height: 100%; <?php echo $rating_css; ?>"><span style=""><?php echo $rating_string; ?></span></div>
3556
  </a>
3557
  </div>