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

Version Description

  • Fix for duplicate amp-custom tag on AMP pages
Download this release

Release Info

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

Code changes from version 2.2.6 to 2.2.7

Files changed (6) hide show
  1. ad-inserter.php +29 -21
  2. constants.php +1 -1
  3. css/ad-inserter.css +1 -1
  4. js/ad-inserter.js +154 -4
  5. preview-adb.php +2 -1
  6. readme.txt +7 -1
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.2.6
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -12,6 +12,9 @@ Plugin URI: http://adinserter.pro/documentation
12
 
13
  Change Log
14
 
 
 
 
15
  Ad Inserter 2.2.6 - 2017-11-07
16
  - Fix for posts filter counter not counting
17
  - Added list with short overview of all code blocks
@@ -1251,12 +1254,16 @@ function ai_wp_hook () {
1251
  if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1252
  // AMP, Accelerated Mobile Pages
1253
  add_action ('amp_post_template_head', 'ai_amp_head_hook');
 
1254
 
1255
  // WP AMP Ninja
1256
  add_action ('wpamp_custom_script', 'ai_amp_head_hook');
 
 
1257
 
1258
  // WP AMP - Accelerated Mobile Pages for WordPress
1259
  add_action ('amphtml_template_head', 'ai_amp_head_hook');
 
1260
  } else
1261
  // WP
1262
  add_action ('wp_head', 'ai_wp_head_hook');
@@ -1464,20 +1471,6 @@ function add_head_inline_styles_and_scripts () {
1464
  }
1465
  }
1466
 
1467
- function add_amp_head_inline_styles_and_scripts () {
1468
- global $ai_wp_data;
1469
-
1470
- if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
1471
- echo "<style amp-custom>\n";
1472
-
1473
- if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) echo get_alignment_css ();
1474
-
1475
- if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
1476
-
1477
- echo "</style>\n";
1478
- }
1479
- }
1480
-
1481
  function ai_get_js ($js_name, $replace_js_data = true) {
1482
  global $ai_wp_data;
1483
 
@@ -2099,8 +2092,6 @@ function ai_amp_head_hook () {
2099
  $start_time = microtime (true);
2100
  }
2101
 
2102
- add_amp_head_inline_styles_and_scripts ();
2103
-
2104
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2105
 
2106
  $obj = $block_object [AI_HEADER_OPTION_NAME];
@@ -2157,6 +2148,17 @@ function ai_amp_head_hook () {
2157
  }
2158
  }
2159
 
 
 
 
 
 
 
 
 
 
 
 
2160
 
2161
  function ai_wp_footer_hook () {
2162
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
@@ -3377,11 +3379,12 @@ function ai_ajax_backend () {
3377
  urldecode ($_POST ["alignment"]),
3378
  wp_unslash (urldecode ($_POST ["alignment_css"])),
3379
  wp_unslash (urldecode ($_POST ["custom_css"])),
3380
- wp_unslash (urldecode ($_POST ["code"])),
3381
- urldecode ($_POST ["php"]) == 'true');
3382
  }
3383
  elseif ($block == 'adb') {
3384
- generate_code_preview_adb ($block);
 
3385
  }
3386
  }
3387
 
@@ -3904,7 +3907,12 @@ function ai_settings () {
3904
  foreach (array_keys ($ad->wp_options) as $key){
3905
  $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block;
3906
  if (isset ($_POST [$form_field_name])){
3907
- $ad->wp_options [$key] = filter_option ($key, $_POST [$form_field_name]);
 
 
 
 
 
3908
  // $block_settings ++;
3909
  }
3910
  }
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.2.7
5
  Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
12
 
13
  Change Log
14
 
15
+ Ad Inserter 2.2.7 - 2017-11-08
16
+ - Fix for duplicate amp-custom tag on AMP pages
17
+
18
  Ad Inserter 2.2.6 - 2017-11-07
19
  - Fix for posts filter counter not counting
20
  - Added list with short overview of all code blocks
1254
  if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1255
  // AMP, Accelerated Mobile Pages
1256
  add_action ('amp_post_template_head', 'ai_amp_head_hook');
1257
+ add_action ('amp_post_template_css', 'ai_amp_css_hook');
1258
 
1259
  // WP AMP Ninja
1260
  add_action ('wpamp_custom_script', 'ai_amp_head_hook');
1261
+ // No usable hook for custom CSS
1262
+ // add_action ('wpamp_custom_style', 'ai_amp_css_hook');
1263
 
1264
  // WP AMP - Accelerated Mobile Pages for WordPress
1265
  add_action ('amphtml_template_head', 'ai_amp_head_hook');
1266
+ add_action ('amphtml_template_css', 'ai_amp_css_hook');
1267
  } else
1268
  // WP
1269
  add_action ('wp_head', 'ai_wp_head_hook');
