Async JavaScript - Version 2.17.09.29

Version Description

Download this release

Release Info

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

Code changes from version 2.17.06.13 to 2.17.09.29

Files changed (3) hide show
  1. async-javascript.php +36 -34
  2. js/admin.js +18 -8
  3. js/admin.min.js +1 -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: 2.17.06.13
8
  Author: Clough I.T. Solutions
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
@@ -26,7 +26,7 @@ function aj_admin_init() {
26
  define( 'AJ_ADMIN_URL', trailingslashit( admin_url() ) );
27
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
28
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
29
- define( 'AJ_VERSION', '2.17.06.13' );
30
  require_once( AJ_PLUGIN_DIR . 'lib/gtmetrix/class.Services_WTF_Test.php' );
31
  }
32
  /**
@@ -247,6 +247,7 @@ function async_javascript_admin() {
247
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'wizard';
248
  ?>
249
  <div class="wrap aj">
 
250
  <div id="aj_notification"></div>
251
  <h2>Welcome to <?php echo AJ_TITLE; ?></h2>
252
  <h2 class="nav-tab-wrapper">
@@ -1013,6 +1014,7 @@ function async_javascript_dismiss_upgrade() {
1013
  *
1014
  */
1015
  function aj_steps() {
 
1016
  $aj_gtmetrix_results = get_option( 'aj_gtmetrix_results', array() );
1017
  if ( !isset( $_POST['sub_action'] ) ) {
1018
  $return = array(
@@ -1020,13 +1022,13 @@ function aj_steps() {
1020
  'error' => 'No sub action defined.'
1021
  );
1022
  } else {
1023
- $sub_action = $_POST['sub_action'];
1024
  switch ( $sub_action ) {
1025
  case 'aj_step2':
1026
- $aj_gtmetrix_username = $_POST['aj_gtmetrix_username'];
1027
- $aj_gtmetrix_api_key = $_POST['aj_gtmetrix_api_key'];
1028
- $aj_gtmetrix_server = $_POST['aj_gtmetrix_server'];
1029
- $site_url = trailingslashit( $_POST['site_url'] );
1030
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1031
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1032
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
@@ -1070,10 +1072,10 @@ function aj_steps() {
1070
  }
1071
  break;
1072
  case 'aj_step2b':
1073
- $aj_gtmetrix_username = $_POST['aj_gtmetrix_username'];
1074
- $aj_gtmetrix_api_key = $_POST['aj_gtmetrix_api_key'];
1075
- $aj_gtmetrix_server = $_POST['aj_gtmetrix_server'];
1076
- $site_url = trailingslashit( $_POST['site_url'] );
1077
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1078
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1079
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
@@ -1117,10 +1119,10 @@ function aj_steps() {
1117
  }
1118
  break;
1119
  case 'aj_step2c':
1120
- $aj_gtmetrix_username = $_POST['aj_gtmetrix_username'];
1121
- $aj_gtmetrix_api_key = $_POST['aj_gtmetrix_api_key'];
1122
- $aj_gtmetrix_server = $_POST['aj_gtmetrix_server'];
1123
- $site_url = trailingslashit( $_POST['site_url'] );
1124
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1125
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1126
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
@@ -1164,10 +1166,10 @@ function aj_steps() {
1164
  }
1165
  break;
1166
  case 'aj_step2d':
1167
- $aj_gtmetrix_username = $_POST['aj_gtmetrix_username'];
1168
- $aj_gtmetrix_api_key = $_POST['aj_gtmetrix_api_key'];
1169
- $aj_gtmetrix_server = $_POST['aj_gtmetrix_server'];
1170
- $site_url = trailingslashit( $_POST['site_url'] );
1171
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1172
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1173
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
@@ -1211,10 +1213,10 @@ function aj_steps() {
1211
  }
1212
  break;
1213
  case 'aj_step2e':
1214
- $aj_gtmetrix_username = $_POST['aj_gtmetrix_username'];
1215
- $aj_gtmetrix_api_key = $_POST['aj_gtmetrix_api_key'];
1216
- $aj_gtmetrix_server = $_POST['aj_gtmetrix_server'];
1217
- $site_url = trailingslashit( $_POST['site_url'] );
1218
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1219
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1220
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
@@ -1289,7 +1291,7 @@ function aj_steps() {
1289
  }
1290
  break;
1291
  case 'aj_apply_settings':
1292
- $settings = $_POST['settings'];
1293
  if ( $settings != '' ) {
1294
  $best_id = $settings;
1295
  } else {
@@ -1313,10 +1315,10 @@ function aj_steps() {
1313
  $return['status'] = true;
1314
  break;
1315
  case 'aj_gtmetrix_test':
1316
- $aj_gtmetrix_username = $_POST['aj_gtmetrix_username'];
1317
- $aj_gtmetrix_api_key = $_POST['aj_gtmetrix_api_key'];
1318
- $aj_gtmetrix_server = $_POST['aj_gtmetrix_server'];
1319
- $site_url = trailingslashit( $_POST['site_url'] );
1320
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1321
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1322
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
@@ -1362,12 +1364,12 @@ function aj_steps() {
1362
  }
1363
  break;
1364
  case 'aj_save_settings':
1365
- $aj_enabled = $_POST['aj_enabled'];
1366
- $aj_method = $_POST['aj_method'];
1367
- $aj_jquery = $_POST['aj_jquery'];
1368
- $aj_exclusions = $_POST['aj_exclusions'];
1369
- $aj_autoptimize_enabled = $_POST['aj_autoptimize_enabled'];
1370
- $aj_autoptimize_method = $_POST['aj_autoptimize_method'];
1371
  update_option( 'aj_enabled', $aj_enabled );
1372
  update_option( 'aj_method', $aj_method );
1373
  update_option( 'aj_jquery', $aj_jquery );
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: 2.17.09.29
8
  Author: Clough I.T. Solutions
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
26
  define( 'AJ_ADMIN_URL', trailingslashit( admin_url() ) );
27
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
28
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
29
+ define( 'AJ_VERSION', '2.17.09.29' );
30
  require_once( AJ_PLUGIN_DIR . 'lib/gtmetrix/class.Services_WTF_Test.php' );
31
  }
32
  /**
247
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'wizard';
248
  ?>
249
  <div class="wrap aj">
250
+ <input type="hidden" id="aj_nonce" value="<?php echo wp_create_nonce( "aj_nonce" ); ?>" />
251
  <div id="aj_notification"></div>
252
  <h2>Welcome to <?php echo AJ_TITLE; ?></h2>
253
  <h2 class="nav-tab-wrapper">
1014
  *
1015
  */
1016
  function aj_steps() {
1017
+ check_ajax_referer( 'aj_nonce', 'security' );
1018
  $aj_gtmetrix_results = get_option( 'aj_gtmetrix_results', array() );
1019
  if ( !isset( $_POST['sub_action'] ) ) {
1020
  $return = array(
1022
  'error' => 'No sub action defined.'
1023
  );
1024
  } else {
1025
+ $sub_action = sanitize_text_field( $_POST['sub_action'] );
1026
  switch ( $sub_action ) {
1027
  case 'aj_step2':
1028
+ $aj_gtmetrix_username = sanitize_text_field( $_POST['aj_gtmetrix_username'] );
1029
+ $aj_gtmetrix_api_key = sanitize_text_field( $_POST['aj_gtmetrix_api_key'] );
1030
+ $aj_gtmetrix_server = sanitize_text_field( $_POST['aj_gtmetrix_server'] );
1031
+ $site_url = trailingslashit( sanitize_text_field( $_POST['site_url'] ) );
1032
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1033
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1034
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
1072
  }
1073
  break;
1074
  case 'aj_step2b':
1075
+ $aj_gtmetrix_username = sanitize_text_field( $_POST['aj_gtmetrix_username'] );
1076
+ $aj_gtmetrix_api_key = sanitize_text_field( $_POST['aj_gtmetrix_api_key'] );
1077
+ $aj_gtmetrix_server = sanitize_text_field( $_POST['aj_gtmetrix_server'] );
1078
+ $site_url = trailingslashit( sanitize_text_field( $_POST['site_url'] ) );
1079
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1080
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1081
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
1119
  }
1120
  break;
1121
  case 'aj_step2c':
1122
+ $aj_gtmetrix_username = sanitize_text_field( $_POST['aj_gtmetrix_username'] );
1123
+ $aj_gtmetrix_api_key = sanitize_text_field( $_POST['aj_gtmetrix_api_key'] );
1124
+ $aj_gtmetrix_server = sanitize_text_field( $_POST['aj_gtmetrix_server'] );
1125
+ $site_url = trailingslashit( sanitize_text_field( $_POST['site_url'] ) );
1126
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1127
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1128
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
1166
  }
1167
  break;
1168
  case 'aj_step2d':
1169
+ $aj_gtmetrix_username = sanitize_text_field( $_POST['aj_gtmetrix_username'] );
1170
+ $aj_gtmetrix_api_key = sanitize_text_field( $_POST['aj_gtmetrix_api_key'] );
1171
+ $aj_gtmetrix_server = sanitize_text_field( $_POST['aj_gtmetrix_server'] );
1172
+ $site_url = trailingslashit( sanitize_text_field( $_POST['site_url'] ) );
1173
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1174
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1175
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
1213
  }
1214
  break;
1215
  case 'aj_step2e':
1216
+ $aj_gtmetrix_username = sanitize_text_field( $_POST['aj_gtmetrix_username'] );
1217
+ $aj_gtmetrix_api_key = sanitize_text_field( $_POST['aj_gtmetrix_api_key'] );
1218
+ $aj_gtmetrix_server = sanitize_text_field( $_POST['aj_gtmetrix_server'] );
1219
+ $site_url = trailingslashit( sanitize_text_field( $_POST['site_url'] ) );
1220
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1221
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1222
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
1291
  }
1292
  break;
1293
  case 'aj_apply_settings':
1294
+ $settings = sanitize_text_field( $_POST['settings'] );
1295
  if ( $settings != '' ) {
1296
  $best_id = $settings;
1297
  } else {
1315
  $return['status'] = true;
1316
  break;
1317
  case 'aj_gtmetrix_test':
1318
+ $aj_gtmetrix_username = sanitize_text_field( $_POST['aj_gtmetrix_username'] );
1319
+ $aj_gtmetrix_api_key = sanitize_text_field( $_POST['aj_gtmetrix_api_key'] );
1320
+ $aj_gtmetrix_server = sanitize_text_field( $_POST['aj_gtmetrix_server'] );
1321
+ $site_url = trailingslashit( sanitize_text_field( $_POST['site_url'] ) );
1322
  update_option( 'aj_gtmetrix_username', $aj_gtmetrix_username );
1323
  update_option( 'aj_gtmetrix_api_key', $aj_gtmetrix_api_key );
1324
  update_option( 'aj_gtmetrix_server', $aj_gtmetrix_server );
1364
  }
1365
  break;
1366
  case 'aj_save_settings':
1367
+ $aj_enabled = sanitize_text_field( $_POST['aj_enabled'] );
1368
+ $aj_method = sanitize_text_field( $_POST['aj_method'] );
1369
+ $aj_jquery = sanitize_text_field( $_POST['aj_jquery'] );
1370
+ $aj_exclusions = sanitize_text_field( $_POST['aj_exclusions'] );
1371
+ $aj_autoptimize_enabled = sanitize_text_field( $_POST['aj_autoptimize_enabled'] );
1372
+ $aj_autoptimize_method = sanitize_text_field( $_POST['aj_autoptimize_method'] );
1373
  update_option( 'aj_enabled', $aj_enabled );
1374
  update_option( 'aj_method', $aj_method );
1375
  update_option( 'aj_jquery', $aj_jquery );
js/admin.js CHANGED
@@ -1,4 +1,5 @@
1
  function aj_step( theStep ) {
 
2
  var aj_gtmetrix_username = jQuery( '#aj_gtmetrix_username' ).val();
3
  var aj_gtmetrix_api_key = jQuery( '#aj_gtmetrix_api_key' ).val();
4
  var aj_gtmetrix_server = jQuery( '#aj_gtmetrix_server' ).val();
@@ -9,7 +10,8 @@ function aj_step( theStep ) {
9
  'site_url': aj_localize_admin.siteurl,
10
  'aj_gtmetrix_username': aj_gtmetrix_username,
11
  'aj_gtmetrix_api_key': aj_gtmetrix_api_key,
12
- 'aj_gtmetrix_server': aj_gtmetrix_server
 
13
  };
14
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
15
  try {
@@ -67,7 +69,8 @@ function aj_step( theStep ) {
67
  'site_url': aj_localize_admin.siteurl,
68
  'aj_gtmetrix_username': aj_gtmetrix_username,
69
  'aj_gtmetrix_api_key': aj_gtmetrix_api_key,
70
- 'aj_gtmetrix_server': aj_gtmetrix_server
 
71
  };
72
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
73
  try {
@@ -158,20 +161,23 @@ function aj_step( theStep ) {
158
  * functions and actions to load after document ready
159
  */
160
  jQuery( document ).ready( function() {
161
-
162
  jQuery( document ).on( 'click', '.aj-upgrade-notice .notice-dismiss', function() {
 
163
  var notice_id = jQuery( '.aj-upgrade-notice' ).attr( 'data-id' );
164
  jQuery.ajax({
165
  url: aj.ajaxurl,
166
  data: {
167
- action: 'async_javascript_dismiss_upgrade',
168
- notice_id: notice_id
 
169
  }
170
  });
171
  });
172
 
173
  jQuery( document ).on( 'click', '.aj_steps_button', function(e) {
174
  e.preventDefault();
 
175
  var theStep = jQuery( this ).attr( 'data-id' );
176
  if ( theStep == 'aj_goto_settings' ) {
177
  var newURL = aj_localize_admin.ajadminurl + '&tab=settings';
@@ -187,7 +193,8 @@ jQuery( document ).ready( function() {
187
  'action': 'aj_steps',
188
  'sub_action': 'aj_apply_settings',
189
  'settings': settings,
190
- 'site_url': aj_localize_admin.siteurl
 
191
  };
192
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
193
  try {
@@ -237,7 +244,8 @@ jQuery( document ).ready( function() {
237
  'aj_jquery': aj_jquery,
238
  'aj_exclusions': aj_exclusions,
239
  'aj_autoptimize_enabled': aj_autoptimize_enabled,
240
- 'aj_autoptimize_method': aj_autoptimize_method
 
241
  };
242
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
243
  try {
@@ -280,6 +288,7 @@ jQuery( document ).ready( function() {
280
  });
281
 
282
  jQuery( document ).on( 'change', 'input[type=radio][name=aj_step4_check]', function() {
 
283
  var theSelection = jQuery( this ).val();
284
  if ( theSelection == 'y' ) {
285
  jQuery( '#aj_step4_y' ).show();
@@ -291,6 +300,7 @@ jQuery( document ).ready( function() {
291
  });
292
 
293
  jQuery( document ).on( 'click', '.aj_dismiss', function() {
294
- jQuery( '#aj_notification' ).fadeOut( 'slow' );
 
295
  });
296
  });
1
  function aj_step( theStep ) {
2
+ var aj_nonce = jQuery( '#aj_nonce' ).val();
3
  var aj_gtmetrix_username = jQuery( '#aj_gtmetrix_username' ).val();
4
  var aj_gtmetrix_api_key = jQuery( '#aj_gtmetrix_api_key' ).val();
5
  var aj_gtmetrix_server = jQuery( '#aj_gtmetrix_server' ).val();
10
  'site_url': aj_localize_admin.siteurl,
11
  'aj_gtmetrix_username': aj_gtmetrix_username,
12
  'aj_gtmetrix_api_key': aj_gtmetrix_api_key,
13
+ 'aj_gtmetrix_server': aj_gtmetrix_server,
14
+ 'security': aj_nonce
15
  };
16
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
17
  try {
69
  'site_url': aj_localize_admin.siteurl,
70
  'aj_gtmetrix_username': aj_gtmetrix_username,
71
  'aj_gtmetrix_api_key': aj_gtmetrix_api_key,
72
+ 'aj_gtmetrix_server': aj_gtmetrix_server,
73
+ 'security': aj_nonce
74
  };
75
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
76
  try {
161
  * functions and actions to load after document ready
162
  */
163
  jQuery( document ).ready( function() {
164
+
165
  jQuery( document ).on( 'click', '.aj-upgrade-notice .notice-dismiss', function() {
166
+ var aj_nonce = jQuery( '#aj_nonce' ).val();
167
  var notice_id = jQuery( '.aj-upgrade-notice' ).attr( 'data-id' );
168
  jQuery.ajax({
169
  url: aj.ajaxurl,
170
  data: {
171
+ 'action': 'async_javascript_dismiss_upgrade',
172
+ 'notice_id': notice_id,
173
+ 'security': aj_nonce
174
  }
175
  });
176
  });
177
 
178
  jQuery( document ).on( 'click', '.aj_steps_button', function(e) {
179
  e.preventDefault();
180
+ var aj_nonce = jQuery( '#aj_nonce' ).val();
181
  var theStep = jQuery( this ).attr( 'data-id' );
182
  if ( theStep == 'aj_goto_settings' ) {
183
  var newURL = aj_localize_admin.ajadminurl + '&tab=settings';
193
  'action': 'aj_steps',
194
  'sub_action': 'aj_apply_settings',
195
  'settings': settings,
196
+ 'site_url': aj_localize_admin.siteurl,
197
+ 'security': aj_nonce
198
  };
199
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
200
  try {
244
  'aj_jquery': aj_jquery,
245
  'aj_exclusions': aj_exclusions,
246
  'aj_autoptimize_enabled': aj_autoptimize_enabled,
247
+ 'aj_autoptimize_method': aj_autoptimize_method,
248
+ 'security': aj_nonce
249
  };
250
  jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
251
  try {
288
  });
289
 
290
  jQuery( document ).on( 'change', 'input[type=radio][name=aj_step4_check]', function() {
291
+ var aj_nonce = jQuery( '#aj_nonce' ).val();
292
  var theSelection = jQuery( this ).val();
293
  if ( theSelection == 'y' ) {
294
  jQuery( '#aj_step4_y' ).show();
300
  });
301
 
302
  jQuery( document ).on( 'click', '.aj_dismiss', function() {
303
+ var aj_nonce = jQuery( '#aj_nonce' ).val();
304
+ jQuery( '#aj_notification' ).fadeOut( 'slow' );
305
  });
306
  });
js/admin.min.js CHANGED
@@ -1 +1 @@
1
- function aj_step(e){var t=jQuery("#aj_gtmetrix_username").val(),a=jQuery("#aj_gtmetrix_api_key").val(),s=jQuery("#aj_gtmetrix_server").val();if("aj_step_results"==e){var r={action:"aj_steps",sub_action:e,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:t,aj_gtmetrix_api_key:a,aj_gtmetrix_server:s};jQuery.post(aj_localize_admin.ajaxurl,r,function(e){try{if(e=jQuery.parseJSON(e),e.status!==!1){var t=e.baseline_pagespeed,a=e.baseline_yslow,s=e.results.pagespeed_score,r=e.results.yslow_score,_=e.name,i=parseFloat(e.results.fully_loaded_time/1e3).toFixed(2),j=e.url;jQuery(".aj_gtmetrix_config").html(_),s>t?jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase"):t>s?jQuery("#aj_gtmetrix_inde_pagespeed").html("a decrease"):jQuery("#aj_gtmetrix_inde_pagespeed").html("no change"),r>a?jQuery("#aj_gtmetrix_inde_yslow").html("an increase"):a>r?jQuery("#aj_gtmetrix_inde_yslow").html("a decrease"):jQuery("#aj_gtmetrix_inde_yslow").html("no change"),jQuery("#aj_gtmetrix_baseline_pagespeed").html(t+"%"),jQuery("#aj_gtmetrix_best_pagespeed").html(s+"%"),jQuery("#aj_gtmetrix_baseline_yslow").html(a+"%"),jQuery("#aj_gtmetrix_best_yslow").html(r+"%"),jQuery("#aj_gtmetrix_best_fullyloaded").html(i+"s"),jQuery("#aj_gtmetrix_best_url").attr("href",j).html(j),"aj_step2b"==e.id||"aj_step2c"==e.id?(jQuery("#aj_step4_jquery_excluded").hide(),jQuery("#aj_step4_jquery_not_excluded").show()):("aj_step2d"==e.id||"aj_step2e"==e.id)&&(jQuery("#aj_step4_jquery_excluded").show(),jQuery("#aj_step4_jquery_not_excluded").hide()),jQuery(".aj_gtmetrix_credits").html(e.credits),jQuery("#aj_step_results").show()}else console.log(e)}catch(l){console.log(l)}})}else{var r={action:"aj_steps",sub_action:e,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:t,aj_gtmetrix_api_key:a,aj_gtmetrix_server:s};jQuery.post(aj_localize_admin.ajaxurl,r,function(s){try{if(s=jQuery.parseJSON(s),s.status!==!1){var r=s.results.report_url+"/screenshot.jpg",_=s.results.pagespeed_score,i=s.results.yslow_score,j=parseFloat(s.results.fully_loaded_time/1e3).toFixed(2),l=Math.floor(s.results.page_bytes/1024),o=s.results.page_elements,u='<a href="'+s.results.report_url+'" target="_blank">'+s.results.report_url+"</a>",n=u.replace("https://","https://"+t+":"+a+"@"),p=s.name,y=s.url,d=255*(1-_/100),c=255*(1-i/100),m=255*(_/100),Q=255*(i/100),h="rgb("+Math.floor(d)+","+Math.floor(m)+",0 )",g="rgb("+Math.floor(c)+","+Math.floor(Q)+",0 )";"aj_gtmetrix_test"==e&&(e="aj_latest"),jQuery("#"+e+"_please_wait").hide(),jQuery("."+e+"_screenshot").attr("src",r),jQuery("."+e+"_pagespeed").html(_+"%").css({color:h}),jQuery("."+e+"_yslow").html(i+"%").css({color:g}),jQuery("."+e+"_flt").html(j+"s"),jQuery("."+e+"_tps").html(l+"KB"),jQuery("."+e+"_requests").html(o),jQuery("."+e+"_report").html(n),jQuery("#"+e+"_gtmetrix_results").show(),jQuery("."+e+"_gtmetrix").html(p),jQuery("."+e+"_url").attr("href",y).html(y),jQuery(".aj_gtmetrix_credits").html(s.credits),"aj_step2"==e?(jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'),jQuery("#aj_step2b").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2b").offset().top},1e3),aj_step("aj_step2b")):"aj_step2b"==e?(jQuery("#aj_step2c").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2c").offset().top},1e3),aj_step("aj_step2c")):"aj_step2c"==e?(jQuery("#aj_step2d").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2d").offset().top},1e3),aj_step("aj_step2d")):"aj_step2d"==e?(jQuery("#aj_step2e").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2e").offset().top},1e3),aj_step("aj_step2e")):"aj_step2e"==e?(jQuery("#aj_step_results").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step_results").offset().top},1e3),aj_step("aj_step_results")):"aj_latest"==e&&(jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'),jQuery("#aj_latest_gtmetrix_results").show(),jQuery("#aj_latest_please_wait").hide(),jQuery("html, body").animate({scrollTop:jQuery("#aj_latest_please_wait").offset().top},1e3))}else console.log(s)}catch(f){console.log(f)}})}}jQuery(document).ready(function(){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}})}),jQuery(document).on("click",".aj_steps_button",function(e){e.preventDefault();var t=jQuery(this).attr("data-id");if("aj_goto_settings"==t){var a=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=a}else if("aj_apply_settings"==t||"aj_step2b_apply"==t||"aj_step2c_apply"==t||"aj_step2d_apply"==t||"aj_step2e_apply"==t){if("aj_apply_settings"!=t)var s=t.replace("_apply","");else{var s="";jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>')}var r={action:"aj_steps",sub_action:"aj_apply_settings",settings:s,site_url:aj_localize_admin.siteurl};jQuery.post(aj_localize_admin.ajaxurl,r,function(e){try{e=jQuery.parseJSON(e),e.status!==!1?(jQuery("#aj_step5").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step5").offset().top},1e3),""!=s&&jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>')):console.log(e)}catch(t){console.log(t)}})}else if("aj_save_settings"==t){if(jQuery("#aj_enabled").is(":checked"))var _=1;else var _=0;var i=jQuery("input[type=radio][name=aj_method]:checked").val(),j=jQuery("input[type=radio][name=aj_jquery]:checked").val(),l=jQuery("#aj_exclusions").val();if(jQuery("#aj_autoptimize_enabled").is(":visible"))if(jQuery("#aj_autoptimize_enabled").is(":checked"))var o=1,u=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else var o=0,u=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else var o=0,u="async";var r={action:"aj_steps",sub_action:"aj_save_settings",aj_enabled:_,aj_method:i,aj_jquery:j,aj_exclusions:l,aj_autoptimize_enabled:o,aj_autoptimize_method:u};jQuery.post(aj_localize_admin.ajaxurl,r,function(e){try{e=jQuery.parseJSON(e),e.status!==!1?jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'):console.log(e)}catch(t){console.log(t)}})}else{var n=jQuery("#aj_gtmetrix_username").val(),p=jQuery("#aj_gtmetrix_api_key").val(),y=(jQuery("#aj_gtmetrix_server").val(),!1);if(""==n&&(jQuery("#aj_gtmetrix_username").addClass("aj_field_error"),y=!0),""==p&&(jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error"),y=!0),y!==!1)return!1;"aj_gtmetrix_test"!=t?(jQuery(this).hide(),jQuery("#"+t).show()):jQuery("#aj_latest_please_wait").show(),aj_step(t)}}),jQuery(document).on("change","input[type=radio][name=aj_step4_check]",function(){var e=jQuery(this).val();"y"==e?(jQuery("#aj_step4_y").show(),jQuery("#aj_step4_n").hide()):(jQuery("#aj_step4_n").show(),jQuery("#aj_step4_y").hide())}),jQuery(document).on("click",".aj_dismiss",function(){jQuery("#aj_notification").fadeOut("slow")})});
1
+ function aj_step(e){var t=jQuery("#aj_nonce").val(),a=jQuery("#aj_gtmetrix_username").val(),s=jQuery("#aj_gtmetrix_api_key").val(),r=jQuery("#aj_gtmetrix_server").val();if("aj_step_results"==e){var _={action:"aj_steps",sub_action:e,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:a,aj_gtmetrix_api_key:s,aj_gtmetrix_server:r,security:t};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{if(e=jQuery.parseJSON(e),e.status!==!1){var t=e.baseline_pagespeed,a=e.baseline_yslow,s=e.results.pagespeed_score,r=e.results.yslow_score,_=e.name,i=parseFloat(e.results.fully_loaded_time/1e3).toFixed(2),j=e.url;jQuery(".aj_gtmetrix_config").html(_),s>t?jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase"):t>s?jQuery("#aj_gtmetrix_inde_pagespeed").html("a decrease"):jQuery("#aj_gtmetrix_inde_pagespeed").html("no change"),r>a?jQuery("#aj_gtmetrix_inde_yslow").html("an increase"):a>r?jQuery("#aj_gtmetrix_inde_yslow").html("a decrease"):jQuery("#aj_gtmetrix_inde_yslow").html("no change"),jQuery("#aj_gtmetrix_baseline_pagespeed").html(t+"%"),jQuery("#aj_gtmetrix_best_pagespeed").html(s+"%"),jQuery("#aj_gtmetrix_baseline_yslow").html(a+"%"),jQuery("#aj_gtmetrix_best_yslow").html(r+"%"),jQuery("#aj_gtmetrix_best_fullyloaded").html(i+"s"),jQuery("#aj_gtmetrix_best_url").attr("href",j).html(j),"aj_step2b"==e.id||"aj_step2c"==e.id?(jQuery("#aj_step4_jquery_excluded").hide(),jQuery("#aj_step4_jquery_not_excluded").show()):("aj_step2d"==e.id||"aj_step2e"==e.id)&&(jQuery("#aj_step4_jquery_excluded").show(),jQuery("#aj_step4_jquery_not_excluded").hide()),jQuery(".aj_gtmetrix_credits").html(e.credits),jQuery("#aj_step_results").show()}else console.log(e)}catch(l){console.log(l)}})}else{var _={action:"aj_steps",sub_action:e,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:a,aj_gtmetrix_api_key:s,aj_gtmetrix_server:r,security:t};jQuery.post(aj_localize_admin.ajaxurl,_,function(t){try{if(t=jQuery.parseJSON(t),t.status!==!1){var r=t.results.report_url+"/screenshot.jpg",_=t.results.pagespeed_score,i=t.results.yslow_score,j=parseFloat(t.results.fully_loaded_time/1e3).toFixed(2),l=Math.floor(t.results.page_bytes/1024),o=t.results.page_elements,u='<a href="'+t.results.report_url+'" target="_blank">'+t.results.report_url+"</a>",n=u.replace("https://","https://"+a+":"+s+"@"),p=t.name,y=t.url,c=255*(1-_/100),d=255*(1-i/100),m=255*(_/100),Q=255*(i/100),h="rgb("+Math.floor(c)+","+Math.floor(m)+",0 )",g="rgb("+Math.floor(d)+","+Math.floor(Q)+",0 )";"aj_gtmetrix_test"==e&&(e="aj_latest"),jQuery("#"+e+"_please_wait").hide(),jQuery("."+e+"_screenshot").attr("src",r),jQuery("."+e+"_pagespeed").html(_+"%").css({color:h}),jQuery("."+e+"_yslow").html(i+"%").css({color:g}),jQuery("."+e+"_flt").html(j+"s"),jQuery("."+e+"_tps").html(l+"KB"),jQuery("."+e+"_requests").html(o),jQuery("."+e+"_report").html(n),jQuery("#"+e+"_gtmetrix_results").show(),jQuery("."+e+"_gtmetrix").html(p),jQuery("."+e+"_url").attr("href",y).html(y),jQuery(".aj_gtmetrix_credits").html(t.credits),"aj_step2"==e?(jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'),jQuery("#aj_step2b").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2b").offset().top},1e3),aj_step("aj_step2b")):"aj_step2b"==e?(jQuery("#aj_step2c").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2c").offset().top},1e3),aj_step("aj_step2c")):"aj_step2c"==e?(jQuery("#aj_step2d").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2d").offset().top},1e3),aj_step("aj_step2d")):"aj_step2d"==e?(jQuery("#aj_step2e").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2e").offset().top},1e3),aj_step("aj_step2e")):"aj_step2e"==e?(jQuery("#aj_step_results").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step_results").offset().top},1e3),aj_step("aj_step_results")):"aj_latest"==e&&(jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'),jQuery("#aj_latest_gtmetrix_results").show(),jQuery("#aj_latest_please_wait").hide(),jQuery("html, body").animate({scrollTop:jQuery("#aj_latest_please_wait").offset().top},1e3))}else console.log(t)}catch(f){console.log(f)}})}}jQuery(document).ready(function(){jQuery(document).on("click",".aj-upgrade-notice .notice-dismiss",function(){var e=jQuery("#aj_nonce").val(),t=jQuery(".aj-upgrade-notice").attr("data-id");jQuery.ajax({url:aj.ajaxurl,data:{action:"async_javascript_dismiss_upgrade",notice_id:t,security:e}})}),jQuery(document).on("click",".aj_steps_button",function(e){e.preventDefault();var t=jQuery("#aj_nonce").val(),a=jQuery(this).attr("data-id");if("aj_goto_settings"==a){var s=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=s}else if("aj_apply_settings"==a||"aj_step2b_apply"==a||"aj_step2c_apply"==a||"aj_step2d_apply"==a||"aj_step2e_apply"==a){if("aj_apply_settings"!=a)var r=a.replace("_apply","");else{var r="";jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>')}var _={action:"aj_steps",sub_action:"aj_apply_settings",settings:r,site_url:aj_localize_admin.siteurl,security:t};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{e=jQuery.parseJSON(e),e.status!==!1?(jQuery("#aj_step5").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step5").offset().top},1e3),""!=r&&jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>')):console.log(e)}catch(t){console.log(t)}})}else if("aj_save_settings"==a){if(jQuery("#aj_enabled").is(":checked"))var i=1;else var i=0;var j=jQuery("input[type=radio][name=aj_method]:checked").val(),l=jQuery("input[type=radio][name=aj_jquery]:checked").val(),o=jQuery("#aj_exclusions").val();if(jQuery("#aj_autoptimize_enabled").is(":visible"))if(jQuery("#aj_autoptimize_enabled").is(":checked"))var u=1,n=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else var u=0,n=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else var u=0,n="async";var _={action:"aj_steps",sub_action:"aj_save_settings",aj_enabled:i,aj_method:j,aj_jquery:l,aj_exclusions:o,aj_autoptimize_enabled:u,aj_autoptimize_method:n,security:t};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{e=jQuery.parseJSON(e),e.status!==!1?jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'):console.log(e)}catch(t){console.log(t)}})}else{var p=jQuery("#aj_gtmetrix_username").val(),y=jQuery("#aj_gtmetrix_api_key").val(),c=(jQuery("#aj_gtmetrix_server").val(),!1);if(""==p&&(jQuery("#aj_gtmetrix_username").addClass("aj_field_error"),c=!0),""==y&&(jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error"),c=!0),c!==!1)return!1;"aj_gtmetrix_test"!=a?(jQuery(this).hide(),jQuery("#"+a).show()):jQuery("#aj_latest_please_wait").show(),aj_step(a)}}),jQuery(document).on("change","input[type=radio][name=aj_step4_check]",function(){var e=(jQuery("#aj_nonce").val(),jQuery(this).val());"y"==e?(jQuery("#aj_step4_y").show(),jQuery("#aj_step4_n").hide()):(jQuery("#aj_step4_n").show(),jQuery("#aj_step4_y").hide())}),jQuery(document).on("click",".aj_dismiss",function(){jQuery("#aj_nonce").val();jQuery("#aj_notification").fadeOut("slow")})});