Version Description
- Support localization
- Fix the move and don't move system (again)
- Improve url detection in CSS
- Support looking for scripts and styles on just the header
- Fix an issue with data: uris getting modified
- Spanish translation
Download this release
Release Info
Developer | turl |
Plugin | Autoptimize |
Version | 0.5 |
Comparing to | |
See all releases |
Code changes from version 0.4 to 0.5
- autoptimize.php +21 -3
- classes/autoptimizeBase.php +1 -1
- classes/autoptimizeConfig.php +39 -14
- classes/autoptimizeHTML.php +1 -2
- classes/autoptimizeScripts.php +62 -8
- classes/autoptimizeStyles.php +37 -6
- classes/minify-html.php +12 -1
- localization/autoptimize-es_ES.mo +0 -0
- localization/autoptimize-es_ES.po +85 -0
- localization/autoptimize.pot +81 -0
- readme.txt +22 -4
autoptimize.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Autoptimize
|
4 |
-
Plugin URI: http://www.turleando.com.ar/
|
5 |
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
-
Version: 0.
|
7 |
Author: Emilio López
|
8 |
Author URI: http://www.turleando.com.ar/
|
9 |
Released under the GNU General Public License (GPL)
|
@@ -19,6 +19,10 @@ if(!defined('WP_PLUGIN_DIR'))
|
|
19 |
//Load config class
|
20 |
@include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
|
21 |
|
|
|
|
|
|
|
|
|
22 |
//Set up the buffering
|
23 |
function autoptimize_start_buffering()
|
24 |
{
|
@@ -69,12 +73,26 @@ function autoptimize_end_buffering($content)
|
|
69 |
$classes[] = 'autoptimizeStyles';
|
70 |
if($conf->get('autoptimize_html'))
|
71 |
$classes[] = 'autoptimizeHTML';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
//Run the classes
|
74 |
foreach($classes as $name)
|
75 |
{
|
76 |
$instance = new $name($content);
|
77 |
-
if($instance->read())
|
78 |
{
|
79 |
$instance->minify();
|
80 |
$instance->cache();
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Autoptimize
|
4 |
+
Plugin URI: http://www.turleando.com.ar/autoptimize/
|
5 |
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
+
Version: 0.5
|
7 |
Author: Emilio López
|
8 |
Author URI: http://www.turleando.com.ar/
|
9 |
Released under the GNU General Public License (GPL)
|
19 |
//Load config class
|
20 |
@include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
|
21 |
|
22 |
+
//Load translations
|
23 |
+
$plugin_dir = basename(dirname(__FILE__));
|
24 |
+
load_plugin_textdomain('autoptimize','wp-content/plugins/'.$plugin_dir.'/localization',$plugin_dir.'/localization');
|
25 |
+
|
26 |
//Set up the buffering
|
27 |
function autoptimize_start_buffering()
|
28 |
{
|
73 |
$classes[] = 'autoptimizeStyles';
|
74 |
if($conf->get('autoptimize_html'))
|
75 |
$classes[] = 'autoptimizeHTML';
|
76 |
+
|
77 |
+
//Set some options
|
78 |
+
$classoptions = array(
|
79 |
+
'autoptimizeScripts' => array(
|
80 |
+
'justhead' => $conf->get('autoptimize_js_justhead')
|
81 |
+
),
|
82 |
+
'autoptimizeStyles' => array(
|
83 |
+
'justhead' => $conf->get('autoptimize_css_justhead')
|
84 |
+
),
|
85 |
+
'autoptimizeHTML' => array(
|
86 |
+
'justhead' => 0
|
87 |
+
)
|
88 |
+
);
|
89 |
+
|
90 |
|
91 |
//Run the classes
|
92 |
foreach($classes as $name)
|
93 |
{
|
94 |
$instance = new $name($content);
|
95 |
+
if($instance->read($classoptions[$name]['justhead']))
|
96 |
{
|
97 |
$instance->minify();
|
98 |
$instance->cache();
|
classes/autoptimizeBase.php
CHANGED
@@ -11,7 +11,7 @@ abstract class autoptimizeBase
|
|
11 |
}
|
12 |
|
13 |
//Reads the page and collects tags
|
14 |
-
abstract public function read();
|
15 |
|
16 |
//Joins and optimizes collected things
|
17 |
abstract public function minify();
|
11 |
}
|
12 |
|
13 |
//Reads the page and collects tags
|
14 |
+
abstract public function read($justhead);
|
15 |
|
16 |
//Joins and optimizes collected things
|
17 |
abstract public function minify();
|
classes/autoptimizeConfig.php
CHANGED
@@ -41,26 +41,44 @@ class autoptimizeConfig
|
|
41 |
{
|
42 |
?>
|
43 |
<div class="wrap">
|
44 |
-
<h2
|
45 |
|
46 |
<form method="post" action="options.php">
|
47 |
<?php settings_fields('autoptimize'); ?>
|
48 |
-
<table class="form-table">
|
49 |
|
|
|
|
|
50 |
<tr valign="top">
|
51 |
-
<th scope="row"
|
52 |
<td><input type="checkbox" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
|
53 |
</tr>
|
54 |
-
|
|
|
|
|
|
|
55 |
<tr valign="top">
|
56 |
-
<th scope="row"
|
57 |
<td><input type="checkbox" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
|
58 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
|
|
|
|
60 |
<tr valign="top">
|
61 |
-
<th scope="row"
|
62 |
<td><input type="checkbox" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
|
63 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
</table>
|
66 |
|
@@ -75,14 +93,16 @@ class autoptimizeConfig
|
|
75 |
|
76 |
public function addmenu()
|
77 |
{
|
78 |
-
add_options_page('Autoptimize Options','Autoptimize',8,'autoptimize',array($this,'show'));
|
79 |
}
|
80 |
|
81 |
public function registersettings()
|
82 |
{
|
83 |
register_setting('autoptimize','autoptimize_html');
|
84 |
register_setting('autoptimize','autoptimize_js');
|
|
|
85 |
register_setting('autoptimize','autoptimize_css');
|
|
|
86 |
}
|
87 |
|
88 |
public function setmeta($links,$file=null)
|
@@ -119,15 +139,20 @@ class autoptimizeConfig
|
|
119 |
//Default config
|
120 |
$config = array('autoptimize_html' => 0,
|
121 |
'autoptimize_js' => 0,
|
122 |
-
'
|
|
|
|
|
123 |
|
124 |
//Override with user settings
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
131 |
|
132 |
//Save for next question
|
133 |
$this->config = $config;
|
41 |
{
|
42 |
?>
|
43 |
<div class="wrap">
|
44 |
+
<h2><?php _e('Autoptimize Settings','autoptimize'); ?></h2>
|
45 |
|
46 |
<form method="post" action="options.php">
|
47 |
<?php settings_fields('autoptimize'); ?>
|
|
|
48 |
|
49 |
+
<h3><?php _e('HTML Options','autoptimize'); ?></h3>
|
50 |
+
<table class="form-table">
|
51 |
<tr valign="top">
|
52 |
+
<th scope="row"><?php _e('Optimize HTML Code?','autoptimize'); ?></th>
|
53 |
<td><input type="checkbox" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
|
54 |
</tr>
|
55 |
+
</table>
|
56 |
+
|
57 |
+
<h3><?php _e('JavaScript Options','autoptimize'); ?></h3>
|
58 |
+
<table class="form-table">
|
59 |
<tr valign="top">
|
60 |
+
<th scope="row"><?php _e('Optimize JavaScript Code?','autoptimize'); ?></th>
|
61 |
<td><input type="checkbox" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
|
62 |
</tr>
|
63 |
+
<tr valign="top">
|
64 |
+
<th scope="row"><?php _e('Look for scripts only in <head>?','autoptimize'); ?></th>
|
65 |
+
<td><label for="autoptimize_js_justhead"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
|
66 |
+
<?php _e('Disabled by default. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
|
67 |
+
</tr>
|
68 |
+
</table>
|
69 |
|
70 |
+
<h3><?php _e('CSS Options','autoptimize'); ?></h3>
|
71 |
+
<table class="form-table">
|
72 |
<tr valign="top">
|
73 |
+
<th scope="row"><?php _e('Optimize CSS Code?','autoptimize'); ?></th>
|
74 |
<td><input type="checkbox" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
|
75 |
</tr>
|
76 |
+
<tr valign="top">
|
77 |
+
<th scope="row"><?php _e('Look for styles on just <head>?','autoptimize'); ?></th>
|
78 |
+
<td><label for="autoptimize_css_justhead"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
|
79 |
+
<?php _e('Disabled by default. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
|
80 |
+
</tr>
|
81 |
+
</table>
|
82 |
|
83 |
</table>
|
84 |
|
93 |
|
94 |
public function addmenu()
|
95 |
{
|
96 |
+
add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize',8,'autoptimize',array($this,'show'));
|
97 |
}
|
98 |
|
99 |
public function registersettings()
|
100 |
{
|
101 |
register_setting('autoptimize','autoptimize_html');
|
102 |
register_setting('autoptimize','autoptimize_js');
|
103 |
+
register_setting('autoptimize','autoptimize_js_justhead');
|
104 |
register_setting('autoptimize','autoptimize_css');
|
105 |
+
register_setting('autoptimize','autoptimize_css_justhead');
|
106 |
}
|
107 |
|
108 |
public function setmeta($links,$file=null)
|
139 |
//Default config
|
140 |
$config = array('autoptimize_html' => 0,
|
141 |
'autoptimize_js' => 0,
|
142 |
+
'autoptimize_js_justhead' => 0,
|
143 |
+
'autoptimize_css' => 0,
|
144 |
+
'autoptimize_css_justhead' => 0);
|
145 |
|
146 |
//Override with user settings
|
147 |
+
foreach(array_keys($config) as $name)
|
148 |
+
{
|
149 |
+
$conf = get_option($name);
|
150 |
+
if($conf!==false)
|
151 |
+
{
|
152 |
+
//It was set before!
|
153 |
+
$config[$name] = $conf;
|
154 |
+
}
|
155 |
+
}
|
156 |
|
157 |
//Save for next question
|
158 |
$this->config = $config;
|
classes/autoptimizeHTML.php
CHANGED
@@ -2,10 +2,9 @@
|
|
2 |
|
3 |
class autoptimizeHTML extends autoptimizeBase
|
4 |
{
|
5 |
-
private $url = '';
|
6 |
|
7 |
//Does nothing
|
8 |
-
public function read()
|
9 |
{
|
10 |
//Nothing to read for HTML
|
11 |
return true;
|
2 |
|
3 |
class autoptimizeHTML extends autoptimizeBase
|
4 |
{
|
|
|
5 |
|
6 |
//Does nothing
|
7 |
+
public function read($justhead)
|
8 |
{
|
9 |
//Nothing to read for HTML
|
10 |
return true;
|
classes/autoptimizeScripts.php
CHANGED
@@ -3,15 +3,25 @@
|
|
3 |
class autoptimizeScripts extends autoptimizeBase
|
4 |
{
|
5 |
private $scripts = array();
|
6 |
-
private $dontmove = array('document.write','
|
7 |
private $domove = array('gaJsHost');
|
|
|
8 |
private $jscode = '';
|
9 |
private $url = '';
|
10 |
-
private $move = array();
|
|
|
11 |
|
12 |
//Reads the page and collects script tags
|
13 |
-
public function read()
|
14 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
//Get script files
|
16 |
if(preg_match_all('#<script.*</script>#Usmi',$this->content,$matches))
|
17 |
{
|
@@ -31,7 +41,12 @@ class autoptimizeScripts extends autoptimizeBase
|
|
31 |
//OR Script is dynamic (.php etc)
|
32 |
if($this->ismovable($tag))
|
33 |
{
|
34 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
35 |
}else{
|
36 |
//We shouldn't touch this
|
37 |
$tag = '';
|
@@ -116,8 +131,20 @@ class autoptimizeScripts extends autoptimizeBase
|
|
116 |
//Returns the content
|
117 |
public function getcontent()
|
118 |
{
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
$this->content = str_replace('</body>',$bodyreplacement,$this->content);
|
|
|
|
|
121 |
return $this->content;
|
122 |
}
|
123 |
|
@@ -133,6 +160,15 @@ class autoptimizeScripts extends autoptimizeBase
|
|
133 |
}
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
//If we're here it's safe to merge
|
137 |
return true;
|
138 |
}
|
@@ -140,11 +176,14 @@ class autoptimizeScripts extends autoptimizeBase
|
|
140 |
//Checks agains the blacklist
|
141 |
private function ismovable($tag)
|
142 |
{
|
143 |
-
$allowed = !$this->ismergeable($tag);
|
144 |
|
145 |
-
|
146 |
{
|
147 |
-
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
foreach($this->dontmove as $match)
|
@@ -159,4 +198,19 @@ class autoptimizeScripts extends autoptimizeBase
|
|
159 |
//If we're here it's safe to move
|
160 |
return true;
|
161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
}
|
3 |
class autoptimizeScripts extends autoptimizeBase
|
4 |
{
|
5 |
private $scripts = array();
|
6 |
+
private $dontmove = array('document.write','show_ads.js','google_ad');
|
7 |
private $domove = array('gaJsHost');
|
8 |
+
private $domovelast = array('addthis.com');
|
9 |
private $jscode = '';
|
10 |
private $url = '';
|
11 |
+
private $move = array('first' => array(), 'last' => array());
|
12 |
+
private $restofcontent = '';
|
13 |
|
14 |
//Reads the page and collects script tags
|
15 |
+
public function read($justhead)
|
16 |
{
|
17 |
+
//Remove everything that's not the header
|
18 |
+
if($justhead == true)
|
19 |
+
{
|
20 |
+
$content = explode('</head>',$this->content,2);
|
21 |
+
$this->content = $content[0].'</head>';
|
22 |
+
$this->restofcontent = $content[1];
|
23 |
+
}
|
24 |
+
|
25 |
//Get script files
|
26 |
if(preg_match_all('#<script.*</script>#Usmi',$this->content,$matches))
|
27 |
{
|
41 |
//OR Script is dynamic (.php etc)
|
42 |
if($this->ismovable($tag))
|
43 |
{
|
44 |
+
if($this->movetolast($tag))
|
45 |
+
{
|
46 |
+
$this->move['last'][] = $tag;
|
47 |
+
}else{
|
48 |
+
$this->move['first'][] = $tag;
|
49 |
+
}
|
50 |
}else{
|
51 |
//We shouldn't touch this
|
52 |
$tag = '';
|
131 |
//Returns the content
|
132 |
public function getcontent()
|
133 |
{
|
134 |
+
//Restore the full content
|
135 |
+
if(!empty($this->restofcontent))
|
136 |
+
{
|
137 |
+
$this->content .= $this->restofcontent;
|
138 |
+
$this->restofcontent = '';
|
139 |
+
}
|
140 |
+
|
141 |
+
//Add the scripts
|
142 |
+
$bodyreplacement = implode('',$this->move['first']);
|
143 |
+
$bodyreplacement .= '<script type="text/javascript" src="'.$this->url.'"></script>';
|
144 |
+
$bodyreplacement .= implode('',$this->move['last']).'</body>';
|
145 |
$this->content = str_replace('</body>',$bodyreplacement,$this->content);
|
146 |
+
|
147 |
+
//Return the modified HTML
|
148 |
return $this->content;
|
149 |
}
|
150 |
|
160 |
}
|
161 |
}
|
162 |
|
163 |
+
foreach($this->dontmove as $match)
|
164 |
+
{
|
165 |
+
if(strpos($tag,$match)!==false)
|
166 |
+
{
|
167 |
+
//Matched something
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
//If we're here it's safe to merge
|
173 |
return true;
|
174 |
}
|
176 |
//Checks agains the blacklist
|
177 |
private function ismovable($tag)
|
178 |
{
|
|
|
179 |
|
180 |
+
foreach($this->domove as $match)
|
181 |
{
|
182 |
+
if(strpos($tag,$match)!==false)
|
183 |
+
{
|
184 |
+
//Matched something
|
185 |
+
return true;
|
186 |
+
}
|
187 |
}
|
188 |
|
189 |
foreach($this->dontmove as $match)
|
198 |
//If we're here it's safe to move
|
199 |
return true;
|
200 |
}
|
201 |
+
|
202 |
+
private function movetolast($tag)
|
203 |
+
{
|
204 |
+
foreach($this->domovelast as $match)
|
205 |
+
{
|
206 |
+
if(strpos($tag,$match)!==false)
|
207 |
+
{
|
208 |
+
//Matched, return true
|
209 |
+
return true;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
//Should be in 'first'
|
214 |
+
return false;
|
215 |
+
}
|
216 |
}
|
classes/autoptimizeStyles.php
CHANGED
@@ -4,10 +4,19 @@ class autoptimizeStyles extends autoptimizeBase
|
|
4 |
private $css = array();
|
5 |
private $csscode = array();
|
6 |
private $url = array();
|
|
|
7 |
|
8 |
//Reads the page and collects style tags
|
9 |
-
public function read()
|
10 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
//Save IE hacks
|
12 |
$this->content = preg_replace('#(<\!--\[if.*\]>.*<\!\[endif\]-->)#Usie',
|
13 |
'\'%%IEHACK%%\'.base64_encode("$1").\'%%IEHACK%%\'',$this->content);
|
@@ -120,11 +129,13 @@ class autoptimizeStyles extends autoptimizeBase
|
|
120 |
//Manage @imports, while is for recursive import management
|
121 |
foreach($this->csscode as &$thiscss)
|
122 |
{
|
123 |
-
|
|
|
|
|
124 |
{
|
125 |
foreach($matches[0] as $import)
|
126 |
{
|
127 |
-
$url = preg_replace('
|
128 |
$path = $this->getpath($url);
|
129 |
if(file_exists($path) && is_readable($path))
|
130 |
{
|
@@ -139,11 +150,20 @@ class autoptimizeStyles extends autoptimizeBase
|
|
139 |
//TODO: Infinite recursion!
|
140 |
}*/
|
141 |
$thiscss = preg_replace('#(/\*FILESTART\*/.*)'.preg_quote($import,'#').'#Us',$code.'$1',$thiscss);
|
142 |
-
}
|
143 |
//getpath is not working?
|
144 |
-
|
|
|
|
|
|
|
145 |
}
|
146 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
unset($thiscss);
|
149 |
|
@@ -182,10 +202,21 @@ class autoptimizeStyles extends autoptimizeBase
|
|
182 |
{
|
183 |
//Restore IE hacks
|
184 |
$this->content = preg_replace('#%%IEHACK%%(.*)%%IEHACK%%#Usie','base64_decode("$1")',$this->content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
foreach($this->url as $media => $url)
|
186 |
{
|
187 |
$this->content = str_replace('</head>','<link type="text/css" media="'.$media.'" href="'.$url.'" rel="stylesheet" /></head>',$this->content);
|
188 |
}
|
|
|
|
|
189 |
return $this->content;
|
190 |
}
|
191 |
|
@@ -200,7 +231,7 @@ class autoptimizeStyles extends autoptimizeBase
|
|
200 |
foreach($matches[1] as $url)
|
201 |
{
|
202 |
//Remove quotes
|
203 |
-
$url =
|
204 |
if(substr($url,0,1)=='/' || preg_match('#^(https?|ftp)://#i',$url))
|
205 |
{
|
206 |
//URL is absolute
|
4 |
private $css = array();
|
5 |
private $csscode = array();
|
6 |
private $url = array();
|
7 |
+
private $restofcontent = '';
|
8 |
|
9 |
//Reads the page and collects style tags
|
10 |
+
public function read($justhead)
|
11 |
{
|
12 |
+
//Remove everything that's not the header
|
13 |
+
if($justhead == true)
|
14 |
+
{
|
15 |
+
$content = explode('</head>',$this->content,2);
|
16 |
+
$this->content = $content[0].'</head>';
|
17 |
+
$this->restofcontent = $content[1];
|
18 |
+
}
|
19 |
+
|
20 |
//Save IE hacks
|
21 |
$this->content = preg_replace('#(<\!--\[if.*\]>.*<\!\[endif\]-->)#Usie',
|
22 |
'\'%%IEHACK%%\'.base64_encode("$1").\'%%IEHACK%%\'',$this->content);
|
129 |
//Manage @imports, while is for recursive import management
|
130 |
foreach($this->csscode as &$thiscss)
|
131 |
{
|
132 |
+
//Flag to trigger import reconstitution
|
133 |
+
$fiximports = false;
|
134 |
+
while(preg_match_all('#@import.*(?:;|$)#Um',$thiscss,$matches))
|
135 |
{
|
136 |
foreach($matches[0] as $import)
|
137 |
{
|
138 |
+
$url = trim(preg_replace('#.+((?:https?|ftp)://.*\.css)(?:\s|"|\').+#','$1',$import)," \t\n\r\0\x0B\"'");
|
139 |
$path = $this->getpath($url);
|
140 |
if(file_exists($path) && is_readable($path))
|
141 |
{
|
150 |
//TODO: Infinite recursion!
|
151 |
}*/
|
152 |
$thiscss = preg_replace('#(/\*FILESTART\*/.*)'.preg_quote($import,'#').'#Us',$code.'$1',$thiscss);
|
153 |
+
}else{
|
154 |
//getpath is not working?
|
155 |
+
//Encode so preg_match doesn't see it
|
156 |
+
$thiscss = str_replace($import,'/*IMPORT*/'.base64_encode($import).'/*IMPORT*/',$thiscss);
|
157 |
+
$fiximports = true;
|
158 |
+
}
|
159 |
}
|
160 |
}
|
161 |
+
|
162 |
+
//Recover imports
|
163 |
+
if($fiximports)
|
164 |
+
{
|
165 |
+
$thiscss = preg_replace('#/\*IMPORT\*/(.*)/\*IMPORT\*/#Use','base64_decode("$1")',$thiscss);
|
166 |
+
}
|
167 |
}
|
168 |
unset($thiscss);
|
169 |
|
202 |
{
|
203 |
//Restore IE hacks
|
204 |
$this->content = preg_replace('#%%IEHACK%%(.*)%%IEHACK%%#Usie','base64_decode("$1")',$this->content);
|
205 |
+
|
206 |
+
//Restore the full content
|
207 |
+
if(!empty($this->restofcontent))
|
208 |
+
{
|
209 |
+
$this->content .= $this->restofcontent;
|
210 |
+
$this->restofcontent = '';
|
211 |
+
}
|
212 |
+
|
213 |
+
//Add the new stylesheets
|
214 |
foreach($this->url as $media => $url)
|
215 |
{
|
216 |
$this->content = str_replace('</head>','<link type="text/css" media="'.$media.'" href="'.$url.'" rel="stylesheet" /></head>',$this->content);
|
217 |
}
|
218 |
+
|
219 |
+
//Return the modified stylesheet
|
220 |
return $this->content;
|
221 |
}
|
222 |
|
231 |
foreach($matches[1] as $url)
|
232 |
{
|
233 |
//Remove quotes
|
234 |
+
$url = trim($url," \t\n\r\0\x0B\"'");
|
235 |
if(substr($url,0,1)=='/' || preg_match('#^(https?|ftp)://#i',$url))
|
236 |
{
|
237 |
//URL is absolute
|
classes/minify-html.php
CHANGED
@@ -117,6 +117,12 @@ class Minify_HTML {
|
|
117 |
'/\\s*(<textarea\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
|
118 |
,array($this, '_removeTextareaCB')
|
119 |
,$this->_html);
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
// trim each line.
|
122 |
// @todo take into account attribute values that span multiple lines.
|
@@ -136,7 +142,7 @@ class Minify_HTML {
|
|
136 |
,$this->_html);
|
137 |
|
138 |
// use newlines before 1st attribute in open tags (to limit line lengths)
|
139 |
-
|
140 |
|
141 |
// fill placeholders
|
142 |
$this->_html = str_replace(
|
@@ -181,6 +187,11 @@ class Minify_HTML {
|
|
181 |
{
|
182 |
return $this->_reservePlace($m[1]);
|
183 |
}
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
protected function _removeStyleCB($m)
|
186 |
{
|
117 |
'/\\s*(<textarea\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
|
118 |
,array($this, '_removeTextareaCB')
|
119 |
,$this->_html);
|
120 |
+
|
121 |
+
// replace data: URIs with placeholders
|
122 |
+
$this->_html = preg_replace_callback(
|
123 |
+
'/(=("|\')data:.*\\2)/Ui'
|
124 |
+
,array($this, '_removeDataURICB')
|
125 |
+
,$this->_html);
|
126 |
|
127 |
// trim each line.
|
128 |
// @todo take into account attribute values that span multiple lines.
|
142 |
,$this->_html);
|
143 |
|
144 |
// use newlines before 1st attribute in open tags (to limit line lengths)
|
145 |
+
//$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
|
146 |
|
147 |
// fill placeholders
|
148 |
$this->_html = str_replace(
|
187 |
{
|
188 |
return $this->_reservePlace($m[1]);
|
189 |
}
|
190 |
+
|
191 |
+
protected function _removeDataURICB($m)
|
192 |
+
{
|
193 |
+
return $this->_reservePlace($m[1]);
|
194 |
+
}
|
195 |
|
196 |
protected function _removeStyleCB($m)
|
197 |
{
|
localization/autoptimize-es_ES.mo
ADDED
Binary file
|
localization/autoptimize-es_ES.po
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Spanish translation for autoptimize
|
2 |
+
# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009
|
3 |
+
# This file is distributed under the same license as the autoptimize package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
|
5 |
+
#
|
6 |
+
msgid ""
|
7 |
+
msgstr ""
|
8 |
+
"Project-Id-Version: autoptimize\n"
|
9 |
+
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
|
10 |
+
"POT-Creation-Date: 2009-07-12 03:12+0000\n"
|
11 |
+
"PO-Revision-Date: 2009-07-12 18:20+0000\n"
|
12 |
+
"Last-Translator: Emilio <Unknown>\n"
|
13 |
+
"Language-Team: Spanish <es@li.org>\n"
|
14 |
+
"MIME-Version: 1.0\n"
|
15 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
16 |
+
"Content-Transfer-Encoding: 8bit\n"
|
17 |
+
"X-Launchpad-Export-Date: 2009-07-12 19:28+0000\n"
|
18 |
+
"X-Generator: Launchpad (build Unknown)\n"
|
19 |
+
|
20 |
+
#: classes/autoptimizeConfig.php:44
|
21 |
+
msgid "Autoptimize Settings"
|
22 |
+
msgstr "Configuración de Autoptimize"
|
23 |
+
|
24 |
+
#: classes/autoptimizeConfig.php:49
|
25 |
+
msgid "HTML Options"
|
26 |
+
msgstr "Opciones de HTML"
|
27 |
+
|
28 |
+
#: classes/autoptimizeConfig.php:52
|
29 |
+
msgid "Optimize HTML Code?"
|
30 |
+
msgstr "¿Optimizar el código HTML?"
|
31 |
+
|
32 |
+
#: classes/autoptimizeConfig.php:57
|
33 |
+
msgid "JavaScript Options"
|
34 |
+
msgstr "Opciones de JavaScript"
|
35 |
+
|
36 |
+
#: classes/autoptimizeConfig.php:60
|
37 |
+
msgid "Optimize JavaScript Code?"
|
38 |
+
msgstr "¿Optimizar el código JavaScript?"
|
39 |
+
|
40 |
+
#: classes/autoptimizeConfig.php:64
|
41 |
+
msgid "Look for scripts only in <head>?"
|
42 |
+
msgstr "¿Buscar scripts solo en <head>?"
|
43 |
+
|
44 |
+
#: classes/autoptimizeConfig.php:66 classes/autoptimizeConfig.php:79
|
45 |
+
msgid ""
|
46 |
+
"Disabled by default. If the cache gets big, you might want to enable this."
|
47 |
+
msgstr ""
|
48 |
+
"Deshabilitado por defecto. Si el cache se hace grande, tal vez quieras "
|
49 |
+
"habilitar esto."
|
50 |
+
|
51 |
+
#: classes/autoptimizeConfig.php:70
|
52 |
+
msgid "CSS Options"
|
53 |
+
msgstr "Opciones de CSS"
|
54 |
+
|
55 |
+
#: classes/autoptimizeConfig.php:73
|
56 |
+
msgid "Optimize CSS Code?"
|
57 |
+
msgstr "¿Optimizar el código CSS?"
|
58 |
+
|
59 |
+
#: classes/autoptimizeConfig.php:77
|
60 |
+
msgid "Look for styles on just <head>?"
|
61 |
+
msgstr "¿Buscar estilos solo en <head>?"
|
62 |
+
|
63 |
+
#: classes/autoptimizeConfig.php:86
|
64 |
+
msgid "Save Changes"
|
65 |
+
msgstr "Guardar Cambios"
|
66 |
+
|
67 |
+
#: classes/autoptimizeConfig.php:96
|
68 |
+
msgid "Autoptimize Options"
|
69 |
+
msgstr "Configuración de Autoptimize"
|
70 |
+
|
71 |
+
#: classes/autoptimizeConfig.php:120 classes/autoptimizeConfig.php:127
|
72 |
+
msgid "Settings"
|
73 |
+
msgstr "Configuración"
|
74 |
+
|
75 |
+
#. Plugin Name of an extension
|
76 |
+
msgid "Autoptimize"
|
77 |
+
msgstr "Autoptimize"
|
78 |
+
|
79 |
+
#. Description of an extension
|
80 |
+
msgid ""
|
81 |
+
"Optimizes your website, concatenating the CSS and JavaScript code, and "
|
82 |
+
"compressing it."
|
83 |
+
msgstr ""
|
84 |
+
"Optimiza tu sitio web, concatenando el código CSS y Javascript, y "
|
85 |
+
"comprimiéndolo."
|
localization/autoptimize.pot
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR Emilio Lpez
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
#, fuzzy
|
7 |
+
msgid ""
|
8 |
+
msgstr ""
|
9 |
+
"Project-Id-Version: PACKAGE VERSION\n"
|
10 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/autoptimize\n"
|
11 |
+
"POT-Creation-Date: 2009-07-12 03:12+0000\n"
|
12 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
+
"MIME-Version: 1.0\n"
|
16 |
+
"Content-Type: text/plain; charset=CHARSET\n"
|
17 |
+
"Content-Transfer-Encoding: 8bit\n"
|
18 |
+
|
19 |
+
#: classes/autoptimizeConfig.php:44
|
20 |
+
msgid "Autoptimize Settings"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: classes/autoptimizeConfig.php:49
|
24 |
+
msgid "HTML Options"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: classes/autoptimizeConfig.php:52
|
28 |
+
msgid "Optimize HTML Code?"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: classes/autoptimizeConfig.php:57
|
32 |
+
msgid "JavaScript Options"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: classes/autoptimizeConfig.php:60
|
36 |
+
msgid "Optimize JavaScript Code?"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: classes/autoptimizeConfig.php:64
|
40 |
+
msgid "Look for scripts only in <head>?"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: classes/autoptimizeConfig.php:66 classes/autoptimizeConfig.php:79
|
44 |
+
msgid ""
|
45 |
+
"Disabled by default. If the cache gets big, you might want to enable this."
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: classes/autoptimizeConfig.php:70
|
49 |
+
msgid "CSS Options"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: classes/autoptimizeConfig.php:73
|
53 |
+
msgid "Optimize CSS Code?"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: classes/autoptimizeConfig.php:77
|
57 |
+
msgid "Look for styles on just <head>?"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: classes/autoptimizeConfig.php:86
|
61 |
+
msgid "Save Changes"
|
62 |
+
msgstr ""
|
63 |
+
|
64 |
+
#: classes/autoptimizeConfig.php:96
|
65 |
+
msgid "Autoptimize Options"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: classes/autoptimizeConfig.php:120 classes/autoptimizeConfig.php:127
|
69 |
+
msgid "Settings"
|
70 |
+
msgstr ""
|
71 |
+
|
72 |
+
#. Plugin Name of an extension
|
73 |
+
msgid "Autoptimize"
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#. Description of an extension
|
77 |
+
msgid ""
|
78 |
+
"Optimizes your website, concatenating the CSS and JavaScript code, and "
|
79 |
+
"compressing it."
|
80 |
+
msgstr ""
|
81 |
+
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: turl
|
3 |
Donate link: http://www.turleando.com.ar/autoptimize/
|
4 |
Tags: css, html, javascript, js, optimize, speed, cache
|
5 |
-
Requires at least: 2.
|
6 |
-
Tested up to: 2.8
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
|
10 |
|
@@ -14,11 +14,13 @@ 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 |
== Installation ==
|
18 |
|
19 |
1. Upload the `autoptimize` folder to to the `/wp-content/plugins/` directory
|
20 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
21 |
-
1. Go to `Settings -> Autoptimize` and enable the options you want. Generally this means
|
22 |
|
23 |
== Frequently Asked Questions ==
|
24 |
|
@@ -26,8 +28,24 @@ I also recommend using WP Super Cache in conjuction with Autoptimize to speed up
|
|
26 |
|
27 |
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.
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
= 0.4 =
|
32 |
* Write plugin description in English
|
33 |
* Set default config to everything off
|
2 |
Contributors: turl
|
3 |
Donate link: http://www.turleando.com.ar/autoptimize/
|
4 |
Tags: css, html, javascript, js, optimize, speed, cache
|
5 |
+
Requires at least: 2.7
|
6 |
+
Tested up to: 2.8.1
|
7 |
+
Stable tag: 0.5
|
8 |
|
9 |
Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
|
10 |
|
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
|
22 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
23 |
+
1. Go to `Settings -> Autoptimize` and enable the options you want. Generally this means "Optimize HTML/CSS/JavaScript", but if you experience problems you might want to disable some.
|
24 |
|
25 |
== Frequently Asked Questions ==
|
26 |
|
28 |
|
29 |
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.
|
30 |
|
31 |
+
= Where can I report an error? =
|
32 |
+
|
33 |
+
You can fill in a bug in our [bug tracker](https://bugs.launchpad.net/autoptimize), or contact the author through Twitter (@turl) or email (turl at tuxfamily dot org).
|
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 |
+
= 0.5 =
|
42 |
+
* Support localization
|
43 |
+
* Fix the move and don't move system (again)
|
44 |
+
* Improve url detection in CSS
|
45 |
+
* Support looking for scripts and styles on just the header
|
46 |
+
* Fix an issue with data: uris getting modified
|
47 |
+
* Spanish translation
|
48 |
+
|
49 |
= 0.4 =
|
50 |
* Write plugin description in English
|
51 |
* Set default config to everything off
|