Version Description
- first bugfix release by futtta, thanks for a great plugin Turl!
- misc bug fixes, a.o. support for Twenty Twelve theme, admin bar problem in WP3.5, data-uri breaking CSS file naming
Download this release
Release Info
Developer | futtta |
Plugin | Autoptimize |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.5
- autoptimize.php +10 -5
- classes/autoptimizeConfig.php +1 -1
- classes/autoptimizeScripts.php +2 -1
- classes/autoptimizeStyles.php +23 -11
- readme.txt +9 -11
autoptimize.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Autoptimize
|
4 |
-
Plugin URI: http://
|
5 |
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
-
Version: 1.
|
7 |
-
Author:
|
8 |
-
Author URI: http://
|
9 |
Released under the GNU General Public License (GPL)
|
10 |
http://www.gnu.org/licenses/gpl.txt
|
11 |
*/
|
@@ -32,6 +32,9 @@ load_plugin_textdomain('autoptimize','wp-content/plugins/'.$plugin_dir.'/localiz
|
|
32 |
//Set up the buffering
|
33 |
function autoptimize_start_buffering()
|
34 |
{
|
|
|
|
|
|
|
35 |
//Config element
|
36 |
$conf = autoptimizeConfig::instance();
|
37 |
|
@@ -72,6 +75,8 @@ function autoptimize_start_buffering()
|
|
72 |
|
73 |
//Now, start the real thing!
|
74 |
ob_start('autoptimize_end_buffering');
|
|
|
|
|
75 |
}
|
76 |
|
77 |
//Action on end -
|
@@ -135,7 +140,7 @@ function autoptimize_end_buffering($content)
|
|
135 |
if(autoptimizeCache::cacheavail())
|
136 |
{
|
137 |
$conf = autoptimizeConfig::instance();
|
138 |
-
if($conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') || $conf->get('autoptimize_cdn_js') || $conf->get('autoptimize_cdn_css'))
|
139 |
{
|
140 |
//Hook to wordpress
|
141 |
add_action('template_redirect','autoptimize_start_buffering',2);
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Autoptimize
|
4 |
+
Plugin URI: http://blog.futtta.be/category/autoptimize/
|
5 |
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
+
Version: 1.5
|
7 |
+
Author: Frank Goossens (futtta)
|
8 |
+
Author URI: http://blog.futtta.be/
|
9 |
Released under the GNU General Public License (GPL)
|
10 |
http://www.gnu.org/licenses/gpl.txt
|
11 |
*/
|
32 |
//Set up the buffering
|
33 |
function autoptimize_start_buffering()
|
34 |
{
|
35 |
+
// fgo: not for logged in users, to prevent new admin bar issue in wp3.5
|
36 |
+
if (!is_user_logged_in()) {
|
37 |
+
|
38 |
//Config element
|
39 |
$conf = autoptimizeConfig::instance();
|
40 |
|
75 |
|
76 |
//Now, start the real thing!
|
77 |
ob_start('autoptimize_end_buffering');
|
78 |
+
|
79 |
+
}
|
80 |
}
|
81 |
|
82 |
//Action on end -
|
140 |
if(autoptimizeCache::cacheavail())
|
141 |
{
|
142 |
$conf = autoptimizeConfig::instance();
|
143 |
+
if( $conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') || $conf->get('autoptimize_cdn_js') || $conf->get('autoptimize_cdn_css'))
|
144 |
{
|
145 |
//Hook to wordpress
|
146 |
add_action('template_redirect','autoptimize_start_buffering',2);
|
classes/autoptimizeConfig.php
CHANGED
@@ -62,7 +62,7 @@ Like Autoptimize?
|
|
62 |
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
63 |
<img alt="" border="0" src="https://www.paypal.com/es_XC/i/scr/pixel.gif" width="1" height="1">
|
64 |
</form>
|
65 |
-
Buy
|
66 |
</div>
|
67 |
|
68 |
<form method="post" action="options.php">
|
62 |
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
63 |
<img alt="" border="0" src="https://www.paypal.com/es_XC/i/scr/pixel.gif" width="1" height="1">
|
64 |
</form>
|
65 |
+
Buy the original <br /> author a coffee :-)
|
66 |
</div>
|
67 |
|
68 |
<form method="post" action="options.php">
|
classes/autoptimizeScripts.php
CHANGED
@@ -3,7 +3,8 @@
|
|
3 |
class autoptimizeScripts extends autoptimizeBase
|
4 |
{
|
5 |
private $scripts = array();
|
6 |
-
|
|
|
7 |
private $domove = array('gaJsHost','load_cmc','jd.gallery.transitions.js','swfobject.embedSWF(','tiny_mce.js','tinyMCEPreInit.go');
|
8 |
private $domovelast = array('addthis.com','/afsonline/show_afs_search.js','disqus.js','networkedblogs.com/getnetworkwidget','infolinks.com/js/','jd.gallery.js.php','jd.gallery.transitions.js','swfobject.embedSWF(','linkwithin.com/widget.js','tiny_mce.js','tinyMCEPreInit.go');
|
9 |
private $trycatch = false;
|
3 |
class autoptimizeScripts extends autoptimizeBase
|
4 |
{
|
5 |
private $scripts = array();
|
6 |
+
// fgo: add html5.js to avoid aggregating html5 support for older IE browsers
|
7 |
+
private $dontmove = array('document.write','html5.js','show_ads.js','google_ad','blogcatalog.com/w','tweetmeme.com/i','mybloglog.com/','var s_sid = ','histats.com/js','smowtion_size','ads.smowtion.com/ad.js','sc_project','statcounter.com/counter/counter.js','widgets.amung.us','WAU_','wau_add','ws.amazon.com/widgets','media.fastclick.net','/ads/','comment-form-quicktags/quicktags.php','edToolbar','intensedebate.com','ch_client','scripts.chitika.net/','_gaq.push','jotform.com/');
|
8 |
private $domove = array('gaJsHost','load_cmc','jd.gallery.transitions.js','swfobject.embedSWF(','tiny_mce.js','tinyMCEPreInit.go');
|
9 |
private $domovelast = array('addthis.com','/afsonline/show_afs_search.js','disqus.js','networkedblogs.com/getnetworkwidget','infolinks.com/js/','jd.gallery.js.php','jd.gallery.transitions.js','swfobject.embedSWF(','linkwithin.com/widget.js','tiny_mce.js','tinyMCEPreInit.go');
|
10 |
private $trycatch = false;
|
classes/autoptimizeStyles.php
CHANGED
@@ -28,8 +28,7 @@ class autoptimizeStyles extends autoptimizeBase
|
|
28 |
$this->yui = $options['yui'];
|
29 |
|
30 |
//Save IE hacks
|
31 |
-
$this->content = preg_replace('#(<\!--\[if.*\]>.*<\!\[endif\]-->)#Usie',
|
32 |
-
'\'%%IEHACK%%\'.base64_encode("$1").\'%%IEHACK%%\'',$this->content);
|
33 |
|
34 |
//Get <style> and <link>
|
35 |
if(preg_match_all('#(<style[^>]*>.*</style>)|(<link[^>]*text/css[^>]*>)#Usmi',$this->content,$matches))
|
@@ -202,14 +201,22 @@ class autoptimizeStyles extends autoptimizeBase
|
|
202 |
foreach($matches[2] as $count => $quotedurl)
|
203 |
{
|
204 |
$url = trim($quotedurl," \t\n\r\0\x0B\"'");
|
|
|
|
|
205 |
$path = $this->getpath($url);
|
206 |
-
|
|
|
|
|
207 |
{
|
208 |
//It's an image
|
209 |
//Get type
|
210 |
-
|
|
|
211 |
{
|
212 |
-
|
|
|
|
|
|
|
213 |
case 'jpg':
|
214 |
$dataurihead = 'data:image/jpeg;base64,';
|
215 |
break;
|
@@ -275,13 +282,16 @@ class autoptimizeStyles extends autoptimizeBase
|
|
275 |
//CSS cache
|
276 |
foreach($this->csscode as $media => $code)
|
277 |
{
|
|
|
|
|
|
|
278 |
if($this->datauris)
|
279 |
{
|
280 |
//Images for ie! Get the right url
|
281 |
$code = str_replace('%%MHTML%%',$mhtml,$code);
|
282 |
}
|
283 |
|
284 |
-
$md5 = $this->hashmap[md5($code)];
|
285 |
$cache = new autoptimizeCache($md5,'css');
|
286 |
if(!$cache->check())
|
287 |
{
|
@@ -296,21 +306,23 @@ class autoptimizeStyles extends autoptimizeBase
|
|
296 |
public function getcontent()
|
297 |
{
|
298 |
//Restore IE hacks
|
299 |
-
|
300 |
-
|
|
|
301 |
//Restore the full content
|
302 |
if(!empty($this->restofcontent))
|
303 |
{
|
304 |
$this->content .= $this->restofcontent;
|
305 |
-
$this->
|
306 |
}
|
307 |
|
308 |
//Add the new stylesheets
|
309 |
foreach($this->url as $media => $url)
|
310 |
{
|
311 |
-
|
|
|
312 |
}
|
313 |
-
|
314 |
//Return the modified stylesheet
|
315 |
return $this->content;
|
316 |
}
|
28 |
$this->yui = $options['yui'];
|
29 |
|
30 |
//Save IE hacks
|
31 |
+
$this->content = preg_replace('#(<\!--\[if.*\]>.*<\!\[endif\]-->)#Usie','\'%%IEHACK%%\'.base64_encode("$1").\'%%IEHACK%%\'',$this->content);
|
|
|
32 |
|
33 |
//Get <style> and <link>
|
34 |
if(preg_match_all('#(<style[^>]*>.*</style>)|(<link[^>]*text/css[^>]*>)#Usmi',$this->content,$matches))
|
201 |
foreach($matches[2] as $count => $quotedurl)
|
202 |
{
|
203 |
$url = trim($quotedurl," \t\n\r\0\x0B\"'");
|
204 |
+
// fgo: if querystring, remove it from url
|
205 |
+
if (strpos($url,'?') !== false) { $url = reset(explode('?',$url)); }
|
206 |
$path = $this->getpath($url);
|
207 |
+
|
208 |
+
// fgo: jpe?j should be jpe?g I guess + 5KB seems like a lot, lower to 2.5KB
|
209 |
+
if($path != false && preg_match('#\.(jpe?g|png|gif|bmp)$#',$path) && file_exists($path) && is_readable($path) && filesize($path) <= 2560)
|
210 |
{
|
211 |
//It's an image
|
212 |
//Get type
|
213 |
+
$type=end(explode('.',$path));
|
214 |
+
switch($type)
|
215 |
{
|
216 |
+
// fgo: jpeg and jpg
|
217 |
+
case 'jpeg':
|
218 |
+
$dataurihead = 'data:image/jpeg;base64,';
|
219 |
+
break;
|
220 |
case 'jpg':
|
221 |
$dataurihead = 'data:image/jpeg;base64,';
|
222 |
break;
|
282 |
//CSS cache
|
283 |
foreach($this->csscode as $media => $code)
|
284 |
{
|
285 |
+
// fgo, moved from below to prevent empty md5 resulting in filenames without hash autoptimize_.php
|
286 |
+
$md5 = $this->hashmap[md5($code)];
|
287 |
+
|
288 |
if($this->datauris)
|
289 |
{
|
290 |
//Images for ie! Get the right url
|
291 |
$code = str_replace('%%MHTML%%',$mhtml,$code);
|
292 |
}
|
293 |
|
294 |
+
// $md5 = $this->hashmap[md5($code)];
|
295 |
$cache = new autoptimizeCache($md5,'css');
|
296 |
if(!$cache->check())
|
297 |
{
|
306 |
public function getcontent()
|
307 |
{
|
308 |
//Restore IE hacks
|
309 |
+
// fgo: added stripslashes as e modifier escapes stuff
|
310 |
+
$this->content = preg_replace('#%%IEHACK%%(.*)%%IEHACK%%#Usie','stripslashes(base64_decode("$1"))',$this->content);
|
311 |
+
|
312 |
//Restore the full content
|
313 |
if(!empty($this->restofcontent))
|
314 |
{
|
315 |
$this->content .= $this->restofcontent;
|
316 |
+
$this-> nt = '';
|
317 |
}
|
318 |
|
319 |
//Add the new stylesheets
|
320 |
foreach($this->url as $media => $url)
|
321 |
{
|
322 |
+
// fgo: these were added before </head> but that overrides iehack-stylesheets, so adding after </title> for now
|
323 |
+
$this->content = str_replace('</title>','</title><link type="text/css" media="'.$media.'" href="'.$url.'" rel="stylesheet" />',$this->content);
|
324 |
}
|
325 |
+
|
326 |
//Return the modified stylesheet
|
327 |
return $this->content;
|
328 |
}
|
readme.txt
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
=== Autoptimize ===
|
2 |
-
Contributors: turl
|
3 |
-
|
4 |
-
Tags: css, html, javascript, js, optimize, speed, cache
|
5 |
Requires at least: 2.7
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
|
10 |
|
@@ -14,8 +13,6 @@ Autoptimize makes optimizing your site really easy. It concatenates all scripts
|
|
14 |
|
15 |
I also recommend using WP Super Cache in conjuction with Autoptimize to speed up your blog.
|
16 |
|
17 |
-
You can [report bugs](https://bugs.launchpad.net/autoptimize), [ask questions](https://answers.launchpad.net/autoptimize) and [help with translations](https://translations.launchpad.net/autoptimize) in our [Launchpad page](https://launchpad.net/autoptimize).
|
18 |
-
|
19 |
== Installation ==
|
20 |
|
21 |
1. Upload the `autoptimize` folder to to the `/wp-content/plugins/` directory
|
@@ -30,14 +27,15 @@ It concatenates all scripts and styles, minifies and compresses them, adds expir
|
|
30 |
|
31 |
= Where can I report an error? =
|
32 |
|
33 |
-
You can
|
34 |
-
|
35 |
-
= Can I help translating the plugin? =
|
36 |
|
37 |
-
Sure, you can help with translations in the [Launchpad translation page](https://translations.launchpad.net/autoptimize)
|
38 |
|
39 |
== Changelog ==
|
40 |
|
|
|
|
|
|
|
|
|
41 |
= 1.4 =
|
42 |
* Add support for inline style tags with CSS media
|
43 |
* Fix Wordpress top bar
|
1 |
=== Autoptimize ===
|
2 |
+
Contributors: turl, futtta
|
3 |
+
Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, minimize
|
|
|
4 |
Requires at least: 2.7
|
5 |
+
Tested up to: 3.5
|
6 |
+
Stable tag: 1.5
|
7 |
|
8 |
Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
|
9 |
|
13 |
|
14 |
I also recommend using WP Super Cache in conjuction with Autoptimize to speed up your blog.
|
15 |
|
|
|
|
|
16 |
== Installation ==
|
17 |
|
18 |
1. Upload the `autoptimize` folder to to the `/wp-content/plugins/` directory
|
27 |
|
28 |
= Where can I report an error? =
|
29 |
|
30 |
+
You can report problems on the [wordpress.org support forum](http://wordpress.org/support/plugin/autoptimize), or [contact the author using this contact form](http://blog.futtta.be/contact/).
|
|
|
|
|
31 |
|
|
|
32 |
|
33 |
== Changelog ==
|
34 |
|
35 |
+
= 1.5 =
|
36 |
+
* first bugfix release by [futtta](http://blog.futtta.be/2013/01/07/adopting-an-oss-orphan-autoptimize/), thanks for a great plugin Turl!
|
37 |
+
* misc bug fixes, a.o. support for Twenty Twelve theme, admin bar problem in WP3.5, data-uri breaking CSS file naming
|
38 |
+
|
39 |
= 1.4 =
|
40 |
* Add support for inline style tags with CSS media
|
41 |
* Fix Wordpress top bar
|