Async JavaScript - Version 2.18.04.23

Version Description

  • Re-arrange content on the different tabs of the settings page.
  • Continued refactoring of backend code, no functionality should be affected.
  • Remove all images from the project such as the animated hands and progress bar gif.
  • Remove empty rows that added unnecessary space.
  • Switch buttons to use WordPress button styles.
  • Fix broken Dashboard Widget from 2.18.03.15 and reduce font-size to fix text overflow.
  • Remove all CSS !important declarations for easier CSS styling.
  • Remove inline CSS styles.
  • Switch to a CSS based progress bar.
  • Spell check readme.
  • Remove almost all tables from files.
  • Refactor JavaScript.
  • Add wormeyman as a contributor (thanks man!).
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 Async JavaScript
Version 2.18.04.23
Comparing to
See all releases

Code changes from version 2.18.03.15 to 2.18.04.23

async-javascript.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Async JavaScript
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Async JavaScript gives you full control of which scripts to add a 'async' or 'defer' attribute to or to exclude to help increase the performance of your WordPress website
6
- * Version: 2.18.03.15
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: asyncjs
3
  * Plugin Name: Async JavaScript
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Async JavaScript gives you full control of which scripts to add a 'async' or 'defer' attribute to or to exclude to help increase the performance of your WordPress website
6
+ * Version: 2.18.04.23
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: asyncjs
asyncjsAllAjax.php CHANGED
@@ -408,7 +408,7 @@ if ( !isset( $_POST['sub_action'] ) ) {
408
 
409
  if( is_null( $return ) ) {
410
  $return = array(
411
- 'status' => false
412
  );
413
  }
414
 
408
 
409
  if( is_null( $return ) ) {
410
  $return = array(
411
+ 'status' => false
412
  );
413
  }
414
 
asyncjsBackendClass.php CHANGED
@@ -3,9 +3,9 @@ if ( ! defined( 'ABSPATH' ) ) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
- /*
7
  * Backend logic: kicking in admin logic, screens & Ajax
8
- *
9
  */
10
 
11
  class AsyncJavaScriptBackend {
@@ -17,7 +17,7 @@ class AsyncJavaScriptBackend {
17
  define( 'AJ_ADMIN_URL', trailingslashit( admin_url() ) );
18
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
19
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
20
- define( 'AJ_VERSION', '2.18.03.10' );
21
  define( 'AJ_UA', 'Async JavaScript/' . AJ_VERSION . ' (+https://autoptimize.com/)' );
22
  add_action( 'plugins_loaded', array( $this, 'aj_admin_init' ) );
23
  add_action( 'admin_init', array( $this, 'aj_disable_pro' ) );
@@ -25,7 +25,7 @@ class AsyncJavaScriptBackend {
25
 
26
  /**
27
  * the plugin instance
28
- *
29
  */
30
  private static $instance = NULL;
31
 
@@ -43,7 +43,7 @@ class AsyncJavaScriptBackend {
43
 
44
  /**
45
  * aj_activate()
46
- *
47
  */
48
  public static function aj_activate() {
49
 
@@ -51,17 +51,17 @@ class AsyncJavaScriptBackend {
51
 
52
  /**
53
  * plugin deactivate
54
- *
55
  */
56
  public static function aj_deactivate() {
57
-
58
  }
59
 
60
  /**
61
  * plugin uninstaller
62
- *
63
  * removes (hopefully all) options
64
- *
65
  */
66
  public static function aj_uninstall() {
67
  $optionsToRemove = array('aj_async','aj_autoptimize_enabled','aj_autoptimize_method','aj_defer','aj_enabled','aj_exclusions','aj_gtmetrix_api_key','aj_gtmetrix_results','aj_gtmetrix_server','aj_gtmetrix_username','aj_jquery','aj_method','aj_plugin_exclusions','aj_theme_exclusions','aj_version');
@@ -85,7 +85,7 @@ class AsyncJavaScriptBackend {
85
  * register admin stylesheets and javascripts
86
  *
87
  */
88
- public function aj_enqueue_scripts() {
89
  // chosen
90
  wp_enqueue_style('chosen', plugins_url( 'assets/lib/chosen/chosen.min.css', __FILE__ ));
91
  wp_enqueue_script('chosen', plugins_url( 'assets/lib/chosen/chosen.jquery.min.js', __FILE__ ), array( 'jquery' ), AJ_VERSION, true);
@@ -126,11 +126,11 @@ class AsyncJavaScriptBackend {
126
  global $wp, $wpdb;
127
  register_activation_hook( __FILE__, array( $this, 'aj_activate' ) );
128
  register_deactivation_hook( __FILE__, array( $this, 'aj_deactivate' ) );
129
-
130
  if ( !class_exists( 'Services_WTF_Test' ) ) {
131
  require_once( AJ_PLUGIN_DIR . 'lib/gtmetrix/class.Services_WTF_Test.php' );
132
  }
133
-
134
  // check if upgrading from early release so settings can be transferred
135
  $aj_version = get_option( 'aj_version', '' );
136
  if ( $aj_version == '' || $aj_version < '2017.04.25' ) {
@@ -155,12 +155,13 @@ class AsyncJavaScriptBackend {
155
  update_option( 'aj_autoptimize_enabled', $aj_autoptimize_enabled );
156
  update_option( 'aj_autoptimize_method', $aj_autoptimize_method );
157
  }
158
-
159
  if ( $aj_version != AJ_VERSION ) {
160
  update_option( 'aj_version', AJ_VERSION );
161
  }
162
-
163
  add_action( 'wp_dashboard_setup', array( $this, 'register_aj_dashboard_widget' ) );
 
164
  add_action( 'admin_menu', array( $this, 'async_javascript_menu' ) );
165
  add_action( 'wp_ajax_aj_steps', array( $this, 'aj_steps' ) );
166
  add_action( 'admin_notices', array( $this, 'aj_admin_notice' ) );
@@ -286,7 +287,7 @@ class AsyncJavaScriptBackend {
286
  $return = '';
287
  $return .= '<p>'.__('When a JavaScript file is loaded via the <strong><a href="https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts" target="_blank">wp_enqueue_script</a></strong> function, ' . AJ_TITLE . ' will add an <strong>async</strong> or <strong>defer</strong> attribute.','asyncjs').'</p>';
288
  $return .= '<p>'.__('There are several ways an external JavaScript file can be executed:','asyncjs').'</p>';
289
- $return .= '<ul style="list-style:disc inside;">';
290
  $return .= '<li>'.__('If <strong>async</strong> is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)</li>','asyncjs');
291
  $return .= '<li>'.__('If <strong>defer</strong> is present and <strong>async</strong> is not present: The script is executed when the page has finished parsing</li>','asyncjs');
292
  $return .= '<li>'.__('If neither <strong>async</strong> or <strong>defer</strong> is present: The script is fetched and executed immediately, before the browser continues parsing the page</li>','asyncjs');
@@ -294,7 +295,7 @@ class AsyncJavaScriptBackend {
294
  $return .= '<p>'.__('Using <strong>async</strong> or <strong>defer</strong> helps to eliminate render-blocking JavaScript in above-the-fold content. This can also help to increase your pagespeed which in turn can assist in improving your page ranking.</p>','asyncjs');
295
  return $return;
296
  }
297
-
298
  /**
299
  * hints_tips()
300
  *
@@ -335,7 +336,7 @@ class AsyncJavaScriptBackend {
335
  $return .= '</ol>';
336
  return $return;
337
  }
338
-
339
  /**
340
  * aj_steps()
341
  *
3
  exit; // Exit if accessed directly
4
  }
5
 
6
+ /*
7
  * Backend logic: kicking in admin logic, screens & Ajax
8
+ *
9
  */
10
 
11
  class AsyncJavaScriptBackend {
17
  define( 'AJ_ADMIN_URL', trailingslashit( admin_url() ) );
18
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
19
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
20
+ define( 'AJ_VERSION', '3.18.04.23' );
21
  define( 'AJ_UA', 'Async JavaScript/' . AJ_VERSION . ' (+https://autoptimize.com/)' );
22
  add_action( 'plugins_loaded', array( $this, 'aj_admin_init' ) );
23
  add_action( 'admin_init', array( $this, 'aj_disable_pro' ) );
25
 
26
  /**
27
  * the plugin instance
28
+ *
29
  */
30
  private static $instance = NULL;
31
 
43
 
44
  /**
45
  * aj_activate()
46
+ *
47
  */
48
  public static function aj_activate() {
49
 
51
 
52
  /**
53
  * plugin deactivate
54
+ *
55
  */
56
  public static function aj_deactivate() {
57
+
58
  }
59
 
60
  /**
61
  * plugin uninstaller
62
+ *
63
  * removes (hopefully all) options
64
+ *
65
  */
66
  public static function aj_uninstall() {
67
  $optionsToRemove = array('aj_async','aj_autoptimize_enabled','aj_autoptimize_method','aj_defer','aj_enabled','aj_exclusions','aj_gtmetrix_api_key','aj_gtmetrix_results','aj_gtmetrix_server','aj_gtmetrix_username','aj_jquery','aj_method','aj_plugin_exclusions','aj_theme_exclusions','aj_version');
85
  * register admin stylesheets and javascripts
86
  *
87
  */
88
+ public function aj_enqueue_scripts() {
89
  // chosen
90
  wp_enqueue_style('chosen', plugins_url( 'assets/lib/chosen/chosen.min.css', __FILE__ ));
91
  wp_enqueue_script('chosen', plugins_url( 'assets/lib/chosen/chosen.jquery.min.js', __FILE__ ), array( 'jquery' ), AJ_VERSION, true);
126
  global $wp, $wpdb;
127
  register_activation_hook( __FILE__, array( $this, 'aj_activate' ) );
128
  register_deactivation_hook( __FILE__, array( $this, 'aj_deactivate' ) );
129
+
130
  if ( !class_exists( 'Services_WTF_Test' ) ) {
131
  require_once( AJ_PLUGIN_DIR . 'lib/gtmetrix/class.Services_WTF_Test.php' );
132
  }
133
+
134
  // check if upgrading from early release so settings can be transferred
135
  $aj_version = get_option( 'aj_version', '' );
136
  if ( $aj_version == '' || $aj_version < '2017.04.25' ) {
155
  update_option( 'aj_autoptimize_enabled', $aj_autoptimize_enabled );
156
  update_option( 'aj_autoptimize_method', $aj_autoptimize_method );
157
  }
158
+
159
  if ( $aj_version != AJ_VERSION ) {
160
  update_option( 'aj_version', AJ_VERSION );
161
  }
162
+
163
  add_action( 'wp_dashboard_setup', array( $this, 'register_aj_dashboard_widget' ) );
164
+ add_action( 'wp_dashboard_setup', array( $this, 'aj_enqueue_scripts' ) );
165
  add_action( 'admin_menu', array( $this, 'async_javascript_menu' ) );
166
  add_action( 'wp_ajax_aj_steps', array( $this, 'aj_steps' ) );
167
  add_action( 'admin_notices', array( $this, 'aj_admin_notice' ) );
287
  $return = '';
288
  $return .= '<p>'.__('When a JavaScript file is loaded via the <strong><a href="https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts" target="_blank">wp_enqueue_script</a></strong> function, ' . AJ_TITLE . ' will add an <strong>async</strong> or <strong>defer</strong> attribute.','asyncjs').'</p>';
289
  $return .= '<p>'.__('There are several ways an external JavaScript file can be executed:','asyncjs').'</p>';
290
+ $return .= '<ul>';
291
  $return .= '<li>'.__('If <strong>async</strong> is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)</li>','asyncjs');
292
  $return .= '<li>'.__('If <strong>defer</strong> is present and <strong>async</strong> is not present: The script is executed when the page has finished parsing</li>','asyncjs');
293
  $return .= '<li>'.__('If neither <strong>async</strong> or <strong>defer</strong> is present: The script is fetched and executed immediately, before the browser continues parsing the page</li>','asyncjs');
295
  $return .= '<p>'.__('Using <strong>async</strong> or <strong>defer</strong> helps to eliminate render-blocking JavaScript in above-the-fold content. This can also help to increase your pagespeed which in turn can assist in improving your page ranking.</p>','asyncjs');
296
  return $return;
297
  }
298
+
299
  /**
300
  * hints_tips()
301
  *
336
  $return .= '</ol>';
337
  return $return;
338
  }
339
+
340
  /**
341
  * aj_steps()
342
  *
asyncjsDashboardScreens.php CHANGED
@@ -102,6 +102,6 @@ $aj_autoptimize_method = ( get_option( 'aj_autoptimize_method', 'async' ) == 'as
102
  }
103
  ?>
104
  <p><?php _e('Please click on the Settings button below to generate a new GTmetrix Report.','asyncjs'); ?></p>
105
- <p><button data-id="aj_goto_settings" class="aj_steps_button"><?php _e('Settings','asyncjs'); ?></button></p>
106
  </div>
107
  <?php
102
  }
103
  ?>
104
  <p><?php _e('Please click on the Settings button below to generate a new GTmetrix Report.','asyncjs'); ?></p>
105
+ <p><button data-id="aj_goto_settings" class="aj_steps_button button"><?php _e('Settings','asyncjs'); ?></button></p>
106
  </div>
107
  <?php
asyncjsFrontendClass.php CHANGED
@@ -3,10 +3,10 @@ if ( ! defined( 'ABSPATH' ) ) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
- /*
7
  * Frontend logic: add script attribute & change Autoptimize JS attrib if applicable
8
  */
9
-
10
  class AsyncJavaScriptFrontend {
11
  function __construct() {
12
  add_filter( 'script_loader_tag', array( $this, 'aj_async_js' ), 20, 3 );
@@ -33,9 +33,9 @@ class AsyncJavaScriptFrontend {
33
  /**
34
  * aj_async_js()
35
  *
36
- * Main frontend function; adds 'async' or 'defer' attribute to '<script>' tasks called
37
  * via wp_enqueue_script using the 'script_loader_tag' filter
38
- *
39
  */
40
  public function aj_async_js( $tag, $handle, $src ) {
41
  if ( isset( $_GET['aj_simulate'] ) ) {
@@ -129,7 +129,7 @@ class AsyncJavaScriptFrontend {
129
  }
130
  return $tag;
131
  }
132
-
133
  /**
134
  * aj_autoptimize_defer()
135
  *
3
  exit; // Exit if accessed directly
4
  }
5
 
6
+ /*
7
  * Frontend logic: add script attribute & change Autoptimize JS attrib if applicable
8
  */
9
+
10
  class AsyncJavaScriptFrontend {
11
  function __construct() {
12
  add_filter( 'script_loader_tag', array( $this, 'aj_async_js' ), 20, 3 );
33
  /**
34
  * aj_async_js()
35
  *
36
+ * Main frontend function; adds 'async' or 'defer' attribute to '<script>' tasks called
37
  * via wp_enqueue_script using the 'script_loader_tag' filter
38
+ *
39
  */
40
  public function aj_async_js( $tag, $handle, $src ) {
41
  if ( isset( $_GET['aj_simulate'] ) ) {
129
  }
130
  return $tag;
131
  }
132
+
133
  /**
134
  * aj_autoptimize_defer()
135
  *
asyncjsHelpScreens.php CHANGED
@@ -1,42 +1,49 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
  exit; // Exit if accessed directly
4
  }
5
  ?>
6
- <table class="form-table" width="100%" cellpadding="10">
7
- <tr>
8
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/stick_figure_panicking_150_clr_13267.gif" title="Help &amp; Support" alt="Help &amp; Support" class="aj_step_img"></td>
9
- <td scope="row" align="left" style="vertical-align: top !important;">
10
- <h3><?php _e('Help &amp; Support','asyncjs'); ?></h3>
11
- <p style="font-size: 0.7em;"><strong><?php _e('Installed Version: ','asyncjs'); ?></strong><?php echo AJ_VERSION; ?></p>
12
- <p><?php _e('Below are some answers to some frequently asked questions about ','asyncjs'); ?> <?php echo AJ_TITLE; ?></p>
13
- <hr />
14
- <h3><?php _e("Which browsers support the 'async' and 'defer' attributes?",'asyncjs'); ?></h3>
15
- <p><?php _e("The 'async' attribute is new in HTML5. It is supported by the following browsers:",'asyncjs'); ?></p>
16
- <ul>
17
- <li>Chrome</li>
18
- <li>IE 10 <?php _e('and higher','asyncjs'); ?></li>
19
- <li>Firefox 3.6 <?php _e('and higher','asyncjs'); ?></li>
20
- <li>Safari</li>
21
- <li>Opera</li>
22
- </ul>
23
- <hr />
24
- <h3><?php _e('Where can I get help?','asyncjs'); ?></h3>
25
- <p><?php echo AJ_TITLE; ?> <?php _e('is supported exclusively via the wordpress.org support forum','asyncjs'); ?> <a href="https://wordpress.org/support/plugin/async-javascript" target="_blank">https://wordpress.org/support/plugin/async-javascript</a></p>
26
- <hr />
27
- <h3><?php _e('Do you provide premium support (configuration) or performance optimization services?','asyncjs'); ?></h3>
28
- <p><?php _e('We offer premium services for Async JavaScript and also perform full web performance optimization services. More info at ','asyncjs'); ?><a href="https://autoptimize.com/?utm=asyncjs" target="_blank">https://autoptimize.com/</a></p>
29
- <hr />
30
- <h3><?php _e('What about CSS?','asyncjs'); ?></h3>
31
- <p><?php _e('As the name implies, Async JavaScript is built to enhance JavaScript loading only. Async JavaScript does not have any impact on CSS.','asyncjs'); ?></p>
32
- <p><?php _e('We recommend using the awesome <a href="https://wordpress.org/plugins/autoptimize/" target="_blank">Autoptimize</a> plugin alongside Async JavaScript for CSS optimization.','asyncjs'); ?></p>
33
- <hr />
34
- <h3><?php _e('I want out, how should I remove Async JavaScript?','asyncjs'); ?></h3>
35
- <ul>
36
- <li><?php _e('Disable the plugin','asyncjs'); ?></li>
37
- <li><?php _e('Delete the plugin','asyncjs'); ?></li>
38
- </ul>
39
- </td>
40
- </tr>
41
- </table>
42
- <?php
 
 
 
 
 
 
 
1
  <?php
2
+ if (! defined('ABSPATH')) {
3
  exit; // Exit if accessed directly
4
  }
5
  ?>
6
+
7
+ <div class="asItemDetail">
8
+ <h3><?php echo AJ_TITLE; ?></h3>
9
+ <?php echo $this->about_aj(); ?>
10
+ </div>
11
+ <div class="asItemDetail">
12
+ <h3><?php _e('Help &amp; Support', 'asyncjs'); ?></h3>
13
+ <p><strong><?php _e('Installed Version: ', 'asyncjs'); ?></strong><?php echo AJ_VERSION; ?></p>
14
+ <p><?php _e('Below are some answers to some frequently asked questions about ', 'asyncjs'); ?> <?php echo AJ_TITLE; ?></p>
15
+ </div>
16
+ <div class="asItemDetail">
17
+ <h3><?php _e("Which browsers support the 'async' and 'defer' attributes?", 'asyncjs'); ?></h3>
18
+ <p><?php _e("The 'async' attribute is new in HTML5. It is supported by the following browsers:", 'asyncjs'); ?></p>
19
+ <ul>
20
+ <li>Chrome</li>
21
+ <li>IE 10 <?php _e('and higher', 'asyncjs'); ?></li>
22
+ <li>Firefox 3.6 <?php _e('and higher', 'asyncjs'); ?></li>
23
+ <li>Safari</li>
24
+ <li>Opera</li>
25
+ </ul>
26
+ </div>
27
+ <div class="asItemDetail">
28
+ <h3><?php _e('Where can I get help?', 'asyncjs'); ?></h3>
29
+ <p><?php echo AJ_TITLE; ?> <?php _e('is supported exclusively via the wordpress.org support forum', 'asyncjs'); ?> <a href="https://wordpress.org/support/plugin/async-javascript" target="_blank">https://wordpress.org/support/plugin/async-javascript</a></p>
30
+ </div>
31
+ <div class="asItemDetail">
32
+ <h3><?php _e('Do you provide premium support (configuration) or performance optimization services?', 'asyncjs'); ?></h3>
33
+ <p><?php _e('We offer premium services for Async JavaScript and also perform full web performance optimization services. More info at ', 'asyncjs'); ?><a href="https://autoptimize.com/?utm=asyncjs" target="_blank">https://autoptimize.com/</a></p>
34
+ </div>
35
+ <div class="asItemDetail">
36
+ <h3><?php _e('What about CSS?', 'asyncjs'); ?></h3>
37
+ <p><?php _e('As the name implies, Async JavaScript is built to enhance JavaScript loading only. Async JavaScript does not have any impact on CSS.', 'asyncjs'); ?></p>
38
+ <p><?php _e('We recommend using the awesome <a href="https://wordpress.org/plugins/autoptimize/" target="_blank">Autoptimize</a> plugin alongside Async JavaScript for CSS optimization.', 'asyncjs'); ?></p>
39
+ </div>
40
+ <div class="asItemDetail">
41
+ <h3><?php _e('I want out, how should I remove Async JavaScript?', 'asyncjs'); ?></h3>
42
+ <ul>
43
+ <li><?php _e('Disable the plugin', 'asyncjs'); ?></li>
44
+ <li><?php _e('Delete the plugin', 'asyncjs'); ?></li>
45
+ </ul>
46
+ </div>
47
+ <div class="asItemDetail">
48
+ <?php echo $this->hints_tips(); ?>
49
+ </div>
asyncjsPartnersScreens.php CHANGED
@@ -27,7 +27,7 @@ if ( ! defined( 'ABSPATH' ) ) {
27
  margin-bottom:10px;
28
  }
29
  .itemImage {
30
- text-align: center;
31
  }
32
  .itemImage img {
33
  max-width: 95%;
@@ -52,7 +52,7 @@ if ( ! defined( 'ABSPATH' ) ) {
52
  .itemButton a:hover {
53
  text-decoration: none;
54
  color: #23282d;
55
- }
56
  </style>
57
  <?php
58
  echo '<h2>'. __("These related services can improve your site's performance even more!",'asyncjs') . '</h2>';
@@ -70,7 +70,7 @@ function getasyncJSPartnerFeed() {
70
  $maxitems = 0;
71
 
72
  if ( ! is_wp_error( $rss ) ) {
73
- $maxitems = $rss->get_item_quantity( 20 );
74
  $rss_items = $rss->get_items( 0, $maxitems );
75
  } ?>
76
  <ul>
@@ -78,7 +78,7 @@ function getasyncJSPartnerFeed() {
78
  if ( $maxitems == 0 ) {
79
  echo $noFeedText;
80
  } else {
81
- foreach ( $rss_items as $item ) :
82
  $itemURL = esc_url( $item->get_permalink() ); ?>
83
  <li class="itemDetail">
84
  <h3 class="itemTitle"><a href="<?php echo $itemURL; ?>" target="_blank"><?php echo esc_html( $item->get_title() ); ?></a></h3>
27
  margin-bottom:10px;
28
  }
29
  .itemImage {
30
+ text-align: center;
31
  }
32
  .itemImage img {
33
  max-width: 95%;
52
  .itemButton a:hover {
53
  text-decoration: none;
54
  color: #23282d;
55
+ }
56
  </style>
57
  <?php
58
  echo '<h2>'. __("These related services can improve your site's performance even more!",'asyncjs') . '</h2>';
70
  $maxitems = 0;
71
 
72
  if ( ! is_wp_error( $rss ) ) {
73
+ $maxitems = $rss->get_item_quantity( 20 );
74
  $rss_items = $rss->get_items( 0, $maxitems );
75
  } ?>
76
  <ul>
78
  if ( $maxitems == 0 ) {
79
  echo $noFeedText;
80
  } else {
81
+ foreach ( $rss_items as $item ) :
82
  $itemURL = esc_url( $item->get_permalink() ); ?>
83
  <li class="itemDetail">
84
  <h3 class="itemTitle"><a href="<?php echo $itemURL; ?>" target="_blank"><?php echo esc_html( $item->get_title() ); ?></a></h3>
asyncjsSettingsScreens.php CHANGED
@@ -1,151 +1,169 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
- $site_url = trailingslashit( get_site_url() );
7
- $aj_gtmetrix_username = get_option( 'aj_gtmetrix_username', '' );
8
- $aj_gtmetrix_api_key = get_option( 'aj_gtmetrix_api_key', '' );
9
- $aj_gtmetrix_server = get_option( 'aj_gtmetrix_server', '' );
10
- $aj_enabled = get_option( 'aj_enabled', 0 );
11
- $aj_enabled_checked = ( $aj_enabled == 1 ) ? ' checked="checked"' : '';
12
- $aj_method = get_option( 'aj_method', 'async' );
13
- $aj_method_async = ( $aj_method == 'async' ) ? ' checked="checked"' : '';
14
- $aj_method_defer = ( $aj_method == 'defer' ) ? ' checked="checked"' : '';
15
- $aj_jquery = get_option( 'aj_jquery', 'async' );
16
- $aj_jquery = ( $aj_jquery == 'same ' ) ? $aj_method : $aj_jquery;
17
- $aj_jquery_async = ( $aj_jquery == 'async' ) ? ' checked="checked"' : '';
18
- $aj_jquery_defer = ( $aj_jquery == 'defer' ) ? ' checked="checked"' : '';
19
- $aj_jquery_exclude = ( $aj_jquery == 'exclude' ) ? ' checked="checked"' : '';
20
- $aj_async = get_option( 'aj_async', '' );
21
- $aj_defer = get_option( 'aj_defer', '' );
22
- $aj_exclusions = get_option( 'aj_exclusions', '' );
23
- $aj_plugin_exclusions = ( is_array( get_option( 'aj_plugin_exclusions', array() ) ) && !is_null( get_option( 'aj_plugin_exclusions', array() ) ) ? get_option( 'aj_plugin_exclusions', array() ) : explode( ',', get_option( 'aj_plugin_exclusions', '' ) ) );
24
- $aj_theme_exclusions = ( is_array( get_option( 'aj_theme_exclusions', array() ) ) && !is_null( get_option( 'aj_theme_exclusions', array() ) ) ? get_option( 'aj_theme_exclusions', array() ) : explode( ',', get_option( 'aj_theme_exclusions', '' ) ) );
25
- $aj_autoptimize_enabled = get_option( 'aj_autoptimize_enabled', 0 );
26
- $aj_autoptimize_enabled_checked = ( $aj_autoptimize_enabled == 1 ) ? ' checked="checked"' : '';
27
- $aj_autoptimize_method = get_option( 'aj_autoptimize_method', 'async' );
28
- $aj_autoptimize_async = ( $aj_autoptimize_method == 'async' ) ? ' checked="checked"' : '';
29
- $aj_autoptimize_defer = ( $aj_autoptimize_method == 'defer' ) ? ' checked="checked"' : '';
30
  ?>
31
- <table class="form-table" width="100%" cellpadding="10">
32
- <tr id="aj_intro">
33
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/finger_point_out_punch_hole_400_clr_17860.png" title="<?php echo AJ_TITLE; ?>" alt="<?php echo AJ_TITLE; ?>" class="aj_step_img"></td>
34
- <td scope="row" align="left" style="vertical-align: top !important;">
35
- <h3><?php echo AJ_TITLE; ?></h3>
36
- <?php echo $this->about_aj(); ?>
37
- </td>
38
- </tr>
39
- <tr id="aj_quick_settings">
40
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/clock_fast_times_text_10762.gif" title="Quick Settings" alt="Quick Settings" class="aj_step_img"></td>
41
- <td scope="row" align="left" style="vertical-align: top !important;">
42
- <h3><?php _e('Quick Settings','asyncjs'); ?></h3>
43
- <p><?php _e('Use the buttons below to apply common settings.','asyncjs'); ?></p>
44
- <p><?php _e('<strong>Note: </strong>Using the buttons below will erase any current settings within ','asyncjs'); ?><?php echo AJ_TITLE; ?>.</p>
45
- <p>
46
- <button data-id="aj_step2b_apply" class="aj_steps_button"><?php _e('Apply Async','asyncjs'); ?></button>
47
- <button data-id="aj_step2c_apply" class="aj_steps_button"><?php _e('Apply Defer','asyncjs'); ?></button>
48
- <button data-id="aj_step2d_apply" class="aj_steps_button"><?php _e('Apply Async','asyncjs'); _e(' (jQuery excluded)','asyncjs'); ?></button>
49
- <button data-id="aj_step2e_apply" class="aj_steps_button"><?php _e('Apply Defer','asyncjs'); _e(' (jQuery excluded)','asyncjs'); ?></button>
50
- </p>
51
- </td>
52
- </tr>
53
- <tr id="aj_settings_enable">
54
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/finger_point_out_punch_hole_400_clr_17860.png" title="Enable <?php echo AJ_TITLE; ?>" alt="Enable <?php echo AJ_TITLE; ?>" class="aj_step_img"></td>
55
- <td scope="row" align="left" style="vertical-align: top !important;">
56
- <h3><?php _e('Enable ','asyncjs'); ?><?php echo AJ_TITLE; ?></h3>
57
- <p><label><?php _e('Enable ','asyncjs'); ?><?php echo AJ_TITLE; ?>? </label><input type="checkbox" id="aj_enabled" id="aj_enabled" value="1" <?php echo $aj_enabled_checked; ?> /></p>
58
- <hr />
59
- <h3><?php echo AJ_TITLE; ?> Method</h3>
60
- <p><?php _e('Please select the method (<strong>async</strong> or <strong>defer</strong>) that you wish to enable:','asyncjs'); ?></p>
61
- <p><label><?php _e('Method: ','asyncjs'); ?></label><input type="radio" name="aj_method" value="async" <?php echo $aj_method_async; ?> /> Async <input type="radio" name="aj_method" value="defer" <?php echo $aj_method_defer; ?> /> Defer</p>
62
- <hr />
63
- <h3><?php _e('jQuery','asyncjs'); ?></h3>
64
- <p><?php _e('Often if jQuery is loaded with <strong>async</strong> or <strong>defer</strong> it can break some jQuery functions, specifically inline scripts which require jQuery to be loaded before the scripts are run. <strong><em>Sometimes</em></strong> choosing a different method (<strong>async</strong> or <strong>defer</strong>) will work, otherwise it may be necessary to exclude jQuery from having <strong>async</strong> or <strong>defer</strong> applied.','asyncjs'); ?></p>
65
- <p><label><?php _e('jQuery Method: ','asyncjs'); ?></label><input type="radio" name="aj_jquery" value="async" <?php echo $aj_jquery_async; ?> /> Async <input type="radio" name="aj_jquery" value="defer" <?php echo $aj_jquery_defer; ?> /> Defer <input type="radio" name="aj_jquery" value="exclude" <?php echo $aj_jquery_exclude; ?> /> <?php _e('Exclude','asyncjs'); ?></p>
66
- <hr />
67
- <h3><?php _e('Scripts to Async','asyncjs'); ?></h3>
68
- <p><?php _e("Please list any scripts which you would like to apply the 'async' attribute to. (comma seperated list eg: jquery.js,jquery-ui.js)",'asyncjs'); ?></p>
69
- <p><label><?php _e('Async Scripts:','asyncjs'); ?> </label><textarea id="aj_async" style="width:95%;"><?php echo $aj_async; ?></textarea></p>
70
- <hr />
71
- <h3><?php _e('Scripts to Defer','asyncjs'); ?></h3>
72
- <p><?php _e("Please list any scripts which you would like to apply the 'defer' attribute to. (comma seperated list eg: jquery.js,jquery-ui.js)",'asyncjs'); ?></p>
73
- <p><label><?php _e('Defer Scripts:','asyncjs'); ?> </label><textarea id="aj_defer" style="width:95%;"><?php echo $aj_defer; ?></textarea></p>
74
- <hr />
75
- <h3><?php _e('Script Exclusion','asyncjs'); ?></h3>
76
- <p><?php _e('Please list any scripts which you would like excluded from having <strong>async</strong> or <strong>defer</strong> applied during page load. (comma seperated list eg: jquery.js,jquery-ui.js)','asyncjs'); ?></p>
77
- <p><label><?php _e('Exclusions:','asyncjs'); ?> </label><textarea id="aj_exclusions" style="width:95%;"><?php echo $aj_exclusions; ?></textarea></p>
78
- <hr />
79
- <h3><?php _e('Plugin Exclusions','asyncjs'); ?></h3>
80
- <p><?php _e('Please select one or more plugins. Scripts contained within the plugin will not have async / defer applied.','asyncjs'); ?></p>
81
- <p><?php _e('<strong><em>Please Note:</em></strong> This will exclude any JavaScript files which are contained within the files of the selected Plugin(s). External JavaScripts loaded by the selected Plugin(s) are not affected.','asyncjs'); ?></p>
82
- <p><?php _e('For Example: If a plugin is installed in path <strong>/wp-content/plugins/some-plugin/</strong> then and JavaScripts contained within this path will be excluded. If the plugin loads a JavaScript which is countained elsewhere then the Global Method will be used (ie async or defer)','asyncjs'); ?></p>
83
- <p><label><?php _e('Exclusions: ','asyncjs'); ?></label>
84
- <?php
85
- $plugins = get_plugins();
86
- $output = '';
87
- if ( !empty( $plugins ) ) {
88
- $output .= '<select id="aj_plugin_exclusions" class="aj_chosen" multiple="multiple" style="min-width:50%;" >';
89
- foreach ( $plugins as $path=>$plugin ) {
90
- $split = explode( '/', $path );
91
- $text_domain = $split[0];
92
- if ( $text_domain != 'async-javascript' ) {
93
- //var_dump( $aj_plugin_exclusions );
94
- $selected = ( in_array( $text_domain, $aj_plugin_exclusions ) ) ? ' selected="selected"' : '';
95
- $output .= '<option value="' . $text_domain . '"' . $selected . '>' . $plugin['Name'] . '</option>';
96
- }
97
- }
98
- $output .= '</select>';
99
- } else {
100
- $output .= '<p>'.__('No plugins found.','asyncjs').'</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
- echo $output;
103
- ?>
104
- </p>
105
- <hr />
106
- <h3><?php _e('Theme Exclusions','asyncjs'); ?></h3>
107
- <p><?php _e('Please select one or more themes. Scripts contained within the theme will not have async / defer applied.','asyncjs'); ?></p>
108
- <p><?php _e('<strong><em>Please Note:</em></strong> This will exclude any JavaScript files which are contained within the files of the selected Theme(s). External JavaScripts loaded by the selected Theme(s) are not affected.','asyncjs'); ?></p>
109
- <p><?php _e('For Example: If a theme is installed in path <strong>/wp-content/themes/some-theme/</strong> then and JavaScripts contained within this path will be excluded. If the theme loads a JavaScript which is countained elsewhere then the Global Method will be used (ie async or defer)','asyncjs'); ?></p>
110
- <p>
111
- <label><?php _e('Exclusions:','asyncjs'); ?> </label>
112
- <?php
113
- $themes = wp_get_themes();
114
- $output = '';
115
- if ( !empty( $themes ) ) {
116
- $output .= '<select id="aj_theme_exclusions" class="aj_chosen" multiple="multiple" style="min-width:50%;" >';
117
- foreach ( $themes as $path=>$theme ) {
118
- $text_domain = $path;
119
- $selected = ( in_array( $text_domain, $aj_theme_exclusions ) ) ? ' selected="selected"' : '';
120
- $output .= '<option value="' . $text_domain . '"' . $selected . '>' . $theme->Name . '</option>';
121
- }
122
- $output .= '</select>';
123
- } else {
124
- $output .= '<p>'. __('No themes found.','asyncjs').'</p>';
125
- }
126
- echo $output;
127
  ?>
128
- </p>
129
- <hr />
130
- <h3><?php echo AJ_TITLE; ?> <?php _e('For Plugins','asyncjs'); ?></h3>
131
- <p><?php _e('Although not recommended, some themes / plugins can load JavaScript files without using the <strong><a href="https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts" target="_blank">wp_enqueue_script</a></strong> function. In some cases this is necessary for the functionality of the theme / plugin.','asyncjs'); ?></p>
132
- <p><?php _e('If these themes / plugins provide a hook that can be used to manipulate how the JavaScript file is loaded then <?php echo AJ_TITLE; ?> may be able to provide support for these themes / plugins.','asyncjs'); ?></p>
133
- <p><?php _e('If you have any active themes / plugins that <?php echo AJ_TITLE; ?> supports then these will be listed below.','asyncjs'); ?></p>
134
- <p><?php _e('If you think you have found a plugin that <?php echo AJ_TITLE; ?> may be able to provide support for please lodge a ticket at <a href="https://wordpress.org/support/plugin/async-javascript" target="_blank">https://wordpress.org/support/plugin/async-javascript</a>','asyncjs'); ?></p>
135
- <?php
136
- if ( is_plugin_active( 'autoptimize/autoptimize.php' ) ) {
137
- ?>
138
- <div class="aj_plugin">
139
- <h4><?php _e('Plugin: Autoptimize','asyncjs'); ?></h4>
140
- <p><a href="https://wordpress.org/plugins/autoptimize/" target="_blank">https://wordpress.org/plugins/autoptimize/</a></p>
141
- <p><label><?php _e('Enable Autoptimize Support:','asyncjs'); ?> </label><input type="checkbox" id="aj_autoptimize_enabled" value="1" <?php echo $aj_autoptimize_enabled_checked; ?> /></p>
142
- <p><label><?php _e('jQuery Method:','asyncjs'); ?> </label><input type="radio" name="aj_autoptimize_method" value="async" <?php echo $aj_autoptimize_async; ?> /> Async <input type="radio" name="aj_autoptimize_method" value="defer" <?php echo $aj_autoptimize_defer; ?> /> Defer</p>
143
- </div>
144
- <?php
145
  }
146
- ?>
147
- <p><button data-id="aj_save_settings" class="aj_steps_button"><?php _e('Save Settings','asyncjs'); ?></button></p>
148
- </td>
149
- </tr>
150
- </table>
151
- <?php
1
  <?php
2
+ if (! defined('ABSPATH')) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
+ $site_url = trailingslashit(get_site_url());
7
+ $aj_gtmetrix_username = get_option('aj_gtmetrix_username', '');
8
+ $aj_gtmetrix_api_key = get_option('aj_gtmetrix_api_key', '');
9
+ $aj_gtmetrix_server = get_option('aj_gtmetrix_server', '');
10
+ $aj_enabled = get_option('aj_enabled', 0);
11
+ $aj_enabled_checked = ($aj_enabled == 1) ? ' checked="checked"' : '';
12
+ $aj_method = get_option('aj_method', 'async');
13
+ $aj_method_async = ($aj_method == 'async') ? ' checked="checked"' : '';
14
+ $aj_method_defer = ($aj_method == 'defer') ? ' checked="checked"' : '';
15
+ $aj_jquery = get_option('aj_jquery', 'async');
16
+ $aj_jquery = ($aj_jquery == 'same ') ? $aj_method : $aj_jquery;
17
+ $aj_jquery_async = ($aj_jquery == 'async') ? ' checked="checked"' : '';
18
+ $aj_jquery_defer = ($aj_jquery == 'defer') ? ' checked="checked"' : '';
19
+ $aj_jquery_exclude = ($aj_jquery == 'exclude') ? ' checked="checked"' : '';
20
+ $aj_async = get_option('aj_async', '');
21
+ $aj_defer = get_option('aj_defer', '');
22
+ $aj_exclusions = get_option('aj_exclusions', '');
23
+ $aj_plugin_exclusions = (is_array(get_option('aj_plugin_exclusions', array())) && !is_null(get_option('aj_plugin_exclusions', array())) ? get_option('aj_plugin_exclusions', array()) : explode(',', get_option('aj_plugin_exclusions', '')));
24
+ $aj_theme_exclusions = (is_array(get_option('aj_theme_exclusions', array())) && !is_null(get_option('aj_theme_exclusions', array())) ? get_option('aj_theme_exclusions', array()) : explode(',', get_option('aj_theme_exclusions', '')));
25
+ $aj_autoptimize_enabled = get_option('aj_autoptimize_enabled', 0);
26
+ $aj_autoptimize_enabled_checked = ($aj_autoptimize_enabled == 1) ? ' checked="checked"' : '';
27
+ $aj_autoptimize_method = get_option('aj_autoptimize_method', 'async');
28
+ $aj_autoptimize_async = ($aj_autoptimize_method == 'async') ? ' checked="checked"' : '';
29
+ $aj_autoptimize_defer = ($aj_autoptimize_method == 'defer') ? ' checked="checked"' : '';
30
  ?>
31
+
32
+ <div class="asItemDetail">
33
+ <h3><?php _e('Enable ', 'asyncjs'); ?><?php echo AJ_TITLE; ?></h3>
34
+ <p>
35
+ <label><?php _e('Enable ', 'asyncjs'); ?><?php echo AJ_TITLE; ?>? </label>
36
+ <input type="checkbox" id="aj_enabled" id="aj_enabled" value="1" <?php echo $aj_enabled_checked; ?> />
37
+ </p>
38
+ </div>
39
+
40
+ <div class="asItemDetail">
41
+ <h3><?php _e('Quick Settings', 'asyncjs'); ?></h3>
42
+ <p><?php _e('Use the buttons below to apply common settings.', 'asyncjs'); ?></p>
43
+ <p><?php _e('<strong>Note: </strong>Using the buttons below will erase any current settings within ', 'asyncjs'); ?><?php echo AJ_TITLE; ?>.</p>
44
+ <p>
45
+ <button data-id="aj_step2b_apply" class="aj_steps_button button"><?php _e('Apply Async', 'asyncjs'); ?></button>
46
+ <button data-id="aj_step2c_apply" class="aj_steps_button button"><?php _e('Apply Defer', 'asyncjs'); ?></button>
47
+ <button data-id="aj_step2d_apply" class="aj_steps_button button"><?php _e('Apply Async', 'asyncjs'); _e(' (jQuery excluded)', 'asyncjs'); ?></button>
48
+ <button data-id="aj_step2e_apply" class="aj_steps_button button"><?php _e('Apply Defer', 'asyncjs'); _e(' (jQuery excluded)', 'asyncjs'); ?></button>
49
+ </p>
50
+ </div>
51
+
52
+ <div class="asItemDetail">
53
+ <h3><?php echo AJ_TITLE; ?> Method</h3>
54
+ <p><?php _e('Please select the method (<strong>async</strong> or <strong>defer</strong>) that you wish to enable:', 'asyncjs'); ?></p>
55
+ <p><label><?php _e('Method: ', 'asyncjs'); ?></label><input type="radio" name="aj_method" value="async" <?php echo $aj_method_async; ?> /> Async <input type="radio" name="aj_method" value="defer" <?php echo $aj_method_defer; ?> /> Defer</p>
56
+ </div>
57
+ <div class="asItemDetail">
58
+ <h3><?php _e('jQuery', 'asyncjs'); ?></h3>
59
+ <p><?php _e('Often if jQuery is loaded with <strong>async</strong> or <strong>defer</strong> it can break some jQuery functions, specifically inline scripts which require jQuery to be loaded before the scripts are run. <strong><em>Sometimes</em></strong> choosing a different method (<strong>async</strong> or <strong>defer</strong>) will work, otherwise it may be necessary to exclude jQuery from having <strong>async</strong> or <strong>defer</strong> applied.', 'asyncjs'); ?></p>
60
+ <p>
61
+ <label><?php _e('jQuery Method: ', 'asyncjs'); ?></label>
62
+ <input type="radio" name="aj_jquery" value="async" <?php echo $aj_jquery_async; ?> /> Async <input type="radio" name="aj_jquery" value="defer" <?php echo $aj_jquery_defer; ?> /> Defer <input type="radio" name="aj_jquery" value="exclude" <?php echo $aj_jquery_exclude; ?> /> <?php _e('Exclude', 'asyncjs'); ?>
63
+ </p>
64
+ </div>
65
+ <div class="asItemDetail">
66
+ <h3><?php _e('Scripts to Async', 'asyncjs'); ?></h3>
67
+ <p><?php _e("Please list any scripts which you would like to apply the 'async' attribute to. (comma seperated list eg: jquery.js,jquery-ui.js)", 'asyncjs'); ?></p>
68
+ <p>
69
+ <label><?php _e('Scripts to Async:', 'asyncjs'); ?> </label>
70
+ <textarea id="aj_async" style="width:95%;"><?php echo $aj_async; ?></textarea>
71
+ </p>
72
+ </div>
73
+ <div class="asItemDetail">
74
+ <h3><?php _e('Scripts to Defer', 'asyncjs'); ?></h3>
75
+ <p><?php _e("Please list any scripts which you would like to apply the 'defer' attribute to. (comma seperated list eg: jquery.js,jquery-ui.js)", 'asyncjs'); ?></p>
76
+ <p>
77
+ <label><?php _e('Scripts to Defer:', 'asyncjs'); ?> </label>
78
+ <textarea id="aj_defer" style="width:95%;"><?php echo $aj_defer; ?></textarea>
79
+ </p>
80
+ </div>
81
+ <div class="asItemDetail">
82
+ <h3><?php _e('Script Exclusion', 'asyncjs'); ?></h3>
83
+ <p><?php _e('Please list any scripts which you would like excluded from having <strong>async</strong> or <strong>defer</strong> applied during page load. (comma seperated list eg: jquery.js,jquery-ui.js)', 'asyncjs'); ?></p>
84
+ <p>
85
+ <label><?php _e('Scripts to Exclude:', 'asyncjs'); ?> </label>
86
+ <textarea id="aj_exclusions" style="width:95%;"><?php echo $aj_exclusions; ?></textarea>
87
+ </p>
88
+ </div>
89
+ <div class="asItemDetail">
90
+ <h3><?php _e('Plugin Exclusions', 'asyncjs'); ?></h3>
91
+ <p><?php _e('Please select one or more plugins. Scripts contained within the plugin will not have async / defer applied.', 'asyncjs'); ?></p>
92
+ <p><?php _e('<strong><em>Please Note:</em></strong> This will exclude any JavaScript files which are contained within the files of the selected Plugin(s). External JavaScripts loaded by the selected Plugin(s) are not affected.', 'asyncjs'); ?></p>
93
+ <p><?php _e('For Example: If a plugin is installed in path <strong>/wp-content/plugins/some-plugin/</strong> then and JavaScripts contained within this path will be excluded. If the plugin loads a JavaScript which is countained elsewhere then the Global Method will be used (ie async or defer)', 'asyncjs'); ?></p>
94
+ <p><label><?php _e('Exclusions: ', 'asyncjs'); ?></label>
95
+ <?php
96
+ $plugins = get_plugins();
97
+ $output = '';
98
+ if (!empty($plugins)) {
99
+ $output .= '<select id="aj_plugin_exclusions" class="aj_chosen" multiple="multiple" style="min-width:50%;" >';
100
+ foreach ($plugins as $path=>$plugin) {
101
+ $split = explode('/', $path);
102
+ $text_domain = $split[0];
103
+ if ($text_domain != 'async-javascript') {
104
+ //var_dump( $aj_plugin_exclusions );
105
+ $selected = (in_array($text_domain, $aj_plugin_exclusions)) ? ' selected="selected"' : '';
106
+ $output .= '<option value="' . $text_domain . '"' . $selected . '>' . $plugin['Name'] . '</option>';
107
+ }
108
+ }
109
+ $output .= '</select>';
110
+ } else {
111
+ $output .= '<p>'.__('No plugins found.', 'asyncjs').'</p>';
112
+ }
113
+ echo $output;
114
+ ?>
115
+ </p>
116
+ </div>
117
+ <div class="asItemDetail">
118
+ <h3><?php _e('Theme Exclusions', 'asyncjs'); ?></h3>
119
+ <p><?php _e('Please select one or more themes. Scripts contained within the theme will not have async / defer applied.', 'asyncjs'); ?></p>
120
+ <p><?php _e('<strong><em>Please Note:</em></strong> This will exclude any JavaScript files which are contained within the files of the selected Theme(s). External JavaScripts loaded by the selected Theme(s) are not affected.', 'asyncjs'); ?></p>
121
+ <p><?php _e('For Example: If a theme is installed in path <strong>/wp-content/themes/some-theme/</strong> then and JavaScripts contained within this path will be excluded. If the theme loads a JavaScript which is countained elsewhere then the Global Method will be used (ie async or defer)', 'asyncjs'); ?></p>
122
+ <p>
123
+ <label><?php _e('Exclusions:', 'asyncjs'); ?> </label>
124
+ <?php
125
+ $themes = wp_get_themes();
126
+ $output = '';
127
+ if (!empty($themes)) {
128
+ $output .= '<select id="aj_theme_exclusions" class="aj_chosen" multiple="multiple" style="min-width:50%;" >';
129
+ foreach ($themes as $path=>$theme) {
130
+ $text_domain = $path;
131
+ $selected = (in_array($text_domain, $aj_theme_exclusions)) ? ' selected="selected"' : '';
132
+ $output .= '<option value="' . $text_domain . '"' . $selected . '>' . $theme->Name . '</option>';
133
  }
134
+ $output .= '</select>';
135
+ } else {
136
+ $output .= '<p>'. __('No themes found.', 'asyncjs').'</p>';
137
+ }
138
+ echo $output;
139
+ ?>
140
+ </p>
141
+ </div>
142
+ <div class="asItemDetail">
143
+ <h3><?php echo AJ_TITLE; ?> <?php _e('For Plugins', 'asyncjs'); ?></h3>
144
+ <p><?php _e('Although not recommended, some themes / plugins can load JavaScript files without using the <strong><a href="https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts" target="_blank">wp_enqueue_script</a></strong> function. In some cases this is necessary for the functionality of the theme / plugin.', 'asyncjs'); ?></p>
145
+ <p><?php _e('If these themes / plugins provide a hook that can be used to manipulate how the JavaScript file is loaded then <?php echo AJ_TITLE; ?> may be able to provide support for these themes / plugins.', 'asyncjs'); ?></p>
146
+ <p><?php _e('If you have any active themes / plugins that <?php echo AJ_TITLE; ?> supports then these will be listed below.', 'asyncjs'); ?></p>
147
+ <p><?php _e('If you think you have found a plugin that <?php echo AJ_TITLE; ?> may be able to provide support for please lodge a ticket at <a href="https://wordpress.org/support/plugin/async-javascript" target="_blank">https://wordpress.org/support/plugin/async-javascript</a>', 'asyncjs'); ?></p>
148
+ <?php
149
+ if (is_plugin_active('autoptimize/autoptimize.php')) {
 
 
 
 
 
 
 
 
 
150
  ?>
151
+ <div class="aj_plugin">
152
+ <h4><?php _e('Plugin: Autoptimize', 'asyncjs'); ?></h4>
153
+ <p><a href="https://wordpress.org/plugins/autoptimize/" target="_blank">https://wordpress.org/plugins/autoptimize/</a></p>
154
+ <p>
155
+ <label><?php _e('Enable Autoptimize Support:', 'asyncjs'); ?> </label>
156
+ <input type="checkbox" id="aj_autoptimize_enabled" value="1" <?php echo $aj_autoptimize_enabled_checked; ?> />
157
+ </p>
158
+ <p>
159
+ <label><?php _e('jQuery Method:', 'asyncjs'); ?> </label>
160
+ <input type="radio" name="aj_autoptimize_method" value="async" <?php echo $aj_autoptimize_async; ?> /> Async <input type="radio" name="aj_autoptimize_method" value="defer" <?php echo $aj_autoptimize_defer; ?> /> Defer
161
+ </p>
162
+ </div>
163
+ <?php
 
 
 
 
164
  }
165
+ ?>
166
+ </div>
167
+ <p>
168
+ <button data-id="aj_save_settings" class="aj_steps_button button"><?php _e('Save Settings', 'asyncjs'); ?></button>
169
+ </p>
 
asyncjsStatusScreens.php CHANGED
@@ -1,190 +1,189 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
- $site_url = trailingslashit( get_site_url() );
7
- $aj_gtmetrix_username = get_option( 'aj_gtmetrix_username', '' );
8
- $aj_gtmetrix_api_key = get_option( 'aj_gtmetrix_api_key', '' );
9
- $aj_gtmetrix_server = get_option( 'aj_gtmetrix_server', '' );
10
- if ( $aj_gtmetrix_username != '' && $aj_gtmetrix_api_key != '' ) {
11
  $test = new Services_WTF_Test();
12
- $test->api_username( $aj_gtmetrix_username );
13
- $test->api_password( $aj_gtmetrix_api_key );
14
- $test->user_agent( AJ_UA );
15
  $status = $test->status();
16
  $credits = $status['api_credits'];
17
  } else {
18
  $credits = 'N/A';
19
  }
20
- $aj_enabled = ( get_option( 'aj_enabled', 0 ) == 1 ) ? 'Enabled' : 'Disabled';
21
- $aj_method = ( get_option( 'aj_method', 'async' ) == 'async' ) ? 'Async' : 'Defer';
22
- $aj_jquery = get_option( 'aj_jquery', 'async' );
23
- $aj_jquery = ( $aj_jquery == 'same ' ) ? get_option( 'aj_method', 'async' ) : $aj_jquery;
24
- $aj_jquery = ( $aj_jquery == 'async' ) ? 'Async' : ( $aj_jquery == 'defer' ) ? 'Defer' : 'Excluded';
25
- $aj_async = get_option( 'aj_async', '' );
26
- $aj_defer = get_option( 'aj_defer', '' );
27
- $aj_exclusions = get_option( 'aj_exclusions', '' );
28
- $aj_plugin_exclusions = ( is_array( get_option( 'aj_plugin_exclusions', array() ) ) && !is_null( get_option( 'aj_plugin_exclusions', array() ) ) ? get_option( 'aj_plugin_exclusions', array() ) : explode( ',', get_option( 'aj_plugin_exclusions', '' ) ) );
29
- $aj_theme_exclusions = ( is_array( get_option( 'aj_theme_exclusions', array() ) ) && !is_null( get_option( 'aj_theme_exclusions', array() ) ) ? get_option( 'aj_theme_exclusions', array() ) : explode( ',', get_option( 'aj_theme_exclusions', '' ) ) );
30
- $aj_autoptimize_enabled = ( get_option( 'aj_autoptimize_enabled', 0 ) == 1 ) ? 'Enabled' : 'Disabled';
31
- $aj_autoptimize_method = ( get_option( 'aj_autoptimize_method', 'async' ) == 'async' ) ? 'Async' : 'Defer';
32
  ?>
33
- <table class="form-table" width="100%" cellpadding="10">
34
- <tr>
35
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/finger_point_out_punch_hole_400_clr_17860.png" title="Most Recent GTmetrix Results" alt="Most Recent GTmetrix Results" class="aj_step_img"></td>
36
- <td scope="row" align="left">
37
- <h3><?php echo AJ_TITLE; ?></h3>
 
 
 
 
 
 
 
 
 
38
  <ul>
39
- <li><strong><?php _e('Status','asyncjs'); ?>:</strong> <?php echo $aj_enabled; ?></li>
40
- <?php
41
- if ( $aj_enabled == 'Enabled' ) {
42
- ?>
43
- <li><strong><?php _e('Method','asyncjs'); ?>:</strong> <?php echo $aj_method; ?></li>
44
- <li><strong><?php _e('jQuery','asyncjs'); ?>:</strong> <?php echo $aj_jquery; ?></li>
45
- <li><strong><?php _e('Async Scripts','asyncjs'); ?>:</strong> <?php echo $aj_async; ?></li>
46
- <li><strong><?php _e('Defer Scripts','asyncjs'); ?>:</strong> <?php echo $aj_defer; ?></li>
47
- <li><strong><?php _e('Exclusions','asyncjs'); ?>:</strong>
48
- <ul>
49
- <li><strong><?php _e('Scripts','asyncjs'); ?>:</strong> <?php echo $aj_exclusions; ?></li>
50
- <li><strong><?php _e('Plugins','asyncjs'); ?>:</strong> <?php echo implode( ',', $aj_plugin_exclusions ); ?></li>
51
- <li><strong><?php _e('Themes','asyncjs'); ?>:</strong> <?php echo implode( ',', $aj_theme_exclusions ); ?></li>
52
- </ul>
53
- </li>
54
- <?php
55
- if ( is_plugin_active( 'autoptimize/autoptimize.php' ) ) {
56
- ?>
57
- <li><strong><?php _e('Autoptimize Status','asyncjs'); ?>:</strong> <?php echo $aj_autoptimize_enabled; ?></li>
58
- <?php
59
- if ( $aj_autoptimize_enabled == 'Enabled' ) {
60
- ?>
61
- <li><strong><?php _e('Autoptimize Method','asyncjs'); ?>:</strong> <?php echo $aj_autoptimize_method; ?></li>
62
- <?php
63
- }
64
- } else {
65
- ?>
66
- <li><?php _e('Autoptimize not installed or activated.','asyncjs'); ?></li>
67
- <?php
68
- }
69
- }
70
- ?>
71
  </ul>
72
- <hr />
73
- <h3><?php _e('Latest GTmetrix Results','asyncjs'); ?></h3>
 
 
 
74
  <?php
75
- $aj_gtmetrix_results = get_option( 'aj_gtmetrix_results', array() );
76
- if ( isset( $aj_gtmetrix_results['latest'] ) ) {
77
- $latest = $aj_gtmetrix_results['latest'];
78
- $screenshot = $latest['screenshot'];
79
- $pagespeed = $latest['results']['pagespeed_score'];
80
- $yslow = $latest['results']['yslow_score'];
81
- $pr = round( 255 * ( 1 - ( $pagespeed / 100 ) ), 0 );
82
- $yr = round( 255 * ( 1 - ( $yslow / 100 ) ), 0 );
83
- $pg = round( 255 * ( $pagespeed / 100 ), 0 );
84
- $yg = round( 255 * ( $yslow / 100 ), 0 );
85
- $pagespeed_style = ' style="color: rgb(' . $pr . ',' . $pg . ',0 )"';
86
- $yslow_style = ' style="color: rgb(' . $yr . ',' . $yg . ',0 )"';
87
- $flt = number_format( ( float )$latest['results']['fully_loaded_time'] / 1000, 2, '.', '' );
88
- $tps = number_format( ( float )$latest['results']['page_bytes'] / 1024, 0, '.', '' );
89
- $tps = ( $tps > 1024 ) ? number_format( ( float )$tps / 1024, 2, '.', '' ) . 'MB' : $tps . 'KB';
90
- $requests = $latest['results']['page_elements'];
91
- $report = $latest['results']['report_url'];
92
- $report_url = '<a href="' . $report . '" target="_blank">' . $report . '</a>';
93
- ?>
94
- <p id="aj_latest_please_wait"><img src="<?php echo AJ_PLUGIN_URL; ?>images/loading.gif" title="<?php _e('Please Wait','asyncjs'); ?>" alt="<?php _e('Please Wait','asyncjs'); ?>" class="aj_step_img"></p>
95
- <table id="aj_latest_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
96
- <tr>
97
- <td scope="row" align="center"><img src="data:image/jpeg;base64,<?php echo $screenshot; ?>" class="aj_latest_screenshot aj_gtmetrix_screenshot">
98
- <td scope="row" align="center">
99
- <h3><?php _e('PageSpeed Score','asyncjs'); ?></h3>
100
- <span class="aj_latest_pagespeed aj_gtmetrix_result"<?php echo $pagespeed_style; ?>><?php echo $pagespeed; ?>%</span>
101
- </td>
102
- <td scope="row" align="center">
103
- <h3><?php _e('YSlow Score','asyncjs'); ?></h3>
104
- <span class="aj_latest_yslow aj_gtmetrix_result"<?php echo $yslow_style; ?>><?php echo $yslow; ?>%</span>
105
- </td>
106
- <td scope="row" align="center">
107
- <h3><?php _e('Fully Loaded Time','asyncjs'); ?></h3>
108
- <span class="aj_latest_flt aj_gtmetrix_result"><?php echo $flt; ?>s</span>
109
- </td>
110
- <td scope="row" align="center">
111
- <h3><?php _e('Total Page Size','asyncjs'); ?></h3>
112
- <span class="aj_latest_tps aj_gtmetrix_result"><?php echo $tps; ?></span>
113
- </td>
114
- <td scope="row" align="center">
115
- <h3><?php _e('Requests','asyncjs'); ?></h3>
116
- <span class="aj_latest_requests aj_gtmetrix_result"><?php echo $requests; ?></span>
117
- </td>
118
- </tr>
119
- <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:','asyncjs'); ?> <span class="aj_latest_report"><?php echo $report_url; ?></span></td></tr>
120
- </table>
121
- <hr />
122
- <?php
123
- } else {
124
  ?>
125
- <table id="aj_latest_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10" style="display: none;">
126
- <tr>
127
- <td scope="row" align="center"><img src="" class="aj_latest_screenshot aj_gtmetrix_screenshot">
128
- <td scope="row" align="center">
129
- <h3><?php _e('PageSpeed Score','asyncjs'); ?></h3>
130
- <span class="aj_latest_pagespeed aj_gtmetrix_result"></span>
131
- </td>
132
- <td scope="row" align="center">
133
- <h3><?php _e('YSlow Score','asyncjs'); ?></h3>
134
- <span class="aj_latest_yslow aj_gtmetrix_result"></span>
135
- </td>
136
- <td scope="row" align="center">
137
- <h3><?php _e('Fully Loaded Time','asyncjs'); ?></h3>
138
- <span class="aj_latest_flt aj_gtmetrix_result"></span>
139
- </td>
140
- <td scope="row" align="center">
141
- <h3><?php _e('Total Page Size','asyncjs'); ?></h3>
142
- <span class="aj_latest_tps aj_gtmetrix_result"></span>
143
- </td>
144
- <td scope="row" align="center">
145
- <h3><?php _e('Requests','asyncjs'); ?></h3>
146
- <span class="aj_latest_requests aj_gtmetrix_result"></span>
147
- </td>
148
- </tr>
149
- <tr><td scope="row" align="center" colspan="6"><?php _e('See full report:','asyncjs'); ?> <span class="aj_latest_report"></span></td></tr>
150
- </table>
151
- <hr />
152
  <?php
153
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  ?>
155
- <p><?php _e('Please click on the button below to generate a new GTmetrix Report.','asyncjs'); ?></p>
156
- <p><?php _e('<strong>Please Note:</strong> By clicking the button below you acknowledge that you understand that one (1) GTmetrix API credit will be used.','asyncjs'); ?></p>
157
- <p><button data-id="aj_gtmetrix_test" class="aj_steps_button"><?php _e('Run GTmetrix Test','asyncjs'); ?></button></p>
158
- <h3><?php _e('GTmetrix API Key','asyncjs'); ?></h3>
159
- <p><?php _e("If you haven't already done so, grab an API Key from GTmetrix so that Async JavaScript can obtain your PageSpeed / YSlow results. Here's how:",'asyncjs'); ?></p>
160
- <ol>
161
- <li><?php _e('Navigate to <a href="https://gtmetrix.com/api/" target="_blank">https://gtmetrix.com/api/</a> (link opens in a new tab)','asyncjs'); ?></li>
162
- <li><?php _e("If you do not already have an account with GTmetrix, go ahead and sign up (it's FREE!).",'asyncjs'); ?></li>
163
- <li><?php _e('Log in to your GTmetrix account.','asyncjs'); ?></li>
164
- <li><?php _e("If you haven't yet generated your API Key, click on <strong>Generate API Key</strong>",'asyncjs'); ?></li>
165
- <li><?php _e('Copy your Username and API Key into the fields below:','asyncjs'); ?><br /><input type="text" id="aj_gtmetrix_username" value="<?php echo $aj_gtmetrix_username; ?>" placeholder="GTmetrix Username"><input type="text" id="aj_gtmetrix_api_key" value="<?php echo $aj_gtmetrix_api_key; ?>" placeholder="GTmetrix API Key"></li>
166
- <li><?php _e('Select the desired server.','asyncjs'); ?><br />
167
- <select id="aj_gtmetrix_server">
168
- <?php
169
- $gtmetrix_locations = array(
170
- 'Vancouver, Canada' => 1,
171
- 'London, United Kingdom' => 2,
172
- 'Sydney, Australia' => 3,
173
- 'Dallas, United States' => 4,
174
- 'Mumbai, India' => 5
175
- );
176
- foreach ( $gtmetrix_locations as $location => $value ) {
177
- $selected = ( $aj_gtmetrix_server == $value ) ? ' selected="selected"' : '';
178
- echo '<option value="' . $value . '"' . $selected . '>' . $location . '</option>';
179
- }
180
- ?>
181
- </select>
182
- </li>
183
- <li><?php _e('GTmetrix Credits Available:','asyncjs'); ?> <span class="aj_gtmetrix_credits"><?php echo $credits; ?></span></li>
184
- </ol>
185
- <hr />
186
- <?php echo $this->hints_tips(); ?>
187
- </td>
188
- </tr>
189
- </table>
190
  <?php
1
  <?php
2
+ if (! defined('ABSPATH')) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
+ $site_url = trailingslashit(get_site_url());
7
+ $aj_gtmetrix_username = get_option('aj_gtmetrix_username', '');
8
+ $aj_gtmetrix_api_key = get_option('aj_gtmetrix_api_key', '');
9
+ $aj_gtmetrix_server = get_option('aj_gtmetrix_server', '');
10
+ if ($aj_gtmetrix_username != '' && $aj_gtmetrix_api_key != '') {
11
  $test = new Services_WTF_Test();
12
+ $test->api_username($aj_gtmetrix_username);
13
+ $test->api_password($aj_gtmetrix_api_key);
14
+ $test->user_agent(AJ_UA);
15
  $status = $test->status();
16
  $credits = $status['api_credits'];
17
  } else {
18
  $credits = 'N/A';
19
  }
20
+ $aj_enabled = (get_option('aj_enabled', 0) == 1) ? 'Enabled' : 'Disabled';
21
+ $aj_method = (get_option('aj_method', 'async') == 'async') ? 'Async' : 'Defer';
22
+ $aj_jquery = get_option('aj_jquery', 'async');
23
+ $aj_jquery = ($aj_jquery == 'same ') ? get_option('aj_method', 'async') : $aj_jquery;
24
+ $aj_jquery = ($aj_jquery == 'async') ? 'Async' : ($aj_jquery == 'defer') ? 'Defer' : 'Excluded';
25
+ $aj_async = get_option('aj_async', '');
26
+ $aj_defer = get_option('aj_defer', '');
27
+ $aj_exclusions = get_option('aj_exclusions', '');
28
+ $aj_plugin_exclusions = (is_array(get_option('aj_plugin_exclusions', array())) && !is_null(get_option('aj_plugin_exclusions', array())) ? get_option('aj_plugin_exclusions', array()) : explode(',', get_option('aj_plugin_exclusions', '')));
29
+ $aj_theme_exclusions = (is_array(get_option('aj_theme_exclusions', array())) && !is_null(get_option('aj_theme_exclusions', array())) ? get_option('aj_theme_exclusions', array()) : explode(',', get_option('aj_theme_exclusions', '')));
30
+ $aj_autoptimize_enabled = (get_option('aj_autoptimize_enabled', 0) == 1) ? 'Enabled' : 'Disabled';
31
+ $aj_autoptimize_method = (get_option('aj_autoptimize_method', 'async') == 'async') ? 'Async' : 'Defer';
32
  ?>
33
+
34
+
35
+ <div class="asItemDetail">
36
+ <h3><?php echo AJ_TITLE; ?></h3>
37
+ <ul>
38
+ <li><strong><?php _e('Status', 'asyncjs'); ?>:</strong> <?php echo $aj_enabled; ?></li>
39
+ <?php
40
+ if ($aj_enabled == 'Enabled') {
41
+ ?>
42
+ <li><strong><?php _e('Method', 'asyncjs'); ?>:</strong> <?php echo $aj_method; ?></li>
43
+ <li><strong><?php _e('jQuery', 'asyncjs'); ?>:</strong> <?php echo $aj_jquery; ?></li>
44
+ <li><strong><?php _e('Async Scripts', 'asyncjs'); ?>:</strong> <?php echo $aj_async; ?></li>
45
+ <li><strong><?php _e('Defer Scripts', 'asyncjs'); ?>:</strong> <?php echo $aj_defer; ?></li>
46
+ <li><strong><?php _e('Exclusions', 'asyncjs'); ?>:</strong>
47
  <ul>
48
+ <li><strong><?php _e('Scripts', 'asyncjs'); ?>:</strong> <?php echo $aj_exclusions; ?></li>
49
+ <li><strong><?php _e('Plugins', 'asyncjs'); ?>:</strong> <?php echo implode(',', $aj_plugin_exclusions); ?></li>
50
+ <li><strong><?php _e('Themes', 'asyncjs'); ?>:</strong> <?php echo implode(',', $aj_theme_exclusions); ?></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  </ul>
52
+ </li>
53
+ <?php
54
+ if (is_plugin_active('autoptimize/autoptimize.php')) {
55
+ ?>
56
+ <li><strong><?php _e('Autoptimize Status', 'asyncjs'); ?>:</strong> <?php echo $aj_autoptimize_enabled; ?></li>
57
  <?php
58
+ if ($aj_autoptimize_enabled == 'Enabled') {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ?>
60
+ <li><strong><?php _e('Autoptimize Method', 'asyncjs'); ?>:</strong> <?php echo $aj_autoptimize_method; ?></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  <?php
62
  }
63
+ } else {
64
+ ?>
65
+ <li><?php _e('Autoptimize not installed or activated.', 'asyncjs'); ?></li>
66
+ <?php
67
+ }
68
+ }
69
+ ?>
70
+ </ul>
71
+ </div>
72
+ <div class="asItemDetail">
73
+ <h3><?php _e('Latest GTmetrix Results', 'asyncjs'); ?></h3>
74
+ <?php
75
+ $aj_gtmetrix_results = get_option('aj_gtmetrix_results', array());
76
+ if (isset($aj_gtmetrix_results['latest'])) {
77
+ $latest = $aj_gtmetrix_results['latest'];
78
+ $screenshot = $latest['screenshot'];
79
+ $pagespeed = $latest['results']['pagespeed_score'];
80
+ $yslow = $latest['results']['yslow_score'];
81
+ $pr = round(255 * (1 - ($pagespeed / 100)), 0);
82
+ $yr = round(255 * (1 - ($yslow / 100)), 0);
83
+ $pg = round(255 * ($pagespeed / 100), 0);
84
+ $yg = round(255 * ($yslow / 100), 0);
85
+ $pagespeed_style = ' style="color: rgb(' . $pr . ',' . $pg . ',0 )"';
86
+ $yslow_style = ' style="color: rgb(' . $yr . ',' . $yg . ',0 )"';
87
+ $flt = number_format(( float )$latest['results']['fully_loaded_time'] / 1000, 2, '.', '');
88
+ $tps = number_format(( float )$latest['results']['page_bytes'] / 1024, 0, '.', '');
89
+ $tps = ($tps > 1024) ? number_format(( float )$tps / 1024, 2, '.', '') . 'MB' : $tps . 'KB';
90
+ $requests = $latest['results']['page_elements'];
91
+ $report = $latest['results']['report_url'];
92
+ $report_url = '<a href="' . $report . '" target="_blank">' . $report . '</a>'; ?>
93
+ <div id="aj_latest_please_wait"><div class="aj_loader"><h3 class="aj_loader_loading_text"><?php _e('Please Wait', 'asyncjs'); ?></h3></div></div>
94
+ <table id="aj_latest_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
95
+ <tr>
96
+ <td scope="row" align="center"><img src="data:image/jpeg;base64,<?php echo $screenshot; ?>" class="aj_latest_screenshot aj_gtmetrix_screenshot">
97
+ <td scope="row" align="center">
98
+ <h3><?php _e('PageSpeed Score', 'asyncjs'); ?></h3>
99
+ <span class="aj_latest_pagespeed aj_gtmetrix_result"<?php echo $pagespeed_style; ?>><?php echo $pagespeed; ?>%</span>
100
+ </td>
101
+ <td scope="row" align="center">
102
+ <h3><?php _e('YSlow Score', 'asyncjs'); ?></h3>
103
+ <span class="aj_latest_yslow aj_gtmetrix_result"<?php echo $yslow_style; ?>><?php echo $yslow; ?>%</span>
104
+ </td>
105
+ <td scope="row" align="center">
106
+ <h3><?php _e('Fully Loaded Time', 'asyncjs'); ?></h3>
107
+ <span class="aj_latest_flt aj_gtmetrix_result"><?php echo $flt; ?>s</span>
108
+ </td>
109
+ <td scope="row" align="center">
110
+ <h3><?php _e('Total Page Size', 'asyncjs'); ?></h3>
111
+ <span class="aj_latest_tps aj_gtmetrix_result"><?php echo $tps; ?></span>
112
+ </td>
113
+ <td scope="row" align="center">
114
+ <h3><?php _e('Requests', 'asyncjs'); ?></h3>
115
+ <span class="aj_latest_requests aj_gtmetrix_result"><?php echo $requests; ?></span>
116
+ </td>
117
+ </tr>
118
+ <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:', 'asyncjs'); ?> <span class="aj_latest_report"><?php echo $report_url; ?></span></td></tr>
119
+ </table>
120
+ </div>
121
+ <?php
122
+ } else {
123
+ ?>
124
+ <table id="aj_latest_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10" style="display: none;">
125
+ <tr>
126
+ <td scope="row" align="center"><img src="" class="aj_latest_screenshot aj_gtmetrix_screenshot">
127
+ <td scope="row" align="center">
128
+ <h3><?php _e('PageSpeed Score', 'asyncjs'); ?></h3>
129
+ <span class="aj_latest_pagespeed aj_gtmetrix_result"></span>
130
+ </td>
131
+ <td scope="row" align="center">
132
+ <h3><?php _e('YSlow Score', 'asyncjs'); ?></h3>
133
+ <span class="aj_latest_yslow aj_gtmetrix_result"></span>
134
+ </td>
135
+ <td scope="row" align="center">
136
+ <h3><?php _e('Fully Loaded Time', 'asyncjs'); ?></h3>
137
+ <span class="aj_latest_flt aj_gtmetrix_result"></span>
138
+ </td>
139
+ <td scope="row" align="center">
140
+ <h3><?php _e('Total Page Size', 'asyncjs'); ?></h3>
141
+ <span class="aj_latest_tps aj_gtmetrix_result"></span>
142
+ </td>
143
+ <td scope="row" align="center">
144
+ <h3><?php _e('Requests', 'asyncjs'); ?></h3>
145
+ <span class="aj_latest_requests aj_gtmetrix_result"></span>
146
+ </td>
147
+ </tr>
148
+ <tr><td scope="row" align="center" colspan="6"><?php _e('See full report:', 'asyncjs'); ?> <span class="aj_latest_report"></span></td></tr>
149
+ </table>
150
+ </div>
151
+ <?php
152
+ }
153
+ ?>
154
+ <div class="asItemDetail">
155
+ <h3><?php _e('Generate New Report', 'asyncjs'); ?></h3>
156
+ <p><?php _e('Please click on the button below to generate a new GTmetrix Report.', 'asyncjs'); ?></p>
157
+ <p><?php _e('<strong>Please Note:</strong> By clicking the button below you acknowledge that you understand that one (1) GTmetrix API credit will be used.', 'asyncjs'); ?></p>
158
+ <p><button data-id="aj_gtmetrix_test" class="aj_steps_button button"><?php _e('Run GTmetrix Test', 'asyncjs'); ?></button></p>
159
+ </div>
160
+ <div class="asItemDetail">
161
+ <h3><?php _e('GTmetrix API Key', 'asyncjs'); ?></h3>
162
+ <p><?php _e("If you haven't already done so, grab an API Key from GTmetrix so that Async JavaScript can obtain your PageSpeed / YSlow results. Here's how:", 'asyncjs'); ?></p>
163
+ <ol>
164
+ <li><?php _e('Navigate to <a href="https://gtmetrix.com/api/" target="_blank">https://gtmetrix.com/api/</a> (link opens in a new tab)', 'asyncjs'); ?></li>
165
+ <li><?php _e("If you do not already have an account with GTmetrix, go ahead and sign up (it's FREE!).", 'asyncjs'); ?></li>
166
+ <li><?php _e('Log in to your GTmetrix account.', 'asyncjs'); ?></li>
167
+ <li><?php _e("If you haven't yet generated your API Key, click on <strong>Generate API Key</strong>", 'asyncjs'); ?></li>
168
+ <li><?php _e('Copy your Username and API Key into the fields below:', 'asyncjs'); ?><br /><input type="text" id="aj_gtmetrix_username" value="<?php echo $aj_gtmetrix_username; ?>" placeholder="GTmetrix Username"><input type="text" id="aj_gtmetrix_api_key" value="<?php echo $aj_gtmetrix_api_key; ?>" placeholder="GTmetrix API Key"></li>
169
+ <li><?php _e('Select the desired server.', 'asyncjs'); ?><br />
170
+ <select id="aj_gtmetrix_server">
171
+ <?php
172
+ $gtmetrix_locations = array(
173
+ 'Vancouver, Canada' => 1,
174
+ 'London, United Kingdom' => 2,
175
+ 'Sydney, Australia' => 3,
176
+ 'Dallas, United States' => 4,
177
+ 'Mumbai, India' => 5
178
+ );
179
+ foreach ($gtmetrix_locations as $location => $value) {
180
+ $selected = ($aj_gtmetrix_server == $value) ? ' selected="selected"' : '';
181
+ echo '<option value="' . $value . '"' . $selected . '>' . $location . '</option>';
182
+ }
183
  ?>
184
+ </select>
185
+ </li>
186
+ <li><?php _e('GTmetrix Credits Available:', 'asyncjs'); ?> <span class="aj_gtmetrix_credits"><?php echo $credits; ?></span></li>
187
+ </ol>
188
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  <?php
asyncjsWizardScreens.php CHANGED
@@ -1,319 +1,331 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
- /*
7
  * this displays the wizard screen
8
  * uses the AJAX functions
9
  */
10
-
11
- $site_url = trailingslashit( get_site_url() );
12
- $aj_gtmetrix_username = get_option( 'aj_gtmetrix_username', '' );
13
- $aj_gtmetrix_api_key = get_option( 'aj_gtmetrix_api_key', '' );
14
- $aj_gtmetrix_server = get_option( 'aj_gtmetrix_server', '' );
15
- if ( $aj_gtmetrix_username != '' && $aj_gtmetrix_api_key != '' ) {
16
  $test = new Services_WTF_Test();
17
- $test->api_username( $aj_gtmetrix_username );
18
- $test->api_password( $aj_gtmetrix_api_key );
19
- $test->user_agent( AJ_UA );
20
  $status = $test->status();
21
  $credits = $status['api_credits'];
22
  } else {
23
  $credits = 'N/A';
24
  }
25
  ?>
26
- <table class="form-table" width="100%" cellpadding="10">
27
- <tr id="aj_intro">
28
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/finger_point_out_punch_hole_400_clr_17860.png" title="<?php echo AJ_TITLE; ?>" alt="<?php echo AJ_TITLE; ?>" class="aj_step_img"></td>
29
- <td scope="row" align="left" style="vertical-align: top !important;">
30
- <h3><?php echo AJ_TITLE; ?></h3>
31
- <?php echo $this->about_aj(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </td>
33
- </tr>
34
- <tr id="aj_step1">
35
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/number_one_break_hole_150_clr_18741.gif" title="Step 1" alt="GTmetrix API Key" class="aj_step_img"></td>
36
- <td scope="row" align="left" style="vertical-align: top !important;">
37
- <h3><?php _e('Step 1: GTmetrix API Key','asyncjs'); ?></h3>
38
- <p><?php _e('<strong><em>Please Note:</em></strong> You do not have to use this Wizard. All settings can be changed under the','asyncjs'); ?> <a href="<?php echo menu_page_url( AJ_ADMIN_MENU_SLUG, false ) . '&tab=settings'; ?>"><?php _e('Settings','asyncjs'); ?></a> <?php _e('tab.','asyncjs'); ?></p>
39
- <hr />
40
- <p><?php _e("If you haven't already done so, grab an API Key from GTmetrix so that Async JavaScript can obtain your PageSpeed / YSlow results. Here's how:",'asyncjs'); ?></p>
41
- <ol>
42
- <li><?php _e('Navigate to ','asyncjs'); ?><a href="https://gtmetrix.com/api/" target="_blank">https://gtmetrix.com/api/</a> <?php _e('(link opens in a new tab)','asyncjs'); ?></li>
43
- <li><?php _e("If you do not already have an account with GTmetrix, go ahead and sign up (it's FREE!).",'asyncjs'); ?></li>
44
- <li><?php _e('Log in to your GTmetrix account.','asyncjs'); ?></li>
45
- <li><?php _e("If you haven't yet generated your API Key, click on <strong>Generate API Key</strong>",'asyncjs'); ?></li>
46
- <li><?php _e('Copy your Username and API Key into the fields below:','asyncjs'); ?><br /><input type="text" id="aj_gtmetrix_username" value="<?php echo $aj_gtmetrix_username; ?>" placeholder="GTmetrix Username"><input type="text" id="aj_gtmetrix_api_key" value="<?php echo $aj_gtmetrix_api_key; ?>" placeholder="GTmetrix API Key"></li>
47
- <li><?php _e('Select the desired server.','asyncjs'); ?><br />
48
- <select id="aj_gtmetrix_server">
49
- <?php
50
- $gtmetrix_locations = array(
51
- 'Vancouver, Canada' => 1,
52
- 'London, United Kingdom' => 2,
53
- 'Sydney, Australia' => 3,
54
- 'Dallas, United States' => 4,
55
- 'Mumbai, India' => 5
56
- );
57
- foreach ( $gtmetrix_locations as $location => $value ) {
58
- $selected = ( $aj_gtmetrix_server == $value ) ? ' selected="selected"' : '';
59
- echo '<option value="' . $value . '"' . $selected . '>' . $location . '</option>';
60
- }
61
- ?>
62
- </select>
63
- </li>
64
- <li><?php _e('GTmetrix Credits Available: ','asyncjs'); ?><span class="aj_gtmetrix_credits"><?php echo $credits; ?></span></li>
65
- </ol>
66
- <p><?php _e('<strong>Please Note:</strong> By clicking the button below you acknowledge that you understand that five (5) GTmetrix API credits will be used.','asyncjs'); ?></p>
67
- <p><button data-id="aj_step2" class="aj_steps_button"><?php _e('Proceed to Step 2','asyncjs'); ?></button></p>
68
  </td>
69
- </tr>
70
- <tr id="aj_step2" class="aj_steps_hidden">
71
- <td scope="row" align="center"><img src="<?php echo AJ_PLUGIN_URL; ?>images/number_two_break_hole_150_clr_18753.gif" title="Step 2" alt="Initial Test Results" class="aj_step_img"></td>
72
- <td scope="row" align="left">
73
- <h3><?php _e('Step 2: Initial Test Results','asyncjs'); ?></h3>
74
- <p><?php echo AJ_TITLE; ?> <?php _e('will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores.','asyncjs'); ?></p>
75
- <p id="aj_step2_please_wait"><img src="<?php echo AJ_PLUGIN_URL; ?>images/loading.gif" title="<?php _e('Please Wait','asyncjs');?>" alt="<?php _e('Please Wait','asyncjs');?>" class="aj_step_img"></p>
76
- <table id="aj_step2_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
77
- <tr>
78
- <td scope="row" align="center"><img src="" class="aj_step2_screenshot aj_gtmetrix_screenshot">
79
- <td scope="row" align="center">
80
- <h3><?php _e('PageSpeed Score','asyncjs'); ?></h3>
81
- <span class="aj_step2_pagespeed aj_gtmetrix_result"></span>
82
- </td>
83
- <td scope="row" align="center">
84
- <h3><?php _e('YSlow Score','asyncjs'); ?></h3>
85
- <span class="aj_step2_yslow aj_gtmetrix_result"></span>
86
- </td>
87
- <td scope="row" align="center">
88
- <h3><?php _e('Fully Loaded Time','asyncjs'); ?></h3>
89
- <span class="aj_step2_flt aj_gtmetrix_result"></span>
90
- </td>
91
- <td scope="row" align="center">
92
- <h3><?php _e('Total Page Size','asyncjs'); ?></h3>
93
- <span class="aj_step2_tps aj_gtmetrix_result"></span>
94
- </td>
95
- <td scope="row" align="center">
96
- <h3><?php _e('Requests','asyncjs'); ?></h3>
97
- <span class="aj_step2_requests aj_gtmetrix_result"></span>
98
- </td>
99
- </tr>
100
- <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:','asyncjs'); ?> <span class="aj_step2_report"></span></td></tr>
101
- <tr><td scope="row" align="left" colspan="6"><?php _e('Simulate','asyncjs'); ?> <span class="aj_step2_gtmetrix"></span>: <a href="" class="aj_step2_url" target="_blank"></a></tr>
102
- <p></p>
103
- </table>
104
  </td>
105
- </tr>
106
- <tr id="aj_step2b" class="aj_steps_hidden">
107
- <td scope="row" align="center"></td>
108
- <td scope="row" align="left">
109
- <h3><?php _e('Testing: Async','asyncjs');?></h3>
110
- <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'async' method.",'asyncjs'); ?></p>
111
- <p id="aj_step2b_please_wait"><img src="<?php echo AJ_PLUGIN_URL; ?>images/loading.gif" title="<?php _e('Please Wait','asyncjs');?>" alt="<?php _e('Please Wait','asyncjs');?>" class="aj_step_img"></p>
112
- <table id="aj_step2b_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
113
- <tr>
114
- <td scope="row" align="center"><img src="" class="aj_step2b_screenshot aj_gtmetrix_screenshot">
115
- <td scope="row" align="center">
116
- <h3><?php _e('PageSpeed Score','asyncjs');?></h3>
117
- <span class="aj_step2b_pagespeed aj_gtmetrix_result"></span>
118
- </td>
119
- <td scope="row" align="center">
120
- <h3><?php _e('YSlow Score','asyncjs');?></h3>
121
- <span class="aj_step2b_yslow aj_gtmetrix_result"></span>
122
- </td>
123
- <td scope="row" align="center">
124
- <h3><?php _e('Fully Loaded Time','asyncjs');?></h3>
125
- <span class="aj_step2b_flt aj_gtmetrix_result"></span>
126
- </td>
127
- <td scope="row" align="center">
128
- <h3><?php _e('Total Page Size','asyncjs');?></h3>
129
- <span class="aj_step2b_tps aj_gtmetrix_result"></span>
130
- </td>
131
- <td scope="row" align="center">
132
- <h3><?php _e('Requests','asyncjs');?></h3>
133
- <span class="aj_step2b_requests aj_gtmetrix_result"></span>
134
- </td>
135
- </tr>
136
- <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:','asyncjs');?> <span class="aj_step2b_report"></span></td></tr>
137
- <tr><td scope="row" align="left" colspan="6"><?php _e('Simulate','asyncjs');?> <span class="aj_step2b_gtmetrix"></span>: <a href="" class="aj_step2b_url" target="_blank"></a></tr>
138
- </table>
139
  </td>
140
- </tr>
141
- <tr id="aj_step2c" class="aj_steps_hidden">
142
- <td scope="row" align="center"></td>
143
- <td scope="row" align="left">
144
- <h3><?php _e('Testing: Defer','asyncjs');?></h3>
145
- <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'defer' method.",'asyncjs');?></p>
146
- <p id="aj_step2c_please_wait"><img src="<?php echo AJ_PLUGIN_URL; ?>images/loading.gif" title="<?php _e('Please Wait','asyncjs');?>" alt="<?php _e('Please Wait','asyncjs');?>" class="aj_step_img"></p>
147
- <table id="aj_step2c_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
148
- <tr>
149
- <td scope="row" align="center"><img src="" class="aj_step2c_screenshot aj_gtmetrix_screenshot">
150
- <td scope="row" align="center">
151
- <h3><?php _e('PageSpeed Score','asyncjs');?></h3>
152
- <span class="aj_step2c_pagespeed aj_gtmetrix_result"></span>
153
- </td>
154
- <td scope="row" align="center">
155
- <h3><?php _e('YSlow Score','asyncjs');?></h3>
156
- <span class="aj_step2c_yslow aj_gtmetrix_result"></span>
157
- </td>
158
- <td scope="row" align="center">
159
- <h3><?php _e('Fully Loaded Time','asyncjs');?></h3>
160
- <span class="aj_step2c_flt aj_gtmetrix_result"></span>
161
- </td>
162
- <td scope="row" align="center">
163
- <h3><?php _e('Total Page Size','asyncjs');?></h3>
164
- <span class="aj_step2c_tps aj_gtmetrix_result"></span>
165
- </td>
166
- <td scope="row" align="center">
167
- <h3><?php _e('Requests','asyncjs');?></h3>
168
- <span class="aj_step2c_requests aj_gtmetrix_result"></span>
169
- </td>
170
- </tr>
171
- <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:','asyncjs');?> <span class="aj_step2c_report"></span></td></tr>
172
- <tr><td scope="row" align="left" colspan="6"><?php _e('Simulate','asyncjs');?> <span class="aj_step2c_gtmetrix"></span>: <a href="" class="aj_step2c_url" target="_blank"></a></tr>
173
- </table>
174
  </td>
175
  </tr>
176
- <tr id="aj_step2d" class="aj_steps_hidden">
177
- <td scope="row" align="center"></td>
178
- <td scope="row" align="left">
179
- <h3><?php _e('Testing: Async (jQuery excluded)','asyncjs');?></h3>
180
- <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'async' method but excluding jQuery.",'asyncjs');?></p>
181
- <p id="aj_step2d_please_wait"><img src="<?php echo AJ_PLUGIN_URL; ?>images/loading.gif" title="<?php _e('Please Wait','asyncjs');?>" alt="<?php _e('Please Wait','asyncjs');?>" class="aj_step_img"></p>
182
- <table id="aj_step2d_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
183
- <tr>
184
- <td scope="row" align="center"><img src="" class="aj_step2d_screenshot aj_gtmetrix_screenshot">
185
- <td scope="row" align="center">
186
- <h3><?php _e('PageSpeed Score','asyncjs');?></h3>
187
- <span class="aj_step2d_pagespeed aj_gtmetrix_result"></span>
188
- </td>
189
- <td scope="row" align="center">
190
- <h3><?php _e('YSlow Score','asyncjs');?></h3>
191
- <span class="aj_step2d_yslow aj_gtmetrix_result"></span>
192
- </td>
193
- <td scope="row" align="center">
194
- <h3><?php _e('Fully Loaded Time','asyncjs');?></h3>
195
- <span class="aj_step2d_flt aj_gtmetrix_result"></span>
196
- </td>
197
- <td scope="row" align="center">
198
- <h3><?php _e('Total Page Size','asyncjs');?></h3>
199
- <span class="aj_step2d_tps aj_gtmetrix_result"></span>
200
- </td>
201
- <td scope="row" align="center">
202
- <h3><?php _e('Requests','asyncjs');?></h3>
203
- <span class="aj_step2d_requests aj_gtmetrix_result"></span>
204
- </td>
205
- </tr>
206
- <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:','asyncjs');?> <span class="aj_step2d_report"></span></td></tr>
207
- <tr><td scope="row" align="left" colspan="6"><?php _e('Simulate','asyncjs');?> <span class="aj_step2d_gtmetrix"></span>: <a href="" class="aj_step2d_url" target="_blank"></a></tr>
208
- </table>
209
- </td>
210
  </tr>
211
- <tr id="aj_step2e" class="aj_steps_hidden">
212
- <td scope="row" align="center"></td>
213
- <td scope="row" align="left">
214
- <h3><?php _e('Testing: Defer (jQuery excluded)','asyncjs');?></h3>
215
- <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'defer' method but excluding jQuery.",'asyncjs');?></p>
216
- <p id="aj_step2e_please_wait"><img src="<?php echo AJ_PLUGIN_URL; ?>images/loading.gif" title="<?php _e('Please Wait','asyncjs');?>" alt="<?php _e('Please Wait','asyncjs');?>" class="aj_step_img"></p>
217
- <table id="aj_step2e_gtmetrix_results" class="form-table aj-steps-table" width="100%" cellpadding="10">
218
- <tr>
219
- <td scope="row" align="center"><img src="" class="aj_step2e_screenshot aj_gtmetrix_screenshot">
220
- <td scope="row" align="center">
221
- <h3><?php _e('PageSpeed Score','asyncjs');?></h3>
222
- <span class="aj_step2e_pagespeed aj_gtmetrix_result"></span>
223
- </td>
224
- <td scope="row" align="center">
225
- <h3><?php _e('YSlow Score','asyncjs');?></h3>
226
- <span class="aj_step2e_yslow aj_gtmetrix_result"></span>
227
- </td>
228
- <td scope="row" align="center">
229
- <h3><?php _e('Fully Loaded Time','asyncjs');?></h3>
230
- <span class="aj_step2e_flt aj_gtmetrix_result"></span>
231
- </td>
232
- <td scope="row" align="center">
233
- <h3><?php _e('Total Page Size','asyncjs');?></h3>
234
- <span class="aj_step2e_tps aj_gtmetrix_result"></span>
235
- </td>
236
- <td scope="row" align="center">
237
- <h3><?php _e('Requests','asyncjs');?></h3>
238
- <span class="aj_step2e_requests aj_gtmetrix_result"></span>
239
- </td>
240
- </tr>
241
- <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:','asyncjs');?> <span class="aj_step2e_report"></span></td></tr>
242
- <tr><td scope="row" align="left" colspan="6"><?php _e('Simulate','asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a></tr>
243
- </table>
244
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  </tr>
246
- <tr id="aj_step_results" class="aj_steps_hidden">
247
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/number_three_break_hole_150_clr_18837.gif" title="Results &amp; Recommendations" alt="Results &amp; Recommendations" class="aj_step_img"></td>
248
- <td scope="row" align="left">
249
- <h3><?php _e('Step 3: Results &amp; Recommendations','asyncjs');?></h3>
250
- <p><?php echo AJ_TITLE; ?> <?php _e('has finished testing your site with the most common configuration options.','asyncjs');?></p>
251
- <p><?php _e('Based on the tests Async JavaScript has determined that <span class="aj_gtmetrix_config"></span> has resuled in <span id="aj_gtmetrix_inde_pagespeed"></span> in PageSpeed from <span id="aj_gtmetrix_baseline_pagespeed"></span> to <span id="aj_gtmetrix_best_pagespeed"></span> and <span id="aj_gtmetrix_inde_yslow"></span> in YSlow from <span id="aj_gtmetrix_baseline_yslow"></span> to <span id="aj_gtmetrix_best_yslow"></span>, with a Fully Loaded time of','asyncjs');?> <span id="aj_gtmetrix_best_fullyloaded"></span>.</p>
252
- <p><?php _e('Before applying these settings it is important to check your site is still functioning correctly. Click the link below to open your site in a new tab / window to simulate the <?php echo AJ_TITLE; ?> settings and check that everything is working, and also be sure to check the console for any JavaScript errors (see <a href="https://codex.wordpress.org/Using_Your_Browser_to_Diagnose_JavaScript_Errors" target="_blank">Using Your Browser to Diagnose JavaScript Errors</a>)','asyncjs');?></p>
253
- <ul>
254
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_gtmetrix_config"></span>: <a href="" id="aj_gtmetrix_best_url" target="_blank"></a></li>
255
- </ul>
256
- <p><?php _e('Once you have simulated','asyncjs');?> <span class="aj_gtmetrix_config"></span> <?php _e('click on the button below to continue.','asyncjs');?></p>
257
- <p><button data-id="aj_step4" class="aj_steps_button"><?php _e('Proceed to Step 4','asyncjs');?></button></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  </td>
 
 
 
 
 
 
 
259
  </tr>
260
- <tr id="aj_step4" class="aj_steps_hidden">
261
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/number_four_break_hole_150_clr_18840.gif" title="Apply Settings" alt="Apply Settings" class="aj_step_img"></td>
262
- <td scope="row" align="left">
263
- <h3><?php _e('Step 4: Apply Settings','asyncjs');?></h3>
264
- <p><?php _e('Is your site still functioning properly and are there no JavaScript errors in the console?','asyncjs');?></p>
265
- <p><input type="radio" name="aj_step4_check" value="y"> <?php _e('Yes','asyncjs');?> <input type="radio" name="aj_step4_check" value="n"> <?php _e('No','asyncjs');?></p>
266
- <div id="aj_step4_y">
267
- <p><?php _e('Great to hear! To apply these settings click the button below.','asyncjs');?></p>
268
- <p><button data-id="aj_apply_settings" class="aj_steps_button"><?php _e('Apply Settings','asyncjs');?></button></p>
269
- </div>
270
- <div id="aj_step4_n">
271
- <p><?php _e('Ok, so you have run the simulation on <span class="aj_gtmetrix_config"></span> and although there has been an improvement in reported performance, the simulation shows that something is not right with your site.','asyncjs');?></p>
272
- <div id="aj_step4_jquery_excluded">
273
- <p><?php _e('In most cases the issue being experienced relates to jQuery (usually due to inline JavaScript which relies on jQuery) and the solution is to exclude jQuery. However, in this simulation jQuery has already been exculded. As a result a different configuration may work better with a marginal sacrifice in site speed improvement.','asyncjs');?></p>
274
- <p><?php _e('Below are links that can be used to run simulations on each of the basic configurations. Click on each of the links and check the functionality of your site as well as the console for errors.','asyncjs');?></p>
275
- <ul>
276
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_step2b_gtmetrix"></span>: <a href="" class="aj_step2b_url" target="_blank"></a></li>
277
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_step2c_gtmetrix"></span>: <a href="" class="aj_step2c_url" target="_blank"></a></li>
278
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_step2d_gtmetrix"></span>: <a href="" class="aj_step2d_url" target="_blank"></a></li>
279
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a></li>
280
- </ul>
281
- <p><?php _e('Click one of the buttons below to apply these settings or click the Settings button to go to the settings page for manual configuration.','asyncjs');?></p>
282
- <p>
283
- <button data-id="aj_step2b_apply" class="aj_steps_button"><?php _e('Apply','asyncjs');?> <span class="aj_step2b_gtmetrix"></button>
284
- <button data-id="aj_step2c_apply" class="aj_steps_button"><?php _e('Apply','asyncjs');?> <span class="aj_step2c_gtmetrix"></button>
285
- <button data-id="aj_step2d_apply" class="aj_steps_button"><?php _e('Apply','asyncjs');?> <span class="aj_step2d_gtmetrix"></button>
286
- <button data-id="aj_step2e_apply" class="aj_steps_button"><?php _e('Apply','asyncjs');?> <span class="aj_step2e_gtmetrix"></button>
287
- </p>
288
- <p>
289
- <button data-id="aj_goto_settings" class="aj_steps_button"><?php _e('Settings','asyncjs');?></button>
290
- </p>
291
- </div>
292
- <div id="aj_step4_jquery_not_excluded">
293
- <p><?php _e('In most cases the issue being experienced relates to jQuery (usually due to inline JavaScript which relies on jQuery) and the solution is to exclude jQuery.','asyncjs');?></p>
294
- <p><?php _e('Below are links that can be used to run simulations on each of the configurations with jQuery excluded. Click on each of the links and check the functionality of your site as well as the console for errors.','asyncjs');?></p>
295
- <ul>
296
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_step2d_gtmetrix"></span>: <a href="" class="aj_step2d_url" target="_blank"></a></li>
297
- <li><?php _e('Simulate','asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a></li>
298
- </ul>
299
- <p><?php _e('Click one of the buttons below to apply these settings or click the Settings button to go to the settings page for manual configuration.','asyncjs');?></p>
300
- <p>
301
- <button data-id="aj_step2d_apply" class="aj_steps_button"><?php _e('Apply','asyncjs');?> <span class="aj_step2d_gtmetrix"></button>
302
- <button data-id="aj_step2e_apply" class="aj_steps_button"><?php _e('Apply','asyncjs');?> <span class="aj_step2e_gtmetrix"></button>
303
- </p>
304
- <p>
305
- <button data-id="aj_goto_settings" class="aj_steps_button"><?php _e('Settings','asyncjs');?></button>
306
- </p>
307
- </div>
308
- </div>
309
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  </tr>
311
- <tr id="aj_step5" class="aj_steps_hidden">
312
- <td scope="row" align="center" style="vertical-align: top !important;"><img src="<?php echo AJ_PLUGIN_URL; ?>images/number_five_break_hole_150_clr_18842.gif" title="Further Hints &amp; Tips" alt="Further Hints &amp; Tips" class="aj_step_img"></td>
313
- <td scope="row" align="left">
314
- <?php echo $this->hints_tips(); ?>
315
- <p><button data-id="aj_goto_settings" class="aj_steps_button">Settings</button></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  </td>
317
  </tr>
 
 
 
 
 
 
 
 
318
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  <?php
1
  <?php
2
+ if (! defined('ABSPATH')) {
3
  exit; // Exit if accessed directly
4
  }
5
 
6
+ /*
7
  * this displays the wizard screen
8
  * uses the AJAX functions
9
  */
10
+
11
+ $site_url = trailingslashit(get_site_url());
12
+ $aj_gtmetrix_username = get_option('aj_gtmetrix_username', '');
13
+ $aj_gtmetrix_api_key = get_option('aj_gtmetrix_api_key', '');
14
+ $aj_gtmetrix_server = get_option('aj_gtmetrix_server', '');
15
+ if ($aj_gtmetrix_username != '' && $aj_gtmetrix_api_key != '') {
16
  $test = new Services_WTF_Test();
17
+ $test->api_username($aj_gtmetrix_username);
18
+ $test->api_password($aj_gtmetrix_api_key);
19
+ $test->user_agent(AJ_UA);
20
  $status = $test->status();
21
  $credits = $status['api_credits'];
22
  } else {
23
  $credits = 'N/A';
24
  }
25
  ?>
26
+
27
+ <div class="asItemDetail" id="aj_step1">
28
+ <h3><?php _e('Step 1: GTmetrix API Key', 'asyncjs'); ?></h3>
29
+ <p><?php _e('<strong><em>Please Note:</em></strong> You do not have to use this Wizard. All settings can be changed under the', 'asyncjs'); ?> <a href="<?php echo menu_page_url(AJ_ADMIN_MENU_SLUG, false) . '&tab=settings'; ?>"><?php _e('Settings', 'asyncjs'); ?></a> <?php _e('tab.', 'asyncjs'); ?></p>
30
+ <hr />
31
+ <p><?php _e("If you haven't already done so, grab an API Key from GTmetrix so that Async JavaScript can obtain your PageSpeed / YSlow results. Here's how:", 'asyncjs'); ?></p>
32
+ <ol>
33
+ <li><?php _e('Navigate to ', 'asyncjs'); ?><a href="https://gtmetrix.com/api/" target="_blank">https://gtmetrix.com/api/</a> <?php _e('(link opens in a new tab)', 'asyncjs'); ?></li>
34
+ <li><?php _e("If you do not already have an account with GTmetrix, go ahead and sign up (it's FREE!).", 'asyncjs'); ?></li>
35
+ <li><?php _e('Log in to your GTmetrix account.', 'asyncjs'); ?></li>
36
+ <li><?php _e("If you haven't yet generated your API Key, click on <strong>Generate API Key</strong>", 'asyncjs'); ?></li>
37
+ <li><?php _e('Copy your Username and API Key into the fields below:', 'asyncjs'); ?><br /><input type="text" id="aj_gtmetrix_username" value="<?php echo $aj_gtmetrix_username; ?>" placeholder="GTmetrix Username"><input type="text" id="aj_gtmetrix_api_key" value="<?php echo $aj_gtmetrix_api_key; ?>" placeholder="GTmetrix API Key"></li>
38
+ <li><?php _e('Select the desired server.', 'asyncjs'); ?><br />
39
+ <select id="aj_gtmetrix_server">
40
+ <?php
41
+ $gtmetrix_locations = array(
42
+ 'Vancouver, Canada' => 1,
43
+ 'London, United Kingdom' => 2,
44
+ 'Sydney, Australia' => 3,
45
+ 'Dallas, United States' => 4,
46
+ 'Mumbai, India' => 5
47
+ );
48
+ foreach ($gtmetrix_locations as $location => $value) {
49
+ $selected = ($aj_gtmetrix_server == $value) ? ' selected="selected"' : '';
50
+ echo '<option value="' . $value . '"' . $selected . '>' . $location . '</option>';
51
+ }
52
+ ?>
53
+ </select>
54
+ </li>
55
+ <li><?php _e('GTmetrix Credits Available: ', 'asyncjs'); ?><span class="aj_gtmetrix_credits"><?php echo $credits; ?></span></li>
56
+ </ol>
57
+ <p><?php _e('<strong>Please Note:</strong> By clicking the button below you acknowledge that you understand that five (5) GTmetrix API credits will be used.', 'asyncjs'); ?></p>
58
+ <p><button data-id="aj_step2" class="aj_steps_button button"><?php _e('Proceed to Step 2', 'asyncjs'); ?></button></p>
59
+ </div>
60
+
61
+ <div class="asItemDetail aj_steps_hidden" id="aj_step2" >
62
+ <h3><?php _e('Step 2: Initial Test Results', 'asyncjs'); ?></h3>
63
+ <p><?php echo AJ_TITLE; ?> <?php _e('will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores.', 'asyncjs'); ?></p>
64
+ <div id="aj_step2_please_wait">
65
+ <div class="aj_loader"><h3 class="aj_loader_loading_text"><?php _e('Please Wait', 'asyncjs'); ?></h3></div>
66
+ </div>
67
+ <table id="aj_step2_gtmetrix_results" class="form-table aj-steps-table" style="width:100%;padding:10px;">
68
+ <tr>
69
+ <td><img src="" alt="GT Metrix Screenshot" class="aj_step2_screenshot aj_gtmetrix_screenshot">
70
+ <td>
71
+ <h3><?php _e('PageSpeed Score', 'asyncjs'); ?></h3>
72
+ <span class="aj_step2_pagespeed aj_gtmetrix_result"></span>
73
  </td>
74
+ <td>
75
+ <h3><?php _e('YSlow Score', 'asyncjs'); ?></h3>
76
+ <span class="aj_step2_yslow aj_gtmetrix_result"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </td>
78
+ <td>
79
+ <h3><?php _e('Fully Loaded Time', 'asyncjs'); ?></h3>
80
+ <span class="aj_step2_flt aj_gtmetrix_result"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  </td>
82
+ <td>
83
+ <h3><?php _e('Total Page Size', 'asyncjs'); ?></h3>
84
+ <span class="aj_step2_tps aj_gtmetrix_result"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  </td>
86
+ <td>
87
+ <h3><?php _e('Requests', 'asyncjs'); ?></h3>
88
+ <span class="aj_step2_requests aj_gtmetrix_result"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  </td>
90
  </tr>
91
+
92
+ <tr>
93
+ <td colspan="6"><?php _e('See full report:', 'asyncjs'); ?> <span class="aj_step2_report"></span></td>
94
+ </tr>
95
+ <tr>
96
+ <td colspan="6"><?php _e('Simulate', 'asyncjs'); ?> <span class="aj_step2_gtmetrix"></span>: <a href="" class="aj_step2_url" target="_blank"></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  </tr>
98
+
99
+ </table>
100
+ </div>
101
+
102
+ <div class="asItemDetail aj_steps_hidden" id="aj_step2b">
103
+ <h3><?php _e('Testing: Async', 'asyncjs');?></h3>
104
+ <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'async' method.", 'asyncjs'); ?></p>
105
+ <div id="aj_step2b_please_wait"><div class="aj_loader">
106
+ <h3 class="aj_loader_loading_text"><?php _e('Please Wait', 'asyncjs'); ?></h3></div>
107
+ </div>
108
+ <table id="aj_step2b_gtmetrix_results" class="form-table aj-steps-table" style="width:100%;padding:10px;">
109
+ <tr>
110
+ <td><img src="" alt="GT Metrix Screenshot" class="aj_step2b_screenshot aj_gtmetrix_screenshot">
111
+ <td>
112
+ <h3><?php _e('PageSpeed Score', 'asyncjs');?></h3>
113
+ <span class="aj_step2b_pagespeed aj_gtmetrix_result"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  </td>
115
+ <td>
116
+ <h3><?php _e('YSlow Score', 'asyncjs');?></h3>
117
+ <span class="aj_step2b_yslow aj_gtmetrix_result"></span>
118
+ </td>
119
+ <td>
120
+ <h3><?php _e('Fully Loaded Time', 'asyncjs');?></h3>
121
+ <span class="aj_step2b_flt aj_gtmetrix_result"></span>
122
+ </td>
123
+ <td>
124
+ <h3><?php _e('Total Page Size', 'asyncjs');?></h3>
125
+ <span class="aj_step2b_tps aj_gtmetrix_result"></span>
126
+ </td>
127
+ <td>
128
+
129
+ <h3><?php _e('Requests', 'asyncjs');?></h3>
130
+ <span class="aj_step2b_requests aj_gtmetrix_result"></span>
131
+ </td>
132
+ </tr>
133
+ <tr>
134
+ <td colspan="6"><?php _e('See full report:', 'asyncjs');?> <span class="aj_step2b_report"></span></td>
135
+ </tr>
136
+ <tr>
137
+ <td colspan="6"><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2b_gtmetrix"></span>: <a href="" class="aj_step2b_url" target="_blank"></a>
138
  </tr>
139
+
140
+ </table>
141
+ </div>
142
+
143
+ <div class="asItemDetail aj_steps_hidden" id="aj_step2c">
144
+ <h3><?php _e('Testing: Defer', 'asyncjs');?></h3>
145
+ <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'defer' method.", 'asyncjs');?></p>
146
+ <div id="aj_step2c_please_wait">
147
+ <div class="aj_loader"><h3 class="aj_loader_loading_text"><?php _e('Please Wait', 'asyncjs'); ?></h3></div>
148
+ </div>
149
+ <table id="aj_step2c_gtmetrix_results" class="form-table aj-steps-table" style="width:100%;padding:10px;">
150
+ <tr>
151
+ <td><img src="" alt="GT Metrix Screenshot" class="aj_step2c_screenshot aj_gtmetrix_screenshot">
152
+ <td>
153
+ <h3><?php _e('PageSpeed Score', 'asyncjs');?></h3>
154
+ <span class="aj_step2c_pagespeed aj_gtmetrix_result"></span>
155
+ </td>
156
+ <td>
157
+ <h3><?php _e('YSlow Score', 'asyncjs');?></h3>
158
+ <span class="aj_step2c_yslow aj_gtmetrix_result"></span>
159
+ </td>
160
+ <td>
161
+ <h3><?php _e('Fully Loaded Time', 'asyncjs');?></h3>
162
+ <span class="aj_step2c_flt aj_gtmetrix_result"></span>
163
+ </td>
164
+ <td>
165
+ <h3><?php _e('Total Page Size', 'asyncjs');?></h3>
166
+ <span class="aj_step2c_tps aj_gtmetrix_result"></span>
167
  </td>
168
+ <td>
169
+ <h3><?php _e('Requests', 'asyncjs');?></h3>
170
+ <span class="aj_step2c_requests aj_gtmetrix_result"></span>
171
+ </td>
172
+ </tr>
173
+ <tr>
174
+ <td colspan="6"><?php _e('See full report:', 'asyncjs');?> <span class="aj_step2c_report"></span></td>
175
  </tr>
176
+ <tr>
177
+ <td colspan="6"><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2c_gtmetrix"></span>: <a href="" class="aj_step2c_url" target="_blank"></a>
178
+ </tr>
179
+
180
+ </table>
181
+ </div>
182
+
183
+ <div class="asItemDetail aj_steps_hidden" id="aj_step2d">
184
+ <h3><?php _e('Testing: Async (jQuery excluded)', 'asyncjs');?></h3>
185
+ <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'async' method but excluding jQuery.", 'asyncjs');?></p>
186
+ <div id="aj_step2d_please_wait">
187
+ <div class="aj_loader"><h3 class="aj_loader_loading_text"><?php _e('Please Wait', 'asyncjs'); ?></h3></div>
188
+ </div>
189
+ <table id="aj_step2d_gtmetrix_results" class="form-table aj-steps-table" style="width:100%;padding:10px;">
190
+ <tr>
191
+ <td><img src="" alt="GT Metrix Screenshot" class="aj_step2d_screenshot aj_gtmetrix_screenshot">
192
+ <td>
193
+ <h3><?php _e('PageSpeed Score', 'asyncjs');?></h3>
194
+ <span class="aj_step2d_pagespeed aj_gtmetrix_result"></span>
195
+ </td>
196
+ <td>
197
+ <h3><?php _e('YSlow Score', 'asyncjs');?></h3>
198
+ <span class="aj_step2d_yslow aj_gtmetrix_result"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  </td>
200
+ <td>
201
+ <h3><?php _e('Fully Loaded Time', 'asyncjs');?></h3>
202
+ <span class="aj_step2d_flt aj_gtmetrix_result"></span>
203
+
204
+ </td>
205
+ <td>
206
+ <h3><?php _e('Total Page Size', 'asyncjs');?></h3>
207
+ <span class="aj_step2d_tps aj_gtmetrix_result"></span>
208
+ </td>
209
+ <td>
210
+ <h3><?php _e('Requests', 'asyncjs');?></h3>
211
+ <span class="aj_step2d_requests aj_gtmetrix_result"></span>
212
+ </td>
213
+ </tr>
214
+ <tr>
215
+ <td colspan="6"><?php _e('See full report:', 'asyncjs');?> <span class="aj_step2d_report"></span></td>
216
+ </tr>
217
+ <tr>
218
+ <td colspan="6"><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2d_gtmetrix"></span>: <a href="" class="aj_step2d_url" target="_blank"></a>
219
  </tr>
220
+
221
+ </table>
222
+ </div>
223
+
224
+ <div class="asItemDetail aj_steps_hidden" id="aj_step2e">
225
+ <h3><?php _e('Testing: Defer (jQuery excluded)', 'asyncjs');?></h3>
226
+ <p><?php echo AJ_TITLE; ?> <?php _e("will now query GTmetrix and retrieve your sites PageSpeed and YSlow scores whilst simulating the JavaScript 'defer' method but excluding jQuery.", 'asyncjs');?></p>
227
+ <div id="aj_step2e_please_wait">
228
+ <div class="aj_loader"><h3 class="aj_loader_loading_text"><?php _e('Please Wait', 'asyncjs'); ?></h3></div>
229
+ </div>
230
+ <table id="aj_step2e_gtmetrix_results" class="form-table aj-steps-table" style="width:100%;padding:10px;">
231
+ <tr>
232
+ <td><img src="" alt="GT Metrix Screenshot" class="aj_step2e_screenshot aj_gtmetrix_screenshot">
233
+ <td>
234
+ <h3><?php _e('PageSpeed Score', 'asyncjs');?></h3>
235
+ <span class="aj_step2e_pagespeed aj_gtmetrix_result"></span>
236
+ </td>
237
+ <td>
238
+ <h3><?php _e('YSlow Score', 'asyncjs');?></h3>
239
+ <span class="aj_step2e_yslow aj_gtmetrix_result"></span>
240
+ </td>
241
+ <td>
242
+ <h3><?php _e('Fully Loaded Time', 'asyncjs');?></h3>
243
+ <span class="aj_step2e_flt aj_gtmetrix_result"></span>
244
+ </td>
245
+ <td>
246
+ <h3><?php _e('Total Page Size', 'asyncjs');?></h3>
247
+ <span class="aj_step2e_tps aj_gtmetrix_result"></span>
248
+ </td>
249
+ <td>
250
+ <h3><?php _e('Requests', 'asyncjs');?></h3>
251
+ <span class="aj_step2e_requests aj_gtmetrix_result"></span>
252
  </td>
253
  </tr>
254
+ <tr>
255
+ <td colspan="6"><?php _e('See full report:', 'asyncjs');?> <span class="aj_step2e_report"></span></td>
256
+ </tr>
257
+ <tr>
258
+ <td colspan="6"><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a>
259
+ </tr>
260
+ <tr><td scope="row" align="left" colspan="6"><?php _e('See full report:', 'asyncjs');?> <span class="aj_step2e_report"></span></td></tr>
261
+ <tr><td scope="row" align="left" colspan="6"><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a></tr>
262
  </table>
263
+ </div>
264
+
265
+ <div class="asItemDetail aj_steps_hidden" id="aj_step_results">
266
+ <h3><?php _e('Step 3: Results &amp; Recommendations', 'asyncjs');?></h3>
267
+ <p><?php echo AJ_TITLE; ?> <?php _e('has finished testing your site with the most common configuration options.', 'asyncjs');?></p>
268
+ <p><?php _e('Based on the tests Async JavaScript has determined that <span class="aj_gtmetrix_config"></span> has resuled in <span id="aj_gtmetrix_inde_pagespeed"></span> in PageSpeed from <span id="aj_gtmetrix_baseline_pagespeed"></span> to <span id="aj_gtmetrix_best_pagespeed"></span> and <span id="aj_gtmetrix_inde_yslow"></span> in YSlow from <span id="aj_gtmetrix_baseline_yslow"></span> to <span id="aj_gtmetrix_best_yslow"></span>, with a Fully Loaded time of', 'asyncjs');?> <span id="aj_gtmetrix_best_fullyloaded"></span>.</p>
269
+ <p><?php _e('Before applying these settings it is important to check your site is still functioning correctly. Click the link below to open your site in a new tab / window to simulate the <?php echo AJ_TITLE; ?> settings and check that everything is working, and also be sure to check the console for any JavaScript errors (see <a href="https://codex.wordpress.org/Using_Your_Browser_to_Diagnose_JavaScript_Errors" target="_blank">Using Your Browser to Diagnose JavaScript Errors</a>)', 'asyncjs');?></p>
270
+ <ul>
271
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_gtmetrix_config"></span>: <a href="" id="aj_gtmetrix_best_url" target="_blank"></a></li>
272
+ </ul>
273
+ <p><?php _e('Once you have simulated', 'asyncjs');?> <span class="aj_gtmetrix_config"></span> <?php _e('click on the button below to continue.', 'asyncjs');?></p>
274
+ <p><button data-id="aj_step4" class="aj_steps_button button"><?php _e('Proceed to Step 4', 'asyncjs');?></button></p>
275
+ </div>
276
+
277
+ <div class="asItemDetail aj_steps_hidden" id="aj_step4">
278
+ <h3><?php _e('Step 4: Apply Settings', 'asyncjs');?></h3>
279
+ <p><?php _e('Is your site still functioning properly and are there no JavaScript errors in the console?', 'asyncjs');?></p>
280
+ <p><input type="radio" name="aj_step4_check" value="y"> <?php _e('Yes', 'asyncjs');?> <input type="radio" name="aj_step4_check" value="n"> <?php _e('No', 'asyncjs');?></p>
281
+ <div id="aj_step4_y">
282
+ <p><?php _e('Great to hear! To apply these settings click the button below.', 'asyncjs');?></p>
283
+ <p><button data-id="aj_apply_settings" class="aj_steps_button button"><?php _e('Apply Settings', 'asyncjs');?></button></p>
284
+ </div>
285
+ <div id="aj_step4_n">
286
+ <p><?php _e('Ok, so you have run the simulation on <span class="aj_gtmetrix_config"></span> and although there has been an improvement in reported performance, the simulation shows that something is not right with your site.', 'asyncjs');?></p>
287
+ <div id="aj_step4_jquery_excluded">
288
+ <p><?php _e('In most cases the issue being experienced relates to jQuery (usually due to inline JavaScript which relies on jQuery) and the solution is to exclude jQuery. However, in this simulation jQuery has already been exculded. As a result a different configuration may work better with a marginal sacrifice in site speed improvement.', 'asyncjs');?></p>
289
+ <p><?php _e('Below are links that can be used to run simulations on each of the basic configurations. Click on each of the links and check the functionality of your site as well as the console for errors.', 'asyncjs');?></p>
290
+ <ul>
291
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2b_gtmetrix"></span>: <a href="" class="aj_step2b_url" target="_blank"></a></li>
292
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2c_gtmetrix"></span>: <a href="" class="aj_step2c_url" target="_blank"></a></li>
293
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2d_gtmetrix"></span>: <a href="" class="aj_step2d_url" target="_blank"></a></li>
294
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a></li>
295
+ </ul>
296
+ <p><?php _e('Click one of the buttons below to apply these settings or click the Settings button to go to the settings page for manual configuration.', 'asyncjs');?></p>
297
+ <p>
298
+ <button data-id="aj_step2b_apply" class="aj_steps_button button"><?php _e('Apply', 'asyncjs');?> <span class="aj_step2b_gtmetrix"></span></button>
299
+ <button data-id="aj_step2c_apply" class="aj_steps_button button"><?php _e('Apply', 'asyncjs');?> <span class="aj_step2c_gtmetrix"></span></button>
300
+ <button data-id="aj_step2d_apply" class="aj_steps_button button"><?php _e('Apply', 'asyncjs');?> <span class="aj_step2d_gtmetrix"></span></button>
301
+ <button data-id="aj_step2e_apply" class="aj_steps_button button"><?php _e('Apply', 'asyncjs');?> <span class="aj_step2e_gtmetrix"></span></button>
302
+ </p>
303
+ <p>
304
+ <button data-id="aj_goto_settings" class="aj_steps_button button"><?php _e('Settings', 'asyncjs');?></button>
305
+ </p>
306
+ </div>
307
+ <div id="aj_step4_jquery_not_excluded">
308
+ <p><?php _e('In most cases the issue being experienced relates to jQuery (usually due to inline JavaScript which relies on jQuery) and the solution is to exclude jQuery.', 'asyncjs');?></p>
309
+ <p><?php _e('Below are links that can be used to run simulations on each of the configurations with jQuery excluded. Click on each of the links and check the functionality of your site as well as the console for errors.', 'asyncjs');?></p>
310
+ <ul>
311
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2d_gtmetrix"></span>: <a href="" class="aj_step2d_url" target="_blank"></a></li>
312
+ <li><?php _e('Simulate', 'asyncjs');?> <span class="aj_step2e_gtmetrix"></span>: <a href="" class="aj_step2e_url" target="_blank"></a></li>
313
+ </ul>
314
+ <p><?php _e('Click one of the buttons below to apply these settings or click the Settings button to go to the settings page for manual configuration.', 'asyncjs');?></p>
315
+ <p>
316
+ <button data-id="aj_step2d_apply" class="aj_steps_button button"><?php _e('Apply', 'asyncjs');?> <span class="aj_step2d_gtmetrix"></span></button>
317
+ <button data-id="aj_step2e_apply" class="aj_steps_button button"><?php _e('Apply', 'asyncjs');?> <span class="aj_step2e_gtmetrix"></span></button>
318
+ </p>
319
+ <p>
320
+ <button data-id="aj_goto_settings" class="aj_steps_button button"><?php _e('Settings', 'asyncjs');?></button>
321
+ </p>
322
+ </div>
323
+ </div>
324
+ </div>
325
+
326
+ <div class="asItemDetail aj_steps_hidden" id="aj_step5">
327
+ <?php echo $this->hints_tips(); ?>
328
+ <p><button data-id="aj_goto_settings" class="aj_steps_button button">Settings</button></p>
329
+ </div>
330
+
331
  <?php
css/admin.css CHANGED
@@ -1 +1,139 @@
1
- .aj_method,
2
  position:fixed;
3
  top:50%;
4
  left:40%;
5
  width:20%;
6
  z-index:105;
7
  text-align:center;
8
  font-weight:normal;
9
  font-size:14px;
10
  font-weight:bold;
11
  color:white;
12
  background-color:#FF7800;
13
  padding:5px;
14
  border:2px solid #FFF;
15
  padding:0 5px;
16
  cursor:pointer;
17
  float:right;
18
  margin-right:10px;
19
  color:white;
20
  text-decoration:none;
21
  font-weight:bold
22
  padding: 15px;
23
  background-color: #f5f5dc;
24
  margin-top: 15px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  position:fixed;
2
  top:50%;
3
  left:40%;
4
  width:20%;
5
  z-index:105;
6
  text-align:center;
7
  font-weight:normal;
8
  font-size:14px;
9
  font-weight:bold;
10
  color:white;
11
  background-color:#FF7800;
12
  padding:5px;
13
  border:2px solid #FFF;
14
  padding:0 5px;
15
  cursor:pointer;
16
  float:right;
17
  margin-right:10px;
18
  color:white;
19
  text-decoration:none;
20
  font-weight:bold
21
  padding: 15px;
22
  background-color: #f5f5dc;
23
  margin-top: 15px;
24
+ .aj_method,
25
+ .aj_steps_hidden,
26
+ #aj_step2_gtmetrix_results,
27
+ #aj_step2b_gtmetrix_results,
28
+ #aj_step2c_gtmetrix_results,
29
+ #aj_step2d_gtmetrix_results,
30
+ #aj_step2e_gtmetrix_results,
31
+ #aj_latest_please_wait,
32
+ #aj_step4_y,
33
+ #aj_step4_n,
34
+ #aj_notification {
35
+ display: none;
36
+ }
37
+ #aj_step2_gtmetrix_results td,
38
+ #aj_step2b_gtmetrix_results td,
39
+ #aj_step2c_gtmetrix_results td,
40
+ #aj_step2d_gtmetrix_results td,
41
+ #aj_step2e_gtmetrix_results td {
42
+ vertical-align: top;
43
+ text-align: center;
44
+ }
45
+ .aj_gtmetrix_result {
46
+ font-size: 2rem;
47
+ }
48
+ .aj_gtmetrix_screenshot,
49
+ #aj_notification {
50
+ -webkit-box-shadow: 0px 0px 15px 5px rgba(0, 0, 0, 0.75);
51
+ -moz-box-shadow: 0px 0px 15px 5px rgba(0, 0, 0, 0.75);
52
+ box-shadow: 0px 0px 15px 5px rgba(0, 0, 0, 0.75);
53
+ max-width: 200px;
54
+ }
55
+ .aj_gtmetrix_screenshot_dashboard {
56
+ -webkit-box-shadow: 0px 0px 15px 5px rgba(0, 0, 0, 0.75);
57
+ -moz-box-shadow: 0px 0px 15px 5px rgba(0, 0, 0, 0.75);
58
+ box-shadow: 0px 0px 15px 5px rgba(0, 0, 0, 0.75);
59
+ max-width: 125px;
60
+ }
61
+
62
+ .aj-steps-table h3 {
63
+ height: 2em;
64
+ }
65
+ .aj_step_img {
66
+ max-width: 150px;
67
+ }
68
+ .aj_field_error {
69
+ border: solid 1px #ff0000;
70
+ }
71
+ #aj_notification {
72
+ position: fixed;
73
+ top: 50%;
74
+ left: 40%;
75
+ width: 20%;
76
+ z-index: 105;
77
+ text-align: center;
78
+ font-weight: normal;
79
+ font-size: 14px;
80
+ font-weight: bold;
81
+ color: white;
82
+ background-color: #ff7800;
83
+ padding: 5px;
84
+ }
85
+ #aj_notification span.aj_dismiss {
86
+ border: 2px solid #fff;
87
+ padding: 0 5px;
88
+ cursor: pointer;
89
+ float: right;
90
+ margin-right: 10px;
91
+ }
92
+ #aj_notification a {
93
+ color: white;
94
+ text-decoration: none;
95
+ font-weight: bold;
96
+ }
97
+ .aj ol {
98
+ list-style-type: decimal;
99
+ }
100
+ .aj ul {
101
+ list-style-type: circle;
102
+ }
103
+ .aj ol,
104
+ .aj ul {
105
+ margin-left: 2em;
106
+ }
107
+ .aj_plugin {
108
+ border: solid 1px #cccccc;
109
+ padding: 15px;
110
+ background-color: #f5f5dc;
111
+ margin-top: 15px;
112
+ }
113
+ .aj_loader_loading_text {
114
+ margin: 0;
115
+ text-align: center;
116
+ }
117
+ .aj_loader {
118
+ height: 25px;
119
+ width: 100%;
120
+ content: "";
121
+ position: relative;
122
+ overflow: hidden;
123
+ background-color: #ddd;
124
+ }
125
+ .aj_loader:before {
126
+ display: block;
127
+ position: absolute;
128
+ content: "";
129
+ left: -200px;
130
+ width: 200px;
131
+ height: 25px;
132
+ background-color: #2980b9;
133
+ animation: aj_loading 3s linear infinite;
134
+ }
135
+
136
+ @keyframes aj_loading {
137
+ from {
138
+ left: -200px;
139
+ width: 30%;
140
+ }
141
+ 50% {
142
+ width: 30%;
143
+ }
144
+ 70% {
145
+ width: 70%;
146
+ }
147
+ 80% {
148
+ left: 50%;
149
+ }
150
+ 95% {
151
+ left: 120%;
152
+ }
153
+ to {
154
+ left: 100%;
155
+ }
156
+ }
157
+ .asItemDetail {
158
+ background: #fff;
159
+ border: 1px solid #ccc;
160
+ padding: 5px 15px;
161
+ margin: 15px 10px 10px 0;
162
+ }
css/admin.min.css CHANGED
@@ -1 +1 @@
1
- #aj_latest_please_wait,#aj_notification,#aj_step2_gtmetrix_results,#aj_step2b_gtmetrix_results,#aj_step2c_gtmetrix_results,#aj_step2d_gtmetrix_results,#aj_step2e_gtmetrix_results,#aj_step4_n,#aj_step4_y,.aj_method,.aj_steps_hidden{display:none}#aj_step2_gtmetrix_results td,#aj_step2b_gtmetrix_results td,#aj_step2c_gtmetrix_results td,#aj_step2d_gtmetrix_results td,#aj_step2e_gtmetrix_results td{vertical-align:top!important;text-align:center!important}.aj_gtmetrix_result{font-size:2.5rem!important}#aj_notification,.aj_gtmetrix_screenshot{-webkit-box-shadow:0 0 15px 5px rgba(0,0,0,.75);-moz-box-shadow:0 0 15px 5px rgba(0,0,0,.75);box-shadow:0 0 15px 5px rgba(0,0,0,.75);max-width:200px}.aj_gtmetrix_screenshot_dashboard{-webkit-box-shadow:0 0 15px 5px rgba(0,0,0,.75);-moz-box-shadow:0 0 15px 5px rgba(0,0,0,.75);box-shadow:0 0 15px 5px rgba(0,0,0,.75);max-width:125px}.aj-steps-table h3{height:2em!important}.aj_step_img{max-width:150px}.aj_field_error{border:1px solid red!important}#aj_notification{position:fixed;top:50%;left:40%;width:20%;z-index:105;text-align:center;font-size:14px;font-weight:700;color:#fff;background-color:#FF7800;padding:5px}#aj_notification span.aj_dismiss{border:2px solid #FFF;padding:0 5px;cursor:pointer;float:right;margin-right:10px}#aj_notification a{color:#fff;text-decoration:none;font-weight:700}.aj ol{list-style-type:decimal!important}.aj ul{list-style-type:circle!important}.aj ol,.aj ul{margin-left:2em!important}.aj_plugin{border:1px solid #ccc;padding:15px;background-color:beige;margin-top:15px}
1
+ #aj_latest_please_wait,#aj_notification,#aj_step2_gtmetrix_results,#aj_step2b_gtmetrix_results,#aj_step2c_gtmetrix_results,#aj_step2d_gtmetrix_results,#aj_step2e_gtmetrix_results,#aj_step4_n,#aj_step4_y,.aj_method,.aj_steps_hidden{display:none}#aj_step2_gtmetrix_results td,#aj_step2b_gtmetrix_results td,#aj_step2c_gtmetrix_results td,#aj_step2d_gtmetrix_results td,#aj_step2e_gtmetrix_results td{vertical-align:top;text-align:center}.aj_gtmetrix_result{font-size:2rem}#aj_notification,.aj_gtmetrix_screenshot{-webkit-box-shadow:0 0 15px 5px rgba(0,0,0,.75);-moz-box-shadow:0 0 15px 5px rgba(0,0,0,.75);box-shadow:0 0 15px 5px rgba(0,0,0,.75);max-width:200px}.aj_gtmetrix_screenshot_dashboard{-webkit-box-shadow:0 0 15px 5px rgba(0,0,0,.75);-moz-box-shadow:0 0 15px 5px rgba(0,0,0,.75);box-shadow:0 0 15px 5px rgba(0,0,0,.75);max-width:125px}.aj-steps-table h3{height:2em}.aj_loader,.aj_loader:before{content:"";height:25px}.aj_step_img{max-width:150px}.aj_field_error{border:1px solid red}#aj_notification{position:fixed;top:50%;left:40%;width:20%;z-index:105;text-align:center;font-size:14px;font-weight:700;color:#fff;background-color:#ff7800;padding:5px}#aj_notification span.aj_dismiss{border:2px solid #fff;padding:0 5px;cursor:pointer;float:right;margin-right:10px}.aj_plugin,.asItemDetail{border:1px solid #ccc;padding:15px}#aj_notification a{color:#fff;text-decoration:none;font-weight:700}.aj ol{list-style-type:decimal}.aj ul{list-style-type:circle}.aj ol,.aj ul{margin-left:2em}.aj_plugin{background-color:beige;margin-top:15px}.aj_loader_loading_text{margin:0;text-align:center}.aj_loader{width:100%;position:relative;overflow:hidden;background-color:#ddd}.aj_loader:before{display:block;position:absolute;left:-200px;width:200px;background-color:#2980b9;animation:aj_loading 3s linear infinite}@keyframes aj_loading{from{left:-200px;width:30%}50%{width:30%}70%{width:70%}80%{left:50%}95%{left:120%}to{left:100%}}.asItemDetail{background:#fff;margin:15px 10px 10px 0;padding:5px 15px;}
images/async-javascript-pro.jpg DELETED
Binary file
images/clock_fast_times_text_10762.gif DELETED
Binary file
images/crazy-one-week-sale.jpg DELETED
Binary file
images/finger_point_out_punch_hole_400_clr_17860.png DELETED
Binary file
images/loading.gif DELETED
Binary file
images/not_available.jpg DELETED
Binary file
images/number-block-eight.jpg DELETED
Binary file
images/number-block-five.jpg DELETED
Binary file
images/number-block-four.jpg DELETED
Binary file
images/number-block-nine.jpg DELETED
Binary file
images/number-block-one.jpg DELETED
Binary file
images/number-block-seven.jpg DELETED
Binary file
images/number-block-six.jpg DELETED
Binary file
images/number-block-three.jpg DELETED
Binary file
images/number-block-two.jpg DELETED
Binary file
images/number_five_break_hole_150_clr_18842.gif DELETED
Binary file
images/number_four_break_hole_150_clr_18840.gif DELETED
Binary file
images/number_one_break_hole_150_clr_18741.gif DELETED
Binary file
images/number_three_break_hole_150_clr_18837.gif DELETED
Binary file
images/number_two_break_hole_150_clr_18753.gif DELETED
Binary file
images/stick_figure_panicking_150_clr_13267.gif DELETED
Binary file
js/admin.js CHANGED
@@ -1,337 +1,403 @@
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();
6
- if ( theStep == 'aj_step_results' ) {
7
- var data = {
8
- 'action': 'aj_steps',
9
- 'sub_action': theStep,
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 {
18
- response = jQuery.parseJSON( response );
19
- if ( response.status !== false ) {
20
- var baseline_pagespeed = response.baseline_pagespeed;
21
- var baseline_yslow = response.baseline_yslow;
22
- var pagespeed = response.results.pagespeed_score;
23
- var yslow = response.results.yslow_score;
24
- var aj_gtmetrix_config = response.name;
25
- var flt = parseFloat( response.results.fully_loaded_time / 1000 ).toFixed( 2 );
26
- var url = response.url;
27
- jQuery( '.aj_gtmetrix_config' ).html( aj_gtmetrix_config );
28
- if ( pagespeed > baseline_pagespeed ) {
29
- jQuery( '#aj_gtmetrix_inde_pagespeed' ).html( 'an increase' );
30
- } else if ( pagespeed < baseline_pagespeed ) {
31
- jQuery( '#aj_gtmetrix_inde_pagespeed' ).html( 'a decrease' );
32
- } else {
33
- jQuery( '#aj_gtmetrix_inde_pagespeed' ).html( 'no change' );
34
- }
35
- if ( yslow > baseline_yslow ) {
36
- jQuery( '#aj_gtmetrix_inde_yslow' ).html( 'an increase' );
37
- } else if ( yslow < baseline_yslow ) {
38
- jQuery( '#aj_gtmetrix_inde_yslow' ).html( 'a decrease' );
39
- } else {
40
- jQuery( '#aj_gtmetrix_inde_yslow' ).html( 'no change' );
41
- }
42
- jQuery( '#aj_gtmetrix_baseline_pagespeed' ).html( baseline_pagespeed + '%' );
43
- jQuery( '#aj_gtmetrix_best_pagespeed' ).html( pagespeed + '%' );
44
- jQuery( '#aj_gtmetrix_baseline_yslow' ).html( baseline_yslow + '%' );
45
- jQuery( '#aj_gtmetrix_best_yslow' ).html( yslow + '%' );
46
- jQuery( '#aj_gtmetrix_best_fullyloaded' ).html( flt + 's' );
47
- jQuery( '#aj_gtmetrix_best_url' ).attr( 'href', url ).html( url );
48
- if ( response.id == 'aj_step2b' || response.id == 'aj_step2c' ) {
49
- jQuery( '#aj_step4_jquery_excluded' ).hide();
50
- jQuery( '#aj_step4_jquery_not_excluded' ).show();
51
- } else if ( response.id == 'aj_step2d' || response.id == 'aj_step2e' ) {
52
- jQuery( '#aj_step4_jquery_excluded' ).show();
53
- jQuery( '#aj_step4_jquery_not_excluded' ).hide();
54
- }
55
- jQuery( '.aj_gtmetrix_credits' ).html( response.credits );
56
- jQuery( '#aj_step_results' ).show();
57
- } else {
58
- console.log(response);
59
- }
60
- }
61
- catch( err ) {
62
- console.log( err );
63
- }
64
- });
65
- } else {
66
- var data = {
67
- 'action': 'aj_steps',
68
- 'sub_action': theStep,
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 {
77
- response = jQuery.parseJSON( response );
78
- if ( response.status !== false ) {
79
- var screenshot = response.results.report_url + '/screenshot.jpg';
80
- var pagespeed = response.results.pagespeed_score;
81
- var yslow = response.results.yslow_score;
82
- var flt = parseFloat( response.results.fully_loaded_time / 1000 ).toFixed( 2 );
83
- var tps = Math.floor( response.results.page_bytes / 1024 );
84
- if ( tps > 1024 ) {
85
- tps = tps / 1024 + 'MB';
86
- } else {
87
- tps = tps + 'KB';
88
- }
89
- var requests = response.results.page_elements;
90
- var report = '<a href="' + response.results.report_url + '" target="_blank">' + response.results.report_url + '</a>';
91
- var report_url = report.replace( 'https://', 'https://' + aj_gtmetrix_username + ':' + aj_gtmetrix_api_key + '@' );
92
- var step_name = response.name;
93
- var step_url = response.url;
94
- var pr = 255 * ( 1 - ( pagespeed / 100 ) );
95
- var yr = 255 * ( 1 - ( yslow / 100 ) );
96
- var pg = 255 * ( pagespeed / 100 );
97
- var yg = 255 * ( yslow / 100 );
98
- var prgb = 'rgb(' + Math.floor( pr ) + ',' + Math.floor( pg ) + ',0 )';
99
- var yrgb = 'rgb(' + Math.floor( yr ) + ',' + Math.floor( yg ) + ',0 )';
100
- if ( theStep == 'aj_gtmetrix_test' ) {
101
- theStep = 'aj_latest';
102
- }
103
- jQuery( '#' + theStep + '_please_wait' ).hide();
104
- jQuery( '.' + theStep + '_screenshot' ).attr( 'src', screenshot );
105
- jQuery( '.' + theStep + '_pagespeed' ).html( pagespeed + '%' ).css( { color: prgb } );
106
- jQuery( '.' + theStep + '_yslow' ).html( yslow + '%' ).css( { color: yrgb } );
107
- jQuery( '.' + theStep + '_flt' ).html( flt + 's' );
108
- jQuery( '.' + theStep + '_tps' ).html( tps );
109
- jQuery( '.' + theStep + '_requests' ).html( requests );
110
- jQuery( '.' + theStep + '_report' ).html( report_url );
111
- jQuery( '#' + theStep + '_gtmetrix_results' ).show();
112
- jQuery( '.' + theStep + '_gtmetrix' ).html( step_name );
113
- jQuery( '.' + theStep + '_url' ).attr( 'href', step_url ).html( step_url );
114
- jQuery( '.aj_gtmetrix_credits' ).html( response.credits );
115
- if ( theStep == 'aj_step2' ) {
116
- jQuery( '#aj_notification' ).fadeIn( 'slow' ).html( 'Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>' );
117
- jQuery( '#aj_step2b' ).show();
118
- jQuery( 'html, body' ).animate({
119
- scrollTop: jQuery( "#aj_step2b" ).offset().top
120
- }, 1000 );
121
- aj_step( 'aj_step2b' );
122
- } else if ( theStep == 'aj_step2b' ) {
123
- jQuery( '#aj_step2c' ).show();
124
- jQuery( 'html, body' ).animate({
125
- scrollTop: jQuery( "#aj_step2c" ).offset().top
126
- }, 1000 );
127
- aj_step( 'aj_step2c' );
128
- } else if ( theStep == 'aj_step2c' ) {
129
- jQuery( '#aj_step2d' ).show();
130
- jQuery( 'html, body' ).animate({
131
- scrollTop: jQuery( "#aj_step2d" ).offset().top
132
- }, 1000 );
133
- aj_step( 'aj_step2d' );
134
- } else if ( theStep == 'aj_step2d' ) {
135
- jQuery( '#aj_step2e' ).show();
136
- jQuery( 'html, body' ).animate({
137
- scrollTop: jQuery( "#aj_step2e" ).offset().top
138
- }, 1000 );
139
- aj_step( 'aj_step2e' );
140
- } else if ( theStep == 'aj_step2e' ) {
141
- jQuery( '#aj_step_results' ).show();
142
- jQuery( 'html, body' ).animate({
143
- scrollTop: jQuery( "#aj_step_results" ).offset().top
144
- }, 1000 );
145
- aj_step( 'aj_step_results' );
146
- } else if ( theStep == 'aj_latest' ) {
147
- jQuery( '#aj_notification' ).fadeIn( 'slow' ).html( 'Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>' );
148
- jQuery( '#aj_latest_gtmetrix_results' ).show();
149
- jQuery( '#aj_latest_please_wait' ).hide();
150
- jQuery( 'html, body' ).animate({
151
- scrollTop: jQuery( "#aj_latest_please_wait" ).offset().top
152
- }, 1000 );
153
- }
154
- } else {
155
- console.log(response);
156
- }
157
- }
158
- catch( err ) {
159
- console.log( err );
160
- }
161
- });
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
 
165
  /**
166
  * functions and actions to load after document ready
167
  */
168
- jQuery( document ).ready( function() {
169
- if ( typeof jQuery( '.aj_chosen' ).chosen === "function" ) {
170
- jQuery( '.aj_chosen' ).chosen();
171
- }
172
 
173
- jQuery( document ).on( 'click', '.aj-upgrade-notice .notice-dismiss', function() {
174
- var aj_nonce = jQuery( '#aj_nonce' ).val();
175
- var notice_id = jQuery( '.aj-upgrade-notice' ).attr( 'data-id' );
176
- jQuery.ajax({
177
- url: aj.ajaxurl,
178
- data: {
179
- 'action': 'async_javascript_dismiss_upgrade',
180
- 'notice_id': notice_id,
181
- 'security': aj_nonce
182
- }
183
- });
184
- });
 
 
 
 
185
 
186
- jQuery( document ).on( 'click', '.aj_steps_button', function(e) {
187
- e.preventDefault();
188
- var aj_nonce = jQuery( '#aj_nonce' ).val();
189
- var theStep = jQuery( this ).attr( 'data-id' );
190
- if ( theStep == 'aj_goto_settings' ) {
191
- var newURL = aj_localize_admin.ajadminurl + '&tab=settings';
192
- window.location.href = newURL;
193
- } else if ( theStep == 'aj_apply_settings' || theStep == 'aj_step2b_apply' || theStep == 'aj_step2c_apply' || theStep == 'aj_step2d_apply' || theStep == 'aj_step2e_apply') {
194
- if ( theStep != 'aj_apply_settings' ) {
195
- var settings = theStep.replace( '_apply', '' );
196
- } else {
197
- var settings = '';
198
- jQuery( '#aj_notification' ).fadeIn( 'slow' ).html( 'Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>' );
199
- }
200
- var data = {
201
- 'action': 'aj_steps',
202
- 'sub_action': 'aj_apply_settings',
203
- 'settings': settings,
204
- 'site_url': aj_localize_admin.siteurl,
205
- 'security': aj_nonce
206
- };
207
- jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
208
- try {
209
- response = jQuery.parseJSON( response );
210
- if ( response.status !== false ) {
211
- if ( jQuery( '#aj_step4' ).length ) {
212
- jQuery( '#aj_step5' ).show();
213
- jQuery( 'html, body' ).animate({
214
- scrollTop: jQuery( "#aj_step5" ).offset().top
215
- }, 1000 );
216
- if ( settings != '' ) {
217
- jQuery( '#aj_notification' ).fadeIn( 'slow' ).html( 'Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>' );
218
- }
219
- } else {
220
- if ( settings != '' ) {
221
- jQuery( '#aj_notification' ).fadeIn( 'slow' ).html( 'Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>' );
222
- var newURL = aj_localize_admin.ajadminurl + '&tab=settings';
223
- window.location.href = newURL;
224
- }
225
- }
226
- } else {
227
- console.log(response);
228
- }
229
- }
230
- catch( err ) {
231
- console.log( err );
232
- }
233
- });
234
- } else if ( theStep == 'aj_save_settings' ) {
235
- if ( jQuery( '#aj_enabled' ).is( ':checked' ) ) {
236
- var aj_enabled = 1;
237
  } else {
238
- var aj_enabled = 0;
 
 
 
 
239
  }
240
- var aj_method = jQuery( 'input[type=radio][name=aj_method]:checked' ).val();
241
- var aj_jquery = jQuery( 'input[type=radio][name=aj_jquery]:checked' ).val();
242
- var aj_async = jQuery( '#aj_async' ).val();
243
- var aj_defer = jQuery( '#aj_defer' ).val();
244
- var aj_exclusions = jQuery( '#aj_exclusions' ).val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
- if ( typeof jQuery( '.aj_chosen' ).chosen === "function" ) {
247
- var aj_plugin_exclusions = jQuery( '#aj_plugin_exclusions' ).chosen().val();
248
- var aj_theme_exclusions = jQuery( '#aj_theme_exclusions' ).chosen().val();
249
- } else {
250
- var aj_plugin_exclusions = jQuery( '#aj_plugin_exclusions' ).val();
251
- var aj_theme_exclusions = jQuery( '#aj_theme_exclusions' ).val();
252
- }
 
 
 
 
253
 
254
- if ( jQuery( '#aj_autoptimize_enabled' ).is( ':visible' ) ) {
255
- if ( jQuery( '#aj_autoptimize_enabled' ).is( ':checked' ) ) {
256
- var aj_autoptimize_enabled = 1;
257
- var aj_autoptimize_method = jQuery( 'input[type=radio][name=aj_autoptimize_method]:checked' ).val();
258
- } else {
259
- var aj_autoptimize_enabled = 0;
260
- var aj_autoptimize_method = jQuery( 'input[type=radio][name=aj_autoptimize_method]:checked' ).val();
261
- }
262
- } else {
263
- var aj_autoptimize_enabled = 0;
264
- var aj_autoptimize_method = 'async';
265
- }
266
- var data = {
267
- 'action': 'aj_steps',
268
- 'sub_action': 'aj_save_settings',
269
- 'aj_enabled': aj_enabled,
270
- 'aj_method': aj_method,
271
- 'aj_jquery': aj_jquery,
272
- 'aj_async': aj_async,
273
- 'aj_defer': aj_defer,
274
- 'aj_exclusions': aj_exclusions,
275
- 'aj_plugin_exclusions': aj_plugin_exclusions,
276
- 'aj_theme_exclusions': aj_theme_exclusions,
277
- 'aj_autoptimize_enabled': aj_autoptimize_enabled,
278
- 'aj_autoptimize_method': aj_autoptimize_method,
279
- 'security': aj_nonce
280
- };
281
- jQuery.post(aj_localize_admin.ajaxurl, data, function( response ) {
282
- try {
283
- response = jQuery.parseJSON( response );
284
- if ( response.status !== false ) {
285
- jQuery( '#aj_notification' ).fadeIn( 'slow' ).html( 'Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>' );
286
- } else {
287
- console.log(response);
288
- }
289
- }
290
- catch( err ) {
291
- console.log( err );
292
- }
293
- });
294
  } else {
295
- var aj_gtmetrix_username = jQuery( '#aj_gtmetrix_username' ).val();
296
- var aj_gtmetrix_api_key = jQuery( '#aj_gtmetrix_api_key' ).val();
297
- var aj_gtmetrix_server = jQuery( '#aj_gtmetrix_server' ).val();
298
- var isError = false;
299
- if ( aj_gtmetrix_username == '' ) {
300
- jQuery( '#aj_gtmetrix_username' ).addClass( 'aj_field_error' );
301
- isError = true;
302
- }
303
- if ( aj_gtmetrix_api_key == '' ) {
304
- jQuery( '#aj_gtmetrix_api_key' ).addClass( 'aj_field_error' );
305
- isError = true;
306
- }
307
- if ( isError === false ) {
308
- if ( theStep != 'aj_gtmetrix_test' ) {
309
- jQuery( this ).hide();
310
- jQuery( '#' + theStep ).show();
311
- } else {
312
- jQuery( '#aj_latest_please_wait' ).show();
313
- }
314
- aj_step( theStep );
315
- } else {
316
- return false;
317
- }
318
  }
319
- });
320
-
321
- jQuery( document ).on( 'change', 'input[type=radio][name=aj_step4_check]', function() {
322
- var aj_nonce = jQuery( '#aj_nonce' ).val();
323
- var theSelection = jQuery( this ).val();
324
- if ( theSelection == 'y' ) {
325
- jQuery( '#aj_step4_y' ).show();
326
- jQuery( '#aj_step4_n' ).hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  } else {
328
- jQuery( '#aj_step4_n' ).show();
329
- jQuery( '#aj_step4_y' ).hide();
330
  }
331
- });
 
 
 
 
 
332
 
333
- jQuery( document ).on( 'click', '.aj_dismiss', function() {
334
- var aj_nonce = jQuery( '#aj_nonce' ).val();
335
- jQuery( '#aj_notification' ).fadeOut( 'slow' );
336
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  });
1
+ /* globals aj_localize_admin,jQuery */
2
+ /* eslint no-console: 1 */
3
+ // updated:
4
+ // 2018-04-18 15:42:09
5
+ // add notify settings in its own global function
6
+ // so that it can easily be Modified and changed.
7
+ function notifySettingsSaved() {
8
+ jQuery("#aj_notification").
9
+ fadeIn("slow").
10
+ html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>').
11
+ delay(500).
12
+ fadeOut("slow");
13
+ }
14
+
15
+ function aj_step(theStep) {
16
+ var aj_nonce = jQuery("#aj_nonce").val();
17
+ var aj_gtmetrix_username = jQuery("#aj_gtmetrix_username").val();
18
+ var aj_gtmetrix_api_key = jQuery("#aj_gtmetrix_api_key").val();
19
+ var aj_gtmetrix_server = jQuery("#aj_gtmetrix_server").val();
20
+ var data = {
21
+ action: "aj_steps",
22
+ sub_action: theStep,
23
+ site_url: aj_localize_admin.siteurl,
24
+ aj_gtmetrix_username: aj_gtmetrix_username,
25
+ aj_gtmetrix_api_key: aj_gtmetrix_api_key,
26
+ aj_gtmetrix_server: aj_gtmetrix_server,
27
+ security: aj_nonce
28
+ };
29
+ if (theStep == "aj_step_results") {
30
+ jQuery.post(aj_localize_admin.ajaxurl, data, function(response) {
31
+ try {
32
+ response = jQuery.parseJSON(response);
33
+ if (response.status !== false) {
34
+ var baseline_pagespeed = response.baseline_pagespeed;
35
+ var baseline_yslow = response.baseline_yslow;
36
+ var pagespeed = response.results.pagespeed_score;
37
+ var yslow = response.results.yslow_score;
38
+ var aj_gtmetrix_config = response.name;
39
+ var flt = parseFloat(response.results.fully_loaded_time / 1000).toFixed(2);
40
+ var url = response.url;
41
+ jQuery(".aj_gtmetrix_config").html(aj_gtmetrix_config);
42
+ if (pagespeed > baseline_pagespeed) {
43
+ jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase");
44
+ } else if (pagespeed < baseline_pagespeed) {
45
+ jQuery("#aj_gtmetrix_inde_pagespeed").html("a decrease");
46
+ } else {
47
+ jQuery("#aj_gtmetrix_inde_pagespeed").html("no change");
48
+ }
49
+ if (yslow > baseline_yslow) {
50
+ jQuery("#aj_gtmetrix_inde_yslow").html("an increase");
51
+ } else if (yslow < baseline_yslow) {
52
+ jQuery("#aj_gtmetrix_inde_yslow").html("a decrease");
53
+ } else {
54
+ jQuery("#aj_gtmetrix_inde_yslow").html("no change");
55
+ }
56
+ jQuery("#aj_gtmetrix_baseline_pagespeed").html(baseline_pagespeed + "%");
57
+ jQuery("#aj_gtmetrix_best_pagespeed").html(pagespeed + "%");
58
+ jQuery("#aj_gtmetrix_baseline_yslow").html(baseline_yslow + "%");
59
+ jQuery("#aj_gtmetrix_best_yslow").html(yslow + "%");
60
+ jQuery("#aj_gtmetrix_best_fullyloaded").html(flt + "s");
61
+ jQuery("#aj_gtmetrix_best_url").
62
+ attr("href", url).
63
+ html(url);
64
+ if (response.id == "aj_step2b" || response.id == "aj_step2c") {
65
+ jQuery("#aj_step4_jquery_excluded").hide();
66
+ jQuery("#aj_step4_jquery_not_excluded").show();
67
+ } else if (response.id == "aj_step2d" || response.id == "aj_step2e") {
68
+ jQuery("#aj_step4_jquery_excluded").show();
69
+ jQuery("#aj_step4_jquery_not_excluded").hide();
70
+ }
71
+ jQuery(".aj_gtmetrix_credits").html(response.credits);
72
+ jQuery("#aj_step_results").show();
73
+ } else {
74
+ console.log(response);
75
+ }
76
+ } catch (err) {
77
+ console.log(err);
78
+ }
79
+ });
80
+ } else {
81
+ jQuery.post(aj_localize_admin.ajaxurl, data, function(response) {
82
+ try {
83
+ response = jQuery.parseJSON(response);
84
+ if (response.status !== false) {
85
+ var screenshot = response.results.report_url + "/screenshot.jpg";
86
+ var pagespeed = response.results.pagespeed_score;
87
+ var yslow = response.results.yslow_score;
88
+ var flt = parseFloat(response.results.fully_loaded_time / 1000).toFixed(2);
89
+ var tps = Math.floor(response.results.page_bytes / 1024);
90
+ if (tps > 1024) {
91
+ tps = tps / 1024 + "MB";
92
+ } else {
93
+ tps = tps + "KB";
94
+ }
95
+ var requests = response.results.page_elements;
96
+ var report =
97
+ '<a href="' +
98
+ response.results.report_url +
99
+ '" target="_blank">' +
100
+ response.results.report_url +
101
+ "</a>";
102
+ var report_url = report.replace(
103
+ "https://",
104
+ "https://" + aj_gtmetrix_username + ":" + aj_gtmetrix_api_key + "@"
105
+ );
106
+ var step_name = response.name;
107
+ var step_url = response.url;
108
+ var pr = 255 * (1 - pagespeed / 100);
109
+ var yr = 255 * (1 - yslow / 100);
110
+ var pg = 255 * (pagespeed / 100);
111
+ var yg = 255 * (yslow / 100);
112
+ var prgb = "rgb(" + Math.floor(pr) + "," + Math.floor(pg) + ",0 )";
113
+ var yrgb = "rgb(" + Math.floor(yr) + "," + Math.floor(yg) + ",0 )";
114
+ if (theStep == "aj_gtmetrix_test") {
115
+ theStep = "aj_latest";
116
+ }
117
+ jQuery("#" + theStep + "_please_wait").hide();
118
+ jQuery("." + theStep + "_screenshot").attr("src", screenshot);
119
+ jQuery("." + theStep + "_pagespeed").
120
+ html(pagespeed + "%").
121
+ css({ color: prgb });
122
+ jQuery("." + theStep + "_yslow").
123
+ html(yslow + "%").
124
+ css({ color: yrgb });
125
+ jQuery("." + theStep + "_flt").html(flt + "s");
126
+ jQuery("." + theStep + "_tps").html(tps);
127
+ jQuery("." + theStep + "_requests").html(requests);
128
+ jQuery("." + theStep + "_report").html(report_url);
129
+ jQuery("#" + theStep + "_gtmetrix_results").show();
130
+ jQuery("." + theStep + "_gtmetrix").html(step_name);
131
+ jQuery("." + theStep + "_url").
132
+ attr("href", step_url).
133
+ html(step_url);
134
+ jQuery(".aj_gtmetrix_credits").html(response.credits);
135
+ if (theStep == "aj_step2") {
136
+ notifySettingsSaved();
137
+ jQuery("#aj_step2b").show();
138
+ jQuery("html, body").animate(
139
+ {
140
+ scrollTop: jQuery("#aj_step2b").offset().top
141
+ },
142
+ 1000
143
+ );
144
+ aj_step("aj_step2b");
145
+ } else if (theStep == "aj_step2b") {
146
+ jQuery("#aj_step2c").show();
147
+ jQuery("html, body").animate(
148
+ {
149
+ scrollTop: jQuery("#aj_step2c").offset().top
150
+ },
151
+ 1000
152
+ );
153
+ aj_step("aj_step2c");
154
+ } else if (theStep == "aj_step2c") {
155
+ jQuery("#aj_step2d").show();
156
+ jQuery("html, body").animate(
157
+ {
158
+ scrollTop: jQuery("#aj_step2d").offset().top
159
+ },
160
+ 1000
161
+ );
162
+ aj_step("aj_step2d");
163
+ } else if (theStep == "aj_step2d") {
164
+ jQuery("#aj_step2e").show();
165
+ jQuery("html, body").animate(
166
+ {
167
+ scrollTop: jQuery("#aj_step2e").offset().top
168
+ },
169
+ 1000
170
+ );
171
+ aj_step("aj_step2e");
172
+ } else if (theStep == "aj_step2e") {
173
+ jQuery("#aj_step_results").show();
174
+ jQuery("html, body").animate(
175
+ {
176
+ scrollTop: jQuery("#aj_step_results").offset().top
177
+ },
178
+ 1000
179
+ );
180
+ aj_step("aj_step_results");
181
+ } else if (theStep == "aj_latest") {
182
+ notifySettingsSaved();
183
+ jQuery("#aj_latest_gtmetrix_results").show();
184
+ jQuery("#aj_latest_please_wait").hide();
185
+ jQuery("html, body").animate(
186
+ {
187
+ scrollTop: jQuery("#aj_latest_please_wait").offset().top
188
+ },
189
+ 1000
190
+ );
191
+ }
192
+ } else {
193
+ console.log(response);
194
+ }
195
+ } catch (err) {
196
+ console.log(err);
197
+ }
198
+ });
199
+ }
200
  }
201
 
202
  /**
203
  * functions and actions to load after document ready
204
  */
205
+ jQuery(document).ready(function() {
206
+ if (typeof jQuery(".aj_chosen").chosen === "function") {
207
+ jQuery(".aj_chosen").chosen();
208
+ }
209
 
210
+ // jQuery(document).on(
211
+ // "click",
212
+ // ".aj-upgrade-notice .notice-dismiss",
213
+ // function() {
214
+ // var aj_nonce = jQuery("#aj_nonce").val();
215
+ // var notice_id = jQuery(".aj-upgrade-notice").attr("data-id");
216
+ // jQuery.ajax({
217
+ // url: aj.ajaxurl,
218
+ // data: {
219
+ // action: "async_javascript_dismiss_upgrade",
220
+ // notice_id: notice_id,
221
+ // security: aj_nonce
222
+ // }
223
+ // });
224
+ // }
225
+ // );
226
 
227
+ jQuery(document).on("click", ".aj_steps_button", function(e) {
228
+ e.preventDefault();
229
+ var aj_nonce = jQuery("#aj_nonce").val();
230
+ var theStep = jQuery(this).attr("data-id");
231
+ var settings = theStep.replace("_apply", "");
232
+ var aj_enabled = 1;
233
+ if (theStep == "aj_goto_settings") {
234
+ var newURL = aj_localize_admin.ajadminurl + "&tab=settings";
235
+ window.location.href = newURL;
236
+ } else if (
237
+ theStep == "aj_apply_settings" ||
238
+ theStep == "aj_step2b_apply" ||
239
+ theStep == "aj_step2c_apply" ||
240
+ theStep == "aj_step2d_apply" ||
241
+ theStep == "aj_step2e_apply"
242
+ ) {
243
+ if (theStep != "aj_apply_settings") {
244
+ settings = theStep.replace("_apply", "");
245
+ } else {
246
+ settings = "";
247
+ notifySettingsSaved();
248
+ }
249
+ var data = {
250
+ action: "aj_steps",
251
+ sub_action: "aj_apply_settings",
252
+ settings: settings,
253
+ site_url: aj_localize_admin.siteurl,
254
+ security: aj_nonce
255
+ };
256
+ jQuery.post(aj_localize_admin.ajaxurl, data, function(response) {
257
+ try {
258
+ response = jQuery.parseJSON(response);
259
+ if (response.status !== false) {
260
+ if (jQuery("#aj_step4").length) {
261
+ jQuery("#aj_step5").show();
262
+ jQuery("html, body").animate(
263
+ {
264
+ scrollTop: jQuery("#aj_step5").offset().top
265
+ },
266
+ 1000
267
+ );
268
+ if (settings != "") {
269
+ notifySettingsSaved();
270
+ }
 
 
 
 
 
 
 
271
  } else {
272
+ if (settings != "") {
273
+ notifySettingsSaved();
274
+ var newURL = aj_localize_admin.ajadminurl + "&tab=settings";
275
+ window.location.href = newURL;
276
+ }
277
  }
278
+ } else {
279
+ console.log(response);
280
+ }
281
+ } catch (err) {
282
+ console.log(err);
283
+ }
284
+ });
285
+ } else if (theStep == "aj_save_settings") {
286
+ if (jQuery("#aj_enabled").is(":checked")) {
287
+ aj_enabled = 1;
288
+ } else {
289
+ aj_enabled = 0;
290
+ }
291
+ var aj_method = jQuery("input[type=radio][name=aj_method]:checked").val();
292
+ var aj_jquery = jQuery("input[type=radio][name=aj_jquery]:checked").val();
293
+ var aj_async = jQuery("#aj_async").val();
294
+ var aj_defer = jQuery("#aj_defer").val();
295
+ var aj_exclusions = jQuery("#aj_exclusions").val();
296
+ var aj_plugin_exclusions = jQuery("#aj_plugin_exclusions").
297
+ chosen().
298
+ val();
299
+ var aj_theme_exclusions = jQuery("#aj_theme_exclusions").
300
+ chosen().
301
+ val();
302
+ var aj_autoptimize_enabled = 1;
303
+ var aj_autoptimize_method = jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();
304
 
305
+ if (typeof jQuery(".aj_chosen").chosen === "function") {
306
+ aj_plugin_exclusions = jQuery("#aj_plugin_exclusions").
307
+ chosen().
308
+ val();
309
+ aj_theme_exclusions = jQuery("#aj_theme_exclusions").
310
+ chosen().
311
+ val();
312
+ } else {
313
+ aj_plugin_exclusions = jQuery("#aj_plugin_exclusions").val();
314
+ aj_theme_exclusions = jQuery("#aj_theme_exclusions").val();
315
+ }
316
 
317
+ if (jQuery("#aj_autoptimize_enabled").is(":visible")) {
318
+ if (jQuery("#aj_autoptimize_enabled").is(":checked")) {
319
+ aj_autoptimize_enabled = 1;
320
+ aj_autoptimize_method = jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  } else {
322
+ aj_autoptimize_enabled = 0;
323
+ aj_autoptimize_method = jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  }
325
+ } else {
326
+ aj_autoptimize_enabled = 0;
327
+ aj_autoptimize_method = "async";
328
+ }
329
+ var dataSteps = {
330
+ action: "aj_steps",
331
+ sub_action: "aj_save_settings",
332
+ aj_enabled: aj_enabled,
333
+ aj_method: aj_method,
334
+ aj_jquery: aj_jquery,
335
+ aj_async: aj_async,
336
+ aj_defer: aj_defer,
337
+ aj_exclusions: aj_exclusions,
338
+ aj_plugin_exclusions: aj_plugin_exclusions,
339
+ aj_theme_exclusions: aj_theme_exclusions,
340
+ aj_autoptimize_enabled: aj_autoptimize_enabled,
341
+ aj_autoptimize_method: aj_autoptimize_method,
342
+ security: aj_nonce
343
+ };
344
+ jQuery.post(aj_localize_admin.ajaxurl, dataSteps, function(response) {
345
+ try {
346
+ response = jQuery.parseJSON(response);
347
+ if (response.status !== false) {
348
+ notifySettingsSaved();
349
+ } else {
350
+ console.log(response);
351
+ }
352
+ } catch (err) {
353
+ console.log(err);
354
+ }
355
+ });
356
+ } else {
357
+ var aj_gtmetrix_username = jQuery("#aj_gtmetrix_username").val();
358
+ var aj_gtmetrix_api_key = jQuery("#aj_gtmetrix_api_key").val();
359
+ var aj_gtmetrix_server = jQuery("#aj_gtmetrix_server").val();
360
+ var isError = false;
361
+ if (aj_gtmetrix_username == "") {
362
+ jQuery("#aj_gtmetrix_username").addClass("aj_field_error");
363
+ isError = true;
364
+ }
365
+ if (aj_gtmetrix_api_key == "") {
366
+ jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error");
367
+ isError = true;
368
+ }
369
+ if (isError === false) {
370
+ if (theStep != "aj_gtmetrix_test") {
371
+ jQuery(this).hide();
372
+ jQuery("#" + theStep).show();
373
  } else {
374
+ jQuery("#aj_latest_please_wait").show();
 
375
  }
376
+ aj_step(theStep);
377
+ } else {
378
+ return false;
379
+ }
380
+ }
381
+ });
382
 
383
+ jQuery(document).on(
384
+ "change",
385
+ "input[type=radio][name=aj_step4_check]",
386
+ function() {
387
+ var aj_nonce = jQuery("#aj_nonce").val();
388
+ var theSelection = jQuery(this).val();
389
+ if (theSelection == "y") {
390
+ jQuery("#aj_step4_y").show();
391
+ jQuery("#aj_step4_n").hide();
392
+ } else {
393
+ jQuery("#aj_step4_n").show();
394
+ jQuery("#aj_step4_y").hide();
395
+ }
396
+ }
397
+ );
398
+
399
+ jQuery(document).on("click", ".aj_dismiss", function() {
400
+ var aj_nonce = jQuery("#aj_nonce").val();
401
+ jQuery("#aj_notification").fadeOut("slow");
402
+ });
403
  });
js/admin.min.js CHANGED
@@ -1 +1 @@
1
- function aj_step(e){var a=jQuery("#aj_nonce").val(),t=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:t,aj_gtmetrix_api_key:s,aj_gtmetrix_server:r,security:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{if(!1!==(e=jQuery.parseJSON(e)).status){var a=e.baseline_pagespeed,t=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>a?jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase"):s<a?jQuery("#aj_gtmetrix_inde_pagespeed").html("a decrease"):jQuery("#aj_gtmetrix_inde_pagespeed").html("no change"),r>t?jQuery("#aj_gtmetrix_inde_yslow").html("an increase"):r<t?jQuery("#aj_gtmetrix_inde_yslow").html("a decrease"):jQuery("#aj_gtmetrix_inde_yslow").html("no change"),jQuery("#aj_gtmetrix_baseline_pagespeed").html(a+"%"),jQuery("#aj_gtmetrix_best_pagespeed").html(s+"%"),jQuery("#aj_gtmetrix_baseline_yslow").html(t+"%"),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(e){console.log(e)}})}else{_={action:"aj_steps",sub_action:e,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:t,aj_gtmetrix_api_key:s,aj_gtmetrix_server:r,security:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(a){try{if(!1!==(a=jQuery.parseJSON(a)).status){var r=a.results.report_url+"/screenshot.jpg",_=a.results.pagespeed_score,i=a.results.yslow_score,j=parseFloat(a.results.fully_loaded_time/1e3).toFixed(2),l=Math.floor(a.results.page_bytes/1024);l>1024?l=l/1024+"MB":l+="KB";var o=a.results.page_elements,u=('<a href="'+a.results.report_url+'" target="_blank">'+a.results.report_url+"</a>").replace("https://","https://"+t+":"+s+"@"),n=a.name,y=a.url,p=255*(1-_/100),c=255*(1-i/100),d=_/100*255,m=i/100*255,Q="rgb("+Math.floor(p)+","+Math.floor(d)+",0 )",h="rgb("+Math.floor(c)+","+Math.floor(m)+",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:Q}),jQuery("."+e+"_yslow").html(i+"%").css({color:h}),jQuery("."+e+"_flt").html(j+"s"),jQuery("."+e+"_tps").html(l),jQuery("."+e+"_requests").html(o),jQuery("."+e+"_report").html(u),jQuery("#"+e+"_gtmetrix_results").show(),jQuery("."+e+"_gtmetrix").html(n),jQuery("."+e+"_url").attr("href",y).html(y),jQuery(".aj_gtmetrix_credits").html(a.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(a)}catch(e){console.log(e)}})}}jQuery(document).ready(function(){"function"==typeof jQuery(".aj_chosen").chosen&&jQuery(".aj_chosen").chosen(),jQuery(document).on("click",".aj-upgrade-notice .notice-dismiss",function(){var e=jQuery("#aj_nonce").val(),a=jQuery(".aj-upgrade-notice").attr("data-id");jQuery.ajax({url:aj.ajaxurl,data:{action:"async_javascript_dismiss_upgrade",notice_id:a,security:e}})}),jQuery(document).on("click",".aj_steps_button",function(e){e.preventDefault();var a=jQuery("#aj_nonce").val(),t=jQuery(this).attr("data-id");if("aj_goto_settings"==t){var s=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=s}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 r=t.replace("_apply","");else{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:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{if(!1!==(e=jQuery.parseJSON(e)).status){if(jQuery("#aj_step4").length)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>');else if(""!=r){jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>');var a=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=a}}else console.log(e)}catch(e){console.log(e)}})}else if("aj_save_settings"==t){if(jQuery("#aj_enabled").is(":checked"))var i=1;else 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_async").val(),u=jQuery("#aj_defer").val(),n=jQuery("#aj_exclusions").val();if("function"==typeof jQuery(".aj_chosen").chosen)var y=jQuery("#aj_plugin_exclusions").chosen().val(),p=jQuery("#aj_theme_exclusions").chosen().val();else y=jQuery("#aj_plugin_exclusions").val(),p=jQuery("#aj_theme_exclusions").val();if(jQuery("#aj_autoptimize_enabled").is(":visible"))if(jQuery("#aj_autoptimize_enabled").is(":checked"))var c=1,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else c=0,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else c=0,d="async";_={action:"aj_steps",sub_action:"aj_save_settings",aj_enabled:i,aj_method:j,aj_jquery:l,aj_async:o,aj_defer:u,aj_exclusions:n,aj_plugin_exclusions:y,aj_theme_exclusions:p,aj_autoptimize_enabled:c,aj_autoptimize_method:d,security:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{!1!==(e=jQuery.parseJSON(e)).status?jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>'):console.log(e)}catch(e){console.log(e)}})}else{var m=jQuery("#aj_gtmetrix_username").val(),Q=jQuery("#aj_gtmetrix_api_key").val(),h=(jQuery("#aj_gtmetrix_server").val(),!1);if(""==m&&(jQuery("#aj_gtmetrix_username").addClass("aj_field_error"),h=!0),""==Q&&(jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error"),h=!0),!1!==h)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(){jQuery("#aj_nonce").val();"y"==jQuery(this).val()?(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")})});
1
+ function notifySettingsSaved(){jQuery("#aj_notification").fadeIn("slow").html('Settings Saved <span class="aj_dismiss"><a title="dismiss this notification">x</a></span>').delay(500).fadeOut("slow")}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(),_={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};"aj_step_results"==e?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,j=parseFloat(e.results.fully_loaded_time/1e3).toFixed(2),l=e.url;jQuery(".aj_gtmetrix_config").html(_),s>t?jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase"):s<t?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"):r<a?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(j+"s"),jQuery("#aj_gtmetrix_best_url").attr("href",l).html(l),"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(e){console.log(e)}}):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,j=t.results.yslow_score,l=parseFloat(t.results.fully_loaded_time/1e3).toFixed(2),i=Math.floor(t.results.page_bytes/1024);i>1024?i=i/1024+"MB":i+="KB";var 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+"@"),y=t.name,p=t.url,c=255*(1-_/100),d=255*(1-j/100),m=255*(_/100),Q=255*(j/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(j+"%").css({color:g}),jQuery("."+e+"_flt").html(l+"s"),jQuery("."+e+"_tps").html(i),jQuery("."+e+"_requests").html(o),jQuery("."+e+"_report").html(n),jQuery("#"+e+"_gtmetrix_results").show(),jQuery("."+e+"_gtmetrix").html(y),jQuery("."+e+"_url").attr("href",p).html(p),jQuery(".aj_gtmetrix_credits").html(t.credits),"aj_step2"==e?(notifySettingsSaved(),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&&(notifySettingsSaved(),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(e){console.log(e)}})}jQuery(document).ready(function(){"function"==typeof jQuery(".aj_chosen").chosen&&jQuery(".aj_chosen").chosen(),jQuery(document).on("click",".aj_steps_button",function(e){e.preventDefault();var t=jQuery("#aj_nonce").val(),a=jQuery(this).attr("data-id"),s=a.replace("_apply",""),r=1;if("aj_goto_settings"==a){var _=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=_}else if("aj_apply_settings"==a||"aj_step2b_apply"==a||"aj_step2c_apply"==a||"aj_step2d_apply"==a||"aj_step2e_apply"==a){"aj_apply_settings"!=a?s=a.replace("_apply",""):(s="",notifySettingsSaved());var j={action:"aj_steps",sub_action:"aj_apply_settings",settings:s,site_url:aj_localize_admin.siteurl,security:t};jQuery.post(aj_localize_admin.ajaxurl,j,function(e){try{if(e=jQuery.parseJSON(e),e.status!==!1){if(jQuery("#aj_step4").length)jQuery("#aj_step5").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step5").offset().top},1e3),""!=s&&notifySettingsSaved();else if(""!=s){notifySettingsSaved();var t=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=t}}else console.log(e)}catch(e){console.log(e)}})}else if("aj_save_settings"==a){r=jQuery("#aj_enabled").is(":checked")?1:0;var l=jQuery("input[type=radio][name=aj_method]:checked").val(),i=jQuery("input[type=radio][name=aj_jquery]:checked").val(),o=jQuery("#aj_async").val(),u=jQuery("#aj_defer").val(),n=jQuery("#aj_exclusions").val(),y=jQuery("#aj_plugin_exclusions").chosen().val(),p=jQuery("#aj_theme_exclusions").chosen().val(),c=1,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();"function"==typeof jQuery(".aj_chosen").chosen?(y=jQuery("#aj_plugin_exclusions").chosen().val(),p=jQuery("#aj_theme_exclusions").chosen().val()):(y=jQuery("#aj_plugin_exclusions").val(),p=jQuery("#aj_theme_exclusions").val()),jQuery("#aj_autoptimize_enabled").is(":visible")?jQuery("#aj_autoptimize_enabled").is(":checked")?(c=1,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val()):(c=0,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val()):(c=0,d="async");var m={action:"aj_steps",sub_action:"aj_save_settings",aj_enabled:r,aj_method:l,aj_jquery:i,aj_async:o,aj_defer:u,aj_exclusions:n,aj_plugin_exclusions:y,aj_theme_exclusions:p,aj_autoptimize_enabled:c,aj_autoptimize_method:d,security:t};jQuery.post(aj_localize_admin.ajaxurl,m,function(e){try{e=jQuery.parseJSON(e),e.status!==!1?notifySettingsSaved():console.log(e)}catch(e){console.log(e)}})}else{var Q=jQuery("#aj_gtmetrix_username").val(),h=jQuery("#aj_gtmetrix_api_key").val(),g=(jQuery("#aj_gtmetrix_server").val(),!1);if(""==Q&&(jQuery("#aj_gtmetrix_username").addClass("aj_field_error"),g=!0),""==h&&(jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error"),g=!0),g!==!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")})});
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Async JavaScript ===
2
- Contributors: (cloughit), optimizingmatters, futtta
3
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
4
  Tags: async, javascript, pagespeed, performance, render blocking
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
- Stable tag: 2.18.03.15
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,9 +13,9 @@ Async Javascript lets you add 'async' or 'defer' attribute to scripts to exclude
13
  == Description ==
14
  Eliminate Render-blocking Javascript in above-the-fold content with Async Javascript.
15
 
16
- Render-blocking Javascript prevents above-the-fold content on your page from being rendered until the javascript has finished loading. This can impact on your page speed and ultimately your ranking within search engines. It can also impact your users experience.
17
 
18
- Async JavaScript gives you full control of which scripts to add a 'async' or 'defer' attribute to or to exclude to help increase the performance of your WordPress website.
19
 
20
  == Installation ==
21
  Installation is very straightforward:
@@ -61,6 +61,22 @@ Coming soon!
61
 
62
  == Changelog ==
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  = 2.18.03.15 =
65
 
66
  * bugfix: only load asyncjs' JS & CSS on own settings page [as reported by Marat Petrov](https://wordpress.org/support/topic/error-after-update-117/)
@@ -81,7 +97,7 @@ Coming soon!
81
 
82
  = 2.17.11.03 =
83
 
84
- * MOD: Check for GTMetrix class existance prior to including class
85
 
86
  = 2.17.10.18 =
87
 
@@ -103,11 +119,11 @@ Coming soon!
103
 
104
  = 2.17.05.07 =
105
 
106
- * FIX: Some installs not saving plugin / theme exclusions due to theme incompatibility
107
 
108
  = 2.17.05.06 =
109
 
110
- * MOD/FIX: On some WordPress installs is_plugin_active function being called too early. Moved is_plugin_active into dedicated function called via admin_init as per codex: https://codex.wordpress.org/Function_Reference/is_plugin_active
111
 
112
  = 2.17.05.05 =
113
 
@@ -115,7 +131,7 @@ Coming soon!
115
 
116
  = 2.17.05.04 =
117
 
118
- * FIX: Resolve early loading of plugin causing fatal error due to function not available yet
119
  * FIX: CSS / JS not loading
120
 
121
  = 2.17.05.03 =
@@ -125,6 +141,6 @@ Coming soon!
125
  = 2.17.05.01 =
126
 
127
  * massive Massive MASSIVE rewrite of Async JavaScript!!!
128
- * Now includes a setup Wizard, Status page, Settings page and a help page.
129
  * Communicates directly with GTmetrix (account required)
130
- * Automaticall transfers existing settings from Async JavaScript to Async JavaScript
1
  === Async JavaScript ===
2
+ Contributors: (cloughit), optimizingmatters, futtta, wormeyman
3
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
4
  Tags: async, javascript, pagespeed, performance, render blocking
5
  Requires at least: 4.6
6
  Tested up to: 4.9
7
+ Stable tag: 2.18.04.23
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
  Eliminate Render-blocking Javascript in above-the-fold content with Async Javascript.
15
 
16
+ Render-blocking Javascript prevents above-the-fold content on your page from being rendered until the javascript has finished loading. This can impact on your page speed and ultimately your ranking within search engines. It can also impact your user's experience.
17
 
18
+ Async JavaScript gives you full control of which scripts to add an 'async' or 'defer' attribute to or to exclude to help increase the performance of your WordPress website.
19
 
20
  == Installation ==
21
  Installation is very straightforward:
61
 
62
  == Changelog ==
63
 
64
+ = 2.18.04.23 =
65
+
66
+ * Re-arrange content on the different tabs of the settings page.
67
+ * Continued refactoring of backend code, no functionality should be affected.
68
+ * Remove all images from the project such as the animated hands and progress bar gif.
69
+ * Remove empty rows that added unnecessary space.
70
+ * Switch buttons to use WordPress button styles.
71
+ * Fix broken Dashboard Widget from 2.18.03.15 and reduce font-size to fix text overflow.
72
+ * Remove all CSS !important declarations for easier CSS styling.
73
+ * Remove inline CSS styles.
74
+ * Switch to a CSS based progress bar.
75
+ * Spell check readme.
76
+ * Remove almost all tables from files.
77
+ * Refactor JavaScript.
78
+ * Add wormeyman as a contributor (thanks man!).
79
+
80
  = 2.18.03.15 =
81
 
82
  * bugfix: only load asyncjs' JS & CSS on own settings page [as reported by Marat Petrov](https://wordpress.org/support/topic/error-after-update-117/)
97
 
98
  = 2.17.11.03 =
99
 
100
+ * MOD: Check for GTMetrix class existence prior to including class
101
 
102
  = 2.17.10.18 =
103
 
119
 
120
  = 2.17.05.07 =
121
 
122
+ * FIX: Some installs not saving plugin/theme exclusions due to theme incompatibility
123
 
124
  = 2.17.05.06 =
125
 
126
+ * MOD/FIX: On some WordPress installs is_plugin_active function being called too early. Moved is_plugin_active into a dedicated function called via admin_init as per codex: https://codex.wordpress.org/Function_Reference/is_plugin_active
127
 
128
  = 2.17.05.05 =
129
 
131
 
132
  = 2.17.05.04 =
133
 
134
+ * FIX: Resolve early loading of plugin causing a fatal error due to function not available yet
135
  * FIX: CSS / JS not loading
136
 
137
  = 2.17.05.03 =
141
  = 2.17.05.01 =
142
 
143
  * massive Massive MASSIVE rewrite of Async JavaScript!!!
144
+ * Now includes a Setup Wizard, Status page, Settings page and a help page.
145
  * Communicates directly with GTmetrix (account required)
146
+ * Automatically transfers existing settings from Async JavaScript to Async JavaScript