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

Version Description

  • Changed javascript version check to get plugin version from the HTML page
  • Added warning if old cached version of CSS file is loaded on the settings page
  • Added warning if version query parameter for js/css files is removed due to inappropriate caching
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.2

Files changed (6) hide show
  1. ad-inserter.php +9 -1
  2. constants.php +1 -1
  3. css/ad-inserter.css +4 -0
  4. js/ad-inserter.js +35 -2
  5. readme.txt +52 -5
  6. settings.php +23 -9
ad-inserter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
- Version: 2.0.1
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
@@ -11,6 +11,11 @@ Plugin URI: http://tinymonitor.com/ad-inserter
11
  /*
12
  Change Log
13
 
 
 
 
 
 
14
  Ad Inserter 2.0.1 - 24 September 2016
15
  - Bug fix: Shortcodes called by name were not displayed
16
 
@@ -1657,6 +1662,9 @@ function ai_generate_extract (&$settings) {
1657
 
1658
  // Generate extracted data
1659
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
 
 
 
1660
  $obj->number = $block;
1661
  $obj->wp_options = $settings [$block];
1662
 
1
  <?php
2
  /*
3
  Plugin Name: Ad Inserter
4
+ Version: 2.0.2
5
  Description: Insert any ad or code into Wordpress. Perfect for all kinds of ads. Simply enter any ad or HTML/Javascript/PHP code and select where and how you want to display it.
6
  Author: Igor Funa
7
  Author URI: http://igorfuna.com/
11
  /*
12
  Change Log
13
 
14
+ Ad Inserter 2.0.2 - 25 September 2016
15
+ - Changed javascript version check to get plugin version from the HTML page
16
+ - Added warning if old cached version of CSS file is loaded on the settings page
17
+ - Added warning if version query parameter for js/css files is removed due to inappropriate caching
18
+
19
  Ad Inserter 2.0.1 - 24 September 2016
20
  - Bug fix: Shortcodes called by name were not displayed
21
 
1662
 
1663
  // Generate extracted data
1664
  for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
1665
+
1666
+ if (!isset ($settings [$block])) continue;
1667
+
1668
  $obj->number = $block;
1669
  $obj->wp_options = $settings [$block];
1670
 
constants.php CHANGED
@@ -11,7 +11,7 @@ if (!defined( 'AD_INSERTER_NAME'))
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
- define ('AD_INSERTER_VERSION', '2.0.1');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
11
  define ('AD_INSERTER_NAME', 'Ad Inserter');
12
 
13
  if (!defined( 'AD_INSERTER_VERSION'))
14
+ define ('AD_INSERTER_VERSION', '2.0.2');
15
 
16
  if (!defined ('AD_INSERTER_BLOCKS'))
17
  define ('AD_INSERTER_BLOCKS', 16);
css/ad-inserter.css CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  #blocked-warning {
2
  display: none;
3
  }
1
+ #data {
2
+ font-family: "2.0.2"; /* Used for version number of the file */
3
+ }
4
+
5
  #blocked-warning {
6
  display: none;
7
  }
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.0.1";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -694,12 +694,45 @@ jQuery(document).ready(function($) {
694
 
695
  setTimeout (configure_hidden_tab, 700);
696
 
697
- var plugin_version = $("script[src*='ad-inserter.js']").attr('src').split('=')[1];
698
  if (javascript_version != plugin_version) {
 
 
 
 
 
 
 
 
 
 
 
 
 
699
  $("#javascript-version").html ("&nbsp;javascript " + javascript_version);
700
  $("#javascript-warning").show ();
701
  }
702
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
703
  var index = 16;
704
  if (active_tab != 0) index = active_tab - start;
705
  var block_tabs = $("#ai-tab-container").tabs ({active: index});
1
+ var javascript_version = "2.0.2";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
694
 
695
  setTimeout (configure_hidden_tab, 700);
696
 
697
+ var plugin_version = $('#data').attr ('version');
698
  if (javascript_version != plugin_version) {
699
+
700
+ // Check page HTML
701
+ var javascript_version_parameter = $("script[src*='ad-inserter.js']").attr('src');
702
+ if (typeof javascript_version_parameter == 'undefined') $("#javascript-version-parameter-missing").show (); else {
703
+ javascript_version_parameter_string = javascript_version_parameter.split('=')[1];
704
+ if (typeof javascript_version_parameter_string == 'undefined') {
705
+ $("#javascript-version-parameter-missing").show ();
706
+ }
707
+ else if (javascript_version_parameter_string != plugin_version) {
708
+ $("#javascript-version-parameter").show ();
709
+ }
710
+ }
711
+
712
  $("#javascript-version").html ("&nbsp;javascript " + javascript_version);
713
  $("#javascript-warning").show ();
714
  }
