Async JavaScript - Version 1.17.01.22

Version Description

  • MOD: Changes in notice functionality
Download this release

Release Info

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

Code changes from version 1.17.01.14 to 1.17.01.22

Files changed (5) hide show
  1. async-javascript.php +17 -14
  2. css/admin.min.css +1 -0
  3. js/admin.js +3 -1
  4. js/admin.min.js +1 -0
  5. readme.txt +8 -1
async-javascript.php CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
  Plugin Name: Async JavaScript
5
  Plugin URI: https://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.17.01.14
8
  Author: Clough I.T. Solutions
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
@@ -23,15 +23,15 @@ 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.17.01.14' );
27
  wp_register_style(
28
  'aj_admin_styles',
29
- plugins_url( '/css/admin.css', __FILE__ )
30
  );
31
  wp_enqueue_style( 'aj_admin_styles' );
32
  wp_enqueue_script(
33
  'aj_admin_scripts',
34
- plugins_url( '/js/admin.js', __FILE__ ),
35
  array( 'jquery' ),
36
  time()
37
  );
@@ -57,8 +57,7 @@ function aj_admin_init() {
57
  */
58
  add_action( 'admin_notices', 'async_javascript_upgrade_notice' );
59
  function async_javascript_upgrade_notice() {
60
- $aj_upgrade_notice = get_option( 'aj_upgrade_notice' );
61
- if ( $aj_upgrade_notice != AJ_VERSION ) {
62
  $options = array(
63
  'timeout' => 10, //seconds
64
  'headers' => array(
@@ -70,13 +69,16 @@ function async_javascript_upgrade_notice() {
70
  if ( is_array( $aj_notice_json ) && ! is_wp_error( $aj_notice_json ) ) {
71
  $body = wp_remote_retrieve_body( $aj_notice_json );
72
  $aj_notice = json_decode( $body );
73
- $exp = strtotime( $aj_notice->expire );
74
- $title = $aj_notice->title != '' ? '<string><em>' . stripslashes( $aj_notice->title ) . '</em></strong>' : '';
75
- $message = stripslashes( $aj_notice->message );
76
- $time = current_time( 'timestamp', 1 );
77
- if ( $time < $exp ) {
78
- echo '<div class="notice notice-info is-dismissible aj-upgrade-notice">' . $title . $message . '</div>';
79
- }
 
 
 
80
  }
81
  }
82
  }
@@ -307,7 +309,8 @@ function my_autoptimize_defer( $defer ) {
307
  }
308
  add_action( 'wp_ajax_async_javascript_dismiss_upgrade', 'async_javascript_dismiss_upgrade' );
309
  function async_javascript_dismiss_upgrade() {
310
- update_option( 'aj_upgrade_notice', AJ_VERSION );
 
311
  die();
312
  }
313
  ?>
4
  Plugin Name: Async JavaScript
5
  Plugin URI: https://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.17.01.22
8
  Author: Clough I.T. Solutions
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.17.01.22' );
27
  wp_register_style(
28
  'aj_admin_styles',
29
+ plugins_url( '/css/admin.min.css', __FILE__ )
30
  );
31
  wp_enqueue_style( 'aj_admin_styles' );
32
  wp_enqueue_script(
33
  'aj_admin_scripts',
34
+ plugins_url( '/js/admin.min.js', __FILE__ ),
35
  array( 'jquery' ),
36
  time()
37
  );
57
  */
58
  add_action( 'admin_notices', 'async_javascript_upgrade_notice' );
59
  function async_javascript_upgrade_notice() {
60
+ if ( is_admin() ) {
 
61
  $options = array(
62
  'timeout' => 10, //seconds
63
  'headers' => array(
69
  if ( is_array( $aj_notice_json ) && ! is_wp_error( $aj_notice_json ) ) {
70
  $body = wp_remote_retrieve_body( $aj_notice_json );
71
  $aj_notice = json_decode( $body );
72
+ $aj_upgrade_notice = get_option( 'aj_upgrade_notice' );
73
+ if ( $aj_upgrade_notice != $aj_notice->notice_id ) {
74
+ $exp = strtotime( $aj_notice->expire );
75
+ $title = $aj_notice->title != '' ? '<string><em>' . stripslashes( $aj_notice->title ) . '</em></strong>' : '';
76
+ $message = stripslashes( $aj_notice->message );
77
+ $time = current_time( 'timestamp', 1 );
78
+ if ( $time < $exp ) {
79
+ echo '<div class="notice notice-info is-dismissible aj-upgrade-notice" data-id="' . $aj_notice->notice_id . '">' . $title . $message . '</div>';
80
+ }
81
+ }
82
  }
83
  }
84
  }
309
  }
310
  add_action( 'wp_ajax_async_javascript_dismiss_upgrade', 'async_javascript_dismiss_upgrade' );
311
  function async_javascript_dismiss_upgrade() {
312
+ $notice_id = isset( $_REQUEST['notice_id'] ) && $_REQUEST['notice_id'] != '' ? $_REQUEST['notice_id'] : '';
313
+ update_option( 'aj_upgrade_notice', $notice_id );
314
  die();
315
  }
316
  ?>
css/admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .aj_method{display:none}
js/admin.js CHANGED
@@ -37,10 +37,12 @@ jQuery(document).ready(function() {
37
  });
38
 
39
  jQuery(document).on('click','.aj-upgrade-notice .notice-dismiss',function() {
 
40
  jQuery.ajax({
41
  url: aj.ajaxurl,
42
  data: {
43
- action: 'async_javascript_dismiss_upgrade'
 
44
  }
45
  });
46
  });
37
  });
38
 
39
  jQuery(document).on('click','.aj-upgrade-notice .notice-dismiss',function() {
40
+ var notice_id = jQuery( '.aj-upgrade-notice' ).attr( 'data-id' );
41
  jQuery.ajax({
42
  url: aj.ajaxurl,
43
  data: {
44
+ action: 'async_javascript_dismiss_upgrade',
45
+ notice_id: notice_id
46
  }
47
  });
48
  });
js/admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function isChecked(){jQuery("#aj_enabled").prop("checked")?jQuery(".aj_method").show():jQuery(".aj_method").hide()}jQuery(document).ready(function(){isChecked(),jQuery(document).on("click","#aj_enabled",function(){isChecked()}),jQuery(document).on("click",".aj-upgrade-notice .notice-dismiss",function(){var e=jQuery(".aj-upgrade-notice").attr("data-id");jQuery.ajax({url:aj.ajaxurl,data:{action:"async_javascript_dismiss_upgrade",notice_id:e}})})});
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.7.1
7
- Stable tag: 1.17.01.14
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -51,6 +51,8 @@ The 'async' attribute is new in HTML5. It is supported by the following browsers
51
 
52
  Please lodge a support request at <a href="https://cloughit.com.au/support/?wpsc_category=8" target="_blank">https://cloughit.com.au/support/</a>
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 debug console
@@ -70,9 +72,14 @@ Coming soon!
70
 
71
  == Changelog ==
72
 
 
 
 
 
73
  = 1.17.01.14 =
74
 
75
  * MOD: Update readme.txt information
 
76
 
77
  = 1.16.12.12 =
78
 
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.7.1
7
+ Stable tag: 1.17.01.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
51
 
52
  Please lodge a support request at <a href="https://cloughit.com.au/support/?wpsc_category=8" target="_blank">https://cloughit.com.au/support/</a>
53
 
54
+ Note: Support is NOT offered via the wordpress.org forums.
55
+
56
  = What information should I include when requesting support =
57
 
58
  * A description of the problem, including screenshots and information from your browser's debug console
72
 
73
  == Changelog ==
74
 
75
+ = 1.17.01.22 =
76
+
77
+ * MOD: Changes in notice functionality
78
+
79
  = 1.17.01.14 =
80
 
81
  * MOD: Update readme.txt information
82
+ * MOD: Minify plugin JS & CSS
83
 
84
  = 1.16.12.12 =
85