Autoptimize - Version 2.9.3

Version Description

  • Improvement: add logic to autoptimize_404_handler.php to differentiate between different multisite sites.
  • Improvement: remove the different feeds (and all JS to switch between them) on the settings-page, keeping only the "Autoptimize news".
  • Improvement: reduced autoptimize_enable_site_config option lookups when on multisite and AO is active for network.
  • Fixed wrong variable name that caused PHP notices (but did not affect normal usage) to $w3tc_minify_on.
  • Fix for Autoptimize Toolbar being loaded on AMP pages for logged in administrators/ editors
  • Fix for CDN replacement edge case (if the CDN has the site_url in it).
  • Fix for service availability checks causing too many outgoing requests (root cause likely to be object caching resulting in the autoptimize_service_availability option not being updated)
  • Added "exit survey" when Autoptimize is deactivated (with the kind help of Shakeeb of RapidLoad, thanks brother!)
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 Autoptimize
Version 2.9.3
Comparing to
See all releases

Code changes from version 2.9.2 to 2.9.3

autoptimize.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Autoptimize
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
6
- * Version: 2.9.2
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: autoptimize
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
21
  exit;
22
  }
23
 
24
- define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.9.2' );
25
 
26
  // plugin_dir_path() returns the trailing slash!
27
  define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
3
  * Plugin Name: Autoptimize
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
6
+ * Version: 2.9.3
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: autoptimize
21
  exit;
22
  }
23
 
24
+ define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.9.3' );
25
 
26
  // plugin_dir_path() returns the trailing slash!
27
  define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
classes/autoptimizeBase.php CHANGED
@@ -311,7 +311,7 @@ abstract class autoptimizeBase
311
 
312
  // Allows API/filter to further tweak the cdn url...
313
  $cdn_url = apply_filters( 'autoptimize_filter_base_cdnurl', $cdn_url );
314
- if ( ! empty( $cdn_url ) ) {
315
 
316
  // Simple str_replace-based approach fails when $url is protocol-or-host-relative.
317
  $is_protocol_relative = autoptimizeUtils::is_protocol_relative( $url );
311
 
312
  // Allows API/filter to further tweak the cdn url...
313
  $cdn_url = apply_filters( 'autoptimize_filter_base_cdnurl', $cdn_url );
314
+ if ( ! empty( $cdn_url ) && false === strpos( $url, $cdn_url ) ) {
315
 
316
  // Simple str_replace-based approach fails when $url is protocol-or-host-relative.
317
  $is_protocol_relative = autoptimizeUtils::is_protocol_relative( $url );
classes/autoptimizeCache.php CHANGED
@@ -636,6 +636,9 @@ class autoptimizeCache
636
  $_fallback_php_contents = file_get_contents( AUTOPTIMIZE_PLUGIN_DIR . 'config/' . $_fallback_filename );
637
  $_fallback_php_contents = str_replace( '<?php exit;', '<?php', $_fallback_php_contents );
638
  $_fallback_php_contents = str_replace( '<!--ao-cache-dir-->', AUTOPTIMIZE_CACHE_DIR, $_fallback_php_contents );
 
 
 
639
  if ( apply_filters( 'autoptimize_filter_cache_fallback_log_errors', false ) ) {
640
  $_fallback_php_contents = str_replace( '// error_log', 'error_log', $_fallback_php_contents );
641
  }
636
  $_fallback_php_contents = file_get_contents( AUTOPTIMIZE_PLUGIN_DIR . 'config/' . $_fallback_filename );
637
  $_fallback_php_contents = str_replace( '<?php exit;', '<?php', $_fallback_php_contents );
638
  $_fallback_php_contents = str_replace( '<!--ao-cache-dir-->', AUTOPTIMIZE_CACHE_DIR, $_fallback_php_contents );
639
+ if ( is_multisite() ) {
640
+ $_fallback_php_contents = str_replace( '$multisite = false;', '$multisite = true;', $_fallback_php_contents );
641
+ }
642
  if ( apply_filters( 'autoptimize_filter_cache_fallback_log_errors', false ) ) {
643
  $_fallback_php_contents = str_replace( '// error_log', 'error_log', $_fallback_php_contents );
644
  }
classes/autoptimizeConfig.php CHANGED
@@ -195,7 +195,7 @@ input[type=url]:invalid {color: red; border-color:red;} .form-table th{font-weig
195
  <?php } ?>
196
 
197
  <div id="autoptimize_main">
198
- <h1 id="ao_title"><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
199
  <?php echo $this->ao_admin_tabs(); ?>
200
 
201
  <form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
@@ -380,8 +380,21 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
380
  <table class="form-table">
381
  <tr valign="top">
382
  <th scope="row"><?php _e( 'CDN Base URL', 'autoptimize' ); ?></th>
383
- <td><label><input id="cdn_url" type="text" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*(:\d{2,5})?\/?$" style="width:100%" value="<?php echo esc_url( autoptimizeOptionWrapper::get_option( 'autoptimize_cdn_url', '' ), array( 'http', 'https' ) ); ?>" /><br />
384
- <?php _e( 'Enter your CDN root URL to enable CDN for Autoptimized files. The URL can be http, https or protocol-relative (e.g. <code>//cdn.example.com/</code>). This is not needed for Cloudflare.', 'autoptimize' ); ?></label></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  </tr>
386
  </table>
387
  </li>
@@ -477,7 +490,8 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
477
 
478
  </form>
479
  </div>
480
- <div id="autoptimize_admin_feed" class="hidden">
 
481
  <div class="autoptimize_banner hidden">
482
  <ul>
483
  <?php
@@ -499,48 +513,27 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
499
  <li><?php _e( 'Happy with Autoptimize?', 'autoptimize' ); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e( 'Try my other plugins!', 'autoptimize' ); ?></a></li>
500
  </ul>
501
  </div>
 
502
  <div style="margin-left:10px;margin-top:-5px;">
503
  <h2>
504
- <?php _e( 'futtta about', 'autoptimize' ); ?>
505
- <select id="feed_dropdown" >
506
- <option value="1"><?php _e( 'Autoptimize', 'autoptimize' ); ?></option>
507
- <option value="2"><?php _e( 'WordPress', 'autoptimize' ); ?></option>
508
- <option value="3"><?php _e( 'Web Technology', 'autoptimize' ); ?></option>
509
- </select>
510
  </h2>
511
  <div id="futtta_feed">
512
  <div id="autoptimizefeed">
513
  <?php $this->get_futtta_feeds( 'http://feeds.feedburner.com/futtta_autoptimize' ); ?>
514
  </div>
515
- <div id="wordpressfeed">
516
- <?php $this->get_futtta_feeds( 'http://feeds.feedburner.com/futtta_wordpress' ); ?>
517
- </div>
518
- <div id="webtechfeed">
519
- <?php $this->get_futtta_feeds( 'http://feeds.feedburner.com/futtta_webtech' ); ?>
520
- </div>
521
  </div>
522
  </div>
 
523
  <div style="float:right;margin:50px 15px;"><a href="https://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url() . '/' . plugin_basename( dirname( __FILE__ ) ) . '/external/do_not_donate_smallest.png'; ?>" title="<?php _e( 'Do not donate for this plugin!', 'autoptimize' ); ?>"></a></div>
 
524
  </div>
525
-
526
  <script type="text/javascript">
527
- var feed = new Array;
528
- feed[1]="autoptimizefeed";
529
- feed[2]="wordpressfeed";
530
- feed[3]="webtechfeed";
531
- cookiename="autoptimize_feed";
532
-
533
  jQuery(document).ready(function() {
534
  check_ini_state();
535
 
536
- jQuery('#autoptimize_admin_feed').fadeTo("slow",1).show();
537
  jQuery('.autoptimize_banner').unslider({autoplay:true, delay:3500, infinite: false, arrows:{prev:'<a class="unslider-arrow prev"></a>', next:'<a class="unslider-arrow next"></a>'}}).fadeTo("slow",1).show();
538
 
539
- jQuery( "#feed_dropdown" ).change(function() {
540
- jQuery("#futtta_feed").fadeTo(0,0);
541
- jQuery("#futtta_feed").fadeTo("slow",1);
542
- });
543
-
544
  jQuery( "#autoptimize_html" ).change(function() {
545
  if (this.checked) {
546
  jQuery(".html_sub:visible").fadeTo("fast",1);
@@ -630,11 +623,6 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
630
  jQuery("li.itemDetail:not(.multiSite)").fadeTo("fast",1);
631
  }
632
  });
633
-
634
- jQuery("#feed_dropdown").change(function() { show_feed(jQuery("#feed_dropdown").val()) });
635
- feedid=jQuery.cookie(cookiename);
636
- if(typeof(feedid) !== "string") feedid=1;
637
- show_feed(feedid);
638
  })
639
 
640
  // validate cdn_url.
@@ -677,13 +665,6 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
677
  jQuery("li.itemDetail:not(.multiSite)").fadeTo('fast',.33);
678
  }
679
  }
680
-
681
- function show_feed(id) {
682
- jQuery('#futtta_feed').children().hide();
683
- jQuery('#'+feed[id]).show();
684
- jQuery("#feed_dropdown").val(id);
685
- jQuery.cookie(cookiename,id,{ expires: 365 });
686
- }
687
  </script>
688
  </div>
689
 
@@ -692,15 +673,16 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
692
 
693
  public function addmenu()
