Async JavaScript - Version 1.16.03.23

Version Description

  • FIX: added check for empty string entered in exclusions
Download this release

Release Info

Developer cloughit
Plugin Icon 128x128 Async JavaScript
Version 1.16.03.23
Comparing to
See all releases

Code changes from version 1.16.03.10 to 1.16.03.23

Files changed (2) hide show
  1. async-javascript.php +28 -16
  2. readme.txt +18 -2
async-javascript.php CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
  Plugin Name: Async Javascript
5
  Plugin URI: http://cloughit.com.au/product/async-javascript/
6
  Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
7
- Version: 1.16.03.10
8
  Author: David Clough (cloughit)
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
@@ -23,7 +23,7 @@ add_action('admin_init','aj_admin_init');
23
  function aj_admin_init() {
24
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
25
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
26
- define( 'AJ_VERSION', '1.16.03.10' );
27
  wp_register_style(
28
  'aj_admin_styles',
29
  plugins_url('/css/admin.css',__FILE__)
@@ -39,7 +39,16 @@ function aj_admin_init() {
39
  register_setting( 'aj_options', 'aj_enabled' );
40
  register_setting( 'aj_options', 'aj_method' );
41
  register_setting( 'aj_options', 'aj_exclusions' );
 
42
  register_setting( 'aj_options', 'autoptimize_enabled' );
 
 
 
 
 
 
 
 
43
  }
44
  /**
45
  * async_javascript_menu()
@@ -82,15 +91,18 @@ function async_javascript_admin() {
82
  echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
83
  }
84
  // load settings from database
85
- $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"');
86
- $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
87
- $aj_exclusions = get_option('aj_exclusions');
88
- $autoptimize_enabled = (get_option('autoptimize_enabled') == 1) ? 'checked' : '';
89
  ?>
90
  <div class="wrap">
91
  <h2>Async Javascript Settings</h2>
92
  <form action="options.php" method="post" name="options">
93
- <?php echo wp_nonce_field('update-options'); ?>
 
 
 
 
 
 
 
94
  <table class="form-table" width="100%" cellpadding="10">
95
  <tbody>
96
  <tr>
@@ -147,16 +159,14 @@ function async_javascript_admin() {
147
  <tr><td scope="row" align="left" colspan="2"><hr/><h4>Autoptimize - <a href="https://wordpress.org/plugins/autoptimize/" target="_blank"><?php echo 'https://wordpress.org/plugins/autoptimize/'; ?></a></h4></td></tr>
148
  <tr>
149
  <td scope="row" align="left" style="width:20%;"><label>Enable Autoptimize Support</label></td>
150
- <td scope="row" align="left"><input type="checkbox" name="autoptimize_enabled" value="1" <?php echo $autoptimize_enabled; ?> /></td>
151
  </tr>
152
  <?php
153
  }
154
  ?>
155
  </tbody>
156
  </table>
157
- <input type="hidden" name="action" value="update" />
158
- <input type="hidden" name="page_options" value="aj_enabled,aj_method,autoptimize_enabled,aj_exclusions" />
159
- <input type="submit" name="Submit" value="Update" />
160
  </td>
161
  <td style="width:33%;vertical-align: top;">
162
  <a href="http://cloughit.com.au/product/async-javascript-pro/" target="_blank"><img src="<?php echo AJ_PLUGIN_URL; ?>images/async-javascript-pro.jpg"></a>
@@ -181,15 +191,17 @@ function async_js($url) {
181
  $aj_enabled = (get_option('aj_enabled') == 1) ? true : false;
182
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
183
  $aj_exclusions = get_option('aj_exclusions');
184
- $array_exclusions = !empty($aj_exclusions) ? explode(',',$aj_exclusions) : $aj_exclusions;
185
  if (false !== $aj_enabled && false === is_admin()) {
186
  if (false === strpos($url,'.js')) {
187
  return $url;
188
  }
189
  if (is_array($array_exclusions) && !empty($array_exclusions)) {
190
  foreach ($array_exclusions as $exclusion) {
191
- if (false !== strpos(strtolower($url),strtolower($exclusion))) {
192
- return $url;
 
 
193
  }
194
  }
195
  }
@@ -210,9 +222,9 @@ add_filter('autoptimize_filter_js_defer','my_autoptimize_defer',11);
210
  function my_autoptimize_defer($defer) {
211
  $aj_enabled = (get_option('aj_enabled') == 1) ? true : false;
212
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
213
- $autoptimize_enabled = (get_option('autoptimize_enabled') == 1) ? true : false;
214
  if (false !== $aj_enabled && false === is_admin()) {
215
- if (false !== $autoptimize_enabled) {
216
  return " " . $aj_method . "='" . $aj_method . "' ";
217
  }
218
  }
4
  Plugin Name: Async Javascript
5
  Plugin URI: http://cloughit.com.au/product/async-javascript/
6
  Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
7
+ Version: 1.16.03.23
8
  Author: David Clough (cloughit)
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
23
  function aj_admin_init() {
24
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
25
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
26
+ define( 'AJ_VERSION', '1.16.03.23' );
27
  wp_register_style(
28
  'aj_admin_styles',
29
  plugins_url('/css/admin.css',__FILE__)
39
  register_setting( 'aj_options', 'aj_enabled' );
40
  register_setting( 'aj_options', 'aj_method' );
41
  register_setting( 'aj_options', 'aj_exclusions' );
42
+ register_setting( 'aj_options', 'aj_upgrade_notice' );
43
  register_setting( 'aj_options', 'autoptimize_enabled' );
44
+ register_setting( 'aj_options', 'aj_autoptimize_enabled' );
45
+ $autoptimize_enabled = get_option('autoptimize_enabled');
46
+ $aj_autoptimize_enabled = get_option('aj_autoptimize_enabled');
47
+ if ( $autoptimize_enabled !== false && $aj_autoptimize_enabled === false ) {
48
+ $aj_autoptimize_enabled = $autoptimize_enabled;
49
+ update_option( 'aj_autoptimize_enabled', $aj_autoptimize_enabled );
50
+ delete_option( 'autoptimize_enabled' );
51
+ }
52
  }
53
  /**
54
  * async_javascript_menu()
91
  echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
92
  }
93
  // load settings from database
 
 
 
 
94
  ?>
95
  <div class="wrap">
96
  <h2>Async Javascript Settings</h2>
97
  <form action="options.php" method="post" name="options">
98
+ <?php
99
+ settings_fields( 'aj_options' );
100
+ do_settings_sections( 'aj_options' );
101
+ $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"');
102
+ $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
103
+ $aj_exclusions = get_option('aj_exclusions');
104
+ $aj_autoptimize_enabled = (get_option('aj_autoptimize_enabled') == 1) ? 'checked' : '';
105
+ ?>
106
  <table class="form-table" width="100%" cellpadding="10">
107
  <tbody>
108
  <tr>
159
  <tr><td scope="row" align="left" colspan="2"><hr/><h4>Autoptimize - <a href="https://wordpress.org/plugins/autoptimize/" target="_blank"><?php echo 'https://wordpress.org/plugins/autoptimize/'; ?></a></h4></td></tr>
160
  <tr>
161
  <td scope="row" align="left" style="width:20%;"><label>Enable Autoptimize Support</label></td>
162
+ <td scope="row" align="left"><input type="checkbox" name="aj_autoptimize_enabled" value="1" <?php echo $aj_autoptimize_enabled; ?> /></td>
163
  </tr>
164
  <?php
165
  }
166
  ?>
167
  </tbody>
168
  </table>
169
+ <?php submit_button(); ?>
 
 
170
  </td>
171
  <td style="width:33%;vertical-align: top;">
172
  <a href="http://cloughit.com.au/product/async-javascript-pro/" target="_blank"><img src="<?php echo AJ_PLUGIN_URL; ?>images/async-javascript-pro.jpg"></a>
191
  $aj_enabled = (get_option('aj_enabled') == 1) ? true : false;
192
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
193
  $aj_exclusions = get_option('aj_exclusions');
194
+ $array_exclusions = !empty($aj_exclusions) ? explode(',',$aj_exclusions) : array();
195
  if (false !== $aj_enabled && false === is_admin()) {
196
  if (false === strpos($url,'.js')) {
197
  return $url;
198
  }
199
  if (is_array($array_exclusions) && !empty($array_exclusions)) {
200
  foreach ($array_exclusions as $exclusion) {
201
+ if ( $exclusion != '' ) {
202
+ if (false !== strpos(strtolower($url),strtolower($exclusion))) {
203
+ return $url;
204
+ }
205
  }
206
  }
207
  }
222
  function my_autoptimize_defer($defer) {
223
  $aj_enabled = (get_option('aj_enabled') == 1) ? true : false;
224
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
225
+ $aj_autoptimize_enabled = (get_option('aj_autoptimize_enabled') == 1) ? true : false;
226
  if (false !== $aj_enabled && false === is_admin()) {
227
+ if (false !== $aj_autoptimize_enabled) {
228
  return " " . $aj_method . "='" . $aj_method . "' ";
229
  }
230
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.cloughit.com.au/donate/ (coming soon)
4
  Tags: async,javascript,google,pagespeed,js,speed,performance,boost,render,blocking,above-the-fold
5
  Requires at least: 2.8
6
  Tested up to: 4.4.2
7
- Stable tag: 1.16.03.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -53,7 +53,6 @@ Please lodge a support request at https://wordpress.org/support/plugin/async-jav
53
 
54
  = What information should I include when requesting support =
55
 
56
-
57
  * A description of the problem, including screenshots and information from your browser's Error/ debug console
58
  * URL of your blog (you can turn Async Javascript off, but should be willing to turn it briefly on to have the error visible)
59
  * your Async Javascript settings (including a description of changes you made to the configuration to try to troubleshoot yourself)
@@ -71,6 +70,23 @@ Please lodge a support request at https://wordpress.org/support/plugin/async-jav
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  = 1.16.02.18 =
75
 
76
  * NEW: Added dismissable upgrade notice
4
  Tags: async,javascript,google,pagespeed,js,speed,performance,boost,render,blocking,above-the-fold
5
  Requires at least: 2.8
6
  Tested up to: 4.4.2
7
+ Stable tag: 1.16.03.23
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
53
 
54
  = What information should I include when requesting support =
55
 
 
56
  * A description of the problem, including screenshots and information from your browser's Error/ debug console
57
  * URL of your blog (you can turn Async Javascript off, but should be willing to turn it briefly on to have the error visible)
58
  * your Async Javascript settings (including a description of changes you made to the configuration to try to troubleshoot yourself)
70
 
71
  == Changelog ==
72
 
73
+ = 1.16.03.23 =
74
+
75
+ * FIX: added check for empty string entered in exclusions
76
+
77
+ = 1.16.03.13 =
78
+
79
+ * FIX: Fixed autoptomize settings
80
+ * FIX: Removed redundant settings
81
+
82
+ = 1.16.03.12 =
83
+
84
+ * FIX: Adjust code flow for registered settings
85
+
86
+ = 1.16.03.11 =
87
+
88
+ * FIX: Properly register options
89
+
90
  = 1.16.02.18 =
91
 
92
  * NEW: Added dismissable upgrade notice