1471
  }
1472
  }
1473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1474
  function ai_get_js ($js_name, $replace_js_data = true) {
1475
  global $ai_wp_data;
1476
 
2092
  $start_time = microtime (true);
2093
  }
2094
 
 
 
2095
  $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2096
 
2097
  $obj = $block_object [AI_HEADER_OPTION_NAME];
2148
  }
2149
  }
2150
 
2151
+ function ai_amp_css_hook () {
2152
+ global $ai_wp_data;
2153
+
2154
+ if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
2155
+
2156
+ if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) echo get_alignment_css ();
2157
+
2158
+ if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
2159
+ }
2160
+ }
2161
+
2162
 
2163
  function ai_wp_footer_hook () {
2164
  global $block_object, $ai_wp_data, $ai_total_plugin_time;
3379
  urldecode ($_POST ["alignment"]),
3380
  wp_unslash (urldecode ($_POST ["alignment_css"])),
3381
  wp_unslash (urldecode ($_POST ["custom_css"])),
3382
+ wp_unslash (urldecode (base64_decode ($_POST ["code"]))),
3383
+ urldecode ($_POST ["php"]) == 1);
3384
  }
3385
  elseif ($block == 'adb') {
3386
+ generate_code_preview_adb (wp_unslash (urldecode ($_POST ["code"])), urldecode ($_POST ["php"]) == 1);
3387
+ // generate_code_preview_adb (wp_unslash (urldecode (base64_decode ($_POST ["code"]))), urldecode ($_POST ["php"]) == 1);
3388
  }
3389
  }
3390
 
3907
  foreach (array_keys ($ad->wp_options) as $key){
3908
  $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block;
3909
  if (isset ($_POST [$form_field_name])){
3910
+
3911
+ // if ($key == AI_OPTION_CODE)
3912
+ // $ad->wp_options [$key] = filter_option ($key, base64_decode ($_POST [$form_field_name])); else
3913
+
3914
+ $ad->wp_options [$key] = filter_option ($key, $_POST [$form_field_name]);
3915
+
3916
  // $block_settings ++;
3917
  }
3918
  }
constants.php CHANGED
@@ -19,7 +19,7 @@ if (!defined( 'AD_INSERTER_NAME'))
19
  define ('AD_INSERTER_NAME', 'Ad Inserter');
20
 
21
  if (!defined( 'AD_INSERTER_VERSION'))
22
- define ('AD_INSERTER_VERSION', '2.2.6');
23
 
24
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
25
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
19
  define ('AD_INSERTER_NAME', 'Ad Inserter');
20
 
21
  if (!defined( 'AD_INSERTER_VERSION'))
22
+ define ('AD_INSERTER_VERSION', '2.2.7');
23
 
24
  if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
25
  define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
css/ad-inserter.css CHANGED
@@ -1,5 +1,5 @@
1
  #ai-data {
2
- font-family: "2.2.6"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
1
  #ai-data {
2
+ font-family: "2.2.7"; /* Used for version number of the file */
3
  }
4
 
5
  #blocked-warning {
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.2.6";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -64,6 +64,149 @@ var AI_ADSENSE_IN_FEED = 3;
64
  var AI_ADSENSE_MATCHED_CONTENT = 4;
65
 
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  var shSettings = {
68
  "tab_size":"4",
69
  "use_soft_tabs":"1",
@@ -109,6 +252,7 @@ function SyntaxHighlight (id, block, settings) {
109
  if (textarea.val () == "") {
110
  textarea.removeAttr ("name");
111
  }
 
112
 
113
  jQuery("#ai-active-tab").attr ("value", '[' + active_tab + ',' + active_tab_0 + ']');
114
  });
@@ -1153,12 +1297,16 @@ jQuery(document).ready(function($) {
1153
 
1154
  $(this).blur ();
1155
 
 
 
 
 
1156
  var window_width = 820;
1157
  var window_height = 870;
1158
  var window_left = 120;
1159
  var window_top = (screen.height / 2) - (870 / 2);
1160
  var nonce = $(this).attr ('nonce');
1161
- var param = {'action': 'ai_ajax_backend', 'preview': 'adb', 'ai_check': nonce};
1162
  window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
1163
  });
1164
  }