694
  {
 
695
  if ( is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
696
  // multisite, network admin, ao network activated: add normal settings page at network level.
697
- $hook = add_submenu_page( 'settings.php', __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_network_options', 'autoptimize', array( $this, 'show_config' ) );
698
  } elseif ( is_multisite() && ! is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_enable_site_config' ) ) {
699
  // multisite, ao network activated, not network admin so site specific settings, but "autoptimize_enable_site_config" is off: show "sorry, ask network admin" message iso options.
700
- $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show_network_message' ) );
701
  } else {
702
  // default: show normal options page if not multisite, if multisite but not network activated, if multisite and network activated and "autoptimize_enable_site_config" is on.
703
- $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show_config' ) );
704
  }
705
 
706
  add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) );
@@ -709,7 +691,6 @@ $_rapidload_link = 'https://misc.optimizingmatters.com/partners/?from=csssetting
709
 
710
  public function autoptimize_admin_scripts()
711
  {
712
- wp_enqueue_script( 'jqcookie', plugins_url( '/external/js/jquery.cookie.min.js', __FILE__ ), array( 'jquery' ), null, true );
713
  wp_enqueue_script( 'unslider', plugins_url( '/external/js/unslider-min.js', __FILE__ ), array( 'jquery' ), null, true );
714
  }
715
 
195
  <?php } ?>
196
 
197
  <div id="autoptimize_main">
198
+ <h1 id="ao_title"><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
199
  <?php echo $this->ao_admin_tabs(); ?>
200
 
201
  <form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
380
  <table class="form-table">
381
  <tr valign="top">
382
  <th scope="row"><?php _e( 'CDN Base URL', 'autoptimize' ); ?></th>
383
+ <?php
384
+ if ( true === autoptimizeImages::imgopt_active() && true === apply_filters( 'autoptimize_filter_cdn_set_by_imgopt', false ) ) {
385
+ // cdn set by imgopt, not to be changealbe in the settings.
386
+ $cdn_editable = 'disabled';
387
+ $cdn_placeholder = 'placeholder="' . __( 'The CDN has automatically been set to make use of the image optimization CDN.', 'autoptimize' ) . ' "';
388
+ $cdn_description = '';
389
+ } else {
390
+ $cdn_editable = '';
391
+ $cdn_placeholder = 'placeholder="' . __( 'example: //cdn.yoursite.com/', 'autoptimize' ) . ' "';
392
+ $cdn_description = __( 'Enter your CDN root URL to enable CDN for Autoptimized files. The URL can be http, https or protocol-relative. This is not needed for Cloudflare.', 'autoptimize' );
393
+ }
394
+ ?>
395
+ <td><label><input id="cdn_url" type="text" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*(:\d{2,5})?\/?$" style="width:100%" <?php echo $cdn_placeholder . $cdn_editable; ?> value="<?php echo esc_url( autoptimizeOptionWrapper::get_option( 'autoptimize_cdn_url', '' ), array( 'http', 'https' ) ); ?>" /><br />
396
+ <?php echo $cdn_description; ?>
397
+ </label></td>
398
  </tr>
399
  </table>
400
  </li>
490
 
491
  </form>
492
  </div>
493
+ <div id="autoptimize_admin_feed">
494
+ <?php if ( apply_filters( 'autoptimize_filter_show_partner_tabs', true ) ) { ?>
495
  <div class="autoptimize_banner hidden">
496
  <ul>
497
  <?php
513
  <li><?php _e( 'Happy with Autoptimize?', 'autoptimize' ); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e( 'Try my other plugins!', 'autoptimize' ); ?></a></li>
514
  </ul>
515
  </div>
516
+ <?php } ?>
517
  <div style="margin-left:10px;margin-top:-5px;">
518
  <h2>
519
+ <?php _e( 'Autoptimize news', 'autoptimize' ); ?>
 
 
 
 
 
520
  </h2>
521
  <div id="futtta_feed">
522
  <div id="autoptimizefeed">
523
  <?php $this->get_futtta_feeds( 'http://feeds.feedburner.com/futtta_autoptimize' ); ?>
524
  </div>
 
 
 
 
 
 
525
  </div>
526
  </div>
527
+ <?php if ( apply_filters( 'autoptimize_filter_show_partner_tabs', true ) ) { ?>
528
  <div style="float:right;margin:50px 15px;"><a href="https://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url() . '/' . plugin_basename( dirname( __FILE__ ) ) . '/external/do_not_donate_smallest.png'; ?>" title="<?php _e( 'Do not donate for this plugin!', 'autoptimize' ); ?>"></a></div>
529
+ <?php } ?>
530
  </div>
 
531
  <script type="text/javascript">
 
 
 
 
 
 
532
  jQuery(document).ready(function() {
533
  check_ini_state();
534
 
 
535
  jQuery('.autoptimize_banner').unslider({autoplay:true, delay:3500, infinite: false, arrows:{prev:'<a class="unslider-arrow prev"></a>', next:'<a class="unslider-arrow next"></a>'}}).fadeTo("slow",1).show();
536
 
 
 
 
 
 
537
  jQuery( "#autoptimize_html" ).change(function() {
538
  if (this.checked) {
539
  jQuery(".html_sub:visible").fadeTo("fast",1);
623
  jQuery("li.itemDetail:not(.multiSite)").fadeTo("fast",1);
624
  }
625
  });
 
 
 
 
 
626
  })
627
 
628
  // validate cdn_url.
665
  jQuery("li.itemDetail:not(.multiSite)").fadeTo('fast',.33);
666
  }
667
  }
 
 
 
 
 
 
 
668
  </script>
669
  </div>
670
 
673
 
674
  public function addmenu()
675
  {
676
+ $_my_name = apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? __( 'Autoptimize Pro', 'autoptimize' ) : __( 'Autoptimize', 'autoptimize' );
677
  if ( is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
678
  // multisite, network admin, ao network activated: add normal settings page at network level.
679
+ $hook = add_submenu_page( 'settings.php', __( 'Autoptimize Options', 'autoptimize' ), $_my_name, 'manage_network_options', 'autoptimize', array( $this, 'show_config' ) );
680
  } elseif ( is_multisite() && ! is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_enable_site_config' ) ) {
681
  // multisite, ao network activated, not network admin so site specific settings, but "autoptimize_enable_site_config" is off: show "sorry, ask network admin" message iso options.
682
+ $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), $_my_name, 'manage_options', 'autoptimize', array( $this, 'show_network_message' ) );
683
  } else {
684
  // default: show normal options page if not multisite, if multisite but not network activated, if multisite and network activated and "autoptimize_enable_site_config" is on.
685
+ $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), $_my_name, 'manage_options', 'autoptimize', array( $this, 'show_config' ) );
686
  }
687
 
688
  add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) );
691
 
692
  public function autoptimize_admin_scripts()
693
  {
 
694
  wp_enqueue_script( 'unslider', plugins_url( '/external/js/unslider-min.js', __FILE__ ), array( 'jquery' ), null, true );
695
  }
696
 