715
 
716
+ var css_version = $('#data').css ('font-family').replace(/\"/g, '');
717
+ if (css_version.length > 8) $("#blocked-warning").show (); else
718
+ if (css_version != plugin_version) {
719
+
720
+ // Check page HTML
721
+ var css_version_parameter = $("link[href*='ad-inserter.css']").attr('href');
722
+ if (typeof css_version_parameter == 'undefined') $("#css-version-parameter-missing").show (); else {
723
+ css_version_parameter_string = css_version_parameter.split('=')[1];
724
+ if (typeof css_version_parameter_string == 'undefined') {
725
+ $("#css-version-parameter-missing").show ();
726
+ }
727
+ else if (css_version_parameter_string != plugin_version) {
728
+ $("#css-version-parameter").show ();
729
+ }
730
+ }
731
+
732
+ $("#css-version").html ("&nbsp;CSS " + css_version);
733
+ $("#css-warning").show ();
734
+ }
735
+
736
  var index = 16;
737
  if (active_tab != 0) index = active_tab - start;
738
  var block_tabs = $("#ai-tab-container").tabs ({active: index});
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, banner rotation, multisite, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 4.0
6
  Tested up to: 4.6.1
7
- Stable tag: 2.0.0
8
  License: GPLv3
9
 
10
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
@@ -45,13 +45,16 @@ Few typical settings are described on the <a href="https://wordpress.org/plugins
45
 
46
  **Settings**
47
 
48
- Each code block has 4 independent display options:
49
 
50
  * Automatic Display
51
  * Widget
52
  * Shortcode
53
  * PHP function call
54
 
 
 
 
55
  To rename code block click on the block name. To display code block (ad) at some position **you need to enable and use at least one display option**.
56
 
57
  Automatic Display Options:
@@ -320,10 +323,44 @@ Support for Special Code Blocks:
320
  However, since you are dealing with ads, it may make sense to temporarily disable adblockers in order to check and debug inserted ad codes.
321
  Some security plugins like WP Security or Wordfence may also detect Ad Inserter page as problematic and prevent it from loading. Please be assured that this is false positive.
322
 
323
- **WARNING:** If you are using caching the inserted code may not appear imemdiately on the page. Make sure you have disabled caching when you are testing or debugging.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
325
 
326
- **WARNING:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check and server-side detection work only when the page is generated and Ad Inserter is called.
327
  In such cases please make sure you have disabled caching.
328
 
329
  **DEBUGGING**
@@ -438,7 +475,7 @@ If you deactivate and delete Ad Inserter the settings will stay in the database.
438
  4. Save settings
439
 
440
 
441
- = Settings for **widget** =
442
 
443
  * Nothing needed, just enter the code and save settings - widget is enabled by default
444
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
@@ -766,6 +803,11 @@ AD CODE RIGHT
766
 
767
  == Changelog ==
768
 
 
 
 
 
 
769
  = 2.0.1 =
770
  - Bug fix: Shortcodes called by name were not displayed
771
 
@@ -1004,6 +1046,11 @@ AD CODE RIGHT
1004
 
1005
  == Upgrade Notice ==
1006
 
 
 
 
 
 
1007
  = 2.0.1 =
1008
  Bug fix: Shortcodes called by name were not displayed
1009
 
4
  Tags: adsense, amazon, clickbank, cj, ad, ads, html, javascript, php, code, widget, sidebar, responsive, viewport, rotating, banner, banner rotation, multisite, contextual, shortcodes, widgets, header, footer, users, logged in, not logged in, mobile, desktop, phone, tablet, custom css, category, tag, filter, url, skip
5
  Requires at least: 4.0
6
  Tested up to: 4.6.1
7
+ Stable tag: 2.0.1
8
  License: GPLv3
9
 
10
  Insert any ad or HTML/Javascript/PHP code into Wordpress. Perfect for all kinds of ads. 16 code blocks, many display options and features.
45
 
46
  **Settings**
47
 
48
+ Each code block has 4 display options:
49
 
50
  * Automatic Display
51
  * Widget
52
  * Shortcode
53
  * PHP function call
54
 
55
+ Normally for each code block you use only one display option.
56
+ Of course, you can use all 4 options simultaneously taking into account that all display options use the same block settings (with some exceptions mentioned below).
57
+
58
  To rename code block click on the block name. To display code block (ad) at some position **you need to enable and use at least one display option**.
59
 
60
  Automatic Display Options:
323
  However, since you are dealing with ads, it may make sense to temporarily disable adblockers in order to check and debug inserted ad codes.
324
  Some security plugins like WP Security or Wordfence may also detect Ad Inserter page as problematic and prevent it from loading. Please be assured that this is false positive.
325
 
326
+ **CACHING**
327
+
328
+ Caching on the frontend side (what visitors see) does speed up page loading but may cause some unwanted behavior.
329
+ When you are using caching, Wordpress creates page, Ad Inseter is called to do the job and the created page is saved for quicker serving.
330
+ The next time **the visitor gets cached (saved) page **. Because of this some Ad Inserter functions do not work properly because Ad Inserter is not called when the page is cached:
331
+
332
+ * Block rotation with `|rotate|`
333
+ * User check
334
+ * Server-side device detection
335
+ * Referer check
336
+ * Debugging functions
337
+
338
+ When you need the functions listed above you have to switch off caching.
339
+
340
+ Caching on the backend side (Ad Inserter Settings page) may also cause some unwanted behavior if it is not done properly.
341
+ The problem can occur when the plugin is updated since it also provides new javascript and CSS files.
342
+ In order to prevent browsers from loading old js/css files the plugin appends version info as query parameter to js and css files needed.
343
+
344
+ For example, in the source code of the settings page it should be like this:
345
+
346
+ `<script type='text/javascript' src='http://example.com/wp-content/plugins/ad-inserter/js/ad-inserter.js?ver=2.0.1'></script>
347
+
348
+ <link rel='stylesheet' id='ai-admin-css' href='http://example.com/wp-content/plugins/ad-inserter/css/ad-inserter.css?ver=2.0.1' type='text/css' media='all' />`
349
+
350
+ However, on some websites this version parameter is removed (very likely due to aggresive caching):
351
+
352
+ `<script type='text/javascript' src='http://example.com/wp-content/plugins/ad-inserter/js/ad-inserter.js'></script>
353
+
354
+ <link rel='stylesheet' id='ai-admin-css' href='http://example.com/wp-content/plugins/ad-inserter/css/ad-inserter.css' type='text/css' media='all' />`
355
+
356
+ Because of this the old cached files (css and js) are loaded which cause warnings and unpredicted behavior.
357
+
358
+ If you are using caching make sure the caching software **DOES NOT REMOVE VERSION INFO** parameter from the url. This is needed for browsers to reload the file when the plugin is updated.
359
+
360
+ **WARNING:** If you are using caching the inserted code may not appear immediately on the page. Make sure you have disabled caching when you are testing or debugging.
361
  Some caching plugins like <a href="https://wordpress.org/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> have an option to disable caching for known users.
362
 
363
+ **PLEASE DO NOT FORGET:** If you are using caching some settings may not work as expected. For example, ad rotation, referer check, user check and server-side detection work only when the page is generated and Ad Inserter is called.
364
  In such cases please make sure you have disabled caching.
365
 
366
  **DEBUGGING**
475
  4. Save settings
476
 
477
 
478
+ = Settings for widget =
479
 
480
  * Nothing needed, just enter the code and save settings - widget is enabled by default
481
  * Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save
803
 
804
  == Changelog ==
805
 
806
+ = 2.0.2 =
807
+ - Changed javascript version check to get plugin version from the HTML page
808
+ - Added warning if old cached version of CSS file is loaded on the settings page
809
+ - Added warning if version query parameter for js/css files is removed due to inappropriate caching
810
+
811
  = 2.0.1 =
812
  - Bug fix: Shortcodes called by name were not displayed
813
 
1046
 
1047
  == Upgrade Notice ==
1048
 
1049
+ = 2.0.2 =
1050
+ Changed javascript version check to get plugin version from the HTML page;
1051
+ Added warning if old cached version of CSS file is loaded on the settings page;
1052
+ Added warning if version query parameter for js/css files is removed due to inappropriate caching
1053
+
1054
  = 2.0.1 =
1055
  Bug fix: Shortcodes called by name were not displayed
1056
 
settings.php CHANGED
@@ -36,7 +36,7 @@ function generate_settings_form (){
36
 
37
  ?>
38
 
39
- <div id="data" style="display: none;" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
40
 
41
  <div id="ai-settings" style="float: left;">
42
 
@@ -62,20 +62,33 @@ function generate_settings_form (){
62
  ?>
63
  </div>
64
 
65
- <div id="javascript-warning" class="ai-form" style="width: 735px; padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; display: none;">
66
- <h2 id="javascript-version" style="float: left; color: red;" title="Plugin javascript version">&nbsp;</h2>
67
  <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
68
- Incompatible javscript file loaded, probably due to caching. Please try to delete<br />
69
- browser's cache and reload this page to see if this warning will disappear.
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  </div>
71
  <div style="clear: both;"></div>
72
  </div>
73
 
74
  <div id="blocked-warning" class="ai-form warning-enabled" style="padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
75
- <h2 style="float: left; color: red;" title="Error loading page">PAGE BLOCKED</h2>
76
  <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
77
- This page was not loaded properly. Please check browser and plugins that may block this page.<br />
78
- If you are using <strong>Ad Blocker</strong> please select "Disable on this page" or "Don't run on this page".
79
  </div>
80
  <div style="clear: both;"></div>
81
  </div>
@@ -1211,10 +1224,11 @@ function generate_settings_form (){
1211
  }
1212
  ?>
1213
  <script type="text/javascript">
1214
- setTimeout (show_blocked_warning, 3000);
1215
 
1216
  function show_blocked_warning () {
1217
  jQuery("#blocked-warning.warning-enabled").show ();
 
1218
  }
1219
 
1220
  </script>
36
 
37
  ?>
38
 
39
+ <div id="data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" javascript_debugging="<?php echo get_javascript_debugging () ? '1' : '0'; ?>" ></div>
40
 
41
  <div id="ai-settings" style="float: left;">
42
 
62
  ?>
63
  </div>
64
 
65
+ <div id="javascript-warning" class="ai-form" style="padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; display: none;">
66
+ <h2 id="javascript-version" style="float: left; color: red;" title="Loaded plugin javascript version">&nbsp;</h2>
67
  <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
68
+ <span id="javascript-version-parameter" style="display: none;">Wrong version parameter for the javscript file, probably due to inappropriate caching.<br /></span>
69
+ <span id="javascript-version-parameter-missing" style="display: none;">Missing version parameter for the javscript file, probably due to inappropriate caching.<br /></span>
70
+ Incompatible (old) javscript file loaded, probably due to inappropriate caching.<br />
71
+ Please delete browser's cache and all other caches used and then reload this page.
72
+ </div>
73
+ <div style="clear: both;"></div>
74
+ </div>
75
+
76
+ <div id="css-warning" class="ai-form" style="padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px; display: none;">
77
+ <h2 id="css-version" style="float: left; color: red;" title="Loaded plugin CSS version">&nbsp;</h2>
78
+ <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
79
+ <span id="css-version-parameter" style="display: none;">Wrong version parameter for the CSS file, probably due to inappropriate caching.<br /></span>
80
+ <span id="css-version-parameter-missing" style="display: none;">Missing version parameter for the CSS file, probably due to inappropriate caching.<br /></span>
81
+ Incompatible (old) CSS file loaded, probably due to inappropriate caching.<br />
82
+ Please delete browser's cache and all other caches used and then reload this page.
83
  </div>
84
  <div style="clear: both;"></div>
85
  </div>
86
 
87
  <div id="blocked-warning" class="ai-form warning-enabled" style="padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
88
+ <h2 class="blocked-warning-text" style="float: left; color: red;" title="Error loading page">PAGE BLOCKED</h2>
89
  <div style="float: right; text-align: right; margin: 8px 18px 0px 0;">
90
+ This page was not loaded properly. Please check browser and plugins that may block CSS/javascript<br />
91
+ files for this page. For <strong>Ad Blocker</strong> select "Disable on this page" or "Don't run on this page".
92
  </div>
93
  <div style="clear: both;"></div>
94
  </div>
1224
  }
1225
  ?>
1226
  <script type="text/javascript">
1227
+ setTimeout (show_blocked_warning, 4000);
1228
 
1229
  function show_blocked_warning () {
1230
  jQuery("#blocked-warning.warning-enabled").show ();
1231
+ jQuery("#blocked-warning.warning-enabled .blocked-warning-text").css ('color', '#00f');
1232
  }
1233
 
1234
  </script>