@@ -1544,8 +1692,8 @@ jQuery(document).ready(function($) {
1544
 
1545
  var name = $("#name-label-"+block).text ();
1546
 
1547
- var code = get_editor_text (block);
1548
- var php = $("input#process-php-"+block).is(":checked");
1549
 
1550
  var window_width = 820;
1551
  var window_height = 820;
@@ -2158,3 +2306,5 @@ jQuery(document).ready(function($) {
2158
  console.log ("main time: " + ((current_time - current_time_ready) / 1000).toFixed (3));
2159
  }
2160
  });
 
 
1
+ var javascript_version = "2.2.7";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
64
  var AI_ADSENSE_MATCHED_CONTENT = 4;
65
 
66
 
67
+ /**
68
+ * jQuery BASE64 functions
69
+ *
70
+ * <code>
71
+ * Encodes the given data with base64.
72
+ * String $.base64Encode ( String str )
73
+ * <br />
74
+ * Decodes a base64 encoded data.
75
+ * String $.base64Decode ( String str )
76
+ * </code>
77
+ *
78
+ * Encodes and Decodes the given data in base64.
79
+ * This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
80
+ * Base64-encoded data takes about 33% more space than the original data.
81
+ * This javascript code is used to encode / decode data using base64 (this encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean). Script is fully compatible with UTF-8 encoding. You can use base64 encoded data as simple encryption mechanism.
82
+ * If you plan using UTF-8 encoding in your project don't forget to set the page encoding to UTF-8 (Content-Type meta tag).
83
+ * This function orginally get from the WebToolkit and rewrite for using as the jQuery plugin.
84
+ *
85
+ * Example
86
+ * Code
87
+ * <code>
88
+ * $.base64Encode("I'm Persian.");
89
+ * </code>
90
+ * Result
91
+ * <code>
92
+ * "SSdtIFBlcnNpYW4u"
93
+ * </code>
94
+ * Code
95
+ * <code>
96
+ * $.base64Decode("SSdtIFBlcnNpYW4u");
97
+ * </code>
98
+ * Result
99
+ * <code>
100
+ * "I'm Persian."
101
+ * </code>
102
+ *
103
+ * @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
104
+ * @link http://www.semnanweb.com/jquery-plugin/base64.html (no longer available?)
105
+ * @link https://gist.github.com/gists/1602210
106
+ * @see http://www.webtoolkit.info/
107
+ * @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
108
+ * @param {jQuery} {base64Encode:function(input))
109
+ * @param {jQuery} {base64Decode:function(input))
110
+ * @return string
111
+ */
112
+
113
+ (function($){
114
+
115
+ var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
116
+
117
+ var uTF8Encode = function(string) {
118
+ string = string.replace(/\x0d\x0a/g, "\x0a");
119
+ var output = "";
120
+ for (var n = 0; n < string.length; n++) {
121
+ var c = string.charCodeAt(n);
122
+ if (c < 128) {
123
+ output += String.fromCharCode(c);
124
+ } else if ((c > 127) && (c < 2048)) {
125
+ output += String.fromCharCode((c >> 6) | 192);
126
+ output += String.fromCharCode((c & 63) | 128);
127
+ } else {
128
+ output += String.fromCharCode((c >> 12) | 224);
129
+ output += String.fromCharCode(((c >> 6) & 63) | 128);
130
+ output += String.fromCharCode((c & 63) | 128);
131
+ }
132
+ }
133
+ return output;
134
+ };
135
+
136
+ var uTF8Decode = function(input) {
137
+ var string = "";
138
+ var i = 0;
139
+ var c = c1 = c2 = 0;
140
+ while ( i < input.length ) {
141
+ c = input.charCodeAt(i);
142
+ if (c < 128) {
143
+ string += String.fromCharCode(c);
144
+ i++;
145
+ } else if ((c > 191) && (c < 224)) {
146
+ c2 = input.charCodeAt(i+1);
147
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
148
+ i += 2;
149
+ } else {
150
+ c2 = input.charCodeAt(i+1);
151
+ c3 = input.charCodeAt(i+2);
152
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
153
+ i += 3;
154
+ }
155
+ }
156
+ return string;
157
+ }
158
+
159
+ $.extend({
160
+ base64Encode: function(input) {
161
+ var output = "";
162
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
163
+ var i = 0;
164
+ input = uTF8Encode(input);
165
+ while (i < input.length) {
166
+ chr1 = input.charCodeAt(i++);
167
+ chr2 = input.charCodeAt(i++);
168
+ chr3 = input.charCodeAt(i++);
169
+ enc1 = chr1 >> 2;
170
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
171
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
172
+ enc4 = chr3 & 63;
173
+ if (isNaN(chr2)) {
174
+ enc3 = enc4 = 64;
175
+ } else if (isNaN(chr3)) {
176
+ enc4 = 64;
177
+ }
178
+ output = output + keyString.charAt(enc1) + keyString.charAt(enc2) + keyString.charAt(enc3) + keyString.charAt(enc4);
179
+ }
180
+ return output;
181
+ },
182
+ base64Decode: function(input) {
183
+ var output = "";
184
+ var chr1, chr2, chr3;
185
+ var enc1, enc2, enc3, enc4;
186
+ var i = 0;
187
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
188
+ while (i < input.length) {
189
+ enc1 = keyString.indexOf(input.charAt(i++));
190
+ enc2 = keyString.indexOf(input.charAt(i++));
191
+ enc3 = keyString.indexOf(input.charAt(i++));
192
+ enc4 = keyString.indexOf(input.charAt(i++));
193
+ chr1 = (enc1 << 2) | (enc2 >> 4);
194
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
195
+ chr3 = ((enc3 & 3) << 6) | enc4;
196
+ output = output + String.fromCharCode(chr1);
197
+ if (enc3 != 64) {
198
+ output = output + String.fromCharCode(chr2);
199
+ }
200
+ if (enc4 != 64) {
201
+ output = output + String.fromCharCode(chr3);
202
+ }
203
+ }
204
+ output = uTF8Decode(output);
205
+ return output;
206
+ }
207
+ });
208
+ })(jQuery);
209
+
210
  var shSettings = {
211
  "tab_size":"4",
212
  "use_soft_tabs":"1",
252
  if (textarea.val () == "") {
253
  textarea.removeAttr ("name");
254
  }
255
+ // else textarea.val (jQuery.base64Encode (textarea.val ()));
256
 
257
  jQuery("#ai-active-tab").attr ("value", '[' + active_tab + ',' + active_tab_0 + ']');
258
  });
