Version Description
- New: support for mapped domains as suggested by Michael for tiremoni.com
- 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 by Hugh of www.unitedworldschools.org)
- bugfix: Autoptimize broke data:uri's in CSS in some cases as reported by Joseph from blog-it-solutions.de
- bugfix: avoid PHP notice if CSS exclusion list is empty
- moved "do not donate"-image into plugin
Download this release
Release Info
Developer | futtta |
Plugin | Autoptimize |
Version | 1.7.1 |
Comparing to | |
See all releases |
Code changes from version 1.7.0 to 1.7.1
- autoptimize.php +13 -5
- classes/autoptimizeBase.php +6 -6
- classes/autoptimizeCache.php +16 -0
- classes/autoptimizeConfig.php +1 -1
- classes/autoptimizeStyles.php +17 -11
- classes/external/do_not_donate_smallest.png +0 -0
- readme.txt +10 -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.
|
7 |
Author: Frank Goossens (futtta)
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Released under the GNU General Public License (GPL)
|
@@ -16,11 +16,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
16 |
include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
|
17 |
include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeCache.php');
|
18 |
|
19 |
-
// Plugin constants
|
20 |
define('AUTOPTIMIZE_CACHE_DIR',WP_CONTENT_DIR.'/cache/autoptimize/');
|
21 |
-
define('AUTOPTIMIZE_CACHE_URL',content_url().'/cache/autoptimize/');
|
22 |
define('AUTOPTIMIZE_CACHE_DELAY',true);
|
23 |
-
define('WP_ROOT_URL',str_replace('/wp-content','',content_url()));
|
24 |
define('WP_ROOT_DIR',str_replace('/wp-content','',WP_CONTENT_DIR));
|
25 |
|
26 |
// Initialize the cache at least once
|
@@ -29,7 +27,7 @@ $conf = autoptimizeConfig::instance();
|
|
29 |
/* Check if we're updating, in which case we need to flush the cache
|
30 |
to avoid old versions of aggregated files lingering around */
|
31 |
|
32 |
-
$autoptimize_version="1.7.
|
33 |
$autoptimize_db_version=get_option('autoptimize_version','none');
|
34 |
|
35 |
if ($autoptimize_db_version !== $autoptimize_version) {
|
@@ -127,6 +125,16 @@ function autoptimize_start_buffering()
|
|
127 |
//Action on end -
|
128 |
function autoptimize_end_buffering($content)
|
129 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
// Config element
|
131 |
$conf = autoptimizeConfig::instance();
|
132 |
|
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)
|
16 |
include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
|
17 |
include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeCache.php');
|
18 |
|
19 |
+
// Plugin dir constants (plugin url's defined later to accomodate domain mapped sites)
|
20 |
define('AUTOPTIMIZE_CACHE_DIR',WP_CONTENT_DIR.'/cache/autoptimize/');
|
|
|
21 |
define('AUTOPTIMIZE_CACHE_DELAY',true);
|
|
|
22 |
define('WP_ROOT_DIR',str_replace('/wp-content','',WP_CONTENT_DIR));
|
23 |
|
24 |
// Initialize the cache at least once
|
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) {
|
125 |
//Action on end -
|
126 |
function autoptimize_end_buffering($content)
|
127 |
{
|
128 |
+
// load URL constants as late as possible to allow domain mapper to kick in
|
129 |
+
if (function_exists(domain_mapping_siteurl)) {
|
130 |
+
define('AUTOPTIMIZE_WP_SITE_URL',domain_mapping_siteurl());
|
131 |
+
define('AUTOPTIMIZE_WP_CONTENT_URL',str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL),AUTOPTIMIZE_WP_SITE_URL,content_url()));
|
132 |
+
} else {
|
133 |
+
define('AUTOPTIMIZE_WP_SITE_URL',site_url());
|
134 |
+
define('AUTOPTIMIZE_WP_CONTENT_URL',content_url());
|
135 |
+
}
|
136 |
+
define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.'/cache/autoptimize/');
|
137 |
+
define('AUTOPTIMIZE_WP_ROOT_URL',str_replace('/wp-content','',AUTOPTIMIZE_WP_CONTENT_URL));
|
138 |
// Config element
|
139 |
$conf = autoptimizeConfig::instance();
|
140 |
|
classes/autoptimizeBase.php
CHANGED
@@ -26,11 +26,11 @@ abstract class autoptimizeBase
|
|
26 |
//Converts an URL to a full path
|
27 |
protected function getpath($url)
|
28 |
{
|
29 |
-
|
30 |
-
if ((strpos($url,'//')===false) && (strpos($url,parse_url(
|
31 |
-
$url =
|
32 |
}
|
33 |
-
$path = str_replace(
|
34 |
if(preg_match('#^((https?|ftp):)?//#i',$path))
|
35 |
{
|
36 |
/** External script/css (adsense, etc) */
|
@@ -80,11 +80,11 @@ abstract class autoptimizeBase
|
|
80 |
}
|
81 |
|
82 |
protected function url_replace_cdn($url) {
|
83 |
-
|
84 |
if (!empty($this->cdn_url)) {
|
85 |
// this check is too expensive, is done on admin-screen
|
86 |
// if (preg_match("/^(https?)?:\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*\/?$/",$this->cdn_url)) {
|
87 |
-
$url=str_replace(
|
88 |
// }
|
89 |
}
|
90 |
return $url;
|
26 |
//Converts an URL to a full path
|
27 |
protected function getpath($url)
|
28 |
{
|
29 |
+
|
30 |
+
if ((strpos($url,'//')===false) && (strpos($url,parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST))===false)) {
|
31 |
+
$url = AUTOPTIMIZE_WP_SITE_URL.$url;
|
32 |
}
|
33 |
+
$path = str_replace(AUTOPTIMIZE_WP_ROOT_URL,'',$url);
|
34 |
if(preg_match('#^((https?|ftp):)?//#i',$path))
|
35 |
{
|
36 |
/** External script/css (adsense, etc) */
|
80 |
}
|
81 |
|
82 |
protected function url_replace_cdn($url) {
|
83 |
+
|
84 |
if (!empty($this->cdn_url)) {
|
85 |
// this check is too expensive, is done on admin-screen
|
86 |
// if (preg_match("/^(https?)?:\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*\/?$/",$this->cdn_url)) {
|
87 |
+
$url=str_replace(AUTOPTIMIZE_WP_SITE_URL,rtrim($this->cdn_url,'/'),$url);
|
88 |
// }
|
89 |
}
|
90 |
return $url;
|
classes/autoptimizeCache.php
CHANGED
@@ -169,6 +169,22 @@ class autoptimizeCache
|
|
169 |
if(!is_file($indexFile)) {
|
170 |
@file_put_contents($indexFile,'<html><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/">Autoptimize</a></body></html>');
|
171 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
//All OK
|
174 |
return true;
|
169 |
if(!is_file($indexFile)) {
|
170 |
@file_put_contents($indexFile,'<html><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/">Autoptimize</a></body></html>');
|
171 |
}
|
172 |
+
|
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>
|
181 |
+
<IfModule mod_expires.c>
|
182 |
+
ExpiresActive On
|
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;
|
classes/autoptimizeConfig.php
CHANGED
@@ -193,7 +193,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
193 |
</h3>
|
194 |
<div id="futtta_feed"></div>
|
195 |
</div>
|
196 |
-
<div style="float:right;margin:50px 15px;"><
|
197 |
</div>
|
198 |
|
199 |
<script type="text/javascript">
|
193 |
</h3>
|
194 |
<div id="futtta_feed"></div>
|
195 |
</div>
|
196 |
+
<div style="float:right;margin:50px 15px;"><a href="http://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo content_url(); ?>/plugins/autoptimize/classes/external/do_not_donate_smallest.png" title="<?php _e("Do not donate for this plugin!"); ?>"></a></div>
|
197 |
</div>
|
198 |
|
199 |
<script type="text/javascript">
|
classes/autoptimizeStyles.php
CHANGED
@@ -275,10 +275,15 @@ class autoptimizeStyles extends autoptimizeBase
|
|
275 |
//Minify
|
276 |
if (class_exists('Minify_CSS_Compressor')) {
|
277 |
// legacy
|
278 |
-
$
|
279 |
} else if(class_exists('CSSmin')) {
|
280 |
$cssmin = new CSSmin();
|
281 |
-
$
|
|
|
|
|
|
|
|
|
|
|
282 |
}
|
283 |
|
284 |
$this->hashmap[md5($code)] = $hash;
|
@@ -384,14 +389,13 @@ class autoptimizeStyles extends autoptimizeBase
|
|
384 |
{
|
385 |
//Remove quotes
|
386 |
$url = trim($url," \t\n\r\0\x0B\"'");
|
387 |
-
if(substr($url,0,1)=='/' || preg_match('#^(https
|
388 |
{
|
389 |
//URL is absolute
|
390 |
continue;
|
391 |
}else{
|
392 |
-
//relative URL
|
393 |
-
|
394 |
-
$newurl = WP_ROOT_URL.str_replace('//','/',$dir.'/'.$url);
|
395 |
$hash = md5($url);
|
396 |
$code = str_replace($matches[0][$k],$hash,$code);
|
397 |
$replace[$hash] = 'url('.$newurl.')';
|
@@ -407,12 +411,14 @@ class autoptimizeStyles extends autoptimizeBase
|
|
407 |
|
408 |
private function ismovable($tag)
|
409 |
{
|
410 |
-
|
411 |
-
|
412 |
-
if(strpos($tag,$match)!==false)
|
413 |
{
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
416 |
}
|
417 |
}
|
418 |
|
275 |
//Minify
|
276 |
if (class_exists('Minify_CSS_Compressor')) {
|
277 |
// legacy
|
278 |
+
$tmp_code = trim(Minify_CSS_Compressor::process($code));
|
279 |
} else if(class_exists('CSSmin')) {
|
280 |
$cssmin = new CSSmin();
|
281 |
+
$tmp_code = trim($cssmin->run($code));
|
282 |
+
}
|
283 |
+
|
284 |
+
if (!empty($tmp_code)) {
|
285 |
+
$code=$tmp_code;
|
286 |
+
unset($tmp_code);
|
287 |
}
|
288 |
|
289 |
$this->hashmap[md5($code)] = $hash;
|
389 |
{
|
390 |
//Remove quotes
|
391 |
$url = trim($url," \t\n\r\0\x0B\"'");
|
392 |
+
if(substr($url,0,1)=='/' || preg_match('#^(https?://|ftp://|data:)#i',$url))
|
393 |
{
|
394 |
//URL is absolute
|
395 |
continue;
|
396 |
}else{
|
397 |
+
// relative URL
|
398 |
+
$newurl = AUTOPTIMIZE_WP_ROOT_URL.str_replace('//','/',$dir.'/'.$url);
|
|
|
399 |
$hash = md5($url);
|
400 |
$code = str_replace($matches[0][$k],$hash,$code);
|
401 |
$replace[$hash] = 'url('.$newurl.')';
|
411 |
|
412 |
private function ismovable($tag)
|
413 |
{
|
414 |
+
if (is_array($this->dontmove)) {
|
415 |
+
foreach($this->dontmove as $match)
|
|
|
416 |
{
|
417 |
+
if(strpos($tag,$match)!==false)
|
418 |
+
{
|
419 |
+
//Matched something
|
420 |
+
return false;
|
421 |
+
}
|
422 |
}
|
423 |
}
|
424 |
|
classes/external/do_not_donate_smallest.png
ADDED
Binary file
|
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.
|
8 |
|
9 |
Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
|
10 |
|
@@ -12,7 +12,7 @@ Autoptimize speeds up your website and helps you save bandwidth by aggregating a
|
|
12 |
|
13 |
Autoptimize makes optimizing your site really easy. It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head, and scripts to the footer. It also minifies the HTML code itself, making your page really lightweight. There are advanced options available to enable you to tailor Autoptimize to each and every site's specific need.
|
14 |
|
15 |
-
If you consider performance important,
|
16 |
[HyperCache](http://wordpress.org/extend/plugins/hyper-cache/) to complement Autoptimize.
|
17 |
|
18 |
== Installation ==
|
@@ -99,6 +99,13 @@ You can report problems on the [wordpress.org support forum](http://wordpress.or
|
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
= 1.7.0 =
|
103 |
* New: exclude CSS
|
104 |
* New: defer CSS
|
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 |
|
12 |
|
13 |
Autoptimize makes optimizing your site really easy. It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head, and scripts to the footer. It also minifies the HTML code itself, making your page really lightweight. There are advanced options available to enable you to tailor Autoptimize to each and every site's specific need.
|
14 |
|
15 |
+
If you consider performance important, you really should use a caching-plugin such as e.g. [WP Super Cache](http://wordpress.org/extend/plugins/wp-super-cache/) or
|
16 |
[HyperCache](http://wordpress.org/extend/plugins/hyper-cache/) to complement Autoptimize.
|
17 |
|
18 |
== Installation ==
|
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/))
|
105 |
+
* bugfix: Autoptimize broke data:uri's in CSS in some cases as reported by [Joseph from blog-it-solutions.de](http://www.blog-it-solutions.de/)
|
106 |
+
* bugfix: avoid PHP notice if CSS exclusion list is empty
|
107 |
+
* moved "do not donate"-image into plugin
|
108 |
+
|
109 |
= 1.7.0 =
|
110 |
* New: exclude CSS
|
111 |
* New: defer CSS
|