classes/autoptimizeCriticalCSSBase.php CHANGED
@@ -108,7 +108,7 @@ class autoptimizeCriticalCSSBase {
108
  $autoptimize_ccss_options['ao_ccss_rtimelimit'] = get_option( 'autoptimize_ccss_rtimelimit', '30' );
109
  $autoptimize_ccss_options['ao_ccss_noptimize'] = get_option( 'autoptimize_ccss_noptimize', false );
110
  $autoptimize_ccss_options['ao_ccss_debug'] = get_option( 'autoptimize_ccss_debug', false );
111
- $autoptimize_ccss_options['ao_ccss_key'] = get_option( 'autoptimize_ccss_key' );
112
  $autoptimize_ccss_options['ao_ccss_keyst'] = get_option( 'autoptimize_ccss_keyst' );
113
  $autoptimize_ccss_options['ao_ccss_loggedin'] = get_option( 'autoptimize_ccss_loggedin', '1' );
114
  $autoptimize_ccss_options['ao_ccss_forcepath'] = get_option( 'autoptimize_ccss_forcepath', '1' );
108
  $autoptimize_ccss_options['ao_ccss_rtimelimit'] = get_option( 'autoptimize_ccss_rtimelimit', '30' );
109
  $autoptimize_ccss_options['ao_ccss_noptimize'] = get_option( 'autoptimize_ccss_noptimize', false );
110
  $autoptimize_ccss_options['ao_ccss_debug'] = get_option( 'autoptimize_ccss_debug', false );
111
+ $autoptimize_ccss_options['ao_ccss_key'] = apply_filters( 'autoptimize_filter_ccss_key', get_option( 'autoptimize_ccss_key' ) );
112
  $autoptimize_ccss_options['ao_ccss_keyst'] = get_option( 'autoptimize_ccss_keyst' );
113
  $autoptimize_ccss_options['ao_ccss_loggedin'] = get_option( 'autoptimize_ccss_loggedin', '1' );
114
  $autoptimize_ccss_options['ao_ccss_forcepath'] = get_option( 'autoptimize_ccss_forcepath', '1' );
classes/autoptimizeCriticalCSSCron.php CHANGED
@@ -473,7 +473,7 @@ class autoptimizeCriticalCSSCron {
473
  // Avoid AO optimizations if required by config or avoid lazyload if lazyload is active in AO.
474
  if ( ! empty( $ao_ccss_noptimize ) ) {
475
  $src_url .= '?ao_noptirocket=1';
476
- } elseif ( class_exists( 'autoptimizeImages', false ) && autoptimizeImages::should_lazyload_wrapper() ) {
477
  $src_url .= '?ao_nolazy=1';
478
  }
479
 
473
  // Avoid AO optimizations if required by config or avoid lazyload if lazyload is active in AO.
474
  if ( ! empty( $ao_ccss_noptimize ) ) {
475
  $src_url .= '?ao_noptirocket=1';
476
+ } elseif ( ( class_exists( 'autoptimizeImages', false ) && autoptimizeImages::should_lazyload_wrapper() ) || apply_filters( 'autoptimize_filter_ccss_enforce_nolazy', false ) ) {
477
  $src_url .= '?ao_nolazy=1';
478
  }
479
 
classes/autoptimizeCriticalCSSSettings.php CHANGED
@@ -111,7 +111,7 @@ class autoptimizeCriticalCSSSettings {
111
  <div class="wrap">
112
  <div id="autoptimize_main">
113
  <div id="ao_title_and_button">
114
- <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
115
  </div>
116
 
117
  <?php
111
  <div class="wrap">
112
  <div id="autoptimize_main">
113
  <div id="ao_title_and_button">
114
+ <h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
115
  </div>
116
 
117
  <?php
classes/autoptimizeExitSurvey.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add exit-survey logic to plugins-page.
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ class autoptimizeExitSurvey
11
+ {
12
+ function __construct() {
13
+ global $pagenow;
14
+
15
+ if ( $pagenow != 'plugins.php' ) {
16
+ return;
17
+ }
18
+
19
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_survey_scripts' ) );
20
+ add_action( 'admin_footer', array( $this, 'render_survey_model' ) );
21
+ }
22
+
23
+ function enqueue_survey_scripts() {
24
+ wp_enqueue_script( 'ao_exit_survey', plugins_url( '/static/exit-survey/exit-survey.js', __FILE__ ), array(
25
+ 'jquery'
26
+ ), AUTOPTIMIZE_PLUGIN_VERSION );
27
+
28
+ wp_enqueue_style( 'ao_exit_survey', plugins_url( '/static/exit-survey/exit-survey.css', __FILE__ ), null, AUTOPTIMIZE_PLUGIN_VERSION );
29
+ }
30
+
31
+ function render_survey_model() {
32
+ $data = array(
33
+ "home" => home_url(),
34
+ "dest" => 'aHR0cHM6Ly9taXNjLm9wdGltaXppbmdtYXR0ZXJzLmNvbS9hb19leGl0X3N1cnZleS9pbmRleC5waHA='
35
+ );
36
+ ?>
37
+
38
+ <div class="ao-plugin-uninstall-feedback-popup ao-feedback" id="ao_uninstall_feedback_popup" data-modal="<?php echo base64_encode(json_encode($data)) ?>">
39
+ <div class="popup--header">
40
+ <h5>Sorry to see you go, we would appreciate if you let us know why you're deactivating Autoptimize!</h5>
41
+ </div><!--/.popup--header-->
42
+ <div class="popup--body">
43
+ <ul class="popup--form">
44
+ <li ao-option-id="5">
45
+ <input type="radio" name="ao-deactivate-option" id="ao_feedback5">
46
+ <label for="ao_feedback5">
47
+ I don't see a performance improvement.
48
+ </label>
49
+ </li>
50
+ <li ao-option-id="6">
51
+ <input type="radio" name="ao-deactivate-option" id="ao_feedback6">
52
+ <label for="ao_feedback6">
53
+ It broke my site.
54
+ </label>
55
+ <li ao-option-id="4">
56
+ <input type="radio" name="ao-deactivate-option" id="ao_feedback4">
57
+ <label for="ao_feedback4">
58
+ I found a better solution.
59
+ </label>
60
+ <li ao-option-id="3">
61
+ <input type="radio" name="ao-deactivate-option" id="ao_feedback3">
62
+ <label for="ao_feedback3">
63
+ I'm just disabling temporarily.
64
+ </label>
65
+ <li ao-option-id="999">
66
+ <input type="radio" name="ao-deactivate-option" id="ao_feedback999">
67
+ <label for="ao_feedback999">
68
+ Other (please specify below) </label>
69
+ <textarea width="100%" rows="2" name="comments" placeholder="What can we do better?"></textarea></li>
70
+ </ul>
71
+ </div><!--/.popup--body-->
72
+ <div class="popup--footer">
73
+ <div class="actions">
74
+ <a href="#" class="info-disclosure-link">What info do we collect?</a>
75
+ <div class="info-disclosure-content"><p>Below is a detailed view of all data that Optimizing Matters will receive if
76
+ you fill in this survey. Email address or IP addresses will not be sent.</p>
77
+ <ul>
78
+ <li><strong>Plugin version </strong> <code id="ao_plugin_version"> <?php echo AUTOPTIMIZE_PLUGIN_VERSION ?> </code></li>
79
+ <li><strong>Current website:</strong> <code> <?php echo trailingslashit(get_site_url()) ?> </code></li>
80
+ <li><strong>Uninstall reason </strong> <i> Selected reason from the above survey </i></li>
81
+ </ul>
82
+ </div>
83
+ <div class="buttons">
84
+ <input type="submit"
85
+ name="ao-deactivate-no"
86
+ id="ao-deactivate-no"
87
+ class="button"
88
+ value="Skip &amp; Deactivate">
89
+ <input type="submit"
90
+ name="ao-deactivate-yes"
91
+ id="ao-deactivate-yes"
92
+ class="button button-primary"
93
+ value="Submit &amp; Deactivate"
94
+ data-after-text="Submit &amp; Deactivate"
95
+ disabled="1"></div>
96
+
97
+ </div><!--/.actions-->
98
+ </div><!--/.popup--footer-->
99
+ </div>
100
+ <?php }
101
+ }
classes/autoptimizeExtra.php CHANGED
@@ -487,7 +487,7 @@ class autoptimizeExtra
487
  </style>
488
  <script>document.title = "Autoptimize: <?php _e( 'Extra', 'autoptimize' ); ?> " + document.title;</script>
489
  <div class="wrap">
490
- <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
491
  <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
492
  <?php if ( 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_js' ) && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_css' ) && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_html' ) && ! autoptimizeImages::imgopt_active() ) { ?>
493
  <div class="notice-warning notice"><p>
487
  </style>
488
  <script>document.title = "Autoptimize: <?php _e( 'Extra', 'autoptimize' ); ?> " + document.title;</script>
489
  <div class="wrap">
490
+ <h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
491
  <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
492
  <?php if ( 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_js' ) && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_css' ) && 'on' !== autoptimizeOptionWrapper::get_option( 'autoptimize_html' ) && ! autoptimizeImages::imgopt_active() ) { ?>
493
  <div class="notice-warning notice"><p>
classes/autoptimizeHTML.php CHANGED
@@ -82,6 +82,12 @@ class autoptimizeHTML extends autoptimizeBase
82
  $options['xhtml'] = true;
83
  }
84
 
 
 
 
 
 
 
85
  $tmp_content = AO_Minify_HTML::minify( $this->content, $options );
86
  if ( ! empty( $tmp_content ) ) {
87
  $this->content = $tmp_content;
82
  $options['xhtml'] = true;
83
  }
84
 
85
+ // Optionally (filter-based, GUI later) minify inline JS & CSS.
86
+ if ( apply_filters( 'autoptimize_html_minify_inline_js_css', false ) ) {
87
+ $options['jsMinifier'] = 'JSMin::minify';
88
+ $options['cssMinifier'] = 'autoptimizeCSSmin::minify';
89
+ }
90
+
91
  $tmp_content = AO_Minify_HTML::minify( $this->content, $options );
92
  if ( ! empty( $tmp_content ) ) {
93
  $this->content = $tmp_content;
classes/autoptimizeImages.php CHANGED
@@ -52,8 +52,18 @@ class autoptimizeImages
52
  // get service availability and add it to the options-array.
53
  $value['availabilities'] = autoptimizeOptionWrapper::get_option( 'autoptimize_service_availablity' );
54
 
55
- if ( empty( $value['availabilities'] ) ) {
56
- $value['availabilities'] = autoptimizeUtils::check_service_availability( true );
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  return $value;
@@ -369,7 +379,8 @@ class autoptimizeImages
369
  } elseif ( 0 === strpos( $result, '/' ) ) {
370
  // Root-relative...
371
  $result = $parsed_site_url['scheme'] . '://' . $parsed_site_url['host'] . $result;
372
- } elseif ( ! empty( $cdn_domain ) && strpos( $result, $cdn_domain ) !== 0 ) {
 
373
  $result = str_replace( $cdn_domain, $parsed_site_url['host'], $result );
374
  }
375
 
@@ -582,7 +593,7 @@ class autoptimizeImages
582
  if ( isset( $indiv_srcset_parts[1] ) && rtrim( $indiv_srcset_parts[1], 'w' ) !== $indiv_srcset_parts[1] ) {
583
  $imgopt_w = rtrim( $indiv_srcset_parts[1], 'w' );
584
  }
585
- if ( $this->can_optimize_image( $indiv_srcset_parts[0], $tag, $testing ) ) {
586
  $imgopt_url = $this->build_imgopt_url( $indiv_srcset_parts[0], $imgopt_w, '' );
587
  $srcset = str_replace( $indiv_srcset_parts[0], $imgopt_url, $srcset );
588
  }
@@ -602,7 +613,7 @@ class autoptimizeImages
602
  foreach ( $urls as $url ) {
603
  $full_src_orig = $url[0];
604
  $url = $url[1];
605
- if ( $this->can_optimize_image( $url, $tag, $testing ) ) {
606
  $imgopt_url = $this->build_imgopt_url( $url, $imgopt_w, $imgopt_h );
607
  $full_imgopt_src = str_replace( $url, $imgopt_url, $full_src_orig );
608
  $tag = str_replace( $full_src_orig, $full_imgopt_src, $tag );
@@ -624,7 +635,7 @@ class autoptimizeImages
624
  $_url = $this->normalize_img_url( $_url );
625
 
626
  $placeholder = '';
627
- if ( $this->can_optimize_image( $_url, $tag ) && apply_filters( 'autoptimize_filter_imgopt_lazyload_dolqip', true, $_url ) ) {
628
  $lqip_w = '';
629
  $lqip_h = '';
630
  if ( isset( $imgopt_w ) && ! empty( $imgopt_w ) ) {
@@ -694,7 +705,7 @@ class autoptimizeImages
694
  return $out;
695
  }
696
 
697
- public function get_size_from_tag( $tag ) {
698
  // reusable function to extract widht and height from an image tag
699
  // enforcing a filterable maximum width and height (default 4999X4999).
700
  $width = '';
@@ -757,7 +768,7 @@ class autoptimizeImages
757
  return $lazyload_return;
758
  }
759
 
760
- public function check_nolazy() {
761
  if ( array_key_exists( 'ao_nolazy', $_GET ) && '1' === $_GET['ao_nolazy'] ) {
762
  return true;
763
  } else {
@@ -886,7 +897,7 @@ class autoptimizeImages
886
  echo apply_filters( 'autoptimize_filter_imgopt_lazyload_js', '<script async' . $type_js . $noptimize_flag . ' src=\'' . $lazysizes_js . '\'></script>' );
887
  }
888
 
889
- public function get_cdn_url() {
890
  // getting CDN url here to avoid having to make bigger changes to autoptimizeBase.
891
  static $cdn_url = null;
892
 
@@ -1082,7 +1093,7 @@ class autoptimizeImages
1082
  </style>
1083
  <script>document.title = "Autoptimize: <?php _e( 'Images', 'autoptimize' ); ?> " + document.title;</script>
1084
  <div class="wrap">
1085
- <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
1086
  <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
1087
  <?php if ( 'down' === $options['availabilities']['extra_imgopt']['status'] ) { ?>
1088
  <div class="notice-warning notice"><p>
52
  // get service availability and add it to the options-array.
53
  $value['availabilities'] = autoptimizeOptionWrapper::get_option( 'autoptimize_service_availablity' );
54
 
55
+ if ( empty( $value['availabilities'] || ! is_array( $value['availabilities'] ) ) ) {
56
+ $value['availabilities'] = null;
57
+
58
+ if ( autoptimizeImages::imgopt_active() ) {
59
+ $value['availabilities'] = autoptimizeUtils::check_service_availability( true );
60
+ }
61
+
62
+ if ( null === $value['availabilities'] ) {
63
+ // We can't seem to check service availability, use mock result with imgopt status UP.
64
+ $_mock_settings = array( 'extra_imgopt' => array( 'status' => 'up', 'hosts' => array( '1' => 'https://sp-ao.shortpixel.ai/' ) ), 'critcss' => array( 'status' => 'up' ) );
65
+ $value['availabilities'] = $_mock_settings;
66
+ }
67
  }
68
 
69
  return $value;
379
  } elseif ( 0 === strpos( $result, '/' ) ) {
380
  // Root-relative...
381
  $result = $parsed_site_url['scheme'] . '://' . $parsed_site_url['host'] . $result;
382
+ } elseif ( ! empty( $cdn_domain ) && false === strpos( $this->get_imgopt_host(), $cdn_domain ) && strpos( $result, $cdn_domain ) !== 0 ) {
383
+ // remove CDN except if it is the image optimization one.
384
  $result = str_replace( $cdn_domain, $parsed_site_url['host'], $result );
385
  }
386
 
593
  if ( isset( $indiv_srcset_parts[1] ) && rtrim( $indiv_srcset_parts[1], 'w' ) !== $indiv_srcset_parts[1] ) {
594
  $imgopt_w = rtrim( $indiv_srcset_parts[1], 'w' );
595
  }
596
+ if ( $this->can_optimize_image( $indiv_srcset_parts[0], $tag, $testing ) && false === apply_filters( 'autoptimize_filter_imgopt_do_spai', false ) ) {
597
  $imgopt_url = $this->build_imgopt_url( $indiv_srcset_parts[0], $imgopt_w, '' );
598
  $srcset = str_replace( $indiv_srcset_parts[0], $imgopt_url, $srcset );
599
  }
613
  foreach ( $urls as $url ) {
614
  $full_src_orig = $url[0];
615
  $url = $url[1];
616
+ if ( $this->can_optimize_image( $url, $tag, $testing ) && false === apply_filters( 'autoptimize_filter_imgopt_do_spai', false ) ) {
617
  $imgopt_url = $this->build_imgopt_url( $url, $imgopt_w, $imgopt_h );
618
  $full_imgopt_src = str_replace( $url, $imgopt_url, $full_src_orig );
619
  $tag = str_replace( $full_src_orig, $full_imgopt_src, $tag );
635
  $_url = $this->normalize_img_url( $_url );
636
 
637
  $placeholder = '';
638
+ if ( $this->can_optimize_image( $_url, $tag ) && apply_filters( 'autoptimize_filter_imgopt_lazyload_dolqip', true, $_url ) && false === apply_filters( 'autoptimize_filter_imgopt_do_spai', false ) ) {
639
  $lqip_w = '';
640
  $lqip_h = '';
641
  if ( isset( $imgopt_w ) && ! empty( $imgopt_w ) ) {
705
  return $out;
706
  }
707
 
708
+ public static function get_size_from_tag( $tag ) {
709
  // reusable function to extract widht and height from an image tag
710
  // enforcing a filterable maximum width and height (default 4999X4999).
711
  $width = '';
768
  return $lazyload_return;
769
  }
770
 
771
+ public static function check_nolazy() {
772
  if ( array_key_exists( 'ao_nolazy', $_GET ) && '1' === $_GET['ao_nolazy'] ) {
773
  return true;
774
  } else {
897
  echo apply_filters( 'autoptimize_filter_imgopt_lazyload_js', '<script async' . $type_js . $noptimize_flag . ' src=\'' . $lazysizes_js . '\'></script>' );
898
  }
899
 
900
+ public static function get_cdn_url() {
901
  // getting CDN url here to avoid having to make bigger changes to autoptimizeBase.
902
  static $cdn_url = null;
903
 
1093
  </style>
1094
  <script>document.title = "Autoptimize: <?php _e( 'Images', 'autoptimize' ); ?> " + document.title;</script>
1095
  <div class="wrap">
1096
+ <h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
1097
  <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
1098
  <?php if ( 'down' === $options['availabilities']['extra_imgopt']['status'] ) { ?>
1099
  <div class="notice-warning notice"><p>
classes/autoptimizeMain.php CHANGED
@@ -60,7 +60,7 @@ class autoptimizeMain
60
  add_action( 'autoptimize_setup_done', array( $this, 'version_upgrades_check' ) );
61
  add_action( 'autoptimize_setup_done', array( $this, 'check_cache_and_run' ) );
62
  add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_ao_extra' ), 15 );
63
- add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_partners_tab' ), 20 );
64
  add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_criticalcss' ), 11 );
65
  add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_notfound_fallback' ), 10 );
66
 
@@ -186,7 +186,7 @@ class autoptimizeMain
186
  if ( class_exists( 'Jetpack' ) && apply_filters( 'autoptimize_filter_main_disable_jetpack_cdn', true ) && ( $conf->get( 'autoptimize_js' ) || $conf->get( 'autoptimize_css' ) ) ) {
187
  add_filter( 'jetpack_force_disable_site_accelerator', '__return_true' );
188
  }
189
-
190
  // Add "no cache found" notice.
191
  add_action( 'admin_notices', 'autoptimizeMain::notice_nopagecache', 99 );
192
  add_action( 'admin_notices', 'autoptimizeMain::notice_potential_conflict', 99 );
@@ -209,11 +209,12 @@ class autoptimizeMain
209
  }
210
  }
211
 
212
- public function maybe_run_partners_tab()
213
  {
214
- // Loads partners tab code if in admin (and not in admin-ajax.php)!
215
  if ( autoptimizeConfig::is_admin_and_not_ajax() ) {
216
  new autoptimizePartners();
 
217
  }
218
  }
219
 
@@ -369,7 +370,7 @@ class autoptimizeMain
369
  if ( false === $ao_noptimize && array_key_exists( 'PageSpeed', $_GET ) && 'off' === $_GET['PageSpeed'] ) {
370
  $ao_noptimize = true;
371
  }
372
-
373
  // If page/ post check post_meta to see if optimize is off.
374
  if ( false === autoptimizeConfig::get_post_meta_ao_settings( 'ao_post_optimize' ) ) {
375
  $ao_noptimize = true;
@@ -715,12 +716,12 @@ class autoptimizeMain
715
  echo '</p></div>';
716
  }
717
  }
718
-
719
  public static function notice_nopagecache()
720
  {
721
  /*
722
  * Autoptimize does not do page caching (yet) but not everyone knows, so below logic tries to find out if page caching is available and if not show a notice on the AO Settings pages.
723
- *
724
  * uses helper function in autoptimizeUtils.php
725
  */
726
  $_ao_nopagecache_notice = __( 'It looks like your site might not have <strong>page caching</strong> which is a <strong>must-have for performance</strong>. If you are sure you have a page cache, you can close this notice, but when in doubt check with your host if they offer this or install a page caching plugin like for example', 'autoptimize' );
@@ -728,9 +729,8 @@ class autoptimizeMain
728
  $_ao_nopagecache_notice .= ' <a href="' . $_ao_pagecache_install_url . 'wp+super+cache' . '">WP Super Cache</a>, <a href="' . $_ao_pagecache_install_url . 'keycdn+cache+enabler' . '">KeyCDN Cache Enabler</a>, ...';
729
  $_ao_nopagecache_dismissible = 'ao-nopagecache-forever'; // the notice is only shown once and will not re-appear when dismissed.
730
  $_is_ao_settings_page = autoptimizeUtils::is_ao_settings();
731
- $_found_pagecache = false;
732
 
733
- if ( current_user_can( 'manage_options' ) && $_is_ao_settings_page && PAnD::is_admin_notice_active( $_ao_nopagecache_dismissible ) && true === apply_filters( 'autopitmize_filter_main_show_pagecache_notice', true ) ) {
734
  if ( false === autoptimizeUtils::find_pagecache() ) {
735
  echo '<div class="notice notice-info is-dismissible" data-dismissible="' . $_ao_nopagecache_dismissible . '"><p>';
736
  echo $_ao_nopagecache_notice;
@@ -749,7 +749,7 @@ class autoptimizeMain
749
  $_ao_potential_conflict_dismissible = 'ao-potential-conflict-forever'; // the notice is only shown once and will not re-appear when dismissed.
750
  $_is_ao_settings_page = autoptimizeUtils::is_ao_settings();
751
 
752
- if ( current_user_can( 'manage_options' ) && $_is_ao_settings_page && PAnD::is_admin_notice_active( $_ao_potential_conflict_dismissible ) && true === apply_filters( 'autopitmize_filter_main_show_potential_conclict_notice', true ) ) {
753
  $_potential_conflicts = autoptimizeUtils::find_potential_conflicts();
754
  if ( false !== $_potential_conflicts ) {
755
  $_ao_potential_conflict_notice .= '<strong>' . $_potential_conflicts . '</strong>.';
60
  add_action( 'autoptimize_setup_done', array( $this, 'version_upgrades_check' ) );
61
  add_action( 'autoptimize_setup_done', array( $this, 'check_cache_and_run' ) );
62
  add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_ao_extra' ), 15 );
63
+ add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_admin_only_trinkets' ), 20 );
64
  add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_criticalcss' ), 11 );
65
  add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_notfound_fallback' ), 10 );
66
 
186
  if ( class_exists( 'Jetpack' ) && apply_filters( 'autoptimize_filter_main_disable_jetpack_cdn', true ) && ( $conf->get( 'autoptimize_js' ) || $conf->get( 'autoptimize_css' ) ) ) {
187
  add_filter( 'jetpack_force_disable_site_accelerator', '__return_true' );
188
  }
189
+
190
  // Add "no cache found" notice.
191
  add_action( 'admin_notices', 'autoptimizeMain::notice_nopagecache', 99 );
192
  add_action( 'admin_notices', 'autoptimizeMain::notice_potential_conflict', 99 );
209
  }
210
  }
211
 
212
+ public function maybe_run_admin_only_trinkets()
213
  {
214
+ // Loads partners tab and exit survey code if in admin (and not in admin-ajax.php)!
215
  if ( autoptimizeConfig::is_admin_and_not_ajax() ) {
216
  new autoptimizePartners();
217
+ new autoptimizeExitSurvey();
218
  }
219
  }
220
 
370
  if ( false === $ao_noptimize && array_key_exists( 'PageSpeed', $_GET ) && 'off' === $_GET['PageSpeed'] ) {
371
  $ao_noptimize = true;
372
  }
373
+
374
  // If page/ post check post_meta to see if optimize is off.
375
  if ( false === autoptimizeConfig::get_post_meta_ao_settings( 'ao_post_optimize' ) ) {
376
  $ao_noptimize = true;
716
  echo '</p></div>';
717
  }
718
  }
719
+
720
  public static function notice_nopagecache()
721
  {
722
  /*
723
  * Autoptimize does not do page caching (yet) but not everyone knows, so below logic tries to find out if page caching is available and if not show a notice on the AO Settings pages.
724
+ *
725
  * uses helper function in autoptimizeUtils.php
726
  */
727
  $_ao_nopagecache_notice = __( 'It looks like your site might not have <strong>page caching</strong> which is a <strong>must-have for performance</strong>. If you are sure you have a page cache, you can close this notice, but when in doubt check with your host if they offer this or install a page caching plugin like for example', 'autoptimize' );
729
  $_ao_nopagecache_notice .= ' <a href="' . $_ao_pagecache_install_url . 'wp+super+cache' . '">WP Super Cache</a>, <a href="' . $_ao_pagecache_install_url . 'keycdn+cache+enabler' . '">KeyCDN Cache Enabler</a>, ...';
730
  $_ao_nopagecache_dismissible = 'ao-nopagecache-forever'; // the notice is only shown once and will not re-appear when dismissed.
731
  $_is_ao_settings_page = autoptimizeUtils::is_ao_settings();
 
732
 
733
+ if ( current_user_can( 'manage_options' ) && $_is_ao_settings_page && PAnD::is_admin_notice_active( $_ao_nopagecache_dismissible ) && true === apply_filters( 'autoptimize_filter_main_show_pagecache_notice', true ) ) {
734
  if ( false === autoptimizeUtils::find_pagecache() ) {
735
  echo '<div class="notice notice-info is-dismissible" data-dismissible="' . $_ao_nopagecache_dismissible . '"><p>';
736
  echo $_ao_nopagecache_notice;
749
  $_ao_potential_conflict_dismissible = 'ao-potential-conflict-forever'; // the notice is only shown once and will not re-appear when dismissed.
750
  $_is_ao_settings_page = autoptimizeUtils::is_ao_settings();
751
 
752
+ if ( current_user_can( 'manage_options' ) && $_is_ao_settings_page && PAnD::is_admin_notice_active( $_ao_potential_conflict_dismissible ) && true === apply_filters( 'autoptimize_filter_main_show_potential_conclict_notice', true ) ) {
753
  $_potential_conflicts = autoptimizeUtils::find_potential_conflicts();
754
  if ( false !== $_potential_conflicts ) {
755
  $_ao_potential_conflict_notice .= '<strong>' . $_potential_conflicts . '</strong>.';
classes/autoptimizeMetabox.php CHANGED
@@ -132,7 +132,7 @@ class autoptimizeMetabox
132
  }
133
 
134
  // if CSS opt and inline & defer are on and if we have a slug, the button can be active.
135
- if ( false !== $_slug && 'on' === get_option( 'autoptimize_css', false ) && 'on' === get_option( 'autoptimize_css_defer', false ) && ! empty( get_option( 'autoptimize_ccss_key', false ) ) && '2' === get_option( 'autoptimize_ccss_keyst', false ) ) {
136
  $_generate_disabled = false;
137
  }
138
  ?>
132
  }
133
 
134
  // if CSS opt and inline & defer are on and if we have a slug, the button can be active.
135
+ if ( false !== $_slug && 'on' === get_option( 'autoptimize_css', false ) && 'on' === get_option( 'autoptimize_css_defer', false ) && ! empty( apply_filters( 'autoptimize_filter_ccss_key', get_option( 'autoptimize_ccss_key', false ) ) ) && '2' === get_option( 'autoptimize_ccss_keyst', false ) ) {
136
  $_generate_disabled = false;
137
  }
138
  ?>
classes/autoptimizeOptionWrapper.php CHANGED
@@ -34,14 +34,27 @@ class autoptimizeOptionWrapper {
34
  * @return mixed Value set for the option.
35
  */
36
  public static function get_option( $option, $default = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  // This is always a network setting, it is on by default to ensure settings are available at site level unless explicitly turned off.
38
  if ( 'autoptimize_enable_site_config' === $option ) {
39
- return get_network_option( get_main_network_id(), $option, 'on' );
40
  }
41
 
42
  // If the plugin is network activated and our per site setting is not on, use the network configuration.
43
- $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config', 'on' );
44
- if ( self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
45
  return get_network_option( get_main_network_id(), $option, $default );
46
  }
47
 
34
  * @return mixed Value set for the option.
35
  */
36
  public static function get_option( $option, $default = false ) {
37
+ if ( is_multisite() && self::is_ao_active_for_network() ) {
38
+ static $configuration_per_site = null;
39
+ if ( null === $configuration_per_site || defined( 'TEST_MULTISITE_FORCE_AO_ON_NETWORK' ) ) {
40
+ $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config', 'on' );
41
+ if ( null === $configuration_per_site ) {
42
+ // Config per site is off, set as empty string to make sure the var it is not null any more so it can be cached.
43
+ $configuration_per_site = '';
44
+ }
45
+ }
46
+ } else {
47
+ // Kind of dummy value as when not on multisite or if AO not network enabled, config is always on site-level.
48
+ $configuration_per_site = 'on';
49
+ }
50
+
51
  // This is always a network setting, it is on by default to ensure settings are available at site level unless explicitly turned off.
52
  if ( 'autoptimize_enable_site_config' === $option ) {
53
+ return $configuration_per_site;
54
  }
55
 
56
  // If the plugin is network activated and our per site setting is not on, use the network configuration.
57
+ if ( is_multisite() && self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
 
58
  return get_network_option( get_main_network_id(), $option, $default );
59
  }
60
 
classes/autoptimizePartners.php CHANGED
@@ -138,7 +138,7 @@ class autoptimizePartners
138
  </style>
139
  <script>document.title = "Autoptimize: <?php _e( 'Optimize More!', 'autoptimize' ); ?> " + document.title;</script>
140
  <div class="wrap">
141
- <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
142
  <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
143
  <?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?>
144
  <div>
138
  </style>
139
  <script>document.title = "Autoptimize: <?php _e( 'Optimize More!', 'autoptimize' ); ?> " + document.title;</script>
140
  <div class="wrap">
141
+ <h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
142
  <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
143
  <?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?>
144
  <div>
classes/autoptimizeScripts.php CHANGED
@@ -486,7 +486,7 @@ class autoptimizeScripts extends autoptimizeBase
486
  * @param string $tag Script node & child(ren).
487
  * @return bool
488
  */
489
- public function should_aggregate( $tag )
490
  {
491
  if ( empty( $tag ) ) {
492
  return false;
486
  * @param string $tag Script node & child(ren).
487
  * @return bool
488
  */
489
+ public static function should_aggregate( $tag )
490
  {
491
  if ( empty( $tag ) ) {
492
  return false;
classes/autoptimizeStyles.php CHANGED
@@ -1040,7 +1040,7 @@ class autoptimizeStyles extends autoptimizeBase
1040
  if ( $this->defer && 'print' !== $media ) {
1041
  $preload_onload = autoptimizeConfig::get_ao_css_preload_onload( $media );
1042
 
1043
- $preload_css_block .= '<link rel="stylesheet" media="print" href="' . $url . '" onload="' . $preload_onload . '" />';
1044
  if ( apply_filters( 'autoptimize_fitler_css_preload_and_print', false ) ) {
1045
  $preload_css_block = '<link rel="preload" as="stylesheet" href="' . $url . '"/>' . $preload_css_block;
1046
  }
1040
  if ( $this->defer && 'print' !== $media ) {
1041
  $preload_onload = autoptimizeConfig::get_ao_css_preload_onload( $media );
1042
 
1043
+ $preload_css_block .= apply_filters( 'autoptimize_filter_css_single_deferred_link', '<link rel="stylesheet" media="print" href="' . $url . '" onload="' . $preload_onload . '" />' );
1044
  if ( apply_filters( 'autoptimize_fitler_css_preload_and_print', false ) ) {
1045
  $preload_css_block = '<link rel="preload" as="stylesheet" href="' . $url . '"/>' . $preload_css_block;
1046
  }
classes/autoptimizeToolbar.php CHANGED
@@ -23,7 +23,7 @@ class autoptimizeToolbar
23
  public function load_toolbar()
24
  {
25
  // Check permissions and that toolbar is not hidden via filter.
26
- if ( current_user_can( 'manage_options' ) && apply_filters( 'autoptimize_filter_toolbar_show', true ) ) {
27
 
28
  // Create a handler for the AJAX toolbar requests.
29
  add_action( 'wp_ajax_autoptimize_delete_cache', array( $this, 'delete_cache' ) );
@@ -74,9 +74,10 @@ class autoptimizeToolbar
74
 
75
  // Create or add new items into the Admin Toolbar.
76
  // Main "Autoptimize" node.
 
77
  $wp_admin_bar->add_node( array(
78
  'id' => 'autoptimize',
79
- 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Autoptimize', 'autoptimize' ) . '</span>',
80
  'href' => admin_url( 'options-general.php?page=autoptimize' ),
81
  'meta' => array( 'class' => 'bullet-' . $color ),
82
  ));
@@ -84,7 +85,7 @@ class autoptimizeToolbar
84
  // "Cache Info" node.
85
  $wp_admin_bar->add_node( array(
86
  'id' => 'autoptimize-cache-info',
87
- 'title' => '<p>' . __( 'Cache Info', 'autoptimize' ) . '</p>' .
88
  '<div class="autoptimize-radial-bar" percentage="' . $percentage . '">' .
89
  '<div class="autoptimize-circle">' .
90
  '<div class="mask full"><div class="fill bg-' . $color . '"></div></div>' .
@@ -103,7 +104,7 @@ class autoptimizeToolbar
103
  // "Delete Cache" node.
104
  $wp_admin_bar->add_node( array(
105
  'id' => 'autoptimize-delete-cache',
106
- 'title' => __( 'Delete Cache', 'autoptimize' ),
107
  'parent' => 'autoptimize',
108
  ));
109
  }
23
  public function load_toolbar()
24
  {
25
  // Check permissions and that toolbar is not hidden via filter.
26
+ if ( current_user_can( 'manage_options' ) && apply_filters( 'autoptimize_filter_toolbar_show', true ) && ! autoptimizeMain::is_amp_markup('') ) {
27
 
28
  // Create a handler for the AJAX toolbar requests.
29
  add_action( 'wp_ajax_autoptimize_delete_cache', array( $this, 'delete_cache' ) );
74
 
75
  // Create or add new items into the Admin Toolbar.
76
  // Main "Autoptimize" node.
77
+ $_my_name = apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? __( 'Autoptimize Pro', 'autoptimize' ) : __( 'Autoptimize', 'autoptimize' );
78
  $wp_admin_bar->add_node( array(
79
  'id' => 'autoptimize',
80
+ 'title' => '<span class="ab-icon"></span><span class="ab-label">' . $_my_name . '</span>',
81
  'href' => admin_url( 'options-general.php?page=autoptimize' ),
82
  'meta' => array( 'class' => 'bullet-' . $color ),
83
  ));
85
  // "Cache Info" node.
86
  $wp_admin_bar->add_node( array(
87
  'id' => 'autoptimize-cache-info',
88
+ 'title' => '<p>' . __( 'CSS/ JS Cache Info', 'autoptimize' ) . '</p>' .
89
  '<div class="autoptimize-radial-bar" percentage="' . $percentage . '">' .
90
  '<div class="autoptimize-circle">' .
91
  '<div class="mask full"><div class="fill bg-' . $color . '"></div></div>' .
104
  // "Delete Cache" node.
105
  $wp_admin_bar->add_node( array(
106
  'id' => 'autoptimize-delete-cache',
107
+ 'title' => __( 'Clear CSS/ JS Cache', 'autoptimize' ),
108
  'parent' => 'autoptimize',
109
  ));
110
  }
classes/autoptimizeUtils.php CHANGED
@@ -401,45 +401,49 @@ class autoptimizeUtils
401
  *
402
  * @return bool
403
  */
404
- public static function find_pagecache() {
405
  static $_found_pagecache = null;
406
 
407
  if ( null === $_found_pagecache ) {
408
- $_page_cache_constants = array( 'NGINX_HELPER_BASENAME', 'KINSTA_CACHE_ZONE', 'PL_INSTANCE_REF', 'WP_NINUKIS_WP_NAME', 'CACHE_ENABLER_VERSION', 'SBP_PLUGIN_NAME', 'SERVEBOLT_PLUGIN_FILE', 'SWCFPC_PLUGIN_PATH', 'CACHIFY_CACHE_DIR', 'WP_ROCKET_CACHE_PATH', 'WPO_VERSION', 'NGINX_HELPER_BASEURL' );
409
- $_page_cache_classes = array( 'Swift_Performance_Cache', 'WpFastestCache', 'c_ws_plugin__qcache_purging_routines', 'zencache', 'comet_cache', 'WpeCommon', 'FlywheelNginxCompat', 'PagelyCachePurge' );
410
- $_page_cache_functions = array( 'wp_cache_clear_cache', 'w3tc_pgcache_flush', 'wp_fast_cache_bulk_delete_all', 'rapidcache_clear_cache', 'sg_cachepress_purge_cache', 'prune_super_cache' );
411
- $_ao_pagecache_transient = 'autoptimize_pagecache_check';
412
- $_found_pagecache = get_transient( $_ao_pagecache_transient );
 
 
 
 
413
 
414
  if ( current_user_can( 'manage_options' ) && false === $_found_pagecache ) {
415
  // loop through known pagecache constants.
416
- foreach ( $_page_cache_constants as $_constant ) {
417
  if ( defined( $_constant ) ) {
418
- $_found_pagecache = true;
419
  break;
420
  }
421
  }
422
  // and loop through known pagecache classes.
423
  if ( false === $_found_pagecache ) {
424
- foreach ( $_page_cache_classes as $_class ) {
425
  if ( class_exists( $_class ) ) {
426
- $_found_pagecache = true;
427
  break;
428
  }
429
  }
430
  }
431
  // and loop through known pagecache functions.
432
  if ( false === $_found_pagecache ) {
433
- foreach ( $_page_cache_functions as $_function ) {
434
  if ( function_exists( $_function ) ) {
435
- $_found_pagecache = true;
436
  break;
437
  }
438
  }
439
  }
440
 
441
  // store in transient for 1 week if pagecache found.
442
- if ( true === $_found_pagecache ) {
443
  set_transient( $_ao_pagecache_transient, true, WEEK_IN_SECONDS );
444
  }
445
  }
@@ -475,7 +479,7 @@ class autoptimizeUtils
475
  } elseif ( defined( 'W3TC_VERSION' ) ) {
476
  $w3tcConfig = file_get_contents( WP_CONTENT_DIR . '/w3tc-config/master.php' );
477
  $w3tc_minify_on = strpos( $w3tcConfig, '"minify.enabled": true' );
478
- if ( $w3tc_minify ) {
479
  return 'W3 Total Cache';
480
  }
481
  } elseif ( defined('SiteGround_Optimizer\VERSION') ) {
401
  *
402
  * @return bool
403
  */
404
+ public static function find_pagecache( $disregard_transient = false ) {
405
  static $_found_pagecache = null;
406
 
407
  if ( null === $_found_pagecache ) {
408
+ $_page_cache_constants = array( 'NgInx' => 'NGINX_HELPER_BASENAME', 'Kinsta' => 'KINSTA_CACHE_ZONE', 'Presslabs' => 'PL_INSTANCE_REF', '' => 'Pressidium', 'Cache Enabler' => 'CACHE_ENABLER_VERSION', 'Speed Booster Pack' => 'SBP_PLUGIN_NAME', 'Servebolt' => 'SERVEBOLT_PLUGIN_FILE', 'WP CloudFlare Super Page Cache' => 'SWCFPC_PLUGIN_PATH', 'Cachify' => 'CACHIFY_CACHE_DIR', 'WP Rocket' => 'WP_ROCKET_CACHE_PATH', 'WP Optimize' => 'WPO_VERSION', 'Autoptimize Pro' => 'AO_PRO_PAGECACHE_CACHE_DIR' );
409
+ $_page_cache_classes = array( 'Swift Performance' => 'Swift_Performance_Cache', 'WP Fastest Cache' => 'WpFastestCache', 'Quick Cache' => 'c_ws_plugin__qcache_purging_routines', 'ZenCache' => 'zencache', 'Comet Cache' => 'comet_cache', 'WP Engine' => 'WpeCommon', 'Flywheel' => 'FlywheelNginxCompat', 'Pagely' => 'PagelyCachePurge' );
410
+ $_page_cache_functions = array( 'WP Super Cache' => 'wp_cache_clear_cache', 'W3 Total Cache' => 'w3tc_pgcache_flush', 'WP Fast Cache' => 'wp_fast_cache_bulk_delete_all', 'Rapidcache' => 'rapidcache_clear_cache', 'Siteground' => 'sg_cachepress_purge_cache', 'WP Super Cache' => 'prune_super_cache' );
411
+
412
+ $_found_pagecache = false;
413
+ if ( true !== $disregard_transient ) {
414
+ $_ao_pagecache_transient = 'autoptimize_pagecache_check';
415
+ $_found_pagecache = get_transient( $_ao_pagecache_transient );
416
+ }
417
 
418
  if ( current_user_can( 'manage_options' ) && false === $_found_pagecache ) {
419
  // loop through known pagecache constants.
420
+ foreach ( $_page_cache_constants as $_name => $_constant ) {
421
  if ( defined( $_constant ) ) {
422
+ $_found_pagecache = $_name;
423
  break;
424
  }
425
  }
426
  // and loop through known pagecache classes.
427
  if ( false === $_found_pagecache ) {
428
+ foreach ( $_page_cache_classes as $_name => $_class ) {
429
  if ( class_exists( $_class ) ) {
430
+ $_found_pagecache = $_name;
431
  break;
432
  }
433
  }
434
  }
435
  // and loop through known pagecache functions.
436
  if ( false === $_found_pagecache ) {
437
+ foreach ( $_page_cache_functions as $_name => $_function ) {
438
  if ( function_exists( $_function ) ) {
439
+ $_found_pagecache = $_name;
440
  break;
441
  }
442
  }
443
  }
444
 
445
  // store in transient for 1 week if pagecache found.
446
+ if ( true === $_found_pagecache && true !== $disregard_transient ) {
447
  set_transient( $_ao_pagecache_transient, true, WEEK_IN_SECONDS );
448
  }
449
  }
479
  } elseif ( defined( 'W3TC_VERSION' ) ) {
480
  $w3tcConfig = file_get_contents( WP_CONTENT_DIR . '/w3tc-config/master.php' );
481
  $w3tc_minify_on = strpos( $w3tcConfig, '"minify.enabled": true' );
482
+ if ( $w3tc_minify_on ) {
483
  return 'W3 Total Cache';
484
  }
485
  } elseif ( defined('SiteGround_Optimizer\VERSION') ) {
classes/critcss-inc/admin_settings_key.php CHANGED
@@ -15,6 +15,12 @@
15
  function ao_ccss_render_key( $key, $status, $status_msg, $message, $color ) {
16
  if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) {
17
  $key = __( 'API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize' );
 
 
 
 
 
 
18
  }
19
  ?>
20
  <ul id="key-panel">
15
  function ao_ccss_render_key( $key, $status, $status_msg, $message, $color ) {
16
  if ( defined( 'AUTOPTIMIZE_CRITICALCSS_API_KEY' ) ) {
17
  $key = __( 'API key provided by your host/ WordPress administrator, no need to enter anything here. In case of problems with the API key, contact your host/ WordPress administrator.', 'autoptimize' );
18
+ } else if ( has_filter( 'autoptimize_filter_ccss_key' ) ) {
19
+ if ( defined( 'AO_PRO_VERSION' ) ) {
20
+ $key = __( 'You\'re using Autoptimize Pro, so you don\'t need to provide an API Key.', 'autoptimize' );
21
+ } else {
22
+ $key = __( 'API Key provided by a filter, no need to enter anything here.', 'autoptimize' );
23
+ }
24
  }
25
  ?>
26
  <ul id="key-panel">
classes/static/exit-survey/exit-survey.css ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ tr[data-slug="autoptimize"] span.deactivate{
3
+ position: relative;
4
+ }
5
+
6
+ .ao-feedback {
7
+ background: #fff;
8
+ max-width: 400px;
9
+ z-index: 10000;
10
+ box-shadow: 0 0 15px -5px rgba(0, 0, 0, .5);
11
+ transition: all .3s ease-out;
12
+ }
13
+
14
+
15
+ .ao-feedback .popup--header {
16
+ position: relative;
17
+ background-color: #e5e5e5;
18
+ }
19
+
20
+ .ao-feedback .popup--header h5 {
21
+ margin: 0;
22
+ font-size: 13px;
23
+ padding: 10px 15px;
24
+ color: #222;
25
+ font-weight: 600;
26
+ text-align: left;
27
+ }
28
+
29
+ .ao-feedback .popup--body {
30
+ padding: 15px;
31
+ }
32
+
33
+ .ao-feedback .popup--form {
34
+ margin: 0;
35
+ font-size: 13px;
36
+ }
37
+
38
+ .ao-feedback .popup--form input[type="radio"] {
39
+ margin: 0 10px 0 0;
40
+ }
41
+
42
+ .ao-feedback .popup--form input[type="radio"]:checked ~ textarea {
43
+ display: block;
44
+ }
45
+
46
+ .ao-feedback .popup--form textarea {
47
+ width: 100%;
48
+ margin: 10px 0 0;
49
+ display: none;
50
+ max-height: 150px;
51
+ }
52
+
53
+ .ao-feedback li {
54
+ display: flex;
55
+ align-items: center;
56
+ margin-bottom: 15px;
57
+ flex-wrap: wrap;
58
+ }
59
+
60
+ .ao-feedback li label {
61
+ max-width: 90%;
62
+ }
63
+
64
+ .ao-feedback li:last-child {
65
+ margin-bottom: 0;
66
+ }
67
+
68
+ .ao-feedback .popup--footer {
69
+ padding: 0 15px 15px;
70
+ }
71
+
72
+ .ao-feedback .actions {
73
+ display: flex;
74
+ flex-wrap: wrap;
75
+ }
76
+
77
+ .info-disclosure-link {
78
+ width: 100%;
79
+ margin-bottom: 15px;
80
+ }
81
+
82
+ .ao-feedback .info-disclosure-content {
83
+ max-height: 0;
84
+ overflow: hidden;
85
+ width: 100%;
86
+ transition: .3s ease;
87
+ }
88
+
89
+ .ao-feedback .info-disclosure-content.active {
90
+ max-height: 300px;
91
+ }
92
+
93
+ .ao-feedback .info-disclosure-content p {
94
+ margin: 0;
95
+ }
96
+
97
+ .ao-feedback .info-disclosure-content ul {
98
+ margin: 10px 0;
99
+ border-radius: 3px;
100
+ }
101
+
102
+ .ao-feedback .info-disclosure-content ul li {
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: space-between;
106
+ margin-bottom: 0;
107
+ padding: 5px 0;
108
+ border-bottom: 1px solid #ccc;
109
+ }
110
+
111
+ .ao-feedback .buttons {
112
+ display: flex;
113
+ width: 100%;
114
+ }
115
+
116
+ .ao-feedback .buttons input:last-child {
117
+ margin-left: auto;
118
+ }
119
+
120
+ .ao-plugin-uninstall-feedback-popup .popup--header:before {
121
+ content: "";
122
+ display: block;
123
+ position: absolute;
124
+ border: 20px solid #e5e5e5;
125
+ left: -10px;
126
+ top: 50%;
127
+ border-top: 20px solid transparent;
128
+ border-bottom: 20px solid transparent;
129
+ border-left: 0;
130
+ transform: translateY(-50%);
131
+ }
132
+
133
+ .ao-plugin-uninstall-feedback-popup {
134
+ display: none;
135
+ position: absolute;
136
+ white-space: normal;
137
+ width: 400px;
138
+ left: 122%;
139
+ top: -21px;
140
+ }
141
+
142
+ .ao-plugin-uninstall-feedback-popup.sending-feedback .popup--body i {
143
+ animation: rotation 2s infinite linear;
144
+ display: block;
145
+ float: none;
146
+ align-items: center;
147
+ width: 100%;
148
+ margin: 0 auto;
149
+ height: 100%;
150
+ background: transparent;
151
+ padding: 0;
152
+ }
153
+
154
+ .ao-plugin-uninstall-feedback-popup.sending-feedback .popup--body i:before {
155
+ padding: 0;
156
+ background: transparent;
157
+ box-shadow: none;
158
+ color: #b4b9be
159
+ }
160
+
161
+
162
+ .ao-plugin-uninstall-feedback-popup.active {
163
+ display: block;
164
+ }
165
+
166
+ body.ao-feedback-open .ao-feedback-overlay {
167
+ content: "";
168
+ display: block;
169
+ background-color: rgba(0, 0, 0, 0.5);
170
+ top: 0;
171
+ bottom: 0;
172
+ right: 0;
173
+ left: 0;
174
+ z-index: 10000;
175
+ position: fixed;
176
+ }
177
+
178
+ @media (max-width: 768px) {
179
+ .ao-plugin-uninstall-feedback-popup {
180
+ position: fixed;
181
+ max-width: 100%;
182
+ margin: 0 auto;
183
+ left: 50%;
184
+ top: 50px;
185
+ transform: translateX(-50%);
186
+ }
187
+
188
+ .ao-plugin-uninstall-feedback-popup .popup--header:before {
189
+ display: none;
190
+ }
191
+ }
classes/static/exit-survey/exit-survey.js ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ $(document).ready(function () {
3
+ var targetElement = 'tr[data-slug="autoptimize"] span.deactivate a';
4
+ var redirectUrl = $(targetElement).attr('href');
5
+ if ($('.ao-feedback-overlay').length === 0) {
6
+ $('body').prepend('<div class="ao-feedback-overlay"></div>');
7
+ }
8
+ $('#ao_uninstall_feedback_popup').appendTo($(targetElement).parent());
9
+
10
+ $(targetElement).on('click', function (e) {
11
+ e.preventDefault();
12
+ $('#ao_uninstall_feedback_popup ').addClass('active');
13
+ $('body').addClass('ao-feedback-open');
14
+ $('.ao-feedback-overlay').on('click', function () {
15
+ $('#ao_uninstall_feedback_popup ').removeClass('active');
16
+ $('body').removeClass('ao-feedback-open');
17
+ });
18
+ });
19
+
20
+ $('#ao_uninstall_feedback_popup .info-disclosure-link').on('click', function (e) {
21
+ e.preventDefault();
22
+ $(this).parent().find('.info-disclosure-content').toggleClass('active');
23
+ });
24
+
25
+ $('#ao_uninstall_feedback_popup input[type="radio"]').on('change', function () {
26
+ var radio = $(this);
27
+ if (radio.parent().find('textarea').length > 0 &&
28
+ radio.parent().find('textarea').val().length === 0) {
29
+ $('#ao_uninstall_feedback_popup #ao-deactivate-yes').attr('disabled', 'disabled');
30
+ radio.parent().find('textarea').on('keyup', function (e) {
31
+ if ($(this).val().length === 0) {
32
+ $('#ao_uninstall_feedback_popup #ao-deactivate-yes').attr('disabled', 'disabled');
33
+ } else {
34
+ $('#ao_uninstall_feedback_popup #ao-deactivate-yes').removeAttr('disabled');
35
+ }
36
+ });
37
+ } else {
38
+ $('#ao_uninstall_feedback_popup #ao-deactivate-yes').removeAttr('disabled');
39
+ }
40
+ });
41
+
42
+ $('#ao_uninstall_feedback_popup #ao-deactivate-no').on('click', function (e) {
43
+ e.preventDefault();
44
+ e.stopPropagation();
45
+ $(targetElement).unbind('click');
46
+ $('body').removeClass('ao-feedback-open');
47
+ $('#ao_uninstall_feedback_popup').remove();
48
+ if (redirectUrl !== '') {
49
+ location.href = redirectUrl;
50
+ }
51
+ });
52
+
53
+ $('#ao_uninstall_feedback_popup #ao-deactivate-yes').on('click', function (e) {
54
+ e.preventDefault();
55
+ e.stopPropagation();
56
+ $(targetElement).unbind('click');
57
+
58
+ var modal_data = JSON.parse(atob($('#ao_uninstall_feedback_popup').data('modal')))
59
+
60
+ var selectedOption = $( '#ao_uninstall_feedback_popup input[name="ao-deactivate-option"]:checked' );
61
+
62
+ var reason;
63
+
64
+ if( selectedOption.attr("id") === "ao_feedback999" ){
65
+ reason = 'Other: ' + selectedOption.parent().find('textarea').val().trim()
66
+ }else{
67
+ reason = selectedOption.parent().find('label').text().trim()
68
+ }
69
+
70
+ var data = {
71
+ 'url': modal_data.home,
72
+ 'reason': reason,
73
+ 'type': 'wordpress',
74
+ 'version' : $('#ao_plugin_version').text().trim(),
75
+ };
76
+ $.ajax({
77
+ type: 'POST',
78
+ url: atob( modal_data.dest ),
79
+ data: data,
80
+ complete() {
81
+ $('body').removeClass('ao-feedback-open');
82
+ $('#ao_uninstall_feedback_popup').remove();
83
+ if (redirectUrl !== '') {
84
+ location.href = redirectUrl;
85
+ }
86
+ },
87
+ beforeSend() {
88
+ $('#ao_uninstall_feedback_popup').addClass('sending-feedback');
89
+ $('#ao_uninstall_feedback_popup .popup--footer').remove();
90
+ $('#ao_uninstall_feedback_popup .popup--body').html('<i class="dashicons dashicons-update-alt"></i>');
91
+ }
92
+ });
93
+ });
94
+ });
95
+ })(jQuery);
config/autoptimize_404_handler.php CHANGED
@@ -29,7 +29,16 @@ if ( strpos( $original_request, 'uucss/uucss-' ) !== false ) {
29
  $fallback_target = preg_replace( '/(.*)_(?:[a-z0-9]{32})\.(js|css)$/', '${1}_fallback.${2}', $original_request );
30
  $ao_cache_dir = '<!--ao-cache-dir-->';
31
  $js_or_css = pathinfo( $original_request, PATHINFO_EXTENSION );
32
- $fallback_path = $ao_cache_dir . $js_or_css . '/autoptimize_fallback.' . $js_or_css;
 
 
 
 
 
 
 
 
 
33
 
34
  if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
35
  // error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
29
  $fallback_target = preg_replace( '/(.*)_(?:[a-z0-9]{32})\.(js|css)$/', '${1}_fallback.${2}', $original_request );
30
  $ao_cache_dir = '<!--ao-cache-dir-->';
31
  $js_or_css = pathinfo( $original_request, PATHINFO_EXTENSION );
32
+
33
+ // add multisite logic.
34
+ $multisite = false;
35
+ if ( true === $multisite ) {
36
+ preg_match( '#\/([0-9]{1,3})\/(?:js|css)\/[a-z0-9]*_fallback\.(?:js|css)$#', $fallback_target, $child_site_id );
37
+ $ao_root_cache_dir = preg_replace( '#[0-9]*\/$#', '', $ao_cache_dir );
38
+ $ao_cache_dir = $ao_root_cache_dir . $child_site_id[1] . '/';
39
+ }
40
+
41
+ $fallback_path = $ao_cache_dir . $js_or_css . '/autoptimize_fallback.' . $js_or_css;
42
 
43
  if ( $original_request !== $fallback_target && file_exists( $fallback_path ) ) {
44
  // error_log( 'Autoptimize file ' . $original_request . ' not found, using fallback instead.' );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 4.9
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
- Stable tag: 2.9.2
9
 
10
  Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
11
 
@@ -325,6 +325,16 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
325
 
326
  == Changelog ==
327
 
 
 
 
 
 
 
 
 
 
 
328
  = 2.9.2 =
329
  * New: page/ post settings now have a "Generate Critical CSS"-button (critical CSS needs to be active with valid API key)
330
  * Improvement: also check WP Rocket settings for possible conflicts
5
  Requires at least: 4.9
6
  Tested up to: 5.8
7
  Requires PHP: 5.6
8
+ Stable tag: 2.9.3
9
 
10
  Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
11
 
325
 
326
  == Changelog ==
327
 
328
+ = 2.9.3 =
329
+ * Improvement: add logic to autoptimize_404_handler.php to differentiate between different multisite sites.
330
+ * Improvement: remove the different feeds (and all JS to switch between them) on the settings-page, keeping only the "Autoptimize news".
331
+ * Improvement: reduced autoptimize_enable_site_config option lookups when on multisite and AO is active for network.
332
+ * Fixed wrong variable name that caused PHP notices (but did not affect normal usage) to $w3tc_minify_on.
333
+ * Fix for Autoptimize Toolbar being loaded on AMP pages for logged in administrators/ editors
334
+ * Fix for CDN replacement edge case (if the CDN has the site_url in it).
335
+ * Fix for service availability checks causing too many outgoing requests (root cause likely to be object caching resulting in the autoptimize_service_availability option not being updated)
336
+ * Added "exit survey" when Autoptimize is deactivated (with the kind help of Shakeeb of RapidLoad, thanks brother!)
337
+
338
  = 2.9.2 =
339
  * New: page/ post settings now have a "Generate Critical CSS"-button (critical CSS needs to be active with valid API key)
340
  * Improvement: also check WP Rocket settings for possible conflicts