Autoptimize - Version 1.7.2

Version Description

  • 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 and by Peter Stolwijk
  • 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
  • tested and approved for WordPress 3.8 (beta1)
Download this release

Release Info

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

Code changes from version 1.7.1 to 1.7.2

Files changed (3) hide show
  1. autoptimize.php +14 -8
  2. classes/autoptimizeStyles.php +14 -9
  3. readme.txt +7 -2
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.1
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.1";
31
  $autoptimize_db_version=get_option('autoptimize_version','none');
32
 
33
  if ($autoptimize_db_version !== $autoptimize_version) {
@@ -97,10 +97,12 @@ function autoptimize_start_buffering()
97
  if($conf->get('autoptimize_js'))
98
  {
99
  include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeScripts.php');
100
- if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) {
101
- @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/jsmin-1.1.1.php');
102
- } else {
103
- @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/minify-2.1.7-jsmin.php');
 
 
104
  }
105
  define('CONCATENATE_SCRIPTS',false);
106
  define('COMPRESS_SCRIPTS',false);
@@ -110,9 +112,13 @@ function autoptimize_start_buffering()
110
  {
111
  include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeStyles.php');
112
  if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) {
113
- @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/minify-css-compressor.php');
 
 
114
  } else {
115
- @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-1.php');
 
 
116
  }
117
  define('COMPRESS_CSS',false);
118
  }
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
  /* 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) {
97
  if($conf->get('autoptimize_js'))
98
  {
99
  include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeScripts.php');
100
+ if (!class_exists('JSMin')) {
101
+ if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) {
102
+ @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/jsmin-1.1.1.php');
103
+ } else {
104
+ @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/minify-2.1.7-jsmin.php');
105
+ }
106
  }
107
  define('CONCATENATE_SCRIPTS',false);
108
  define('COMPRESS_SCRIPTS',false);
112
  {
113
  include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeStyles.php');
114
  if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) {
115
+ if (!class_exists('Minify_CSS_Compressor')) {
116
+ @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/minify-css-compressor.php');
117
+ }
118
  } else {
119
+ if (!class_exists('CSSmin')) {
120
+ @include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-1.php');
121
+ }
122
  }
123
  define('COMPRESS_CSS',false);
124
  }
classes/autoptimizeStyles.php CHANGED
@@ -165,15 +165,20 @@ class autoptimizeStyles extends autoptimizeBase
165
  {
166
  $url = trim(preg_replace('#^.*((?:https?|ftp)://.*\.css).*$#','$1',$import)," \t\n\r\0\x0B\"'");
167
  $path = $this->getpath($url);
168
- if(file_exists($path) && is_readable($path))
169
- {
170
  $code = addcslashes($this->fixurls($path,file_get_contents($path)),"\\");
171
  $code = preg_replace('/\x{EF}\x{BB}\x{BF}/','',$code);
172
- $thiscss = preg_replace('#(/\*FILESTART\*/.*)'.preg_quote($import,'#').'#Us','/*FILESTART2*/'.$code.'$1',$thiscss);
173
- }else{
174
- //getpath is not working?
175
- //Encode so preg_match doesn't see it
176
- $thiscss = str_replace($import,'/*IMPORT*/'.base64_encode($import).'/*IMPORT*/',$thiscss);
 
 
 
 
 
177
  $fiximports = true;
178
  }
179
  }
@@ -181,10 +186,10 @@ class autoptimizeStyles extends autoptimizeBase
181
  $thiscss = preg_replace('#/\*FILESTART2\*/#','/*FILESTART*/',$thiscss);
182
  }
183
 
184
- //Recover imports
185
  if($fiximports)
186
  {
187
- $thiscss = preg_replace('#/\*IMPORT\*/(.*)/\*IMPORT\*/#Use','base64_decode("$1")',$thiscss);
188
  }
189
  }
190
  unset($thiscss);
165
  {
166
  $url = trim(preg_replace('#^.*((?:https?|ftp)://.*\.css).*$#','$1',$import)," \t\n\r\0\x0B\"'");
167
  $path = $this->getpath($url);
168
+ $import_ok=false;
169
+ if (file_exists($path) && is_readable($path)) {
170
  $code = addcslashes($this->fixurls($path,file_get_contents($path)),"\\");
171
  $code = preg_replace('/\x{EF}\x{BB}\x{BF}/','',$code);
172
+ if(!empty($code)) {
173
+ $thiscss = preg_replace('#(/\*FILESTART\*/.*)'.preg_quote($import,'#').'#Us','/*FILESTART2*/'.$code.'$1',$thiscss);
174
+ $import_ok=true;
175
+ }
176
+ }
177
+
178
+ if (!$import_ok) {
179
+ // external imports and general fall-back
180
+ $external_imports .= $import;
181
+ $thiscss = str_replace($import,'',$thiscss);
182
  $fiximports = true;
183
  }
184
  }
186
  $thiscss = preg_replace('#/\*FILESTART2\*/#','/*FILESTART*/',$thiscss);
187
  }
188
 
189
+ // add external imports to top of aggregated CSS
190
  if($fiximports)
191
  {
192
+ $thiscss=$external_imports.$thiscss;
193
  }
194
  }
195
  unset($thiscss);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: futtta, turl
3
  Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, minimize, minification, performance, pagespeed, booster, multisite
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.7
7
- Stable tag: 1.7.1
8
 
9
  Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
10
 
@@ -99,6 +99,11 @@ You can report problems on the [wordpress.org support forum](http://wordpress.or
99
 
100
  == Changelog ==
101
 
 
 
 
 
 
102
  = 1.7.1 =
103
  * New: support for mapped domains as suggested by [Michael for tiremoni.com](http://tiremoni.com/)
104
  * Added an .htaccess to wp-content/cache/autoptimize to overwrite other caching directives (fixing a problem with WP Super Cache's .htaccess really, [as reported](http://wordpress.org/support/topic/expiresmax-age-compatibility-with-supercache) by [Hugh of www.unitedworldschools.org](http://www.unitedworldschools.org/))
3
  Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, minimize, minification, performance, pagespeed, booster, multisite
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
 
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
105
+ * tested and approved for WordPress 3.8 (beta1)
106
+
107
  = 1.7.1 =
108
  * New: support for mapped domains as suggested by [Michael for tiremoni.com](http://tiremoni.com/)
109
  * Added an .htaccess to wp-content/cache/autoptimize to overwrite other caching directives (fixing a problem with WP Super Cache's .htaccess really, [as reported](http://wordpress.org/support/topic/expiresmax-age-compatibility-with-supercache) by [Hugh of www.unitedworldschools.org](http://www.unitedworldschools.org/))