1297
 
1298
  $(this).blur ();
1299
 
1300
+ var code = get_editor_text ('a');
1301
+ // var code = $.base64Encode (get_editor_text ('a'));
1302
+ var php = $("input#process-php-a").is(":checked") ? 1 : 0;
1303
+
1304
  var window_width = 820;
1305
  var window_height = 870;
1306
  var window_left = 120;
1307
  var window_top = (screen.height / 2) - (870 / 2);
1308
  var nonce = $(this).attr ('nonce');
1309
+ var param = {'action': 'ai_ajax_backend', 'preview': 'adb', 'ai_check': nonce, 'code': code, 'php': php};
1310
  window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
1311
  });
1312
  }
1692
 
1693
  var name = $("#name-label-"+block).text ();
1694
 
1695
+ var code = $.base64Encode (get_editor_text (block));
1696
+ var php = $("input#process-php-"+block).is(":checked") ? 1 : 0;
1697
 
1698
  var window_width = 820;
1699
  var window_height = 820;
2306
  console.log ("main time: " + ((current_time - current_time_ready) / 1000).toFixed (3));
2307
  }
2308
  });
2309
+
2310
+
preview-adb.php CHANGED
@@ -25,13 +25,14 @@ function ai_mce_buttons_2 ($buttons, $id) {
25
  return $buttons;
26
  }
27
 
28
- function generate_code_preview_adb () {
29
  global $block_object, $ai_wp_data;
30
 
31
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
32
 
33
  $obj = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
34
  $adb_message = $obj->get_ad_data();
 
35
 
36
  wp_enqueue_script ('ai-adb-js', plugins_url ('includes/js/ad-inserter-check.js', __FILE__), array (
37
  'jquery',
25
  return $buttons;
26
  }
27
 
28
+ function generate_code_preview_adb ($client_code = null, $process_php = null) {
29
  global $block_object, $ai_wp_data;
30
 
31
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
32
 
33
  $obj = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
34
  $adb_message = $obj->get_ad_data();
35
+ // $adb_message = $obj->ai_getCode ($client_code, $process_php);
36
 
37
  wp_enqueue_script ('ai-adb-js', plugins_url ('includes/js/ad-inserter-check.js', __FILE__), array (
38
  'jquery',
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: ads, adsense, ad management, advertising manager, advanced contextual ads,
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.2.4
9
- Stable tag: 2.2.5
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
@@ -747,6 +747,9 @@ AD CODE RIGHT
747
 
748
  == Changelog ==
749
 
 
 
 
750
  = 2.2.6 =
751
  - Fix for posts filter counter not counting
752
  - Added list with short overview of all code blocks
@@ -875,6 +878,9 @@ AD CODE RIGHT
875
 
876
  == Upgrade Notice ==
877
 
 
 
 
878
  = 2.2.6 =
879
  Fix for posts filter counter not counting;
880
  Added list with short overview of all code blocks;
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.2.4
9
+ Stable tag: 2.2.6
10
  License: GPLv3
11
 
12
  Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
747
 
748
  == Changelog ==
749
 
750
+ = 2.2.7 =
751
+ - Fix for duplicate amp-custom tag on AMP pages
752
+
753
  = 2.2.6 =
754
  - Fix for posts filter counter not counting
755
  - Added list with short overview of all code blocks
878
 
879
  == Upgrade Notice ==
880
 
881
+ = 2.2.7 =
882
+ Fix for duplicate amp-custom tag on AMP pages
883
+
884
  = 2.2.6 =
885
  Fix for posts filter counter not counting;
886
  Added list with short overview of all code blocks;