Autoptimize - Version 1.7.3

Version Description

  • improvement: remove cache + options on uninstall as requested by Gingerbreadmen
  • improvement: set .htaccess to allow PHP execution in wp-content/cache/autoptimize when saving optimized files as PHP, as suggested by (David Mottershead of bermuda4u.com}[http://www.bermuda4u.com/] but forbid PHP execution when saving aggregated script/css as static files (except for multisite).
  • bugfix: avoid Yoast SEO sitemaps going blank (due optimization of Yoast's dynamically built XML/XSL) as reported by Vance Hallman and Armand Hadife. More info on this issue can be found on my blog.
  • smaller changes to readme.txt
Download this release

Release Info

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

Code changes from version 1.7.2 to 1.7.3

autoptimize.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Autoptimize
4
  Plugin URI: http://blog.futtta.be/autoptimize
5
  Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
6
- Version: 1.7.2
7
  Author: Frank Goossens (futtta)
8
  Author URI: http://blog.futtta.be/
9
  Released under the GNU General Public License (GPL)
@@ -27,7 +27,7 @@ $conf = autoptimizeConfig::instance();
27
  /* Check if we're updating, in which case we need to flush the cache
28
  to avoid old versions of aggregated files lingering around */
29
 
30
- $autoptimize_version="1.7.2";
31
  $autoptimize_db_version=get_option('autoptimize_version','none');
32
 
33
  if ($autoptimize_db_version !== $autoptimize_version) {
@@ -59,6 +59,26 @@ define('AUTOPTIMIZE_CACHE_NOGZIP',(bool) $conf->get('autoptimize_cache_nogzip'))
59
  $plugin_dir = basename(dirname(__FILE__));
60
  load_plugin_textdomain('autoptimize','wp-content/plugins/'.$plugin_dir.'/localization',$plugin_dir.'/localization');
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  function autoptimize_install_config_notice() {
63
  echo '<div class="updated"><p>';
64
  _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize' );
@@ -131,6 +151,8 @@ function autoptimize_start_buffering()
131
  //Action on end -
132
  function autoptimize_end_buffering($content)
133
  {
 
 
134
  // load URL constants as late as possible to allow domain mapper to kick in
135
  if (function_exists(domain_mapping_siteurl)) {
136
  define('AUTOPTIMIZE_WP_SITE_URL',domain_mapping_siteurl());
@@ -200,5 +222,7 @@ if(autoptimizeCache::cacheavail())
200
  }
201
  }
202
 
 
 
203
  // Do not pollute other plugins
204
  unset($conf);
3
  Plugin Name: Autoptimize
4
  Plugin URI: http://blog.futtta.be/autoptimize
5
  Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
6
+ Version: 1.7.3
7
  Author: Frank Goossens (futtta)
8
  Author URI: http://blog.futtta.be/
9
  Released under the GNU General Public License (GPL)
27
  /* Check if we're updating, in which case we need to flush the cache
28
  to avoid old versions of aggregated files lingering around */
29
 
30
+ $autoptimize_version="1.7.3";
31
  $autoptimize_db_version=get_option('autoptimize_version','none');
32
 
33
  if ($autoptimize_db_version !== $autoptimize_version) {
59
  $plugin_dir = basename(dirname(__FILE__));
60
  load_plugin_textdomain('autoptimize','wp-content/plugins/'.$plugin_dir.'/localization',$plugin_dir.'/localization');
61
 
62
+ function autoptimize_uninstall(){
63
+ autoptimizeCache::clearall();
64
+
65
+ $delete_options=array("autoptimize_cache_clean", "autoptimize_cache_nogzip", "autoptimize_css", "autoptimize_css_datauris", "autoptimize_css_justhead", "autoptimize_css_defer", "autoptimize_css_exclude", "autoptimize_html", "autoptimize_html_keepcomments", "autoptimize_js", "autoptimize_js_exclude", "autoptimize_js_forcehead", "autoptimize_js_justhead", "autoptimize_js_trycatch", "autoptimize_version", "autoptimize_show_adv", "autoptimize_cdn_url");
66
+
67
+ if ( !is_multisite() ) {
68
+ foreach ($delete_options as $del_opt) { delete_option( $del_opt ); }
69
+ } else {
70
+ global $wpdb;
71
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
72
+ $original_blog_id = get_current_blog_id();
73
+ foreach ( $blog_ids as $blog_id )
74
+ {
75
+ switch_to_blog( $blog_id );
76
+ foreach ($delete_options as $del_opt) { delete_option( $del_opt ); }
77
+ }
78
+ switch_to_blog( $original_blog_id );
79
+ }
80
+ }
81
+
82
  function autoptimize_install_config_notice() {
83
  echo '<div class="updated"><p>';
84
  _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize' );
151
  //Action on end -
152
  function autoptimize_end_buffering($content)
153
  {
154
+ if ( stripos($content,"<html") === false || stripos($content,"<xsl:stylesheet") !== false ) { return $content;}
155
+
156
  // load URL constants as late as possible to allow domain mapper to kick in
157
  if (function_exists(domain_mapping_siteurl)) {
158
  define('AUTOPTIMIZE_WP_SITE_URL',domain_mapping_siteurl());
222
  }
223
  }
224
 
225
+ register_uninstall_hook(__FILE__, "autoptimize_uninstall");
226
+
227
  // Do not pollute other plugins
228
  unset($conf);
classes/autoptimizeCache.php CHANGED
@@ -83,6 +83,8 @@ class autoptimizeCache
83
  @unlink(AUTOPTIMIZE_CACHE_DIR.$file);
84
  }
85
  }
 
 
86
 
87
  // Do we need to clean any caching plugins cache-files?
88
  if(function_exists('wp_cache_clear_cache')) {
@@ -173,8 +175,25 @@ class autoptimizeCache
173
  /** write .htaccess here to overrule wp_super_cache */
174
  $htAccess=AUTOPTIMIZE_CACHE_DIR.'/.htaccess';
175
  if(!is_file($htAccess)) {
176
- @file_put_contents($htAccess,
177
- '<IfModule mod_headers.c>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  Header set Vary "Accept-Encoding"
179
  Header set Cache-Control "max-age=10672000, must-revalidate"
180
  </IfModule>
@@ -183,9 +202,12 @@ class autoptimizeCache
183
  ExpiresByType text/css A30672000
184
  ExpiresByType text/javascript A30672000
185
  ExpiresByType application/javascript A30672000
186
- </IfModule>');
 
 
 
 
187
  }
188
-
189
  //All OK
190
  return true;
191
  }
83
  @unlink(AUTOPTIMIZE_CACHE_DIR.$file);
84
  }
85
  }
86
+
87
+ @unlink(AUTOPTIMIZE_CACHE_DIR."/.htaccess");
88
 
89
  // Do we need to clean any caching plugins cache-files?
90
  if(function_exists('wp_cache_clear_cache')) {
175
  /** write .htaccess here to overrule wp_super_cache */
176
  $htAccess=AUTOPTIMIZE_CACHE_DIR.'/.htaccess';
177
  if(!is_file($htAccess)) {
178
+ if (is_multisite()) {@file_put_contents($htAccess,'<IfModule mod_headers.c>
179
+ Header set Vary "Accept-Encoding"
180
+ Header set Cache-Control "max-age=10672000, must-revalidate"
181
+ </IfModule>
182
+ <IfModule mod_expires.c>
183
+ ExpiresActive On
184
+ ExpiresByType text/css A30672000
185
+ ExpiresByType text/javascript A30672000
186
+ ExpiresByType application/javascript A30672000
187
+ </IfModule>
188
+ <Files *.php>
189
+ Allow from all
190
+ </Files>');
191
+ } else if (AUTOPTIMIZE_CACHE_NOGZIP == false) {
192
+ @file_put_contents($htAccess,'<Files *.php>
193
+ Allow from all
194
+ </Files>');
195
+ } else {
196
+ @file_put_contents($htAccess,'<IfModule mod_headers.c>
197
  Header set Vary "Accept-Encoding"
198
  Header set Cache-Control "max-age=10672000, must-revalidate"
199
  </IfModule>
202
  ExpiresByType text/css A30672000
203
  ExpiresByType text/javascript A30672000
204
  ExpiresByType application/javascript A30672000
205
+ </IfModule>
206
+ <Files *.php>
207
+ Deny from all
208
+ </Files>');
209
+ }
210
  }
 
211
  //All OK
212
  return true;
213
  }
classes/autoptimizeConfig.php CHANGED
@@ -129,7 +129,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
129
  <tr valign="top" class="hidden ao_adv">
130
  <th scope="row"><?php _e('Defer CSS loading?','autoptimize'); ?></th>
131
  <td><label for="autoptimize_css_defer"><input type="checkbox" name="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer')?'checked="checked" ':''; ?>/>
132
- <?php _e('Normally CSS is loaded in the &lt;head&gt;-section of the HTML, but for mobile performance reasons having it deferred can be better.','autoptimize'); ?></label></td>
133
  </tr>
134
  <tr valign="top" class="hidden ao_adv">
135
  <th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); ?></th>
129
  <tr valign="top" class="hidden ao_adv">
130
  <th scope="row"><?php _e('Defer CSS loading?','autoptimize'); ?></th>
131
  <td><label for="autoptimize_css_defer"><input type="checkbox" name="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer')?'checked="checked" ':''; ?>/>
132
+ <?php _e('Normally CSS is loaded in the &lt;head&gt;-section of the HTML, but for mobile performance reasons having it deferred can be better. ','autoptimize'); _e('<strong>Warning</strong>: this can slow down your site, <a href="http://wordpress.org/plugins/autoptimize/faq/" target="_blank">check the FAQ</a> before activating this option!','autoptimize'); ?></label></td>
133
  </tr>
134
  <tr valign="top" class="hidden ao_adv">
135
  <th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); ?></th>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, mi
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 2.7
6
  Tested up to: 3.8
7
- Stable tag: 1.7.2
8
 
9
  Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
10
 
@@ -62,6 +62,10 @@ Based on earlier feedback received from BuddyPress users, CSS and JS-Autoptimiza
62
 
63
  There have been reports of sightings of javascript errors when using Autoptimize together with WP SlimStat. Both [Camu (WP SlimStat developer)](http://profiles.wordpress.org/coolmann/) and I have installed both plugins on test-environments and [found no proof of such incompatibility](http://wordpress.org/support/topic/dropdown-menus-dont-work-when-slimstat-is-enabled?replies=14#post-4086894). Our common conclusion is that there are rare cases in which yet another theme or plugin's JavaScript are triggering these errors. If you do encounter JavaScript-errors when you have both WP SlimStat and Autoptimize installed, add "SlimStatParams, wp-slimstat.js" in the "Exclude scripts from autoptimize:" option on the admin-page and all should be well.
64
 
 
 
 
 
65
  = Configuring & Troubleshooting Autoptimize =
66
 
67
  After having installed and activated the plugin, you'll have access to an admin page where you can to enable HTML, CSS and JavaScript optimization. According to your liking, you can start of just enabling all of them, or if you're more cautious one at a time.
@@ -99,6 +103,12 @@ You can report problems on the [wordpress.org support forum](http://wordpress.or
99
 
100
  == Changelog ==
101
 
 
 
 
 
 
 
102
  = 1.7.2 =
103
  * improvement: extra checks in CSS @import-handling + move import rules to top of CSS if not imported successfully, based a.o. on bug reports [by ozum](http://wordpress.org/support/topic/zero-lenght-file-with-css-optimization) and by [Peter Stolwijk](http://wordpress.org/support/topic/cant-activate-plugin-22?replies=13#post-4891377)
104
  * improvement: check if JS and CSS minifier classes exist and only load if they don't to avoid possible conflicts with other themes or plugins that already loaded minifiers
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 2.7
6
  Tested up to: 3.8
7
+ Stable tag: 1.7.3
8
 
9
  Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
10
 
62
 
63
  There have been reports of sightings of javascript errors when using Autoptimize together with WP SlimStat. Both [Camu (WP SlimStat developer)](http://profiles.wordpress.org/coolmann/) and I have installed both plugins on test-environments and [found no proof of such incompatibility](http://wordpress.org/support/topic/dropdown-menus-dont-work-when-slimstat-is-enabled?replies=14#post-4086894). Our common conclusion is that there are rare cases in which yet another theme or plugin's JavaScript are triggering these errors. If you do encounter JavaScript-errors when you have both WP SlimStat and Autoptimize installed, add "SlimStatParams, wp-slimstat.js" in the "Exclude scripts from autoptimize:" option on the admin-page and all should be well.
64
 
65
+ = Problems with CSS of Kickstart theme when on WP Engine =
66
+
67
+ Although multiple users are succesfully running Autoptimize on WP Engine, there is [one confirmed issue when using the Kickstart-theme with Autoptimize on WP Engine](http://wordpress.org/support/topic/zero-lenght-file-with-css-optimization). The problem is that Autoptimize can't source in the import, leading to an empty CSS-file (which does not happen wen not on WP Engine). As a workaround you can link to the CSS-file from within your header.php, as suggested by [Ozum of fortibase.com](http://www.fortibase.com/)
68
+
69
  = Configuring & Troubleshooting Autoptimize =
70
 
71
  After having installed and activated the plugin, you'll have access to an admin page where you can to enable HTML, CSS and JavaScript optimization. According to your liking, you can start of just enabling all of them, or if you're more cautious one at a time.
103
 
104
  == Changelog ==
105
 
106
+ = 1.7.3 =
107
+ * improvement: remove cache + options on uninstall as [requested by Gingerbreadmen](http://wordpress.org/support/topic/wp_options-entries)
108
+ * improvement: set .htaccess to allow PHP execution in wp-content/cache/autoptimize when saving optimized files as PHP, as suggested by (David Mottershead of bermuda4u.com}[http://www.bermuda4u.com/] but forbid PHP execution when saving aggregated script/css as static files (except for multisite).
109
+ * bugfix: avoid Yoast SEO sitemaps going blank (due optimization of Yoast's dynamically built XML/XSL) as reported by [Vance Hallman](http://www.icefishing.co) and [Armand Hadife](http://solar-flag-pole-lights.com/). More info on this issue [can be found on my blog](http://blog.futtta.be/2013/12/09/blank-yoast-seo-sitemaps-no-more/).
110
+ * smaller changes to readme.txt
111
+
112
  = 1.7.2 =
113
  * improvement: extra checks in CSS @import-handling + move import rules to top of CSS if not imported successfully, based a.o. on bug reports [by ozum](http://wordpress.org/support/topic/zero-lenght-file-with-css-optimization) and by [Peter Stolwijk](http://wordpress.org/support/topic/cant-activate-plugin-22?replies=13#post-4891377)
114
  * improvement: check if JS and CSS minifier classes exist and only load if they don't to avoid possible conflicts with other themes or plugins that already loaded minifiers