Version Description
- improvement: more intelligent CDN-replacement logic, thanks Squazz for reporting and testing
- improvement: allow strings (comments) to be excluded from HTML-optimization (comment removal)
- improvement: changed priority with which AO gets triggered by WordPress, solving JS not being aggregated when NextGen Galleries is active, with great help from msebald
- improvement: extra JS exclude-strings: gist.github.com, text/html, text/template, wp-slimstat.min.js, _stq, nonce, post_id (the latter two were removed from the "manual" exclude list on the settings-page)
- new in API: autoptimize_filter_html_exclude, autoptimize_filter_css_defer, autoptimize_filter_css_inline, autoptimize_filter_base_replace_cdn, autoptimize_filter_js_noptimize, autoptimize_filter_css_noptimize, autoptimize_filter_html_noptimize
- bugfix: remove some PHP notices, as reported by dimitrov.adrian
- bugfix: make sure HTML-optimalization does not gobble a space before a cite as proposed by ecdltf
- bugfix: cleaning the cache did not work on non-default directories as encountered by NoahJ Champion
- upgraded to yui compressor php port 2.4.8-4
- added arabic translation, thanks to the ekleel team
- tested with WordPress 4.2 beta 3
Download this release
Release Info
Developer | futtta |
Plugin | Autoptimize |
Version | 1.9.3 |
Comparing to | |
See all releases |
Code changes from version 1.9.2 to 1.9.3
- LICENSE +340 -0
- README.md +218 -0
- autoptimize.php +4 -4
- classes/autoptimizeBase.php +34 -15
- classes/autoptimizeCache.php +1 -1
- classes/autoptimizeConfig.php +8 -5
- classes/autoptimizeHTML.php +38 -15
- classes/autoptimizeScripts.php +7 -3
- classes/autoptimizeStyles.php +28 -3
- classes/external/php/minify-html.php +1 -1
- classes/external/php/yui-php-cssmin-2.4.8-2_fgo.php +0 -777
- classes/external/php/yui-php-cssmin-2.4.8-3.php +0 -777
- classes/external/php/{yui-php-cssmin-2.4.8-3_fixes.php → yui-php-cssmin-2.4.8-4.php} +2 -2
- localization/autoptimize-ar.mo +0 -0
- localization/autoptimize-ar.po +295 -0
- localization/autoptimize-de_DE.po +1 -1
- localization/autoptimize-fa_IR.po +1 -1
- localization/autoptimize-fr_FR.po +1 -1
- localization/autoptimize-nl_BE.po +1 -1
- localization/autoptimize-nl_NL.po +1 -1
- localization/autoptimize-pl_PL.po +1 -1
- localization/autoptimize-pt_BR.po +1 -1
- localization/autoptimize-sv_SE.po +1 -1
- localization/autoptimize-tr_TR.po +1 -1
- localization/autoptimize-uk_UA.po +1 -1
- localization/autoptimize.pot +1 -1
- readme.txt +28 -19
LICENSE
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
{description}
|
294 |
+
Copyright (C) {year} {fullname}
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
{signature of Ty Coon}, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
340 |
+
|
README.md
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Autoptimize
|
2 |
+
===========
|
3 |
+
|
4 |
+
The [official Autoptimize repo on Github can be found here](https://github.com/futtta/autoptimize/).
|
5 |
+
|
6 |
+
## Example use of Autoptimize's API
|
7 |
+
|
8 |
+
### Filter: `autoptimize_filter_css_datauri_maxsize`
|
9 |
+
|
10 |
+
```php
|
11 |
+
add_filter('autoptimize_filter_css_datauri_maxsize','my_ao_override_dataursize',10,1);
|
12 |
+
/**
|
13 |
+
* Change the threshold at which background images are turned into data URI-s.
|
14 |
+
*
|
15 |
+
* @param $urisize: default size
|
16 |
+
* @return: your own preferred size
|
17 |
+
*/
|
18 |
+
function my_ao_override_dataursize($urisizeIn) {
|
19 |
+
return 100000;
|
20 |
+
}
|
21 |
+
```
|
22 |
+
|
23 |
+
### Filter: `autoptimize_filter_css_datauri_exclude`
|
24 |
+
|
25 |
+
```php
|
26 |
+
add_filter('autoptimize_filter_css_datauri_exclude','my_ao_exclude_image',10,1);
|
27 |
+
/**
|
28 |
+
* Exclude background images from being turned into data URI-s.
|
29 |
+
*
|
30 |
+
* @param $imageexcl: default images excluded (empty)
|
31 |
+
* @return: comma-seperated list of images to exclude
|
32 |
+
*/
|
33 |
+
function my_ao_exclude_image($imageexcl) {
|
34 |
+
return "adfreebutton.jpg, otherimage.png";
|
35 |
+
}
|
36 |
+
```
|
37 |
+
|
38 |
+
### Filter: `autoptimize_filter_js_defer`
|
39 |
+
|
40 |
+
```php
|
41 |
+
add_filter('autoptimize_filter_js_defer','my_ao_override_defer',10,1);
|
42 |
+
/**
|
43 |
+
* Change flag added to Javascript.
|
44 |
+
*
|
45 |
+
* @param $defer: default value, "" when forced in head, "defer " when not forced in head
|
46 |
+
* @return: new value
|
47 |
+
*/
|
48 |
+
function my_ao_override_defer($defer) {
|
49 |
+
return $defer."async ";
|
50 |
+
}
|
51 |
+
```
|
52 |
+
|
53 |
+
### Filter: autoptimize_filter_noptimize
|
54 |
+
|
55 |
+
```php
|
56 |
+
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0);
|
57 |
+
/**
|
58 |
+
* Stop autoptimize from optimizing, e.g. based on URL as in example.
|
59 |
+
*
|
60 |
+
* @return: boolean, true or false
|
61 |
+
*/
|
62 |
+
function my_ao_noptimize() {
|
63 |
+
if (strpos($_SERVER['REQUEST_URI'],'no-autoptimize-now')!==false) {
|
64 |
+
return true;
|
65 |
+
} else {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
```
|
70 |
+
|
71 |
+
### Filter: `autoptimize_filter_js_exclude`
|
72 |
+
|
73 |
+
```php
|
74 |
+
add_filter('autoptimize_filter_js_exclude','my_ao_override_jsexclude',10,1);
|
75 |
+
/**
|
76 |
+
* JS optimization exclude strings, as configured in admin page.
|
77 |
+
*
|
78 |
+
* @param $exclude: comma-seperated list of exclude strings
|
79 |
+
* @return: comma-seperated list of exclude strings
|
80 |
+
*/
|
81 |
+
function my_ao_override_jsexclude($exclude) {
|
82 |
+
return $exclude.", customize-support";
|
83 |
+
}
|
84 |
+
```
|
85 |
+
|
86 |
+
### Filter: `autoptimize_filter_css_exclude`
|
87 |
+
|
88 |
+
```php
|
89 |
+
add_filter('autoptimize_filter_css_exclude','my_ao_override_cssexclude',10,1);
|
90 |
+
/**
|
91 |
+
* CSS optimization exclude strings, as configured in admin page.
|
92 |
+
*
|
93 |
+
* @param $exclude: comma-seperated list of exclude strings
|
94 |
+
* @return: comma-seperated list of exclude strings
|
95 |
+
*/
|
96 |
+
function my_ao_override_cssexclude($exclude) {
|
97 |
+
return $exclude.", recentcomments";
|
98 |
+
}
|
99 |
+
```
|
100 |
+
|
101 |
+
## Filter: `autoptimize_filter_js_movelast`
|
102 |
+
|
103 |
+
```php
|
104 |
+
add_filter('autoptimize_filter_js_movelast','my_ao_override_movelast',10,1);
|
105 |
+
/**
|
106 |
+
* Internal array of what script can be moved to the bottom of the HTML.
|
107 |
+
*
|
108 |
+
* @param array $movelast
|
109 |
+
* @return: updated array
|
110 |
+
*/
|
111 |
+
function my_ao_override_movelast($movelast) {
|
112 |
+
$movelast[]="console.log";
|
113 |
+
return $movelast;
|
114 |
+
}
|
115 |
+
```
|
116 |
+
|
117 |
+
### Filter: `autoptimize_filter_css_replacetag`
|
118 |
+
|
119 |
+
```php
|
120 |
+
add_filter('autoptimize_filter_css_replacetag','my_ao_override_css_replacetag',10,1);
|
121 |
+
/**
|
122 |
+
* Where in the HTML is optimized CSS injected.
|
123 |
+
*
|
124 |
+
* @param array $replacetag, containing the html-tag and the method (inject "before", "after" or "replace")
|
125 |
+
* @return array with updated values
|
126 |
+
*/
|
127 |
+
function my_ao_override_css_replacetag($replacetag) {
|
128 |
+
return array("<head>","after");
|
129 |
+
}
|
130 |
+
```
|
131 |
+
|
132 |
+
### Filter: `autoptimize_filter_js_replacetag`
|
133 |
+
|
134 |
+
```php
|
135 |
+
add_filter('autoptimize_filter_js_replacetag','my_ao_override_js_replacetag',10,1);
|
136 |
+
/**
|
137 |
+
* Where in the HTML optimized JS is injected.
|
138 |
+
*
|
139 |
+
* @param array $replacetag, containing the html-tag and the method (inject "before", "after" or "replace")
|
140 |
+
* @return array with updated values
|
141 |
+
*/
|
142 |
+
function my_ao_override_js_replacetag($replacetag) {
|
143 |
+
return array("<injectjs />","replace");
|
144 |
+
}
|
145 |
+
```
|
146 |
+
|
147 |
+
### Filter: `autoptimize_js_do_minify`
|
148 |
+
|
149 |
+
```php
|
150 |
+
add_filter('autoptimize_js_do_minify','my_ao_js_minify',10,1);
|
151 |
+
/**
|
152 |
+
* Do we want to minify?
|
153 |
+
* If set to false autoptimize effectively only aggregates, but does not minify.
|
154 |
+
*
|
155 |
+
* @return: boolean true or false
|
156 |
+
*/
|
157 |
+
function my_ao_js_minify() {
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
```
|
161 |
+
|
162 |
+
### Filter: `autoptimize_css_do_minify`
|
163 |
+
|
164 |
+
```php
|
165 |
+
add_filter('autoptimize_css_do_minify','my_ao_css_minify',10,1);
|
166 |
+
/**
|
167 |
+
* Do we want to minify?
|
168 |
+
* If set to false autoptimize effectively only aggregates, but does not minify.
|
169 |
+
*
|
170 |
+
* @return: boolean true or false
|
171 |
+
*/
|
172 |
+
function my_ao_css_minify() {
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
```
|
176 |
+
|
177 |
+
### Filter: `autoptimize_js_include_inline`
|
178 |
+
|
179 |
+
```php
|
180 |
+
add_filter('autoptimize_js_include_inline','my_ao_js_include_inline',10,1);
|
181 |
+
/**
|
182 |
+
* Do we want AO to also aggregate inline JS?
|
183 |
+
*
|
184 |
+
* @return: boolean true or false
|
185 |
+
*/
|
186 |
+
function my_ao_js_include_inline() {
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
```
|
190 |
+
|
191 |
+
### Filter: `autoptimize_css_include_inline`
|
192 |
+
|
193 |
+
```php
|
194 |
+
add_filter('autoptimize_css_include_inline','my_ao_css_include_inline',10,1);
|
195 |
+
/**
|
196 |
+
* Do we want AO to also aggregate inline CSS?
|
197 |
+
*
|
198 |
+
* @return: boolean true or false
|
199 |
+
*/
|
200 |
+
function my_ao_css_include_inline() {
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
```
|
204 |
+
|
205 |
+
### Filter: `autoptimize_filter_css_defer_inline`
|
206 |
+
|
207 |
+
```php
|
208 |
+
add_filter('autoptimize_filter_css_defer_inline','my_ao_css_defer_inline',10,1);
|
209 |
+
/**
|
210 |
+
* What CSS to inline when "defer and inline" is activated.
|
211 |
+
*
|
212 |
+
* @param $inlined: string with above the fold CSS as configured in admin
|
213 |
+
* @return: updated string with above the fold CSS
|
214 |
+
*/
|
215 |
+
function my_ao_css_defer_inline($inlined) {
|
216 |
+
return $inlined."h2,h1{color:red !important;}";
|
217 |
+
}
|
218 |
+
```
|
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.9.
|
7 |
Author: Frank Goossens (futtta)
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Domain Path: localization/
|
@@ -44,7 +44,7 @@ $conf = autoptimizeConfig::instance();
|
|
44 |
/* Check if we're updating, in which case we might need to do stuff and flush the cache
|
45 |
to avoid old versions of aggregated files lingering around */
|
46 |
|
47 |
-
$autoptimize_version="1.9.
|
48 |
$autoptimize_db_version=get_option('autoptimize_version','none');
|
49 |
|
50 |
if ($autoptimize_db_version !== $autoptimize_version) {
|
@@ -190,7 +190,7 @@ function autoptimize_start_buffering() {
|
|
190 |
}
|
191 |
} else {
|
192 |
if (!class_exists('CSSmin')) {
|
193 |
-
@include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-
|
194 |
}
|
195 |
}
|
196 |
define('COMPRESS_CSS',false);
|
@@ -312,7 +312,7 @@ if(autoptimizeCache::cacheavail()) {
|
|
312 |
$conf = autoptimizeConfig::instance();
|
313 |
if( $conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') || $conf->get('autoptimize_cdn_js') || $conf->get('autoptimize_cdn_css')) {
|
314 |
// Hook to wordpress
|
315 |
-
add_action('
|
316 |
}
|
317 |
}
|
318 |
|
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.9.3
|
7 |
Author: Frank Goossens (futtta)
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Domain Path: localization/
|
44 |
/* Check if we're updating, in which case we might need to do stuff and flush the cache
|
45 |
to avoid old versions of aggregated files lingering around */
|
46 |
|
47 |
+
$autoptimize_version="1.9.3";
|
48 |
$autoptimize_db_version=get_option('autoptimize_version','none');
|
49 |
|
50 |
if ($autoptimize_db_version !== $autoptimize_version) {
|
190 |
}
|
191 |
} else {
|
192 |
if (!class_exists('CSSmin')) {
|
193 |
+
@include(WP_PLUGIN_DIR.'/autoptimize/classes/external/php/yui-php-cssmin-2.4.8-4.php');
|
194 |
}
|
195 |
}
|
196 |
define('COMPRESS_CSS',false);
|
312 |
$conf = autoptimizeConfig::instance();
|
313 |
if( $conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') || $conf->get('autoptimize_cdn_js') || $conf->get('autoptimize_cdn_css')) {
|
314 |
// Hook to wordpress
|
315 |
+
add_action('init','autoptimize_start_buffering',-1);
|
316 |
}
|
317 |
}
|
318 |
|
classes/autoptimizeBase.php
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
<?php
|
2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
3 |
|
4 |
-
abstract class autoptimizeBase
|
5 |
-
{
|
6 |
protected $content = '';
|
|
|
7 |
|
8 |
-
public function __construct($content)
|
9 |
-
|
10 |
-
|
11 |
-
//Best place to catch errors
|
12 |
}
|
13 |
|
14 |
//Reads the page and collects tags
|
@@ -25,6 +24,8 @@ abstract class autoptimizeBase
|
|
25 |
|
26 |
//Converts an URL to a full path
|
27 |
protected function getpath($url) {
|
|
|
|
|
28 |
if (strpos($url,'%')!==false) {
|
29 |
$url=urldecode($url);
|
30 |
}
|
@@ -41,7 +42,7 @@ abstract class autoptimizeBase
|
|
41 |
}
|
42 |
|
43 |
// first check; hostname wp site should be hostname of url
|
44 |
-
if (parse_url($url,PHP_URL_HOST)!==parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST)) {
|
45 |
return false;
|
46 |
}
|
47 |
|
@@ -170,12 +171,30 @@ abstract class autoptimizeBase
|
|
170 |
return $comments_out;
|
171 |
}
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
protected function inject_in_html($payload,$replaceTag) {
|
181 |
if (strpos($this->content,$replaceTag[0])!== false) {
|
@@ -189,9 +208,9 @@ abstract class autoptimizeBase
|
|
189 |
$this->content = str_replace($replaceTag[0],$replaceBlock,$this->content);
|
190 |
} else {
|
191 |
$this->content .= $payload;
|
192 |
-
if (!$tagWarning) {
|
193 |
$this->content .= "<!--noptimize--><!-- Autoptimize found a problem with the HTML in your Theme, tag ".$replaceTag[0]." missing --><!--/noptimize-->";
|
194 |
-
$tagWarning=true;
|
195 |
}
|
196 |
}
|
197 |
}
|
1 |
<?php
|
2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
3 |
|
4 |
+
abstract class autoptimizeBase {
|
|
|
5 |
protected $content = '';
|
6 |
+
protected $tagWarning = false;
|
7 |
|
8 |
+
public function __construct($content) {
|
9 |
+
$this->content = $content;
|
10 |
+
//Best place to catch errors
|
|
|
11 |
}
|
12 |
|
13 |
//Reads the page and collects tags
|
24 |
|
25 |
//Converts an URL to a full path
|
26 |
protected function getpath($url) {
|
27 |
+
$url=apply_filters( 'autoptimize_filter_cssjs_alter_url', $url);
|
28 |
+
|
29 |
if (strpos($url,'%')!==false) {
|
30 |
$url=urldecode($url);
|
31 |
}
|
42 |
}
|
43 |
|
44 |
// first check; hostname wp site should be hostname of url
|
45 |
+
if (@parse_url($url,PHP_URL_HOST)!==parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST)) {
|
46 |
return false;
|
47 |
}
|
48 |
|
171 |
return $comments_out;
|
172 |
}
|
173 |
|
174 |
+
protected function url_replace_cdn($url) {
|
175 |
+
if (!empty($this->cdn_url)) {
|
176 |
+
// first allow API filter to take care of CDN replacement
|
177 |
+
$tmp_url = apply_filters( 'autoptimize_filter_base_replace_cdn',$url);
|
178 |
+
if ($tmp_url === $url) {
|
179 |
+
// secondly prepend domain-less absolute URL's
|
180 |
+
if((substr($url,0,1)==='/')&&(substr($url,1,1)!=='/')) {
|
181 |
+
$url=rtrim($this->cdn_url,'/').$url;
|
182 |
+
} else {
|
183 |
+
// three: replace full url's with scheme
|
184 |
+
$tmp_url=str_replace(AUTOPTIMIZE_WP_SITE_URL,rtrim($this->cdn_url,'/'),$url);
|
185 |
+
if ($tmp_url===$url) {
|
186 |
+
// last attempt; replace scheme-less URL's
|
187 |
+
$url=str_replace(preg_replace('/https?:/','',AUTOPTIMIZE_WP_SITE_URL),rtrim($this->cdn_url,'/'),$url);
|
188 |
+
} else {
|
189 |
+
$url=$tmp_url;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
} else {
|
193 |
+
$url=$tmp_url;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
return $url;
|
197 |
+
}
|
198 |
|
199 |
protected function inject_in_html($payload,$replaceTag) {
|
200 |
if (strpos($this->content,$replaceTag[0])!== false) {
|
208 |
$this->content = str_replace($replaceTag[0],$replaceBlock,$this->content);
|
209 |
} else {
|
210 |
$this->content .= $payload;
|
211 |
+
if (!$this->tagWarning) {
|
212 |
$this->content .= "<!--noptimize--><!-- Autoptimize found a problem with the HTML in your Theme, tag ".$replaceTag[0]." missing --><!--/noptimize-->";
|
213 |
+
$this->tagWarning=true;
|
214 |
}
|
215 |
}
|
216 |
}
|
classes/autoptimizeCache.php
CHANGED
@@ -78,7 +78,7 @@ class autoptimizeCache {
|
|
78 |
foreach ($scan as $scandirName=>$scanneddir) {
|
79 |
$thisAoCacheDir=rtrim(AUTOPTIMIZE_CACHE_DIR.$scandirName,"/")."/";
|
80 |
foreach($scanneddir as $file) {
|
81 |
-
if(!in_array($file,array('.','..')) && strpos($file,
|
82 |
@unlink($thisAoCacheDir.$file);
|
83 |
}
|
84 |
}
|
78 |
foreach ($scan as $scandirName=>$scanneddir) {
|
79 |
$thisAoCacheDir=rtrim(AUTOPTIMIZE_CACHE_DIR.$scandirName,"/")."/";
|
80 |
foreach($scanneddir as $file) {
|
81 |
+
if(!in_array($file,array('.','..')) && strpos($file,AUTOPTIMIZE_CACHEFILE_PREFIX) !== false && is_file($thisAoCacheDir.$file)) {
|
82 |
@unlink($thisAoCacheDir.$file);
|
83 |
}
|
84 |
}
|
classes/autoptimizeConfig.php
CHANGED
@@ -91,13 +91,13 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
91 |
<?php _e('For performance reasons it is better to include JavaScript at the bottom of HTML, but this sometimes breaks things. Especially useful for jQuery-based themes.','autoptimize'); ?></label></td>
|
92 |
</tr>
|
93 |
<tr valign="top" class="hidden js_sub ao_adv">
|
94 |
-
<th scope="row"><?php _e('Look for scripts only in <head>?','autoptimize');
|
95 |
<td><label for="autoptimize_js_justhead"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
|
96 |
-
<?php _e('Mostly
|
97 |
</tr>
|
98 |
<tr valign="top" class="hidden js_sub ao_adv">
|
99 |
<th scope="row"><?php _e('Exclude scripts from Autoptimize:','autoptimize'); ?></th>
|
100 |
-
<td><label for="autoptimize_js_exclude"><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude',"s_sid,smowtion_size,sc_project,WAU_,wau_add,comment-form-quicktags,edToolbar,ch_client,
|
101 |
<?php _e('A comma-seperated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated and minimized by Autoptimize.','autoptimize'); ?></label></td>
|
102 |
</tr>
|
103 |
<tr valign="top" class="hidden js_sub ao_adv">
|
@@ -119,7 +119,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
119 |
<?php _e('Enable this to include small background-images in the CSS itself instead of as seperate downloads.','autoptimize'); ?></label></td>
|
120 |
</tr>
|
121 |
<tr valign="top" class="hidden css_sub ao_adv">
|
122 |
-
<th scope="row"><?php _e('Look for styles only in <head>?','autoptimize'); ?></th>
|
123 |
<td><label for="autoptimize_css_justhead"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
|
124 |
<?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
|
125 |
</tr>
|
@@ -183,6 +183,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
183 |
</form>
|
184 |
</div>
|
185 |
<div style="float:right;width:30%" id="autoptimize_admin_feed">
|
|
|
186 |
<div style="margin-left:10px;margin-top:-5px;">
|
187 |
<h3>
|
188 |
<?php _e("futtta about","autoptimize") ?>
|
@@ -219,6 +220,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
219 |
if (jQuery("#autoptimize_js").attr('checked')) {
|
220 |
jQuery(".js_sub:visible").fadeTo("fast",1);
|
221 |
}
|
|
|
222 |
jQuery( "input#autoptimize_show_adv" ).val("1");
|
223 |
});
|
224 |
|
@@ -232,6 +234,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
232 |
if (!jQuery("#autoptimize_js").attr('checked')) {
|
233 |
jQuery(".js_sub:visible").fadeTo("fast",.33);
|
234 |
}
|
|
|
235 |
jQuery( "input#autoptimize_show_adv" ).val("0");
|
236 |
});
|
237 |
|
@@ -378,7 +381,7 @@ if (get_option('autoptimize_show_adv','0')=='1') {
|
|
378 |
$config = array('autoptimize_html' => 0,
|
379 |
'autoptimize_html_keepcomments' => 0,
|
380 |
'autoptimize_js' => 0,
|
381 |
-
'autoptimize_js_exclude' => "s_sid, smowtion_size, sc_project, WAU_, wau_add, comment-form-quicktags, edToolbar, ch_client,
|
382 |
'autoptimize_js_trycatch' => 0,
|
383 |
'autoptimize_js_justhead' => 0,
|
384 |
'autoptimize_js_forcehead' => 0,
|
91 |
<?php _e('For performance reasons it is better to include JavaScript at the bottom of HTML, but this sometimes breaks things. Especially useful for jQuery-based themes.','autoptimize'); ?></label></td>
|
92 |
</tr>
|
93 |
<tr valign="top" class="hidden js_sub ao_adv">
|
94 |
+
<th scope="row"><?php _e('Look for scripts only in <head>?','autoptimize'); _e(' <i>(deprecated)</i>','autoptimize');?></th>
|
95 |
<td><label for="autoptimize_js_justhead"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
|
96 |
+
<?php _e('Mostly useful in combination with previous option when using jQuery-based templates, but might help keeping cache size under control.','autoptimize'); ?></label></td>
|
97 |
</tr>
|
98 |
<tr valign="top" class="hidden js_sub ao_adv">
|
99 |
<th scope="row"><?php _e('Exclude scripts from Autoptimize:','autoptimize'); ?></th>
|
100 |
+
<td><label for="autoptimize_js_exclude"><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude',"s_sid,smowtion_size,sc_project,WAU_,wau_add,comment-form-quicktags,edToolbar,ch_client,seal.js"); ?>"/><br />
|
101 |
<?php _e('A comma-seperated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated and minimized by Autoptimize.','autoptimize'); ?></label></td>
|
102 |
</tr>
|
103 |
<tr valign="top" class="hidden js_sub ao_adv">
|
119 |
<?php _e('Enable this to include small background-images in the CSS itself instead of as seperate downloads.','autoptimize'); ?></label></td>
|
120 |
</tr>
|
121 |
<tr valign="top" class="hidden css_sub ao_adv">
|
122 |
+
<th scope="row"><?php _e('Look for styles only in <head>?','autoptimize'); _e(' <i>(deprecated)</i>','autoptimize'); ?></th>
|
123 |
<td><label for="autoptimize_css_justhead"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
|
124 |
<?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
|
125 |
</tr>
|
183 |
</form>
|
184 |
</div>
|
185 |
<div style="float:right;width:30%" id="autoptimize_admin_feed">
|
186 |
+
<div style="margin:0px 15px 15px 15px;font-size:larger;"><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=futtta"><?php _e("Happy with Autoptimize? Try my other plugins!"); ?></a></div>
|
187 |
<div style="margin-left:10px;margin-top:-5px;">
|
188 |
<h3>
|
189 |
<?php _e("futtta about","autoptimize") ?>
|
220 |
if (jQuery("#autoptimize_js").attr('checked')) {
|
221 |
jQuery(".js_sub:visible").fadeTo("fast",1);
|
222 |
}
|
223 |
+
check_ini_state()
|
224 |
jQuery( "input#autoptimize_show_adv" ).val("1");
|
225 |
});
|
226 |
|
234 |
if (!jQuery("#autoptimize_js").attr('checked')) {
|
235 |
jQuery(".js_sub:visible").fadeTo("fast",.33);
|
236 |
}
|
237 |
+
check_ini_state()
|
238 |
jQuery( "input#autoptimize_show_adv" ).val("0");
|
239 |
});
|
240 |
|
381 |
$config = array('autoptimize_html' => 0,
|
382 |
'autoptimize_html_keepcomments' => 0,
|
383 |
'autoptimize_js' => 0,
|
384 |
+
'autoptimize_js_exclude' => "s_sid, smowtion_size, sc_project, WAU_, wau_add, comment-form-quicktags, edToolbar, ch_client, seal.js",
|
385 |
'autoptimize_js_trycatch' => 0,
|
386 |
'autoptimize_js_justhead' => 0,
|
387 |
'autoptimize_js_forcehead' => 0,
|
classes/autoptimizeHTML.php
CHANGED
@@ -4,22 +4,38 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
4 |
|
5 |
class autoptimizeHTML extends autoptimizeBase {
|
6 |
private $keepcomments = false;
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
{
|
11 |
-
//Remove the HTML comments?
|
12 |
$this->keepcomments = (bool) $options['keepcomments'];
|
13 |
|
14 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return true;
|
16 |
}
|
17 |
|
18 |
//Joins and optimizes CSS
|
19 |
-
public function minify()
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
// noptimize me
|
24 |
$this->content = $this->hide_noptimize($this->content);
|
25 |
|
@@ -36,23 +52,30 @@ class autoptimizeHTML extends autoptimizeBase {
|
|
36 |
|
37 |
// restore noptimize
|
38 |
$this->content = $this->restore_noptimize($this->content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
return true;
|
40 |
}
|
41 |
|
42 |
-
//Didn't minify :(
|
43 |
return false;
|
44 |
}
|
45 |
|
46 |
-
//Does nothing
|
47 |
-
public function cache()
|
48 |
-
{
|
49 |
//No cache for HTML
|
50 |
return true;
|
51 |
}
|
52 |
|
53 |
//Returns the content
|
54 |
-
public function getcontent()
|
55 |
-
{
|
56 |
return $this->content;
|
57 |
}
|
58 |
}
|
4 |
|
5 |
class autoptimizeHTML extends autoptimizeBase {
|
6 |
private $keepcomments = false;
|
7 |
+
private $exclude = array('<!-- ngg_resource_manager_marker -->');
|
8 |
|
9 |
+
public function read($options) {
|
10 |
+
// Remove the HTML comments?
|
|
|
|
|
11 |
$this->keepcomments = (bool) $options['keepcomments'];
|
12 |
|
13 |
+
// filter to add strings to be excluded from HTML minification
|
14 |
+
$excludeHTML = apply_filters( 'autoptimize_filter_html_exclude','' );
|
15 |
+
if ($excludeHTML!=="") {
|
16 |
+
$exclHTMLArr = array_filter(array_map('trim',explode(",",$excludeHTML)));
|
17 |
+
$this->exclude = array_merge($exclHTMLArr,$this->exclude);
|
18 |
+
}
|
19 |
+
|
20 |
+
// Nothing else for HTML
|
21 |
return true;
|
22 |
}
|
23 |
|
24 |
//Joins and optimizes CSS
|
25 |
+
public function minify() {
|
26 |
+
$noptimizeHTML = apply_filters( 'autoptimize_filter_html_noptimize', false, $this->content );
|
27 |
+
if ($noptimizeHTML)
|
28 |
+
return false;
|
29 |
+
|
30 |
+
if(class_exists('Minify_HTML')) {
|
31 |
+
// wrap the to-be-excluded strings in noptimize tags
|
32 |
+
foreach ($this->exclude as $exclString) {
|
33 |
+
if (strpos($this->content,$exclString)!==false) {
|
34 |
+
$replString="<!--noptimize-->".$exclString."<!--/noptimize-->";
|
35 |
+
$this->content=str_replace($exclString,$replString,$this->content);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
// noptimize me
|
40 |
$this->content = $this->hide_noptimize($this->content);
|
41 |
|
52 |
|
53 |
// restore noptimize
|
54 |
$this->content = $this->restore_noptimize($this->content);
|
55 |
+
|
56 |
+
// remove the noptimize-wrapper from around the excluded strings
|
57 |
+
foreach ($this->exclude as $exclString) {
|
58 |
+
$replString="<!--noptimize-->".$exclString."<!--/noptimize-->";
|
59 |
+
if (strpos($this->content,$replString)!==false) {
|
60 |
+
$this->content=str_replace($replString,$exclString,$this->content);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
return true;
|
65 |
}
|
66 |
|
67 |
+
// Didn't minify :(
|
68 |
return false;
|
69 |
}
|
70 |
|
71 |
+
// Does nothing
|
72 |
+
public function cache() {
|
|
|
73 |
//No cache for HTML
|
74 |
return true;
|
75 |
}
|
76 |
|
77 |
//Returns the content
|
78 |
+
public function getcontent() {
|
|
|
79 |
return $this->content;
|
80 |
}
|
81 |
}
|
classes/autoptimizeScripts.php
CHANGED
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
3 |
|
4 |
class autoptimizeScripts extends autoptimizeBase {
|
5 |
private $scripts = array();
|
6 |
-
private $dontmove = array('document.write','html5.js','show_ads.js','google_ad','blogcatalog.com/w','tweetmeme.com/i','mybloglog.com/','histats.com/js','ads.smowtion.com/ad.js','statcounter.com/counter/counter.js','widgets.amung.us','ws.amazon.com/widgets','media.fastclick.net','/ads/','comment-form-quicktags/quicktags.php','edToolbar','intensedebate.com','scripts.chitika.net/','_gaq.push','jotform.com/','admin-bar.min.js','GoogleAnalyticsObject','plupload.full.min.js','syntaxhighlighter','adsbygoogle','application/ld+json');
|
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;
|
@@ -15,9 +15,13 @@ class autoptimizeScripts extends autoptimizeBase {
|
|
15 |
private $restofcontent = '';
|
16 |
private $md5hash = '';
|
17 |
|
18 |
-
//Reads the page and collects script tags
|
19 |
public function read($options) {
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
if($options['justhead'] == true) {
|
22 |
$content = explode('</head>',$this->content,2);
|
23 |
$this->content = $content[0].'</head>';
|
3 |
|
4 |
class autoptimizeScripts extends autoptimizeBase {
|
5 |
private $scripts = array();
|
6 |
+
private $dontmove = array('document.write','html5.js','show_ads.js','google_ad','blogcatalog.com/w','tweetmeme.com/i','mybloglog.com/','histats.com/js','ads.smowtion.com/ad.js','statcounter.com/counter/counter.js','widgets.amung.us','ws.amazon.com/widgets','media.fastclick.net','/ads/','comment-form-quicktags/quicktags.php','edToolbar','intensedebate.com','scripts.chitika.net/','_gaq.push','jotform.com/','admin-bar.min.js','GoogleAnalyticsObject','plupload.full.min.js','syntaxhighlighter','adsbygoogle','application/ld+json','text/html','text/template','gist.github.com','wp-slimstat.min.js','_stq','nonce','post_id');
|
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;
|
15 |
private $restofcontent = '';
|
16 |
private $md5hash = '';
|
17 |
|
18 |
+
// Reads the page and collects script tags
|
19 |
public function read($options) {
|
20 |
+
$noptimizeJS = apply_filters( 'autoptimize_filter_js_noptimize', false, $this->content );
|
21 |
+
if ($noptimizeJS)
|
22 |
+
return false;
|
23 |
+
|
24 |
+
// Remove everything that's not the header
|
25 |
if($options['justhead'] == true) {
|
26 |
$content = explode('</head>',$this->content,2);
|
27 |
$this->content = $content[0].'</head>';
|
classes/autoptimizeStyles.php
CHANGED
@@ -10,9 +10,16 @@ class autoptimizeStyles extends autoptimizeBase {
|
|
10 |
private $datauris = false;
|
11 |
private $hashmap = array();
|
12 |
private $alreadyminified = false;
|
|
|
|
|
|
|
13 |
|
14 |
//Reads the page and collects style tags
|
15 |
public function read($options) {
|
|
|
|
|
|
|
|
|
16 |
// Remove everything that's not the header
|
17 |
if ($options['justhead'] == true) {
|
18 |
$content = explode('</head>',$this->content,2);
|
@@ -28,13 +35,18 @@ class autoptimizeStyles extends autoptimizeBase {
|
|
28 |
}
|
29 |
|
30 |
// should we defer css?
|
|
|
31 |
$this->defer = $options['defer'];
|
|
|
32 |
|
33 |
// should we inline while deferring?
|
|
|
34 |
$this->defer_inline = $options['defer_inline'];
|
35 |
|
36 |
// should we inline?
|
|
|
37 |
$this->inline = $options['inline'];
|
|
|
38 |
|
39 |
// get cdn url
|
40 |
$this->cdn_url = $options['cdn_url'];
|
@@ -270,6 +282,8 @@ class autoptimizeStyles extends autoptimizeBase {
|
|
270 |
if($icheck->check()) {
|
271 |
// we have the base64 image in cache
|
272 |
$headAndData=$icheck->retrieve();
|
|
|
|
|
273 |
} else {
|
274 |
// It's an image and we don't have it in cache, get the type
|
275 |
$explA=explode('.',$ipath);
|
@@ -310,6 +324,13 @@ class autoptimizeStyles extends autoptimizeBase {
|
|
310 |
// Store image on the mhtml document
|
311 |
$this->mhtml .= "--_\r\nContent-Location:{$mhtmlcount}\r\nContent-Transfer-Encoding:base64\r\n\r\n{$base64data}\r\n";
|
312 |
$mhtmlcount++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
}
|
314 |
}
|
315 |
} else if ((is_array($matches)) && (!empty($this->cdn_url))) {
|
@@ -326,7 +347,7 @@ class autoptimizeStyles extends autoptimizeBase {
|
|
326 |
}
|
327 |
|
328 |
// Minify
|
329 |
-
if (($this->
|
330 |
if (class_exists('Minify_CSS_Compressor')) {
|
331 |
$tmp_code = trim(Minify_CSS_Compressor::process($code));
|
332 |
} else if(class_exists('CSSmin')) {
|
@@ -334,15 +355,19 @@ class autoptimizeStyles extends autoptimizeBase {
|
|
334 |
if (method_exists($cssmin,"run")) {
|
335 |
$tmp_code = trim($cssmin->run($code));
|
336 |
} elseif (@is_callable(array($cssmin,"minify"))) {
|
337 |
-
$tmp_code = trim(CssMin::minify($code));
|
338 |
}
|
339 |
}
|
340 |
-
$tmp_code = apply_filters( 'autoptimize_css_after_minify',$tmp_code );
|
341 |
if (!empty($tmp_code)) {
|
342 |
$code = $tmp_code;
|
343 |
unset($tmp_code);
|
344 |
}
|
345 |
}
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
$this->hashmap[md5($code)] = $hash;
|
348 |
}
|
10 |
private $datauris = false;
|
11 |
private $hashmap = array();
|
12 |
private $alreadyminified = false;
|
13 |
+
private $inline = false;
|
14 |
+
private $defer = false;
|
15 |
+
private $defer_inline = false;
|
16 |
|
17 |
//Reads the page and collects style tags
|
18 |
public function read($options) {
|
19 |
+
$noptimizeCSS = apply_filters( 'autoptimize_filter_css_noptimize', false, $this->content );
|
20 |
+
if ($noptimizeCSS)
|
21 |
+
return false;
|
22 |
+
|
23 |
// Remove everything that's not the header
|
24 |
if ($options['justhead'] == true) {
|
25 |
$content = explode('</head>',$this->content,2);
|
35 |
}
|
36 |
|
37 |
// should we defer css?
|
38 |
+
// value: true/ false
|
39 |
$this->defer = $options['defer'];
|
40 |
+
$this->defer = apply_filters( 'autoptimize_filter_css_defer', $this->defer );
|
41 |
|
42 |
// should we inline while deferring?
|
43 |
+
// value: inlined CSS
|
44 |
$this->defer_inline = $options['defer_inline'];
|
45 |
|
46 |
// should we inline?
|
47 |
+
// value: true/ false
|
48 |
$this->inline = $options['inline'];
|
49 |
+
$this->inline = apply_filters( 'autoptimize_filter_css_inline', $this->inline );
|
50 |
|
51 |
// get cdn url
|
52 |
$this->cdn_url = $options['cdn_url'];
|
282 |
if($icheck->check()) {
|
283 |
// we have the base64 image in cache
|
284 |
$headAndData=$icheck->retrieve();
|
285 |
+
$_base64data=explode(";base64,",$headAndData);
|
286 |
+
$base64data=$_base64data[1];
|
287 |
} else {
|
288 |
// It's an image and we don't have it in cache, get the type
|
289 |
$explA=explode('.',$ipath);
|
324 |
// Store image on the mhtml document
|
325 |
$this->mhtml .= "--_\r\nContent-Location:{$mhtmlcount}\r\nContent-Transfer-Encoding:base64\r\n\r\n{$base64data}\r\n";
|
326 |
$mhtmlcount++;
|
327 |
+
} else {
|
328 |
+
// just cdn the URL if applicable
|
329 |
+
if (!empty($this->cdn_url)) {
|
330 |
+
$url = trim($quotedurl," \t\n\r\0\x0B\"'");
|
331 |
+
$cdn_url=$this->url_replace_cdn($url);
|
332 |
+
$imgreplace[$matches[1][$count]] = str_replace($quotedurl,$cdn_url,$matches[1][$count]);
|
333 |
+
}
|
334 |
}
|
335 |
}
|
336 |
} else if ((is_array($matches)) && (!empty($this->cdn_url))) {
|
347 |
}
|
348 |
|
349 |
// Minify
|
350 |
+
if (($this->alreadyminified!==true) && (apply_filters( "autoptimize_css_do_minify", true))) {
|
351 |
if (class_exists('Minify_CSS_Compressor')) {
|
352 |
$tmp_code = trim(Minify_CSS_Compressor::process($code));
|
353 |
} else if(class_exists('CSSmin')) {
|
355 |
if (method_exists($cssmin,"run")) {
|
356 |
$tmp_code = trim($cssmin->run($code));
|
357 |
} elseif (@is_callable(array($cssmin,"minify"))) {
|
358 |
+
$tmp_code = trim(CssMin::minify($code,false));
|
359 |
}
|
360 |
}
|
|
|
361 |
if (!empty($tmp_code)) {
|
362 |
$code = $tmp_code;
|
363 |
unset($tmp_code);
|
364 |
}
|
365 |
}
|
366 |
+
$tmp_code = apply_filters( 'autoptimize_css_after_minify',$code );
|
367 |
+
if (!empty($tmp_code)) {
|
368 |
+
$code = $tmp_code;
|
369 |
+
unset($tmp_code);
|
370 |
+
}
|
371 |
|
372 |
$this->hashmap[md5($code)] = $hash;
|
373 |
}
|
classes/external/php/minify-html.php
CHANGED
@@ -141,7 +141,7 @@ class Minify_HTML {
|
|
141 |
|
142 |
// remove ws around block/undisplayed elements
|
143 |
$this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
|
144 |
-
.'|caption|center|
|
145 |
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
|
146 |
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
|
147 |
.'|ul)\\b[^>]*>)/i', '$1', $this->_html);
|
141 |
|
142 |
// remove ws around block/undisplayed elements
|
143 |
$this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
|
144 |
+
.'|caption|center|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
|
145 |
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
|
146 |
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
|
147 |
.'|ul)\\b[^>]*>)/i', '$1', $this->_html);
|
classes/external/php/yui-php-cssmin-2.4.8-2_fgo.php
DELETED
@@ -1,777 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*!
|
4 |
-
* cssmin.php 2.4.8-2
|
5 |
-
* Author: Tubal Martin - http://tubalmartin.me/
|
6 |
-
* Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port
|
7 |
-
*
|
8 |
-
* This is a PHP port of the CSS minification tool distributed with YUICompressor,
|
9 |
-
* itself a port of the cssmin utility by Isaac Schlueter - http://foohack.com/
|
10 |
-
* Permission is hereby granted to use the PHP version under the same
|
11 |
-
* conditions as the YUICompressor.
|
12 |
-
*/
|
13 |
-
|
14 |
-
/*!
|
15 |
-
* YUI Compressor
|
16 |
-
* http://developer.yahoo.com/yui/compressor/
|
17 |
-
* Author: Julien Lecomte - http://www.julienlecomte.net/
|
18 |
-
* Copyright (c) 2013 Yahoo! Inc. All rights reserved.
|
19 |
-
* The copyrights embodied in the content of this file are licensed
|
20 |
-
* by Yahoo! Inc. under the BSD (revised) open source license.
|
21 |
-
*/
|
22 |
-
|
23 |
-
class CSSmin
|
24 |
-
{
|
25 |
-
const NL = '___YUICSSMIN_PRESERVED_NL___';
|
26 |
-
const TOKEN = '___YUICSSMIN_PRESERVED_TOKEN_';
|
27 |
-
const COMMENT = '___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_';
|
28 |
-
const CLASSCOLON = '___YUICSSMIN_PSEUDOCLASSCOLON___';
|
29 |
-
const QUERY_FRACTION = '___YUICSSMIN_QUERY_FRACTION___';
|
30 |
-
|
31 |
-
private $comments;
|
32 |
-
private $preserved_tokens;
|
33 |
-
private $memory_limit;
|
34 |
-
private $max_execution_time;
|
35 |
-
private $pcre_backtrack_limit;
|
36 |
-
private $pcre_recursion_limit;
|
37 |
-
private $raise_php_limits;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @param bool|int $raise_php_limits
|
41 |
-
* If true, PHP settings will be raised if needed
|
42 |
-
*/
|
43 |
-
public function __construct($raise_php_limits = TRUE)
|
44 |
-
{
|
45 |
-
// Set suggested PHP limits
|
46 |
-
$this->memory_limit = 128 * 1048576; // 128MB in bytes
|
47 |
-
$this->max_execution_time = 60; // 1 min
|
48 |
-
$this->pcre_backtrack_limit = 1000 * 1000;
|
49 |
-
$this->pcre_recursion_limit = 500 * 1000;
|
50 |
-
|
51 |
-
$this->raise_php_limits = (bool) $raise_php_limits;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Minify a string of CSS
|
56 |
-
* @param string $css
|
57 |
-
* @param int|bool $linebreak_pos
|
58 |
-
* @return string
|
59 |
-
*/
|
60 |
-
public function run($css = '', $linebreak_pos = FALSE)
|
61 |
-
{
|
62 |
-
if (empty($css)) {
|
63 |
-
return '';
|
64 |
-
}
|
65 |
-
|
66 |
-
if ($this->raise_php_limits) {
|
67 |
-
$this->do_raise_php_limits();
|
68 |
-
}
|
69 |
-
|
70 |
-
$this->comments = array();
|
71 |
-
$this->preserved_tokens = array();
|
72 |
-
|
73 |
-
$start_index = 0;
|
74 |
-
$length = strlen($css);
|
75 |
-
|
76 |
-
$css = $this->extract_data_urls($css);
|
77 |
-
|
78 |
-
// collect all comment blocks...
|
79 |
-
while (($start_index = $this->index_of($css, '/*', $start_index)) >= 0) {
|
80 |
-
$end_index = $this->index_of($css, '*/', $start_index + 2);
|
81 |
-
if ($end_index < 0) {
|
82 |
-
$end_index = $length;
|
83 |
-
}
|
84 |
-
$comment_found = $this->str_slice($css, $start_index + 2, $end_index);
|
85 |
-
$this->comments[] = $comment_found;
|
86 |
-
$comment_preserve_string = self::COMMENT . (count($this->comments) - 1) . '___';
|
87 |
-
$css = $this->str_slice($css, 0, $start_index + 2) . $comment_preserve_string . $this->str_slice($css, $end_index);
|
88 |
-
// Set correct start_index: Fixes issue #2528130
|
89 |
-
$start_index = $end_index + 2 + strlen($comment_preserve_string) - strlen($comment_found);
|
90 |
-
}
|
91 |
-
|
92 |
-
// preserve strings so their content doesn't get accidentally minified
|
93 |
-
$css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css);
|
94 |
-
|
95 |
-
// Let's divide css code in chunks of 5.000 chars aprox.
|
96 |
-
// Reason: PHP's PCRE functions like preg_replace have a "backtrack limit"
|
97 |
-
// of 100.000 chars by default (php < 5.3.7) so if we're dealing with really
|
98 |
-
// long strings and a (sub)pattern matches a number of chars greater than
|
99 |
-
// the backtrack limit number (i.e. /(.*)/s) PCRE functions may fail silently
|
100 |
-
// returning NULL and $css would be empty.
|
101 |
-
$charset = '';
|
102 |
-
$charset_regexp = '/(@charset)( [^;]+;)/i';
|
103 |
-
$css_chunks = array();
|
104 |
-
$css_chunk_length = 5000; // aprox size, not exact
|
105 |
-
$start_index = 0;
|
106 |
-
$i = $css_chunk_length; // save initial iterations
|
107 |
-
$l = strlen($css);
|
108 |
-
|
109 |
-
|
110 |
-
// if the number of characters is 25000 or less, do not chunk
|
111 |
-
if ($l <= $css_chunk_length) {
|
112 |
-
$css_chunks[] = $css;
|
113 |
-
} else {
|
114 |
-
// chunk css code securely
|
115 |
-
while ($i < $l) {
|
116 |
-
$i += 50; // save iterations
|
117 |
-
if ($l - $start_index <= $css_chunk_length || $i >= $l) {
|
118 |
-
$css_chunks[] = $this->str_slice($css, $start_index);
|
119 |
-
break;
|
120 |
-
}
|
121 |
-
if ($css[$i - 1] === '}' && $i - $start_index > $css_chunk_length) {
|
122 |
-
// If there are two ending curly braces }} separated or not by spaces,
|
123 |
-
// join them in the same chunk (i.e. @media blocks)
|
124 |
-
$next_chunk = substr($css, $i);
|
125 |
-
if (preg_match('/^\s*\}/', $next_chunk)) {
|
126 |
-
$i = $i + $this->index_of($next_chunk, '}') + 1;
|
127 |
-
}
|
128 |
-
|
129 |
-
$css_chunks[] = $this->str_slice($css, $start_index, $i);
|
130 |
-
$start_index = $i;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
// Minify each chunk
|
136 |
-
for ($i = 0, $n = count($css_chunks); $i < $n; $i++) {
|
137 |
-
$css_chunks[$i] = $this->minify($css_chunks[$i], $linebreak_pos);
|
138 |
-
// Keep the first @charset at-rule found
|
139 |
-
if (empty($charset) && preg_match($charset_regexp, $css_chunks[$i], $matches)) {
|
140 |
-
$charset = strtolower($matches[1]) . $matches[2];
|
141 |
-
}
|
142 |
-
// Delete all @charset at-rules
|
143 |
-
$css_chunks[$i] = preg_replace($charset_regexp, '', $css_chunks[$i]);
|
144 |
-
}
|
145 |
-
|
146 |
-
// Update the first chunk and push the charset to the top of the file.
|
147 |
-
$css_chunks[0] = $charset . $css_chunks[0];
|
148 |
-
|
149 |
-
return implode('', $css_chunks);
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Sets the memory limit for this script
|
154 |
-
* @param int|string $limit
|
155 |
-
*/
|
156 |
-
public function set_memory_limit($limit)
|
157 |
-
{
|
158 |
-
$this->memory_limit = $this->normalize_int($limit);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Sets the maximum execution time for this script
|
163 |
-
* @param int|string $seconds
|
164 |
-
*/
|
165 |
-
public function set_max_execution_time($seconds)
|
166 |
-
{
|
167 |
-
$this->max_execution_time = (int) $seconds;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Sets the PCRE backtrack limit for this script
|
172 |
-
* @param int $limit
|
173 |
-
*/
|
174 |
-
public function set_pcre_backtrack_limit($limit)
|
175 |
-
{
|
176 |
-
$this->pcre_backtrack_limit = (int) $limit;
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Sets the PCRE recursion limit for this script
|
181 |
-
* @param int $limit
|
182 |
-
*/
|
183 |
-
public function set_pcre_recursion_limit($limit)
|
184 |
-
{
|
185 |
-
$this->pcre_recursion_limit = (int) $limit;
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Try to configure PHP to use at least the suggested minimum settings
|
190 |
-
*/
|
191 |
-
private function do_raise_php_limits()
|
192 |
-
{
|
193 |
-
$php_limits = array(
|
194 |
-
'memory_limit' => $this->memory_limit,
|
195 |
-
'max_execution_time' => $this->max_execution_time,
|
196 |
-
'pcre.backtrack_limit' => $this->pcre_backtrack_limit,
|
197 |
-
'pcre.recursion_limit' => $this->pcre_recursion_limit
|
198 |
-
);
|
199 |
-
|
200 |
-
// If current settings are higher respect them.
|
201 |
-
foreach ($php_limits as $name => $suggested) {
|
202 |
-
$current = $this->normalize_int(ini_get($name));
|
203 |
-
// memory_limit exception: allow -1 for "no memory limit".
|
204 |
-
if ($current > -1 && ($suggested == -1 || $current < $suggested)) {
|
205 |
-
ini_set($name, $suggested);
|
206 |
-
}
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Does bulk of the minification
|
212 |
-
* @param string $css
|
213 |
-
* @param int|bool $linebreak_pos
|
214 |
-
* @return string
|
215 |
-
*/
|
216 |
-
private function minify($css, $linebreak_pos)
|
217 |
-
{
|
218 |
-
// strings are safe, now wrestle the comments
|
219 |
-
for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
|
220 |
-
|
221 |
-
$token = $this->comments[$i];
|
222 |
-
$placeholder = '/' . self::COMMENT . $i . '___/';
|
223 |
-
|
224 |
-
// ! in the first position of the comment means preserve
|
225 |
-
// so push to the preserved tokens keeping the !
|
226 |
-
if (substr($token, 0, 1) === '!') {
|
227 |
-
$this->preserved_tokens[] = $token;
|
228 |
-
$token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
|
229 |
-
$css = preg_replace($placeholder, $token_tring, $css, 1);
|
230 |
-
// Preserve new lines for /*! important comments
|
231 |
-
$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css);
|
232 |
-
$css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/', '$1'.self::NL, $css);
|
233 |
-
continue;
|
234 |
-
}
|
235 |
-
|
236 |
-
// \ in the last position looks like hack for Mac/IE5
|
237 |
-
// shorten that to /*\*/ and the next one to /**/
|
238 |
-
if (substr($token, (strlen($token) - 1), 1) === '\\') {
|
239 |
-
$this->preserved_tokens[] = '\\';
|
240 |
-
$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
241 |
-
$i = $i + 1; // attn: advancing the loop
|
242 |
-
$this->preserved_tokens[] = '';
|
243 |
-
$css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
244 |
-
continue;
|
245 |
-
}
|
246 |
-
|
247 |
-
// keep empty comments after child selectors (IE7 hack)
|
248 |
-
// e.g. html >/**/ body
|
249 |
-
if (strlen($token) === 0) {
|
250 |
-
$start_index = $this->index_of($css, $this->str_slice($placeholder, 1, -1));
|
251 |
-
if ($start_index > 2) {
|
252 |
-
if (substr($css, $start_index - 3, 1) === '>') {
|
253 |
-
$this->preserved_tokens[] = '';
|
254 |
-
$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
// in all other cases kill the comment
|
260 |
-
$css = preg_replace('/\/\*' . $this->str_slice($placeholder, 1, -1) . '\*\//', '', $css, 1);
|
261 |
-
}
|
262 |
-
|
263 |
-
|
264 |
-
// Normalize all whitespace strings to single spaces. Easier to work with that way.
|
265 |
-
$css = preg_replace('/\s+/', ' ', $css);
|
266 |
-
|
267 |
-
// Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters
|
268 |
-
$css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css);
|
269 |
-
|
270 |
-
// Shorten & preserve calculations calc(...) since spaces are important
|
271 |
-
$css = preg_replace_callback('/calc(\(((?:[^\(\)]+|(?1))*)\))/i', array($this, 'replace_calc'), $css);
|
272 |
-
|
273 |
-
// Replace positive sign from numbers preceded by : or a white-space before the leading space is removed
|
274 |
-
// +1.2em to 1.2em, +.8px to .8px, +2% to 2%
|
275 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)\+(\.?\d+)/S', '$1$2', $css);
|
276 |
-
|
277 |
-
// Remove leading zeros from integer and float numbers preceded by : or a white-space
|
278 |
-
// 000.6 to .6, -0.8 to -.8, 0050 to 50, -01.05 to -1.05
|
279 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?)0+(\.?\d+)/S', '$1$2$3', $css);
|
280 |
-
|
281 |
-
// Remove trailing zeros from float numbers preceded by : or a white-space
|
282 |
-
// -6.0100em to -6.01em, .0100 to .01, 1.200px to 1.2px
|
283 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?)(\d?\.\d+?)0+([^\d])/S', '$1$2$3$4', $css);
|
284 |
-
|
285 |
-
// Remove trailing .0 -> -9.0 to -9
|
286 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?\d+)\.0([^\d])/S', '$1$2$3', $css);
|
287 |
-
|
288 |
-
// Replace 0 length numbers with 0
|
289 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)\-?\.?0+([^\d])/S', '${1}0$2', $css);
|
290 |
-
|
291 |
-
// Remove the spaces before the things that should not have spaces before them.
|
292 |
-
// But, be careful not to turn "p :link {...}" into "p:link{...}"
|
293 |
-
// Swap out any pseudo-class colons with the token, and then swap back.
|
294 |
-
// fgo; simpler regex to avoid stack overflow in PCRE, cfr. https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/issues/11
|
295 |
-
// $css = preg_replace_callback('/(?:^|\})(?:(?:[^\{\:])+\:)+(?:[^\{]*\{)/', array($this, 'replace_colon'), $css);
|
296 |
-
$css = preg_replace_callback('/(?:(?:^|\})([^\{]*\s:))/', array($this, 'replace_colon'), $css);
|
297 |
-
|
298 |
-
// Remove spaces before the things that should not have spaces before them.
|
299 |
-
$css = preg_replace('/\s+([\!\{\}\;\:\>\+\(\)\]\~\=,])/', '$1', $css);
|
300 |
-
|
301 |
-
// Restore spaces for !important
|
302 |
-
$css = preg_replace('/\!important/i', ' !important', $css);
|
303 |
-
|
304 |
-
// bring back the colon
|
305 |
-
$css = preg_replace('/' . self::CLASSCOLON . '/', ':', $css);
|
306 |
-
|
307 |
-
// retain space for special IE6 cases
|
308 |
-
$css = preg_replace_callback('/\:first\-(line|letter)(\{|,)/i', array($this, 'lowercase_pseudo_first'), $css);
|
309 |
-
|
310 |
-
// no space after the end of a preserved comment
|
311 |
-
$css = preg_replace('/\*\/ /', '*/', $css);
|
312 |
-
|
313 |
-
// lowercase some popular @directives
|
314 |
-
$css = preg_replace_callback('/@(font-face|import|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?keyframe|media|page|namespace)/i', array($this, 'lowercase_directives'), $css);
|
315 |
-
|
316 |
-
// lowercase some more common pseudo-elements
|
317 |
-
$css = preg_replace_callback('/:(active|after|before|checked|disabled|empty|enabled|first-(?:child|of-type)|focus|hover|last-(?:child|of-type)|link|only-(?:child|of-type)|root|:selection|target|visited)/i', array($this, 'lowercase_pseudo_elements'), $css);
|
318 |
-
|
319 |
-
// lowercase some more common functions
|
320 |
-
$css = preg_replace_callback('/:(lang|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|(?:-(?:moz|webkit)-)?any)\(/i', array($this, 'lowercase_common_functions'), $css);
|
321 |
-
|
322 |
-
// lower case some common function that can be values
|
323 |
-
// NOTE: rgb() isn't useful as we replace with #hex later, as well as and() is already done for us
|
324 |
-
$css = preg_replace_callback('/([:,\( ]\s*)(attr|color-stop|from|rgba|to|url|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?(?:calc|max|min|(?:repeating-)?(?:linear|radial)-gradient)|-webkit-gradient)/iS', array($this, 'lowercase_common_functions_values'), $css);
|
325 |
-
|
326 |
-
// Put the space back in some cases, to support stuff like
|
327 |
-
// @media screen and (-webkit-min-device-pixel-ratio:0){
|
328 |
-
$css = preg_replace('/\band\(/i', 'and (', $css);
|
329 |
-
|
330 |
-
// Remove the spaces after the things that should not have spaces after them.
|
331 |
-
$css = preg_replace('/([\!\{\}\:;\>\+\(\[\~\=,])\s+/S', '$1', $css);
|
332 |
-
|
333 |
-
// remove unnecessary semicolons
|
334 |
-
$css = preg_replace('/;+\}/', '}', $css);
|
335 |
-
|
336 |
-
// Fix for issue: #2528146
|
337 |
-
// Restore semicolon if the last property is prefixed with a `*` (lte IE7 hack)
|
338 |
-
// to avoid issues on Symbian S60 3.x browsers.
|
339 |
-
$css = preg_replace('/(\*[a-z0-9\-]+\s*\:[^;\}]+)(\})/', '$1;$2', $css);
|
340 |
-
|
341 |
-
// Replace 0 length units 0(px,em,%) with 0.
|
342 |
-
$css = preg_replace('/(^|[^0-9])(?:0?\.)?0(?:em|ex|ch|rem|vw|vh|vm|vmin|cm|mm|in|px|pt|pc|%|deg|g?rad|m?s|k?hz)/iS', '${1}0', $css);
|
343 |
-
|
344 |
-
// 0% step in a keyframe? restore the % unit
|
345 |
-
$css = preg_replace_callback('/(@[a-z\-]*?keyframes[^\{]*?\{)(.*?\}\s*\})/iS', array($this, 'replace_keyframe_zero'), $css);
|
346 |
-
|
347 |
-
// Replace 0 0; or 0 0 0; or 0 0 0 0; with 0.
|
348 |
-
$css = preg_replace('/\:0(?: 0){1,3}(;|\}| \!)/', ':0$1', $css);
|
349 |
-
|
350 |
-
// Fix for issue: #2528142
|
351 |
-
// Replace text-shadow:0; with text-shadow:0 0 0;
|
352 |
-
$css = preg_replace('/(text-shadow\:0)(;|\}| \!)/i', '$1 0 0$2', $css);
|
353 |
-
|
354 |
-
// Replace background-position:0; with background-position:0 0;
|
355 |
-
// same for transform-origin
|
356 |
-
// Changing -webkit-mask-position: 0 0 to just a single 0 will result in the second parameter defaulting to 50% (center)
|
357 |
-
$css = preg_replace('/(background\-position|webkit-mask-position|(?:webkit|moz|o|ms|)\-?transform\-origin)\:0(;|\}| \!)/iS', '$1:0 0$2', $css);
|
358 |
-
|
359 |
-
// Shorten colors from rgb(51,102,153) to #336699, rgb(100%,0%,0%) to #ff0000 (sRGB color space)
|
360 |
-
// Shorten colors from hsl(0, 100%, 50%) to #ff0000 (sRGB color space)
|
361 |
-
// This makes it more likely that it'll get further compressed in the next step.
|
362 |
-
$css = preg_replace_callback('/rgb\s*\(\s*([0-9,\s\-\.\%]+)\s*\)(.{1})/i', array($this, 'rgb_to_hex'), $css);
|
363 |
-
$css = preg_replace_callback('/hsl\s*\(\s*([0-9,\s\-\.\%]+)\s*\)(.{1})/i', array($this, 'hsl_to_hex'), $css);
|
364 |
-
|
365 |
-
// Shorten colors from #AABBCC to #ABC or short color name.
|
366 |
-
$css = $this->compress_hex_colors($css);
|
367 |
-
|
368 |
-
// border: none to border:0, outline: none to outline:0
|
369 |
-
$css = preg_replace('/(border\-?(?:top|right|bottom|left|)|outline)\:none(;|\}| \!)/iS', '$1:0$2', $css);
|
370 |
-
|
371 |
-
// shorter opacity IE filter
|
372 |
-
$css = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $css);
|
373 |
-
|
374 |
-
// Find a fraction that is used for Opera's -o-device-pixel-ratio query
|
375 |
-
// Add token to add the "\" back in later
|
376 |
-
$css = preg_replace('/\(([a-z\-]+):([0-9]+)\/([0-9]+)\)/i', '($1:$2'. self::QUERY_FRACTION .'$3)', $css);
|
377 |
-
|
378 |
-
// Remove empty rules.
|
379 |
-
$css = preg_replace('/[^\};\{\/]+\{\}/S', '', $css);
|
380 |
-
|
381 |
-
// Add "/" back to fix Opera -o-device-pixel-ratio query
|
382 |
-
$css = preg_replace('/'. self::QUERY_FRACTION .'/', '/', $css);
|
383 |
-
|
384 |
-
// Replace multiple semi-colons in a row by a single one
|
385 |
-
// See SF bug #1980989
|
386 |
-
$css = preg_replace('/;;+/', ';', $css);
|
387 |
-
|
388 |
-
// Restore new lines for /*! important comments
|
389 |
-
$css = preg_replace('/'. self::NL .'/', "\n", $css);
|
390 |
-
|
391 |
-
// Lowercase all uppercase properties
|
392 |
-
$css = preg_replace_callback('/(\{|\;)([A-Z\-]+)(\:)/', array($this, 'lowercase_properties'), $css);
|
393 |
-
|
394 |
-
// Some source control tools don't like it when files containing lines longer
|
395 |
-
// than, say 8000 characters, are checked in. The linebreak option is used in
|
396 |
-
// that case to split long lines after a specific column.
|
397 |
-
if ($linebreak_pos !== FALSE && (int) $linebreak_pos >= 0) {
|
398 |
-
$linebreak_pos = (int) $linebreak_pos;
|
399 |
-
$start_index = $i = 0;
|
400 |
-
while ($i < strlen($css)) {
|
401 |
-
$i++;
|
402 |
-
if ($css[$i - 1] === '}' && $i - $start_index > $linebreak_pos) {
|
403 |
-
$css = $this->str_slice($css, 0, $i) . "\n" . $this->str_slice($css, $i);
|
404 |
-
$start_index = $i;
|
405 |
-
}
|
406 |
-
}
|
407 |
-
}
|
408 |
-
|
409 |
-
// restore preserved comments and strings in reverse order
|
410 |
-
for ($i = count($this->preserved_tokens) - 1; $i >= 0; $i--) {
|
411 |
-
$css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1);
|
412 |
-
}
|
413 |
-
|
414 |
-
// Trim the final string (for any leading or trailing white spaces)
|
415 |
-
return trim($css);
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Utility method to replace all data urls with tokens before we start
|
420 |
-
* compressing, to avoid performance issues running some of the subsequent
|
421 |
-
* regexes against large strings chunks.
|
422 |
-
*
|
423 |
-
* @param string $css
|
424 |
-
* @return string
|
425 |
-
*/
|
426 |
-
private function extract_data_urls($css)
|
427 |
-
{
|
428 |
-
// Leave data urls alone to increase parse performance.
|
429 |
-
$max_index = strlen($css) - 1;
|
430 |
-
$append_index = $index = $last_index = $offset = 0;
|
431 |
-
$sb = array();
|
432 |
-
$pattern = '/url\(\s*(["\']?)data\:/i';
|
433 |
-
|
434 |
-
// Since we need to account for non-base64 data urls, we need to handle
|
435 |
-
// ' and ) being part of the data string. Hence switching to indexOf,
|
436 |
-
// to determine whether or not we have matching string terminators and
|
437 |
-
// handling sb appends directly, instead of using matcher.append* methods.
|
438 |
-
|
439 |
-
while (preg_match($pattern, $css, $m, 0, $offset)) {
|
440 |
-
$index = $this->index_of($css, $m[0], $offset);
|
441 |
-
$last_index = $index + strlen($m[0]);
|
442 |
-
$start_index = $index + 4; // "url(".length()
|
443 |
-
$end_index = $last_index - 1;
|
444 |
-
$terminator = $m[1]; // ', " or empty (not quoted)
|
445 |
-
$found_terminator = FALSE;
|
446 |
-
|
447 |
-
if (strlen($terminator) === 0) {
|
448 |
-
$terminator = ')';
|
449 |
-
}
|
450 |
-
|
451 |
-
while ($found_terminator === FALSE && $end_index+1 <= $max_index) {
|
452 |
-
$end_index = $this->index_of($css, $terminator, $end_index + 1);
|
453 |
-
|
454 |
-
// endIndex == 0 doesn't really apply here
|
455 |
-
if ($end_index > 0 && substr($css, $end_index - 1, 1) !== '\\') {
|
456 |
-
$found_terminator = TRUE;
|
457 |
-
if (')' != $terminator) {
|
458 |
-
$end_index = $this->index_of($css, ')', $end_index);
|
459 |
-
}
|
460 |
-
}
|
461 |
-
}
|
462 |
-
|
463 |
-
// Enough searching, start moving stuff over to the buffer
|
464 |
-
$sb[] = $this->str_slice($css, $append_index, $index);
|
465 |
-
|
466 |
-
if ($found_terminator) {
|
467 |
-
$token = $this->str_slice($css, $start_index, $end_index);
|
468 |
-
$token = preg_replace('/\s+/', '', $token);
|
469 |
-
$this->preserved_tokens[] = $token;
|
470 |
-
|
471 |
-
$preserver = 'url(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___)';
|
472 |
-
$sb[] = $preserver;
|
473 |
-
|
474 |
-
$append_index = $end_index + 1;
|
475 |
-
} else {
|
476 |
-
// No end terminator found, re-add the whole match. Should we throw/warn here?
|
477 |
-
$sb[] = $this->str_slice($css, $index, $last_index);
|
478 |
-
$append_index = $last_index;
|
479 |
-
}
|
480 |
-
|
481 |
-
$offset = $last_index;
|
482 |
-
}
|
483 |
-
|
484 |
-
$sb[] = $this->str_slice($css, $append_index);
|
485 |
-
|
486 |
-
return implode('', $sb);
|
487 |
-
}
|
488 |
-
|
489 |
-
/**
|
490 |
-
* Utility method to compress hex color values of the form #AABBCC to #ABC or short color name.
|
491 |
-
*
|
492 |
-
* DOES NOT compress CSS ID selectors which match the above pattern (which would break things).
|
493 |
-
* e.g. #AddressForm { ... }
|
494 |
-
*
|
495 |
-
* DOES NOT compress IE filters, which have hex color values (which would break things).
|
496 |
-
* e.g. filter: chroma(color="#FFFFFF");
|
497 |
-
*
|
498 |
-
* DOES NOT compress invalid hex values.
|
499 |
-
* e.g. background-color: #aabbccdd
|
500 |
-
*
|
501 |
-
* @param string $css
|
502 |
-
* @return string
|
503 |
-
*/
|
504 |
-
private function compress_hex_colors($css)
|
505 |
-
{
|
506 |
-
// Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters)
|
507 |
-
$pattern = '/(\=\s*?["\']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/iS';
|
508 |
-
$_index = $index = $last_index = $offset = 0;
|
509 |
-
$sb = array();
|
510 |
-
// See: http://ajaxmin.codeplex.com/wikipage?title=CSS%20Colors
|
511 |
-
$short_safe = array(
|
512 |
-
'#808080' => 'gray',
|
513 |
-
'#008000' => 'green',
|
514 |
-
'#800000' => 'maroon',
|
515 |
-
'#000080' => 'navy',
|
516 |
-
'#808000' => 'olive',
|
517 |
-
'#ffa500' => 'orange',
|
518 |
-
'#800080' => 'purple',
|
519 |
-
'#c0c0c0' => 'silver',
|
520 |
-
'#008080' => 'teal',
|
521 |
-
'#f00' => 'red'
|
522 |
-
);
|
523 |
-
|
524 |
-
while (preg_match($pattern, $css, $m, 0, $offset)) {
|
525 |
-
$index = $this->index_of($css, $m[0], $offset);
|
526 |
-
$last_index = $index + strlen($m[0]);
|
527 |
-
$is_filter = $m[1] !== null && $m[1] !== '';
|
528 |
-
|
529 |
-
$sb[] = $this->str_slice($css, $_index, $index);
|
530 |
-
|
531 |
-
if ($is_filter) {
|
532 |
-
// Restore, maintain case, otherwise filter will break
|
533 |
-
$sb[] = $m[1] . '#' . $m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7];
|
534 |
-
} else {
|
535 |
-
if (strtolower($m[2]) == strtolower($m[3]) &&
|
536 |
-
strtolower($m[4]) == strtolower($m[5]) &&
|
537 |
-
strtolower($m[6]) == strtolower($m[7])) {
|
538 |
-
// Compress.
|
539 |
-
$hex = '#' . strtolower($m[3] . $m[5] . $m[7]);
|
540 |
-
} else {
|
541 |
-
// Non compressible color, restore but lower case.
|
542 |
-
$hex = '#' . strtolower($m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]);
|
543 |
-
}
|
544 |
-
// replace Hex colors to short safe color names
|
545 |
-
$sb[] = array_key_exists($hex, $short_safe) ? $short_safe[$hex] : $hex;
|
546 |
-
}
|
547 |
-
|
548 |
-
$_index = $offset = $last_index - strlen($m[8]);
|
549 |
-
}
|
550 |
-
|
551 |
-
$sb[] = $this->str_slice($css, $_index);
|
552 |
-
|
553 |
-
return implode('', $sb);
|
554 |
-
}
|
555 |
-
|
556 |
-
/* CALLBACKS
|
557 |
-
* ---------------------------------------------------------------------------------------------
|
558 |
-
*/
|
559 |
-
|
560 |
-
private function replace_string($matches)
|
561 |
-
{
|
562 |
-
$match = $matches[0];
|
563 |
-
$quote = substr($match, 0, 1);
|
564 |
-
// Must use addcslashes in PHP to avoid parsing of backslashes
|
565 |
-
$match = addcslashes($this->str_slice($match, 1, -1), '\\');
|
566 |
-
|
567 |
-
// maybe the string contains a comment-like substring?
|
568 |
-
// one, maybe more? put'em back then
|
569 |
-
if (($pos = $this->index_of($match, self::COMMENT)) >= 0) {
|
570 |
-
for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
|
571 |
-
$match = preg_replace('/' . self::COMMENT . $i . '___/', $this->comments[$i], $match, 1);
|
572 |
-
}
|
573 |
-
}
|
574 |
-
|
575 |
-
// minify alpha opacity in filter strings
|
576 |
-
$match = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $match);
|
577 |
-
|
578 |
-
$this->preserved_tokens[] = $match;
|
579 |
-
return $quote . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . $quote;
|
580 |
-
}
|
581 |
-
|
582 |
-
private function replace_colon($matches)
|
583 |
-
{
|
584 |
-
return preg_replace('/\:/', self::CLASSCOLON, $matches[0]);
|
585 |
-
}
|
586 |
-
|
587 |
-
private function replace_calc($matches)
|
588 |
-
{
|
589 |
-
$this->preserved_tokens[] = trim(preg_replace('/\s*([\*\/\(\),])\s*/', '$1', $matches[2]));
|
590 |
-
return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
|
591 |
-
}
|
592 |
-
|
593 |
-
private function preserve_old_IE_specific_matrix_definition($matches)
|
594 |
-
{
|
595 |
-
$this->preserved_tokens[] = $matches[1];
|
596 |
-
return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
|
597 |
-
}
|
598 |
-
|
599 |
-
private function replace_keyframe_zero($matches)
|
600 |
-
{
|
601 |
-
return $matches[1] . preg_replace('/0\s*,/', '0%,', preg_replace('/\s*0\s*\{/', '0%{', $matches[2]));
|
602 |
-
}
|
603 |
-
|
604 |
-
private function rgb_to_hex($matches)
|
605 |
-
{
|
606 |
-
// Support for percentage values rgb(100%, 0%, 45%);
|
607 |
-
if ($this->index_of($matches[1], '%') >= 0){
|
608 |
-
$rgbcolors = explode(',', str_replace('%', '', $matches[1]));
|
609 |
-
for ($i = 0; $i < count($rgbcolors); $i++) {
|
610 |
-
$rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55);
|
611 |
-
}
|
612 |
-
} else {
|
613 |
-
$rgbcolors = explode(',', $matches[1]);
|
614 |
-
}
|
615 |
-
|
616 |
-
// Values outside the sRGB color space should be clipped (0-255)
|
617 |
-
for ($i = 0; $i < count($rgbcolors); $i++) {
|
618 |
-
$rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255);
|
619 |
-
$rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]);
|
620 |
-
}
|
621 |
-
|
622 |
-
// Fix for issue #2528093
|
623 |
-
if (!preg_match('/[\s\,\);\}]/', $matches[2])){
|
624 |
-
$matches[2] = ' ' . $matches[2];
|
625 |
-
}
|
626 |
-
|
627 |
-
return '#' . implode('', $rgbcolors) . $matches[2];
|
628 |
-
}
|
629 |
-
|
630 |
-
private function hsl_to_hex($matches)
|
631 |
-
{
|
632 |
-
$values = explode(',', str_replace('%', '', $matches[1]));
|
633 |
-
$h = floatval($values[0]);
|
634 |
-
$s = floatval($values[1]);
|
635 |
-
$l = floatval($values[2]);
|
636 |
-
|
637 |
-
// Wrap and clamp, then fraction!
|
638 |
-
$h = ((($h % 360) + 360) % 360) / 360;
|
639 |
-
$s = $this->clamp_number($s, 0, 100) / 100;
|
640 |
-
$l = $this->clamp_number($l, 0, 100) / 100;
|
641 |
-
|
642 |
-
if ($s == 0) {
|
643 |
-
$r = $g = $b = $this->round_number(255 * $l);
|
644 |
-
} else {
|
645 |
-
$v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
|
646 |
-
$v1 = (2 * $l) - $v2;
|
647 |
-
$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3)));
|
648 |
-
$g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h));
|
649 |
-
$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3)));
|
650 |
-
}
|
651 |
-
|
652 |
-
return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2]));
|
653 |
-
}
|
654 |
-
|
655 |
-
private function lowercase_pseudo_first($matches)
|
656 |
-
{
|
657 |
-
return ':first-'. strtolower($matches[1]) .' '. $matches[2];
|
658 |
-
}
|
659 |
-
|
660 |
-
private function lowercase_directives($matches)
|
661 |
-
{
|
662 |
-
return '@'. strtolower($matches[1]);
|
663 |
-
}
|
664 |
-
|
665 |
-
private function lowercase_pseudo_elements($matches)
|
666 |
-
{
|
667 |
-
return ':'. strtolower($matches[1]);
|
668 |
-
}
|
669 |
-
|
670 |
-
private function lowercase_common_functions($matches)
|
671 |
-
{
|
672 |
-
return ':'. strtolower($matches[1]) .'(';
|
673 |
-
}
|
674 |
-
|
675 |
-
private function lowercase_common_functions_values($matches)
|
676 |
-
{
|
677 |
-
return $matches[1] . strtolower($matches[2]);
|
678 |
-
}
|
679 |
-
|
680 |
-
private function lowercase_properties($matches)
|
681 |
-
{
|
682 |
-
return $matches[1].strtolower($matches[2]).$matches[3];
|
683 |
-
}
|
684 |
-
|
685 |
-
/* HELPERS
|
686 |
-
* ---------------------------------------------------------------------------------------------
|
687 |
-
*/
|
688 |
-
|
689 |
-
private function hue_to_rgb($v1, $v2, $vh)
|
690 |
-
{
|
691 |
-
$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
|
692 |
-
if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
|
693 |
-
if ($vh * 2 < 1) return $v2;
|
694 |
-
if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
|
695 |
-
return $v1;
|
696 |
-
}
|
697 |
-
|
698 |
-
private function round_number($n)
|
699 |
-
{
|
700 |
-
return intval(floor(floatval($n) + 0.5), 10);
|
701 |
-
}
|
702 |
-
|
703 |
-
private function clamp_number($n, $min, $max)
|
704 |
-
{
|
705 |
-
return min(max($n, $min), $max);
|
706 |
-
}
|
707 |
-
|
708 |
-
/**
|
709 |
-
* PHP port of Javascript's "indexOf" function for strings only
|
710 |
-
* Author: Tubal Martin http://blog.margenn.com
|
711 |
-
*
|
712 |
-
* @param string $haystack
|
713 |
-
* @param string $needle
|
714 |
-
* @param int $offset index (optional)
|
715 |
-
* @return int
|
716 |
-
*/
|
717 |
-
private function index_of($haystack, $needle, $offset = 0)
|
718 |
-
{
|
719 |
-
$index = strpos($haystack, $needle, $offset);
|
720 |
-
|
721 |
-
return ($index !== FALSE) ? $index : -1;
|
722 |
-
}
|
723 |
-
|
724 |
-
/**
|
725 |
-
* PHP port of Javascript's "slice" function for strings only
|
726 |
-
* Author: Tubal Martin http://blog.margenn.com
|
727 |
-
* Tests: http://margenn.com/tubal/str_slice/
|
728 |
-
*
|
729 |
-
* @param string $str
|
730 |
-
* @param int $start index
|
731 |
-
* @param int|bool $end index (optional)
|
732 |
-
* @return string
|
733 |
-
*/
|
734 |
-
private function str_slice($str, $start = 0, $end = FALSE)
|
735 |
-
{
|
736 |
-
if ($end !== FALSE && ($start < 0 || $end <= 0)) {
|
737 |
-
$max = strlen($str);
|
738 |
-
|
739 |
-
if ($start < 0) {
|
740 |
-
if (($start = $max + $start) < 0) {
|
741 |
-
return '';
|
742 |
-
}
|
743 |
-
}
|
744 |
-
|
745 |
-
if ($end < 0) {
|
746 |
-
if (($end = $max + $end) < 0) {
|
747 |
-
return '';
|
748 |
-
}
|
749 |
-
}
|
750 |
-
|
751 |
-
if ($end <= $start) {
|
752 |
-
return '';
|
753 |
-
}
|
754 |
-
}
|
755 |
-
|
756 |
-
$slice = ($end === FALSE) ? substr($str, $start) : substr($str, $start, $end - $start);
|
757 |
-
return ($slice === FALSE) ? '' : $slice;
|
758 |
-
}
|
759 |
-
|
760 |
-
/**
|
761 |
-
* Convert strings like "64M" or "30" to int values
|
762 |
-
* @param mixed $size
|
763 |
-
* @return int
|
764 |
-
*/
|
765 |
-
private function normalize_int($size)
|
766 |
-
{
|
767 |
-
if (is_string($size)) {
|
768 |
-
switch (substr($size, -1)) {
|
769 |
-
case 'M': case 'm': return $size * 1048576;
|
770 |
-
case 'K': case 'k': return $size * 1024;
|
771 |
-
case 'G': case 'g': return $size * 1073741824;
|
772 |
-
}
|
773 |
-
}
|
774 |
-
|
775 |
-
return (int) $size;
|
776 |
-
}
|
777 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/external/php/yui-php-cssmin-2.4.8-3.php
DELETED
@@ -1,777 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*!
|
4 |
-
* cssmin.php 2.4.8-3
|
5 |
-
* Author: Tubal Martin - http://tubalmartin.me/
|
6 |
-
* Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port
|
7 |
-
*
|
8 |
-
* This is a PHP port of the CSS minification tool distributed with YUICompressor,
|
9 |
-
* itself a port of the cssmin utility by Isaac Schlueter - http://foohack.com/
|
10 |
-
* Permission is hereby granted to use the PHP version under the same
|
11 |
-
* conditions as the YUICompressor.
|
12 |
-
*/
|
13 |
-
|
14 |
-
/*!
|
15 |
-
* YUI Compressor
|
16 |
-
* http://developer.yahoo.com/yui/compressor/
|
17 |
-
* Author: Julien Lecomte - http://www.julienlecomte.net/
|
18 |
-
* Copyright (c) 2013 Yahoo! Inc. All rights reserved.
|
19 |
-
* The copyrights embodied in the content of this file are licensed
|
20 |
-
* by Yahoo! Inc. under the BSD (revised) open source license.
|
21 |
-
*/
|
22 |
-
|
23 |
-
class CSSmin
|
24 |
-
{
|
25 |
-
const NL = '___YUICSSMIN_PRESERVED_NL___';
|
26 |
-
const TOKEN = '___YUICSSMIN_PRESERVED_TOKEN_';
|
27 |
-
const COMMENT = '___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_';
|
28 |
-
const CLASSCOLON = '___YUICSSMIN_PSEUDOCLASSCOLON___';
|
29 |
-
const QUERY_FRACTION = '___YUICSSMIN_QUERY_FRACTION___';
|
30 |
-
|
31 |
-
private $comments;
|
32 |
-
private $preserved_tokens;
|
33 |
-
private $memory_limit;
|
34 |
-
private $max_execution_time;
|
35 |
-
private $pcre_backtrack_limit;
|
36 |
-
private $pcre_recursion_limit;
|
37 |
-
private $raise_php_limits;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @param bool|int $raise_php_limits
|
41 |
-
* If true, PHP settings will be raised if needed
|
42 |
-
*/
|
43 |
-
public function __construct($raise_php_limits = TRUE)
|
44 |
-
{
|
45 |
-
// Set suggested PHP limits
|
46 |
-
$this->memory_limit = 128 * 1048576; // 128MB in bytes
|
47 |
-
$this->max_execution_time = 60; // 1 min
|
48 |
-
$this->pcre_backtrack_limit = 1000 * 1000;
|
49 |
-
$this->pcre_recursion_limit = 500 * 1000;
|
50 |
-
|
51 |
-
$this->raise_php_limits = (bool) $raise_php_limits;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Minify a string of CSS
|
56 |
-
* @param string $css
|
57 |
-
* @param int|bool $linebreak_pos
|
58 |
-
* @return string
|
59 |
-
*/
|
60 |
-
public function run($css = '', $linebreak_pos = FALSE)
|
61 |
-
{
|
62 |
-
if (empty($css)) {
|
63 |
-
return '';
|
64 |
-
}
|
65 |
-
|
66 |
-
if ($this->raise_php_limits) {
|
67 |
-
$this->do_raise_php_limits();
|
68 |
-
}
|
69 |
-
|
70 |
-
$this->comments = array();
|
71 |
-
$this->preserved_tokens = array();
|
72 |
-
|
73 |
-
$start_index = 0;
|
74 |
-
$length = strlen($css);
|
75 |
-
|
76 |
-
$css = $this->extract_data_urls($css);
|
77 |
-
|
78 |
-
// collect all comment blocks...
|
79 |
-
while (($start_index = $this->index_of($css, '/*', $start_index)) >= 0) {
|
80 |
-
$end_index = $this->index_of($css, '*/', $start_index + 2);
|
81 |
-
if ($end_index < 0) {
|
82 |
-
$end_index = $length;
|
83 |
-
}
|
84 |
-
$comment_found = $this->str_slice($css, $start_index + 2, $end_index);
|
85 |
-
$this->comments[] = $comment_found;
|
86 |
-
$comment_preserve_string = self::COMMENT . (count($this->comments) - 1) . '___';
|
87 |
-
$css = $this->str_slice($css, 0, $start_index + 2) . $comment_preserve_string . $this->str_slice($css, $end_index);
|
88 |
-
// Set correct start_index: Fixes issue #2528130
|
89 |
-
$start_index = $end_index + 2 + strlen($comment_preserve_string) - strlen($comment_found);
|
90 |
-
}
|
91 |
-
|
92 |
-
// preserve strings so their content doesn't get accidentally minified
|
93 |
-
$css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css);
|
94 |
-
|
95 |
-
// Let's divide css code in chunks of 5.000 chars aprox.
|
96 |
-
// Reason: PHP's PCRE functions like preg_replace have a "backtrack limit"
|
97 |
-
// of 100.000 chars by default (php < 5.3.7) so if we're dealing with really
|
98 |
-
// long strings and a (sub)pattern matches a number of chars greater than
|
99 |
-
// the backtrack limit number (i.e. /(.*)/s) PCRE functions may fail silently
|
100 |
-
// returning NULL and $css would be empty.
|
101 |
-
$charset = '';
|
102 |
-
$charset_regexp = '/(@charset)( [^;]+;)/i';
|
103 |
-
$css_chunks = array();
|
104 |
-
$css_chunk_length = 5000; // aprox size, not exact
|
105 |
-
$start_index = 0;
|
106 |
-
$i = $css_chunk_length; // save initial iterations
|
107 |
-
$l = strlen($css);
|
108 |
-
|
109 |
-
|
110 |
-
// if the number of characters is 5000 or less, do not chunk
|
111 |
-
if ($l <= $css_chunk_length) {
|
112 |
-
$css_chunks[] = $css;
|
113 |
-
} else {
|
114 |
-
// chunk css code securely
|
115 |
-
while ($i < $l) {
|
116 |
-
$i += 50; // save iterations
|
117 |
-
if ($l - $start_index <= $css_chunk_length || $i >= $l) {
|
118 |
-
$css_chunks[] = $this->str_slice($css, $start_index);
|
119 |
-
break;
|
120 |
-
}
|
121 |
-
if ($css[$i - 1] === '}' && $i - $start_index > $css_chunk_length) {
|
122 |
-
// If there are two ending curly braces }} separated or not by spaces,
|
123 |
-
// join them in the same chunk (i.e. @media blocks)
|
124 |
-
$next_chunk = substr($css, $i);
|
125 |
-
if (preg_match('/^\s*\}/', $next_chunk)) {
|
126 |
-
$i = $i + $this->index_of($next_chunk, '}') + 1;
|
127 |
-
}
|
128 |
-
|
129 |
-
$css_chunks[] = $this->str_slice($css, $start_index, $i);
|
130 |
-
$start_index = $i;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
// Minify each chunk
|
136 |
-
for ($i = 0, $n = count($css_chunks); $i < $n; $i++) {
|
137 |
-
$css_chunks[$i] = $this->minify($css_chunks[$i], $linebreak_pos);
|
138 |
-
// Keep the first @charset at-rule found
|
139 |
-
if (empty($charset) && preg_match($charset_regexp, $css_chunks[$i], $matches)) {
|
140 |
-
$charset = strtolower($matches[1]) . $matches[2];
|
141 |
-
}
|
142 |
-
// Delete all @charset at-rules
|
143 |
-
$css_chunks[$i] = preg_replace($charset_regexp, '', $css_chunks[$i]);
|
144 |
-
}
|
145 |
-
|
146 |
-
// Update the first chunk and push the charset to the top of the file.
|
147 |
-
$css_chunks[0] = $charset . $css_chunks[0];
|
148 |
-
|
149 |
-
return implode('', $css_chunks);
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Sets the memory limit for this script
|
154 |
-
* @param int|string $limit
|
155 |
-
*/
|
156 |
-
public function set_memory_limit($limit)
|
157 |
-
{
|
158 |
-
$this->memory_limit = $this->normalize_int($limit);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Sets the maximum execution time for this script
|
163 |
-
* @param int|string $seconds
|
164 |
-
*/
|
165 |
-
public function set_max_execution_time($seconds)
|
166 |
-
{
|
167 |
-
$this->max_execution_time = (int) $seconds;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Sets the PCRE backtrack limit for this script
|
172 |
-
* @param int $limit
|
173 |
-
*/
|
174 |
-
public function set_pcre_backtrack_limit($limit)
|
175 |
-
{
|
176 |
-
$this->pcre_backtrack_limit = (int) $limit;
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Sets the PCRE recursion limit for this script
|
181 |
-
* @param int $limit
|
182 |
-
*/
|
183 |
-
public function set_pcre_recursion_limit($limit)
|
184 |
-
{
|
185 |
-
$this->pcre_recursion_limit = (int) $limit;
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Try to configure PHP to use at least the suggested minimum settings
|
190 |
-
*/
|
191 |
-
private function do_raise_php_limits()
|
192 |
-
{
|
193 |
-
$php_limits = array(
|
194 |
-
'memory_limit' => $this->memory_limit,
|
195 |
-
'max_execution_time' => $this->max_execution_time,
|
196 |
-
'pcre.backtrack_limit' => $this->pcre_backtrack_limit,
|
197 |
-
'pcre.recursion_limit' => $this->pcre_recursion_limit
|
198 |
-
);
|
199 |
-
|
200 |
-
// If current settings are higher respect them.
|
201 |
-
foreach ($php_limits as $name => $suggested) {
|
202 |
-
$current = $this->normalize_int(ini_get($name));
|
203 |
-
// memory_limit exception: allow -1 for "no memory limit".
|
204 |
-
if ($current > -1 && ($suggested == -1 || $current < $suggested)) {
|
205 |
-
ini_set($name, $suggested);
|
206 |
-
}
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Does bulk of the minification
|
212 |
-
* @param string $css
|
213 |
-
* @param int|bool $linebreak_pos
|
214 |
-
* @return string
|
215 |
-
*/
|
216 |
-
private function minify($css, $linebreak_pos)
|
217 |
-
{
|
218 |
-
// strings are safe, now wrestle the comments
|
219 |
-
for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
|
220 |
-
|
221 |
-
$token = $this->comments[$i];
|
222 |
-
$placeholder = '/' . self::COMMENT . $i . '___/';
|
223 |
-
|
224 |
-
// ! in the first position of the comment means preserve
|
225 |
-
// so push to the preserved tokens keeping the !
|
226 |
-
if (substr($token, 0, 1) === '!') {
|
227 |
-
$this->preserved_tokens[] = $token;
|
228 |
-
$token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
|
229 |
-
$css = preg_replace($placeholder, $token_tring, $css, 1);
|
230 |
-
// Preserve new lines for /*! important comments
|
231 |
-
$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css);
|
232 |
-
$css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/', '$1'.self::NL, $css);
|
233 |
-
continue;
|
234 |
-
}
|
235 |
-
|
236 |
-
// \ in the last position looks like hack for Mac/IE5
|
237 |
-
// shorten that to /*\*/ and the next one to /**/
|
238 |
-
if (substr($token, (strlen($token) - 1), 1) === '\\') {
|
239 |
-
$this->preserved_tokens[] = '\\';
|
240 |
-
$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
241 |
-
$i = $i + 1; // attn: advancing the loop
|
242 |
-
$this->preserved_tokens[] = '';
|
243 |
-
$css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
244 |
-
continue;
|
245 |
-
}
|
246 |
-
|
247 |
-
// keep empty comments after child selectors (IE7 hack)
|
248 |
-
// e.g. html >/**/ body
|
249 |
-
if (strlen($token) === 0) {
|
250 |
-
$start_index = $this->index_of($css, $this->str_slice($placeholder, 1, -1));
|
251 |
-
if ($start_index > 2) {
|
252 |
-
if (substr($css, $start_index - 3, 1) === '>') {
|
253 |
-
$this->preserved_tokens[] = '';
|
254 |
-
$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
// in all other cases kill the comment
|
260 |
-
$css = preg_replace('/\/\*' . $this->str_slice($placeholder, 1, -1) . '\*\//', '', $css, 1);
|
261 |
-
}
|
262 |
-
|
263 |
-
|
264 |
-
// Normalize all whitespace strings to single spaces. Easier to work with that way.
|
265 |
-
$css = preg_replace('/\s+/', ' ', $css);
|
266 |
-
|
267 |
-
// Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters
|
268 |
-
$css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css);
|
269 |
-
|
270 |
-
// Shorten & preserve calculations calc(...) since spaces are important
|
271 |
-
$css = preg_replace_callback('/calc(\(((?:[^\(\)]+|(?1))*)\))/i', array($this, 'replace_calc'), $css);
|
272 |
-
|
273 |
-
// Replace positive sign from numbers preceded by : or a white-space before the leading space is removed
|
274 |
-
// +1.2em to 1.2em, +.8px to .8px, +2% to 2%
|
275 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)\+(\.?\d+)/S', '$1$2', $css);
|
276 |
-
|
277 |
-
// Remove leading zeros from integer and float numbers preceded by : or a white-space
|
278 |
-
// 000.6 to .6, -0.8 to -.8, 0050 to 50, -01.05 to -1.05
|
279 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?)0+(\.?\d+)/S', '$1$2$3', $css);
|
280 |
-
|
281 |
-
// Remove trailing zeros from float numbers preceded by : or a white-space
|
282 |
-
// -6.0100em to -6.01em, .0100 to .01, 1.200px to 1.2px
|
283 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?)(\d?\.\d+?)0+([^\d])/S', '$1$2$3$4', $css);
|
284 |
-
|
285 |
-
// Remove trailing .0 -> -9.0 to -9
|
286 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?\d+)\.0([^\d])/S', '$1$2$3', $css);
|
287 |
-
|
288 |
-
// Replace 0 length numbers with 0
|
289 |
-
$css = preg_replace('/((?<!\\\\)\:|\s)\-?\.?0+([^\d])/S', '${1}0$2', $css);
|
290 |
-
|
291 |
-
// Remove the spaces before the things that should not have spaces before them.
|
292 |
-
// But, be careful not to turn "p :link {...}" into "p:link{...}"
|
293 |
-
// Swap out any pseudo-class colons with the token, and then swap back.
|
294 |
-
$css = preg_replace_callback('/(?:^|\})[^\{]*\s+\:/', array($this, 'replace_colon'), $css);
|
295 |
-
|
296 |
-
// Remove spaces before the things that should not have spaces before them.
|
297 |
-
$css = preg_replace('/\s+([\!\{\}\;\:\>\+\(\)\]\~\=,])/', '$1', $css);
|
298 |
-
|
299 |
-
// Restore spaces for !important
|
300 |
-
$css = preg_replace('/\!important/i', ' !important', $css);
|
301 |
-
|
302 |
-
// bring back the colon
|
303 |
-
$css = preg_replace('/' . self::CLASSCOLON . '/', ':', $css);
|
304 |
-
|
305 |
-
// retain space for special IE6 cases
|
306 |
-
$css = preg_replace_callback('/\:first\-(line|letter)(\{|,)/i', array($this, 'lowercase_pseudo_first'), $css);
|
307 |
-
|
308 |
-
// no space after the end of a preserved comment
|
309 |
-
$css = preg_replace('/\*\/ /', '*/', $css);
|
310 |
-
|
311 |
-
// lowercase some popular @directives
|
312 |
-
$css = preg_replace_callback('/@(font-face|import|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?keyframe|media|page|namespace)/i', array($this, 'lowercase_directives'), $css);
|
313 |
-
|
314 |
-
// lowercase some more common pseudo-elements
|
315 |
-
$css = preg_replace_callback('/:(active|after|before|checked|disabled|empty|enabled|first-(?:child|of-type)|focus|hover|last-(?:child|of-type)|link|only-(?:child|of-type)|root|:selection|target|visited)/i', array($this, 'lowercase_pseudo_elements'), $css);
|
316 |
-
|
317 |
-
// lowercase some more common functions
|
318 |
-
$css = preg_replace_callback('/:(lang|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|(?:-(?:moz|webkit)-)?any)\(/i', array($this, 'lowercase_common_functions'), $css);
|
319 |
-
|
320 |
-
// lower case some common function that can be values
|
321 |
-
// NOTE: rgb() isn't useful as we replace with #hex later, as well as and() is already done for us
|
322 |
-
$css = preg_replace_callback('/([:,\( ]\s*)(attr|color-stop|from|rgba|to|url|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?(?:calc|max|min|(?:repeating-)?(?:linear|radial)-gradient)|-webkit-gradient)/iS', array($this, 'lowercase_common_functions_values'), $css);
|
323 |
-
|
324 |
-
// Put the space back in some cases, to support stuff like
|
325 |
-
// @media screen and (-webkit-min-device-pixel-ratio:0){
|
326 |
-
$css = preg_replace('/\band\(/i', 'and (', $css);
|
327 |
-
|
328 |
-
// Remove the spaces after the things that should not have spaces after them.
|
329 |
-
$css = preg_replace('/([\!\{\}\:;\>\+\(\[\~\=,])\s+/S', '$1', $css);
|
330 |
-
|
331 |
-
// remove unnecessary semicolons
|
332 |
-
$css = preg_replace('/;+\}/', '}', $css);
|
333 |
-
|
334 |
-
// Fix for issue: #2528146
|
335 |
-
// Restore semicolon if the last property is prefixed with a `*` (lte IE7 hack)
|
336 |
-
// to avoid issues on Symbian S60 3.x browsers.
|
337 |
-
$css = preg_replace('/(\*[a-z0-9\-]+\s*\:[^;\}]+)(\})/', '$1;$2', $css);
|
338 |
-
|
339 |
-
// Replace 0 <length> and 0 <percentage> values with 0.
|
340 |
-
// <length> data type: https://developer.mozilla.org/en-US/docs/Web/CSS/length
|
341 |
-
// <percentage> data type: https://developer.mozilla.org/en-US/docs/Web/CSS/percentage
|
342 |
-
$css = preg_replace('/([^\\\\]\:|\s)0(?:em|ex|ch|rem|vw|vh|vm|vmin|cm|mm|in|px|pt|pc|%)/iS', '${1}0', $css);
|
343 |
-
|
344 |
-
// 0% step in a keyframe? restore the % unit
|
345 |
-
$css = preg_replace_callback('/(@[a-z\-]*?keyframes[^\{]*?\{)(.*?\}\s*\})/iS', array($this, 'replace_keyframe_zero'), $css);
|
346 |
-
|
347 |
-
// Replace 0 0; or 0 0 0; or 0 0 0 0; with 0.
|
348 |
-
$css = preg_replace('/\:0(?: 0){1,3}(;|\}| \!)/', ':0$1', $css);
|
349 |
-
|
350 |
-
// Fix for issue: #2528142
|
351 |
-
// Replace text-shadow:0; with text-shadow:0 0 0;
|
352 |
-
$css = preg_replace('/(text-shadow\:0)(;|\}| \!)/i', '$1 0 0$2', $css);
|
353 |
-
|
354 |
-
// Replace background-position:0; with background-position:0 0;
|
355 |
-
// same for transform-origin
|
356 |
-
// Changing -webkit-mask-position: 0 0 to just a single 0 will result in the second parameter defaulting to 50% (center)
|
357 |
-
$css = preg_replace('/(background\-position|webkit-mask-position|(?:webkit|moz|o|ms|)\-?transform\-origin)\:0(;|\}| \!)/iS', '$1:0 0$2', $css);
|
358 |
-
|
359 |
-
// Shorten colors from rgb(51,102,153) to #336699, rgb(100%,0%,0%) to #ff0000 (sRGB color space)
|
360 |
-
// Shorten colors from hsl(0, 100%, 50%) to #ff0000 (sRGB color space)
|
361 |
-
// This makes it more likely that it'll get further compressed in the next step.
|
362 |
-
$css = preg_replace_callback('/rgb\s*\(\s*([0-9,\s\-\.\%]+)\s*\)(.{1})/i', array($this, 'rgb_to_hex'), $css);
|
363 |
-
$css = preg_replace_callback('/hsl\s*\(\s*([0-9,\s\-\.\%]+)\s*\)(.{1})/i', array($this, 'hsl_to_hex'), $css);
|
364 |
-
|
365 |
-
// Shorten colors from #AABBCC to #ABC or short color name.
|
366 |
-
$css = $this->compress_hex_colors($css);
|
367 |
-
|
368 |
-
// border: none to border:0, outline: none to outline:0
|
369 |
-
$css = preg_replace('/(border\-?(?:top|right|bottom|left|)|outline)\:none(;|\}| \!)/iS', '$1:0$2', $css);
|
370 |
-
|
371 |
-
// shorter opacity IE filter
|
372 |
-
$css = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $css);
|
373 |
-
|
374 |
-
// Find a fraction that is used for Opera's -o-device-pixel-ratio query
|
375 |
-
// Add token to add the "\" back in later
|
376 |
-
$css = preg_replace('/\(([a-z\-]+):([0-9]+)\/([0-9]+)\)/i', '($1:$2'. self::QUERY_FRACTION .'$3)', $css);
|
377 |
-
|
378 |
-
// Remove empty rules.
|
379 |
-
$css = preg_replace('/[^\};\{\/]+\{\}/S', '', $css);
|
380 |
-
|
381 |
-
// Add "/" back to fix Opera -o-device-pixel-ratio query
|
382 |
-
$css = preg_replace('/'. self::QUERY_FRACTION .'/', '/', $css);
|
383 |
-
|
384 |
-
// Replace multiple semi-colons in a row by a single one
|
385 |
-
// See SF bug #1980989
|
386 |
-
$css = preg_replace('/;;+/', ';', $css);
|
387 |
-
|
388 |
-
// Restore new lines for /*! important comments
|
389 |
-
$css = preg_replace('/'. self::NL .'/', "\n", $css);
|
390 |
-
|
391 |
-
// Lowercase all uppercase properties
|
392 |
-
$css = preg_replace_callback('/(\{|\;)([A-Z\-]+)(\:)/', array($this, 'lowercase_properties'), $css);
|
393 |
-
|
394 |
-
// Some source control tools don't like it when files containing lines longer
|
395 |
-
// than, say 8000 characters, are checked in. The linebreak option is used in
|
396 |
-
// that case to split long lines after a specific column.
|
397 |
-
if ($linebreak_pos !== FALSE && (int) $linebreak_pos >= 0) {
|
398 |
-
$linebreak_pos = (int) $linebreak_pos;
|
399 |
-
$start_index = $i = 0;
|
400 |
-
while ($i < strlen($css)) {
|
401 |
-
$i++;
|
402 |
-
if ($css[$i - 1] === '}' && $i - $start_index > $linebreak_pos) {
|
403 |
-
$css = $this->str_slice($css, 0, $i) . "\n" . $this->str_slice($css, $i);
|
404 |
-
$start_index = $i;
|
405 |
-
}
|
406 |
-
}
|
407 |
-
}
|
408 |
-
|
409 |
-
// restore preserved comments and strings in reverse order
|
410 |
-
for ($i = count($this->preserved_tokens) - 1; $i >= 0; $i--) {
|
411 |
-
$css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1);
|
412 |
-
}
|
413 |
-
|
414 |
-
// Trim the final string (for any leading or trailing white spaces)
|
415 |
-
return trim($css);
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Utility method to replace all data urls with tokens before we start
|
420 |
-
* compressing, to avoid performance issues running some of the subsequent
|
421 |
-
* regexes against large strings chunks.
|
422 |
-
*
|
423 |
-
* @param string $css
|
424 |
-
* @return string
|
425 |
-
*/
|
426 |
-
private function extract_data_urls($css)
|
427 |
-
{
|
428 |
-
// Leave data urls alone to increase parse performance.
|
429 |
-
$max_index = strlen($css) - 1;
|
430 |
-
$append_index = $index = $last_index = $offset = 0;
|
431 |
-
$sb = array();
|
432 |
-
$pattern = '/url\(\s*(["\']?)data\:/i';
|
433 |
-
|
434 |
-
// Since we need to account for non-base64 data urls, we need to handle
|
435 |
-
// ' and ) being part of the data string. Hence switching to indexOf,
|
436 |
-
// to determine whether or not we have matching string terminators and
|
437 |
-
// handling sb appends directly, instead of using matcher.append* methods.
|
438 |
-
|
439 |
-
while (preg_match($pattern, $css, $m, 0, $offset)) {
|
440 |
-
$index = $this->index_of($css, $m[0], $offset);
|
441 |
-
$last_index = $index + strlen($m[0]);
|
442 |
-
$start_index = $index + 4; // "url(".length()
|
443 |
-
$end_index = $last_index - 1;
|
444 |
-
$terminator = $m[1]; // ', " or empty (not quoted)
|
445 |
-
$found_terminator = FALSE;
|
446 |
-
|
447 |
-
if (strlen($terminator) === 0) {
|
448 |
-
$terminator = ')';
|
449 |
-
}
|
450 |
-
|
451 |
-
while ($found_terminator === FALSE && $end_index+1 <= $max_index) {
|
452 |
-
$end_index = $this->index_of($css, $terminator, $end_index + 1);
|
453 |
-
|
454 |
-
// endIndex == 0 doesn't really apply here
|
455 |
-
if ($end_index > 0 && substr($css, $end_index - 1, 1) !== '\\') {
|
456 |
-
$found_terminator = TRUE;
|
457 |
-
if (')' != $terminator) {
|
458 |
-
$end_index = $this->index_of($css, ')', $end_index);
|
459 |
-
}
|
460 |
-
}
|
461 |
-
}
|
462 |
-
|
463 |
-
// Enough searching, start moving stuff over to the buffer
|
464 |
-
$sb[] = $this->str_slice($css, $append_index, $index);
|
465 |
-
|
466 |
-
if ($found_terminator) {
|
467 |
-
$token = $this->str_slice($css, $start_index, $end_index);
|
468 |
-
$token = preg_replace('/\s+/', '', $token);
|
469 |
-
$this->preserved_tokens[] = $token;
|
470 |
-
|
471 |
-
$preserver = 'url(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___)';
|
472 |
-
$sb[] = $preserver;
|
473 |
-
|
474 |
-
$append_index = $end_index + 1;
|
475 |
-
} else {
|
476 |
-
// No end terminator found, re-add the whole match. Should we throw/warn here?
|
477 |
-
$sb[] = $this->str_slice($css, $index, $last_index);
|
478 |
-
$append_index = $last_index;
|
479 |
-
}
|
480 |
-
|
481 |
-
$offset = $last_index;
|
482 |
-
}
|
483 |
-
|
484 |
-
$sb[] = $this->str_slice($css, $append_index);
|
485 |
-
|
486 |
-
return implode('', $sb);
|
487 |
-
}
|
488 |
-
|
489 |
-
/**
|
490 |
-
* Utility method to compress hex color values of the form #AABBCC to #ABC or short color name.
|
491 |
-
*
|
492 |
-
* DOES NOT compress CSS ID selectors which match the above pattern (which would break things).
|
493 |
-
* e.g. #AddressForm { ... }
|
494 |
-
*
|
495 |
-
* DOES NOT compress IE filters, which have hex color values (which would break things).
|
496 |
-
* e.g. filter: chroma(color="#FFFFFF");
|
497 |
-
*
|
498 |
-
* DOES NOT compress invalid hex values.
|
499 |
-
* e.g. background-color: #aabbccdd
|
500 |
-
*
|
501 |
-
* @param string $css
|
502 |
-
* @return string
|
503 |
-
*/
|
504 |
-
private function compress_hex_colors($css)
|
505 |
-
{
|
506 |
-
// Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters)
|
507 |
-
$pattern = '/(\=\s*?["\']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/iS';
|
508 |
-
$_index = $index = $last_index = $offset = 0;
|
509 |
-
$sb = array();
|
510 |
-
// See: http://ajaxmin.codeplex.com/wikipage?title=CSS%20Colors
|
511 |
-
$short_safe = array(
|
512 |
-
'#808080' => 'gray',
|
513 |
-
'#008000' => 'green',
|
514 |
-
'#800000' => 'maroon',
|
515 |
-
'#000080' => 'navy',
|
516 |
-
'#808000' => 'olive',
|
517 |
-
'#ffa500' => 'orange',
|
518 |
-
'#800080' => 'purple',
|
519 |
-
'#c0c0c0' => 'silver',
|
520 |
-
'#008080' => 'teal',
|
521 |
-
'#f00' => 'red'
|
522 |
-
);
|
523 |
-
|
524 |
-
while (preg_match($pattern, $css, $m, 0, $offset)) {
|
525 |
-
$index = $this->index_of($css, $m[0], $offset);
|
526 |
-
$last_index = $index + strlen($m[0]);
|
527 |
-
$is_filter = $m[1] !== null && $m[1] !== '';
|
528 |
-
|
529 |
-
$sb[] = $this->str_slice($css, $_index, $index);
|
530 |
-
|
531 |
-
if ($is_filter) {
|
532 |
-
// Restore, maintain case, otherwise filter will break
|
533 |
-
$sb[] = $m[1] . '#' . $m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7];
|
534 |
-
} else {
|
535 |
-
if (strtolower($m[2]) == strtolower($m[3]) &&
|
536 |
-
strtolower($m[4]) == strtolower($m[5]) &&
|
537 |
-
strtolower($m[6]) == strtolower($m[7])) {
|
538 |
-
// Compress.
|
539 |
-
$hex = '#' . strtolower($m[3] . $m[5] . $m[7]);
|
540 |
-
} else {
|
541 |
-
// Non compressible color, restore but lower case.
|
542 |
-
$hex = '#' . strtolower($m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]);
|
543 |
-
}
|
544 |
-
// replace Hex colors to short safe color names
|
545 |
-
$sb[] = array_key_exists($hex, $short_safe) ? $short_safe[$hex] : $hex;
|
546 |
-
}
|
547 |
-
|
548 |
-
$_index = $offset = $last_index - strlen($m[8]);
|
549 |
-
}
|
550 |
-
|
551 |
-
$sb[] = $this->str_slice($css, $_index);
|
552 |
-
|
553 |
-
return implode('', $sb);
|
554 |
-
}
|
555 |
-
|
556 |
-
/* CALLBACKS
|
557 |
-
* ---------------------------------------------------------------------------------------------
|
558 |
-
*/
|
559 |
-
|
560 |
-
private function replace_string($matches)
|
561 |
-
{
|
562 |
-
$match = $matches[0];
|
563 |
-
$quote = substr($match, 0, 1);
|
564 |
-
// Must use addcslashes in PHP to avoid parsing of backslashes
|
565 |
-
$match = addcslashes($this->str_slice($match, 1, -1), '\\');
|
566 |
-
|
567 |
-
// maybe the string contains a comment-like substring?
|
568 |
-
// one, maybe more? put'em back then
|
569 |
-
if (($pos = $this->index_of($match, self::COMMENT)) >= 0) {
|
570 |
-
for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
|
571 |
-
$match = preg_replace('/' . self::COMMENT . $i . '___/', $this->comments[$i], $match, 1);
|
572 |
-
}
|
573 |
-
}
|
574 |
-
|
575 |
-
// minify alpha opacity in filter strings
|
576 |
-
$match = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $match);
|
577 |
-
|
578 |
-
$this->preserved_tokens[] = $match;
|
579 |
-
return $quote . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . $quote;
|
580 |
-
}
|
581 |
-
|
582 |
-
private function replace_colon($matches)
|
583 |
-
{
|
584 |
-
return preg_replace('/\:/', self::CLASSCOLON, $matches[0]);
|
585 |
-
}
|
586 |
-
|
587 |
-
private function replace_calc($matches)
|
588 |
-
{
|
589 |
-
$this->preserved_tokens[] = trim(preg_replace('/\s*([\*\/\(\),])\s*/', '$1', $matches[2]));
|
590 |
-
return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
|
591 |
-
}
|
592 |
-
|
593 |
-
private function preserve_old_IE_specific_matrix_definition($matches)
|
594 |
-
{
|
595 |
-
$this->preserved_tokens[] = $matches[1];
|
596 |
-
return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
|
597 |
-
}
|
598 |
-
|
599 |
-
private function replace_keyframe_zero($matches)
|
600 |
-
{
|
601 |
-
return $matches[1] . preg_replace('/0\s*,/', '0%,', preg_replace('/\s*0\s*\{/', '0%{', $matches[2]));
|
602 |
-
}
|
603 |
-
|
604 |
-
private function rgb_to_hex($matches)
|
605 |
-
{
|
606 |
-
// Support for percentage values rgb(100%, 0%, 45%);
|
607 |
-
if ($this->index_of($matches[1], '%') >= 0){
|
608 |
-
$rgbcolors = explode(',', str_replace('%', '', $matches[1]));
|
609 |
-
for ($i = 0; $i < count($rgbcolors); $i++) {
|
610 |
-
$rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55);
|
611 |
-
}
|
612 |
-
} else {
|
613 |
-
$rgbcolors = explode(',', $matches[1]);
|
614 |
-
}
|
615 |
-
|
616 |
-
// Values outside the sRGB color space should be clipped (0-255)
|
617 |
-
for ($i = 0; $i < count($rgbcolors); $i++) {
|
618 |
-
$rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255);
|
619 |
-
$rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]);
|
620 |
-
}
|
621 |
-
|
622 |
-
// Fix for issue #2528093
|
623 |
-
if (!preg_match('/[\s\,\);\}]/', $matches[2])){
|
624 |
-
$matches[2] = ' ' . $matches[2];
|
625 |
-
}
|
626 |
-
|
627 |
-
return '#' . implode('', $rgbcolors) . $matches[2];
|
628 |
-
}
|
629 |
-
|
630 |
-
private function hsl_to_hex($matches)
|
631 |
-
{
|
632 |
-
$values = explode(',', str_replace('%', '', $matches[1]));
|
633 |
-
$h = floatval($values[0]);
|
634 |
-
$s = floatval($values[1]);
|
635 |
-
$l = floatval($values[2]);
|
636 |
-
|
637 |
-
// Wrap and clamp, then fraction!
|
638 |
-
$h = ((($h % 360) + 360) % 360) / 360;
|
639 |
-
$s = $this->clamp_number($s, 0, 100) / 100;
|
640 |
-
$l = $this->clamp_number($l, 0, 100) / 100;
|
641 |
-
|
642 |
-
if ($s == 0) {
|
643 |
-
$r = $g = $b = $this->round_number(255 * $l);
|
644 |
-
} else {
|
645 |
-
$v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
|
646 |
-
$v1 = (2 * $l) - $v2;
|
647 |
-
$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3)));
|
648 |
-
$g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h));
|
649 |
-
$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3)));
|
650 |
-
}
|
651 |
-
|
652 |
-
return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2]));
|
653 |
-
}
|
654 |
-
|
655 |
-
private function lowercase_pseudo_first($matches)
|
656 |
-
{
|
657 |
-
return ':first-'. strtolower($matches[1]) .' '. $matches[2];
|
658 |
-
}
|
659 |
-
|
660 |
-
private function lowercase_directives($matches)
|
661 |
-
{
|
662 |
-
return '@'. strtolower($matches[1]);
|
663 |
-
}
|
664 |
-
|
665 |
-
private function lowercase_pseudo_elements($matches)
|
666 |
-
{
|
667 |
-
return ':'. strtolower($matches[1]);
|
668 |
-
}
|
669 |
-
|
670 |
-
private function lowercase_common_functions($matches)
|
671 |
-
{
|
672 |
-
return ':'. strtolower($matches[1]) .'(';
|
673 |
-
}
|
674 |
-
|
675 |
-
private function lowercase_common_functions_values($matches)
|
676 |
-
{
|
677 |
-
return $matches[1] . strtolower($matches[2]);
|
678 |
-
}
|
679 |
-
|
680 |
-
private function lowercase_properties($matches)
|
681 |
-
{
|
682 |
-
return $matches[1].strtolower($matches[2]).$matches[3];
|
683 |
-
}
|
684 |
-
|
685 |
-
/* HELPERS
|
686 |
-
* ---------------------------------------------------------------------------------------------
|
687 |
-
*/
|
688 |
-
|
689 |
-
private function hue_to_rgb($v1, $v2, $vh)
|
690 |
-
{
|
691 |
-
$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
|
692 |
-
if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
|
693 |
-
if ($vh * 2 < 1) return $v2;
|
694 |
-
if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
|
695 |
-
return $v1;
|
696 |
-
}
|
697 |
-
|
698 |
-
private function round_number($n)
|
699 |
-
{
|
700 |
-
return intval(floor(floatval($n) + 0.5), 10);
|
701 |
-
}
|
702 |
-
|
703 |
-
private function clamp_number($n, $min, $max)
|
704 |
-
{
|
705 |
-
return min(max($n, $min), $max);
|
706 |
-
}
|
707 |
-
|
708 |
-
/**
|
709 |
-
* PHP port of Javascript's "indexOf" function for strings only
|
710 |
-
* Author: Tubal Martin http://blog.margenn.com
|
711 |
-
*
|
712 |
-
* @param string $haystack
|
713 |
-
* @param string $needle
|
714 |
-
* @param int $offset index (optional)
|
715 |
-
* @return int
|
716 |
-
*/
|
717 |
-
private function index_of($haystack, $needle, $offset = 0)
|
718 |
-
{
|
719 |
-
$index = strpos($haystack, $needle, $offset);
|
720 |
-
|
721 |
-
return ($index !== FALSE) ? $index : -1;
|
722 |
-
}
|
723 |
-
|
724 |
-
/**
|
725 |
-
* PHP port of Javascript's "slice" function for strings only
|
726 |
-
* Author: Tubal Martin http://blog.margenn.com
|
727 |
-
* Tests: http://margenn.com/tubal/str_slice/
|
728 |
-
*
|
729 |
-
* @param string $str
|
730 |
-
* @param int $start index
|
731 |
-
* @param int|bool $end index (optional)
|
732 |
-
* @return string
|
733 |
-
*/
|
734 |
-
private function str_slice($str, $start = 0, $end = FALSE)
|
735 |
-
{
|
736 |
-
if ($end !== FALSE && ($start < 0 || $end <= 0)) {
|
737 |
-
$max = strlen($str);
|
738 |
-
|
739 |
-
if ($start < 0) {
|
740 |
-
if (($start = $max + $start) < 0) {
|
741 |
-
return '';
|
742 |
-
}
|
743 |
-
}
|
744 |
-
|
745 |
-
if ($end < 0) {
|
746 |
-
if (($end = $max + $end) < 0) {
|
747 |
-
return '';
|
748 |
-
}
|
749 |
-
}
|
750 |
-
|
751 |
-
if ($end <= $start) {
|
752 |
-
return '';
|
753 |
-
}
|
754 |
-
}
|
755 |
-
|
756 |
-
$slice = ($end === FALSE) ? substr($str, $start) : substr($str, $start, $end - $start);
|
757 |
-
return ($slice === FALSE) ? '' : $slice;
|
758 |
-
}
|
759 |
-
|
760 |
-
/**
|
761 |
-
* Convert strings like "64M" or "30" to int values
|
762 |
-
* @param mixed $size
|
763 |
-
* @return int
|
764 |
-
*/
|
765 |
-
private function normalize_int($size)
|
766 |
-
{
|
767 |
-
if (is_string($size)) {
|
768 |
-
switch (substr($size, -1)) {
|
769 |
-
case 'M': case 'm': return $size * 1048576;
|
770 |
-
case 'K': case 'k': return $size * 1024;
|
771 |
-
case 'G': case 'g': return $size * 1073741824;
|
772 |
-
}
|
773 |
-
}
|
774 |
-
|
775 |
-
return (int) $size;
|
776 |
-
}
|
777 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/external/php/{yui-php-cssmin-2.4.8-3_fixes.php → yui-php-cssmin-2.4.8-4.php}
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
/*!
|
4 |
-
* cssmin.php
|
5 |
* Author: Tubal Martin - http://tubalmartin.me/
|
6 |
* Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port
|
7 |
*
|
@@ -598,7 +598,7 @@ class CSSmin
|
|
598 |
|
599 |
private function replace_keyframe_zero($matches)
|
600 |
{
|
601 |
-
|
602 |
}
|
603 |
|
604 |
private function rgb_to_hex($matches)
|
1 |
<?php
|
2 |
|
3 |
/*!
|
4 |
+
* cssmin.php v2.4.8-4
|
5 |
* Author: Tubal Martin - http://tubalmartin.me/
|
6 |
* Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port
|
7 |
*
|
598 |
|
599 |
private function replace_keyframe_zero($matches)
|
600 |
{
|
601 |
+
return $matches[1] . preg_replace('/0(\{|,[^\)\{]+\{)/', '0%$1', $matches[2]) . $matches[3];
|
602 |
}
|
603 |
|
604 |
private function rgb_to_hex($matches)
|
localization/autoptimize-ar.mo
ADDED
Binary file
|
localization/autoptimize-ar.po
ADDED
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2014 Autoptimize
|
2 |
+
# This file is distributed under the same license as the Autoptimize package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Autoptimize - Arabic\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/autoptimize\n"
|
7 |
+
"POT-Creation-Date: 2014-08-22 05:35:46+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2015-03-10 17:00+0300\n"
|
12 |
+
"Last-Translator: \n"
|
13 |
+
"Language-Team: ekleel | ekleel.net <info@ekleel.net>\n"
|
14 |
+
"X-Generator: Poedit 1.5.7\n"
|
15 |
+
"Language: Arabic\n"
|
16 |
+
|
17 |
+
#: autoptimize.php:124
|
18 |
+
msgid ""
|
19 |
+
"Thank you for installing and activating Autoptimize. Please configure it "
|
20 |
+
"under \"Settings\" -> \"Autoptimize\" to start improving your site's "
|
21 |
+
"performance."
|
22 |
+
msgstr ""
|
23 |
+
"شكراً لك لتثبيت وتفعيل Autoptimize. من فضلك قم بضبط الإعدادات في \"إعدادات\" -"
|
24 |
+
"> \"Autoptimize\" لتبدأ بتحسين آداء موقعك."
|
25 |
+
|
26 |
+
#: autoptimize.php:130
|
27 |
+
msgid ""
|
28 |
+
"Autoptimize has just been updated. Please <strong>test your site now</"
|
29 |
+
"strong> and adapt Autoptimize config if needed."
|
30 |
+
msgstr ""
|
31 |
+
"تم تحديث Autoptimize. من فضلك <strong>قم باختبار موقعك الآن</strong> واضبط "
|
32 |
+
"الإعدادات إذا لزم ذلك."
|
33 |
+
|
34 |
+
#: classes/autoptimizeConfig.php:48
|
35 |
+
msgid "Autoptimize Settings"
|
36 |
+
msgstr "إعدادات Autoptimize"
|
37 |
+
|
38 |
+
#: classes/autoptimizeConfig.php:54 classes/autoptimizeConfig.php:60
|
39 |
+
msgid "Show advanced settings"
|
40 |
+
msgstr "إظهار الإعدادات المتقدمة"
|
41 |
+
|
42 |
+
#: classes/autoptimizeConfig.php:55 classes/autoptimizeConfig.php:61
|
43 |
+
msgid "Hide advanced settings"
|
44 |
+
msgstr "إخفاء الإعدادات المتقدمة"
|
45 |
+
|
46 |
+
#: classes/autoptimizeConfig.php:69
|
47 |
+
msgid "HTML Options"
|
48 |
+
msgstr "خيارات HTML"
|
49 |
+
|
50 |
+
#: classes/autoptimizeConfig.php:72
|
51 |
+
msgid "Optimize HTML Code?"
|
52 |
+
msgstr "تحسين أكواد HTML؟"
|
53 |
+
|
54 |
+
#: classes/autoptimizeConfig.php:76
|
55 |
+
msgid "Keep HTML comments?"
|
56 |
+
msgstr "الإبقاء على تعليقات HTML؟"
|
57 |
+
|
58 |
+
#: classes/autoptimizeConfig.php:78
|
59 |
+
msgid ""
|
60 |
+
"Enable this if you want HTML comments to remain in the page, needed for e.g. "
|
61 |
+
"AdSense to function properly."
|
62 |
+
msgstr ""
|
63 |
+
"فعّل هذا الخيار للإبقاء على تعليقات HTML في الصفحة. مطلوبة لـAdSense على سبيل "
|
64 |
+
"المثال."
|
65 |
+
|
66 |
+
#: classes/autoptimizeConfig.php:82
|
67 |
+
msgid "JavaScript Options"
|
68 |
+
msgstr "خيارات JavaScript"
|
69 |
+
|
70 |
+
#: classes/autoptimizeConfig.php:85
|
71 |
+
msgid "Optimize JavaScript Code?"
|
72 |
+
msgstr "تحسين أكواد JavaScript؟"
|
73 |
+
|
74 |
+
#: classes/autoptimizeConfig.php:89
|
75 |
+
msgid "Force JavaScript in <head>?"
|
76 |
+
msgstr "إجبار أكواد JavaScript في <head>؟"
|
77 |
+
|
78 |
+
#: classes/autoptimizeConfig.php:91
|
79 |
+
msgid ""
|
80 |
+
"For performance reasons it is better to include JavaScript at the bottom of "
|
81 |
+
"HTML, but this sometimes breaks things. Especially useful for jQuery-based "
|
82 |
+
"themes."
|
83 |
+
msgstr ""
|
84 |
+
"من الأفضل إدخال أكواد JavaScript في أسفل الصفحة لأسباب مهمة للآداء، ولكن قد "
|
85 |
+
"يحدث بعض المشاكل أحياناً. هذه الخاصية مفيدة للثيمات المعتمدة على jQuery."
|
86 |
+
|
87 |
+
#: classes/autoptimizeConfig.php:94
|
88 |
+
msgid "Look for scripts only in <head>?"
|
89 |
+
msgstr "إبحث عن أكواد فقط في <head>؟"
|
90 |
+
|
91 |
+
#: classes/autoptimizeConfig.php:96
|
92 |
+
msgid ""
|
93 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
94 |
+
"templates, but might help keeping cache size under control."
|
95 |
+
msgstr ""
|
96 |
+
"مفيدة أكثر مع الخيار السابق في الثيمات المعتمدة على jQuery، وقد تقوم بالتحكم "
|
97 |
+
"بحجم ملف الكاش."
|
98 |
+
|
99 |
+
#: classes/autoptimizeConfig.php:99
|
100 |
+
msgid "Exclude scripts from Autoptimize:"
|
101 |
+
msgstr "أكواد JavaScript مستثناه من التحسين:"
|
102 |
+
|
103 |
+
#: classes/autoptimizeConfig.php:101
|
104 |
+
msgid ""
|
105 |
+
"A comma-seperated list of scripts you want to exclude from being optimized, "
|
106 |
+
"for example 'whatever.js, another.js' (without the quotes) to exclude those "
|
107 |
+
"scripts from being aggregated and minimized by Autoptimize."
|
108 |
+
msgstr ""
|
109 |
+
"قائمة مفصولة بعلامة الفاصلة تحتوي على ملفات تريد استثنائها من التحسين. على "
|
110 |
+
"سبيل المثال: 'whatever.js, another.js' (بدون علامة الإقتباس)."
|
111 |
+
|
112 |
+
#: classes/autoptimizeConfig.php:104
|
113 |
+
msgid "Add try-catch wrapping?"
|
114 |
+
msgstr "تفعيل خاصّية try-catch wrapping ؟"
|
115 |
+
|
116 |
+
#: classes/autoptimizeConfig.php:106
|
117 |
+
msgid ""
|
118 |
+
"If your scripts break because of an script error, you might want to try this."
|
119 |
+
msgstr "فعّل هذا الخيار في حالة وجود عطل في ملف الكود."
|
120 |
+
|
121 |
+
#: classes/autoptimizeConfig.php:110
|
122 |
+
msgid "CSS Options"
|
123 |
+
msgstr "خيارات CSS"
|
124 |
+
|
125 |
+
#: classes/autoptimizeConfig.php:113
|
126 |
+
msgid "Optimize CSS Code?"
|
127 |
+
msgstr "تحسين أكواد CSS؟"
|
128 |
+
|
129 |
+
#: classes/autoptimizeConfig.php:117
|
130 |
+
msgid "Generate data: URIs for images?"
|
131 |
+
msgstr "توليد بيانات: روابط للصور؟"
|
132 |
+
|
133 |
+
#: classes/autoptimizeConfig.php:119
|
134 |
+
msgid ""
|
135 |
+
"Enable this to include small background-images in the CSS itself instead of "
|
136 |
+
"as seperate downloads."
|
137 |
+
msgstr ""
|
138 |
+
"فعّل هذا الخيار لإضافة الخلفيات الصغيرة داخل أكواد CSS، بدلاً من تحميلها بشكل "
|
139 |
+
"مستقل."
|
140 |
+
|
141 |
+
#: classes/autoptimizeConfig.php:122
|
142 |
+
msgid "Look for styles only in <head>?"
|
143 |
+
msgstr "ابحث عن أكواد فقط في <head>؟"
|
144 |
+
|
145 |
+
#: classes/autoptimizeConfig.php:124
|
146 |
+
msgid ""
|
147 |
+
"Don't autoptimize CSS outside the head-section. If the cache gets big, you "
|
148 |
+
"might want to enable this."
|
149 |
+
msgstr ""
|
150 |
+
"لا تقم بتحسين ملفات خارج قسم head. قم بتفعيل هذا الخيار إذا كان ملف الكاش "
|
151 |
+
"كبير."
|
152 |
+
|
153 |
+
#: classes/autoptimizeConfig.php:127
|
154 |
+
msgid "Inline and Defer CSS?"
|
155 |
+
msgstr "استخراج أكواد CSS على السطر؟ "
|
156 |
+
|
157 |
+
#: classes/autoptimizeConfig.php:129
|
158 |
+
msgid ""
|
159 |
+
"Inline \"above the fold CSS\" while loading the main autoptimized CSS only "
|
160 |
+
"after page load. <a href=\"http://wordpress.org/plugins/autoptimize/faq/\" "
|
161 |
+
"target=\"_blank\">Check the FAQ</a> before activating this option!"
|
162 |
+
msgstr ""
|
163 |
+
"استخرج \"أكواد CSS فوق الطيّة\" أثناء تحميل ملف الكاش الأساسي فقط بعد تحميل "
|
164 |
+
"الصفحة. <a href=\"http://wordpress.org/plugins/autoptimize/faq/\" target="
|
165 |
+
"\"_blank\">إطّلع على الأسئلة الشائعة</a> قبل تفعيل هذا الخيار!"
|
166 |
+
|
167 |
+
#: classes/autoptimizeConfig.php:133
|
168 |
+
msgid "Paste the above the fold CSS here."
|
169 |
+
msgstr "قم بلصق أكواد CSS فوق الطيّة هنا."
|
170 |
+
|
171 |
+
#: classes/autoptimizeConfig.php:136
|
172 |
+
msgid "Inline all CSS?"
|
173 |
+
msgstr "إستخراج جميع أكواد CSS على السطر؟"
|
174 |
+
|
175 |
+
#: classes/autoptimizeConfig.php:138
|
176 |
+
msgid ""
|
177 |
+
"Inlining all CSS can improve performance for sites with a low pageviews/ "
|
178 |
+
"visitor-rate, but may slow down performance otherwise."
|
179 |
+
msgstr ""
|
180 |
+
"إستخراج أكواد CSS على السطر يحسّن الآداء للمواقع القليل زيارتها. ولكن قد يبطئ "
|
181 |
+
"الآداء قليلاً."
|
182 |
+
|
183 |
+
#: classes/autoptimizeConfig.php:141
|
184 |
+
msgid "Exclude CSS from Autoptimize:"
|
185 |
+
msgstr "أكواد CSS مستثناه من التحسين:"
|
186 |
+
|
187 |
+
#: classes/autoptimizeConfig.php:143
|
188 |
+
msgid "A comma-seperated list of CSS you want to exclude from being optimized."
|
189 |
+
msgstr "قائمة مفصولة بعلامة الفاصلة تحتوي على ملفات تريد استثنائها من التحسين."
|
190 |
+
|
191 |
+
#: classes/autoptimizeConfig.php:147
|
192 |
+
msgid "CDN Options"
|
193 |
+
msgstr "خيارات CDN"
|
194 |
+
|
195 |
+
#: classes/autoptimizeConfig.php:150
|
196 |
+
msgid "CDN Base URL"
|
197 |
+
msgstr "رابط CDN"
|
198 |
+
|
199 |
+
#: classes/autoptimizeConfig.php:152
|
200 |
+
msgid ""
|
201 |
+
"Enter your CDN blog root directory URL if you want to enable CDN for images "
|
202 |
+
"referenced in the CSS."
|
203 |
+
msgstr "قم بإدخال رابط CDN الجذر لمدونتك لتفعيل الصور التي داخل أكواد CSS."
|
204 |
+
|
205 |
+
#: classes/autoptimizeConfig.php:156
|
206 |
+
msgid "Cache Info"
|
207 |
+
msgstr "معلومات الكاش"
|
208 |
+
|
209 |
+
#: classes/autoptimizeConfig.php:159
|
210 |
+
msgid "Cache folder"
|
211 |
+
msgstr "مجلد الكاش"
|
212 |
+
|
213 |
+
#: classes/autoptimizeConfig.php:163
|
214 |
+
msgid "Can we write?"
|
215 |
+
msgstr "هل يمكن الكتابة؟"
|
216 |
+
|
217 |
+
#: classes/autoptimizeConfig.php:164
|
218 |
+
msgid "Yes"
|
219 |
+
msgstr "نعم"
|
220 |
+
|
221 |
+
#: classes/autoptimizeConfig.php:164
|
222 |
+
msgid "No"
|
223 |
+
msgstr "لا"
|
224 |
+
|
225 |
+
#: classes/autoptimizeConfig.php:167
|
226 |
+
msgid "Cached styles and scripts"
|
227 |
+
msgstr "ملفات كاش لـ JavaScripts و CSS"
|
228 |
+
|
229 |
+
#: classes/autoptimizeConfig.php:171
|
230 |
+
msgid "Save aggregated script/css as static files?"
|
231 |
+
msgstr "حفظ ملفات JavaScripts و CSS المجمعة كملفات ثابتة؟"
|
232 |
+
|
233 |
+
#: classes/autoptimizeConfig.php:173
|
234 |
+
msgid ""
|
235 |
+
"By default files saved are static css/js, uncheck this option if your "
|
236 |
+
"webserver doesn't properly handle the compression and expiry."
|
237 |
+
msgstr ""
|
238 |
+
"ملفات JavaScripts و CSS تحفظ بشكل تلقائي كملفات ثابتة. قم بإلغاء هذا الخيار "
|
239 |
+
"إذا كان خادمك لا يقوم بالتعامل مع الضغط والصلاحيات بشكل سليم."
|
240 |
+
|
241 |
+
#: classes/autoptimizeConfig.php:179
|
242 |
+
msgid "Save Changes"
|
243 |
+
msgstr "حفظ التغييرات"
|
244 |
+
|
245 |
+
#: classes/autoptimizeConfig.php:180
|
246 |
+
msgid "Save Changes and Empty Cache"
|
247 |
+
msgstr "حفظ التغييرات وتفريغ الكاش"
|
248 |
+
|
249 |
+
#: classes/autoptimizeConfig.php:188
|
250 |
+
msgid "futtta about"
|
251 |
+
msgstr "عن futtta"
|
252 |
+
|
253 |
+
#. #-#-#-#-# plugin.pot (Autoptimize 1.8.5) #-#-#-#-#
|
254 |
+
#. Plugin Name of the plugin/theme
|
255 |
+
#: classes/autoptimizeConfig.php:190
|
256 |
+
msgid "Autoptimize"
|
257 |
+
msgstr "Autoptimize"
|
258 |
+
|
259 |
+
#: classes/autoptimizeConfig.php:191
|
260 |
+
msgid "WordPress"
|
261 |
+
msgstr "وردبريس"
|
262 |
+
|
263 |
+
#: classes/autoptimizeConfig.php:192
|
264 |
+
msgid "Web Technology"
|
265 |
+
msgstr "تقنية الويب"
|
266 |
+
|
267 |
+
#: classes/autoptimizeConfig.php:197
|
268 |
+
msgid "Do not donate for this plugin!"
|
269 |
+
msgstr "لا تقم بالتبرع لهذه الإضافة!"
|
270 |
+
|
271 |
+
#: classes/autoptimizeConfig.php:313
|
272 |
+
msgid "Autoptimize Options"
|
273 |
+
msgstr "خيارات Autoptimize"
|
274 |
+
|
275 |
+
#: classes/autoptimizeConfig.php:358 classes/autoptimizeConfig.php:364
|
276 |
+
msgid "Settings"
|
277 |
+
msgstr "إعدادات"
|
278 |
+
|
279 |
+
#. Plugin URI of the plugin/theme
|
280 |
+
msgid "http://blog.futtta.be/autoptimize"
|
281 |
+
msgstr "http://blog.futtta.be/autoptimize"
|
282 |
+
|
283 |
+
#. Description of the plugin/theme
|
284 |
+
msgid ""
|
285 |
+
"Optimizes your website, concatenating the CSS and JavaScript code, and "
|
286 |
+
"compressing it."
|
287 |
+
msgstr "حسّن موقعك وسلسل أكواد CSS و JavaScript، وقم بضغطها."
|
288 |
+
|
289 |
+
#. Author of the plugin/theme
|
290 |
+
msgid "Frank Goossens (futtta)"
|
291 |
+
msgstr "Frank Goossens (futtta)"
|
292 |
+
|
293 |
+
#. Author URI of the plugin/theme
|
294 |
+
msgid "http://blog.futtta.be/"
|
295 |
+
msgstr "http://blog.futtta.be/"
|
localization/autoptimize-de_DE.po
CHANGED
@@ -94,7 +94,7 @@ msgstr "Nach Skripten nur in <head> suchen?"
|
|
94 |
|
95 |
#: classes/autoptimizeConfig.php:96
|
96 |
msgid ""
|
97 |
-
"Mostly
|
98 |
"templates, but might help keeping cache size under control."
|
99 |
msgstr ""
|
100 |
"Oft in Kombination mit der vorhergehenden Option nützlich, wenn "
|
94 |
|
95 |
#: classes/autoptimizeConfig.php:96
|
96 |
msgid ""
|
97 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
98 |
"templates, but might help keeping cache size under control."
|
99 |
msgstr ""
|
100 |
"Oft in Kombination mit der vorhergehenden Option nützlich, wenn "
|
localization/autoptimize-fa_IR.po
CHANGED
@@ -91,7 +91,7 @@ msgstr "فقط اسکریپت های موجود در تگ <head> بهین
|
|
91 |
|
92 |
#: classes/autoptimizeConfig.php:96
|
93 |
msgid ""
|
94 |
-
"Mostly
|
95 |
"templates, but might help keeping cache size under control."
|
96 |
msgstr ""
|
97 |
"این گزینه بیشتر زمانی کاربردی است که با گزینه قبلی برای پوسته های تحت jQuery "
|
91 |
|
92 |
#: classes/autoptimizeConfig.php:96
|
93 |
msgid ""
|
94 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
95 |
"templates, but might help keeping cache size under control."
|
96 |
msgstr ""
|
97 |
"این گزینه بیشتر زمانی کاربردی است که با گزینه قبلی برای پوسته های تحت jQuery "
|
localization/autoptimize-fr_FR.po
CHANGED
@@ -92,7 +92,7 @@ msgstr "Chercher les scripts uniquement dans l'en-tête ?"
|
|
92 |
|
93 |
#: classes/autoptimizeConfig.php:96
|
94 |
msgid ""
|
95 |
-
"Mostly
|
96 |
"templates, but might help keeping cache size under control."
|
97 |
msgstr ""
|
98 |
"Surtout utile combiné aux précédentes options lorsque vous utilisez des "
|
92 |
|
93 |
#: classes/autoptimizeConfig.php:96
|
94 |
msgid ""
|
95 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
96 |
"templates, but might help keeping cache size under control."
|
97 |
msgstr ""
|
98 |
"Surtout utile combiné aux précédentes options lorsque vous utilisez des "
|
localization/autoptimize-nl_BE.po
CHANGED
@@ -91,7 +91,7 @@ msgstr "Haal javascript enkel uit <head>?"
|
|
91 |
|
92 |
#: classes/autoptimizeConfig.php:96
|
93 |
msgid ""
|
94 |
-
"Mostly
|
95 |
"templates, but might help keeping cache size under control."
|
96 |
msgstr ""
|
97 |
"Vooral nuttig in combinatie met de vorige optie voor jQuery-gebaseerde "
|
91 |
|
92 |
#: classes/autoptimizeConfig.php:96
|
93 |
msgid ""
|
94 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
95 |
"templates, but might help keeping cache size under control."
|
96 |
msgstr ""
|
97 |
"Vooral nuttig in combinatie met de vorige optie voor jQuery-gebaseerde "
|
localization/autoptimize-nl_NL.po
CHANGED
@@ -91,7 +91,7 @@ msgstr "Haal javascript enkel uit <head>?"
|
|
91 |
|
92 |
#: classes/autoptimizeConfig.php:96
|
93 |
msgid ""
|
94 |
-
"Mostly
|
95 |
"templates, but might help keeping cache size under control."
|
96 |
msgstr ""
|
97 |
"Vooral nuttig in combinatie met de vorige optie voor jQuery-gebaseerde "
|
91 |
|
92 |
#: classes/autoptimizeConfig.php:96
|
93 |
msgid ""
|
94 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
95 |
"templates, but might help keeping cache size under control."
|
96 |
msgstr ""
|
97 |
"Vooral nuttig in combinatie met de vorige optie voor jQuery-gebaseerde "
|
localization/autoptimize-pl_PL.po
CHANGED
@@ -95,7 +95,7 @@ msgstr "Wyszukuj skryptów tylko w <head>?"
|
|
95 |
|
96 |
#: classes/autoptimizeConfig.php:96
|
97 |
msgid ""
|
98 |
-
"Mostly
|
99 |
"templates, but might help keeping cache size under control."
|
100 |
msgstr ""
|
101 |
"Przeważnie użyteczne w połączeniu z poprzednią opcją w momencie kiedy "
|
95 |
|
96 |
#: classes/autoptimizeConfig.php:96
|
97 |
msgid ""
|
98 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
99 |
"templates, but might help keeping cache size under control."
|
100 |
msgstr ""
|
101 |
"Przeważnie użyteczne w połączeniu z poprzednią opcją w momencie kiedy "
|
localization/autoptimize-pt_BR.po
CHANGED
@@ -97,7 +97,7 @@ msgstr "Buscar scripts somente na seção <head>?"
|
|
97 |
|
98 |
#: classes/autoptimizeConfig.php:96
|
99 |
msgid ""
|
100 |
-
"Mostly
|
101 |
"templates, but might help keeping cache size under control."
|
102 |
msgstr ""
|
103 |
"Normalmente usado em conjunto com a opção anterior quando se usa temas "
|
97 |
|
98 |
#: classes/autoptimizeConfig.php:96
|
99 |
msgid ""
|
100 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
101 |
"templates, but might help keeping cache size under control."
|
102 |
msgstr ""
|
103 |
"Normalmente usado em conjunto com a opção anterior quando se usa temas "
|
localization/autoptimize-sv_SE.po
CHANGED
@@ -92,7 +92,7 @@ msgstr "Leta efter script enbart i <head>?"
|
|
92 |
|
93 |
#: classes/autoptimizeConfig.php:96
|
94 |
msgid ""
|
95 |
-
"Mostly
|
96 |
"templates, but might help keeping cache size under control."
|
97 |
msgstr ""
|
98 |
"Mest användbart i kombination med föregående alternativ, när jQuery-baserade "
|
92 |
|
93 |
#: classes/autoptimizeConfig.php:96
|
94 |
msgid ""
|
95 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
96 |
"templates, but might help keeping cache size under control."
|
97 |
msgstr ""
|
98 |
"Mest användbart i kombination med föregående alternativ, när jQuery-baserade "
|
localization/autoptimize-tr_TR.po
CHANGED
@@ -93,7 +93,7 @@ msgstr "Yalnızca <head>'deki JavaScript dosyalarıyla ilgilen"
|
|
93 |
|
94 |
#: classes/autoptimizeConfig.php:96
|
95 |
msgid ""
|
96 |
-
"Mostly
|
97 |
"templates, but might help keeping cache size under control."
|
98 |
msgstr ""
|
99 |
"Çoğunlukla, önceki seçenekle beraber jQuery ağırlıklı temalarında "
|
93 |
|
94 |
#: classes/autoptimizeConfig.php:96
|
95 |
msgid ""
|
96 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
97 |
"templates, but might help keeping cache size under control."
|
98 |
msgstr ""
|
99 |
"Çoğunlukla, önceki seçenekle beraber jQuery ağırlıklı temalarında "
|
localization/autoptimize-uk_UA.po
CHANGED
@@ -152,7 +152,7 @@ msgstr "Оптимізувати скрипти тільки в секції <
|
|
152 |
# @ autoptimize
|
153 |
#: classes/autoptimizeConfig.php:96
|
154 |
msgid ""
|
155 |
-
"Mostly
|
156 |
"templates, but might help keeping cache size under control."
|
157 |
msgstr ""
|
158 |
"Корисна опція (в поєднанні з попередньою опцією), при використанні шаблонів "
|
152 |
# @ autoptimize
|
153 |
#: classes/autoptimizeConfig.php:96
|
154 |
msgid ""
|
155 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
156 |
"templates, but might help keeping cache size under control."
|
157 |
msgstr ""
|
158 |
"Корисна опція (в поєднанні з попередньою опцією), при використанні шаблонів "
|
localization/autoptimize.pot
CHANGED
@@ -80,7 +80,7 @@ msgstr ""
|
|
80 |
|
81 |
#: classes/autoptimizeConfig.php:96
|
82 |
msgid ""
|
83 |
-
"Mostly
|
84 |
"templates, but might help keeping cache size under control."
|
85 |
msgstr ""
|
86 |
|
80 |
|
81 |
#: classes/autoptimizeConfig.php:96
|
82 |
msgid ""
|
83 |
+
"Mostly useful in combination with previous option when using jQuery-based "
|
84 |
"templates, but might help keeping cache size under control."
|
85 |
msgstr ""
|
86 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Autoptimize ===
|
2 |
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: 4.
|
7 |
-
Stable tag: 1.9.
|
8 |
|
9 |
Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
|
10 |
|
@@ -17,11 +17,11 @@ If you consider performance important, you really should use a caching-plugin su
|
|
17 |
|
18 |
== Installation ==
|
19 |
|
20 |
-
Just install
|
21 |
|
22 |
-
1. Upload the zip
|
23 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
24 |
-
1. Go to `Settings
|
25 |
|
26 |
== Frequently Asked Questions ==
|
27 |
|
@@ -33,12 +33,6 @@ It concatenates all scripts and styles, minifies and compresses them, adds expir
|
|
33 |
|
34 |
Although Autoptimize comes without any warranties, it will in general work flawlessly if you configure it correctly. See "Troubleshooting" below for info on how to configure in case of problems.
|
35 |
|
36 |
-
= I activated Autoptimize, but Google Pagespeed Insight still complains? =
|
37 |
-
|
38 |
-
If you have render-blocking JS: be sure not to tick the "force JS in head" if not absolutely needed.
|
39 |
-
|
40 |
-
If you have render-blocking CSS: consider to "inline" or "inline and defer" your CSS. There's more info on these topics below.
|
41 |
-
|
42 |
= What is the use of "inline and defer CSS"? =
|
43 |
|
44 |
CSS in general should go in the head of the document. Recently a.o. Google started promoting deferring non-essential CSS, while inlining those styles needed to build the page above the fold. This is especially important to render pages as quickly as possible on mobile devices. As from Autoptimize 1.9.0 this is easy; select "inline and defer CSS", paste the block of "above the fold CSS" in the input field (text area) and you're good to go!
|
@@ -64,11 +58,14 @@ You can find more information on this topic [in this blog post](http://blog.futt
|
|
64 |
Autoptimize does not have its proper cache purging mechanism, as this could remove optimized CSS/JS which is still referred to in other caches, which would break your site.
|
65 |
|
66 |
You can however keep the cache size at an acceptable level by either:
|
67 |
-
|
68 |
* ticking the "look only in head" option for JS and/or CSS.
|
69 |
* using the API to force AO not to aggregate inline CSS or JS (see example-code in autoptimize_helper.php_example).
|
70 |
* excluding JS-variables (or sometimes CSS-selectors) that change on a per page (or per pageload) basis. You can read how you can do that [in this blogpost](http://blog.futtta.be/2014/03/19/how-to-keep-autoptimizes-cache-size-under-control-and-improve-visitor-experience/).
|
71 |
|
|
|
|
|
|
|
|
|
72 |
= What can I do with the API? =
|
73 |
|
74 |
A whole lot; there are filters you can use to conditionally disable Autoptimize per request, to change the CSS- and JS-excludes, to change the limit for CSS background-images to be inlined in the CSS, to define what JS-files are moved behing the aggregated on, to change the defer-attribute on the aggregated JS script-tag, ... There are examples for many filters in autoptimize_helper.php_example.
|
@@ -87,10 +84,6 @@ If you want your uploaded images to be on the CDN as well, you can change the up
|
|
87 |
|
88 |
If your webserver is properly configured to handle compression (gzip or deflate) and cache expiry (expires and cache-control with sufficient cacheability), you don't need Autoptimize to handle that for you. In that case you can check the "Save aggregated script/css as static files?"-option, which will force Autoptimize to save the aggregated files as .css and .js-files (meaning no PHP is needed to serve these files). This setting is default as of Autoptimize 1.8.
|
89 |
|
90 |
-
= Compatibility with WP SlimSat =
|
91 |
-
|
92 |
-
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.
|
93 |
-
|
94 |
= How does "exclude from optimizing" work? =
|
95 |
|
96 |
Both CSS and JS optimization can skip code from being aggregated and minimized by adding "identifiers" to the comma-seperated exclusion list. The exact identifier string to use can be determined this way:
|
@@ -105,13 +98,16 @@ After having installed and activated the plugin, you'll have access to an admin
|
|
105 |
|
106 |
If your blog doesn't function normally after having turned on Autoptimize, here are some pointers to identify & solve such issues using "advanced settings":
|
107 |
|
|
|
108 |
* In case your blog looks weird, i.e. when the layout gets messed up, there is problem with CSS optimization. In this case you can turn on the option "Look for styles on just head?" and see if that solves the problem. You can also force CSS not to be aggregated by wrapping it in noptimize-tags in your theme or widget or by adding filename (for external stylesheets) or string (for inline styles) to the exclude-list.
|
109 |
* In case some functionality on your site stops working (a carroussel, a menu, the search input, ...) you're likely hitting JavaScript optimization trouble. Enable the option "Look for scripts only in head?" and/or "Force JavaScript in <head>?" and/or "[Add try/catch wrapping](http://blog.futtta.be/2014/08/18/when-should-you-trycatch-javascript/)" and try again. Alternatively -for the technically savvy- you can exclude specific scripts from being treated (moved and/ or aggregated) by Autoptimize by adding a string that will match the offending Javascript or excluding it from within your template files or widgets by wrapping the code between noptimize-tags. Identifying the offending JavaScript and choosing the correct exclusion-string can be trial and error, but in the majority of cases JavaScript optimization issues can be solved this way.
|
110 |
* If your theme uses jQuery, you can try either forcing all in head or excluding jquery(-min).js (and jQuery-plugins if needed).
|
111 |
* If you can't get either CSS or JS optimization working, you can off course always continue using the other two optimization-techniques.
|
112 |
* If you tried the troubleshooting tips above and you still can't get CSS and JS working at all, you can ask for support on the [WordPress Autoptimize support forum](http://wordpress.org/support/plugin/autoptimize). See below for a description of what information you should provide in your "trouble ticket"
|
113 |
|
114 |
-
= Help, I have a blank page after enabling Autoptimize!! =
|
|
|
|
|
115 |
|
116 |
In some rare cases the [CSS minification component](https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/) currently used by Autoptimize crashes due to a lack of resources (see [detailed technical explanation here](http://blog.futtta.be/2014/01/14/irregular-expressions-have-your-stack-for-lunch/)). You can in that case either disable CSS optimization, try to exclude specific CSS from being aggregated or activate the legacy minifiers which don't have that problem. The latter can be accomplished by adding this to your wp-config.php:
|
117 |
|
@@ -134,7 +130,7 @@ define('AUTOPTIMIZE_CACHE_CHILD_DIR','/resources/');
|
|
134 |
define('AUTOPTIMIZE_CACHEFILE_PREFIX','aggregated_');
|
135 |
`
|
136 |
|
137 |
-
If you
|
138 |
`
|
139 |
define( 'AUTOPTIMIZE_WP_CONTENT_NAME','/content' );
|
140 |
`
|
@@ -163,6 +159,19 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
|
|
163 |
|
164 |
== Changelog ==
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
= 1.9.2 =
|
167 |
First of all; Happy holidays, all the best for 2015!!
|
168 |
|
1 |
=== Autoptimize ===
|
2 |
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: 4.2
|
7 |
+
Stable tag: 1.9.3
|
8 |
|
9 |
Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
|
10 |
|
17 |
|
18 |
== Installation ==
|
19 |
|
20 |
+
Just install from your WordPress "Plugins > Add New" screen and all will be well. Manual installation is very straightforward as well:
|
21 |
|
22 |
+
1. Upload the zip file and unzip it in the `/wp-content/plugins/` directory
|
23 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
24 |
+
1. Go to `Settings > Autoptimize` and enable the options you want. Generally this means "Optimize HTML/ CSS/ JavaScript".
|
25 |
|
26 |
== Frequently Asked Questions ==
|
27 |
|
33 |
|
34 |
Although Autoptimize comes without any warranties, it will in general work flawlessly if you configure it correctly. See "Troubleshooting" below for info on how to configure in case of problems.
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
= What is the use of "inline and defer CSS"? =
|
37 |
|
38 |
CSS in general should go in the head of the document. Recently a.o. Google started promoting deferring non-essential CSS, while inlining those styles needed to build the page above the fold. This is especially important to render pages as quickly as possible on mobile devices. As from Autoptimize 1.9.0 this is easy; select "inline and defer CSS", paste the block of "above the fold CSS" in the input field (text area) and you're good to go!
|
58 |
Autoptimize does not have its proper cache purging mechanism, as this could remove optimized CSS/JS which is still referred to in other caches, which would break your site.
|
59 |
|
60 |
You can however keep the cache size at an acceptable level by either:
|
|
|
61 |
* ticking the "look only in head" option for JS and/or CSS.
|
62 |
* using the API to force AO not to aggregate inline CSS or JS (see example-code in autoptimize_helper.php_example).
|
63 |
* excluding JS-variables (or sometimes CSS-selectors) that change on a per page (or per pageload) basis. You can read how you can do that [in this blogpost](http://blog.futtta.be/2014/03/19/how-to-keep-autoptimizes-cache-size-under-control-and-improve-visitor-experience/).
|
64 |
|
65 |
+
= Why is "look only in head" marked as deprecated =
|
66 |
+
|
67 |
+
While "look only in head" still works, it will in the next major version be replaced by an option to choose if inline JS/ CSS should be autoptimized (which is much more useful). So this is just a small heads up, really.
|
68 |
+
|
69 |
= What can I do with the API? =
|
70 |
|
71 |
A whole lot; there are filters you can use to conditionally disable Autoptimize per request, to change the CSS- and JS-excludes, to change the limit for CSS background-images to be inlined in the CSS, to define what JS-files are moved behing the aggregated on, to change the defer-attribute on the aggregated JS script-tag, ... There are examples for many filters in autoptimize_helper.php_example.
|
84 |
|
85 |
If your webserver is properly configured to handle compression (gzip or deflate) and cache expiry (expires and cache-control with sufficient cacheability), you don't need Autoptimize to handle that for you. In that case you can check the "Save aggregated script/css as static files?"-option, which will force Autoptimize to save the aggregated files as .css and .js-files (meaning no PHP is needed to serve these files). This setting is default as of Autoptimize 1.8.
|
86 |
|
|
|
|
|
|
|
|
|
87 |
= How does "exclude from optimizing" work? =
|
88 |
|
89 |
Both CSS and JS optimization can skip code from being aggregated and minimized by adding "identifiers" to the comma-seperated exclusion list. The exact identifier string to use can be determined this way:
|
98 |
|
99 |
If your blog doesn't function normally after having turned on Autoptimize, here are some pointers to identify & solve such issues using "advanced settings":
|
100 |
|
101 |
+
* If all works but you notice your blog is slower, ensure you have a page caching plugin installed (WP Super Cache or similar).
|
102 |
* In case your blog looks weird, i.e. when the layout gets messed up, there is problem with CSS optimization. In this case you can turn on the option "Look for styles on just head?" and see if that solves the problem. You can also force CSS not to be aggregated by wrapping it in noptimize-tags in your theme or widget or by adding filename (for external stylesheets) or string (for inline styles) to the exclude-list.
|
103 |
* In case some functionality on your site stops working (a carroussel, a menu, the search input, ...) you're likely hitting JavaScript optimization trouble. Enable the option "Look for scripts only in head?" and/or "Force JavaScript in <head>?" and/or "[Add try/catch wrapping](http://blog.futtta.be/2014/08/18/when-should-you-trycatch-javascript/)" and try again. Alternatively -for the technically savvy- you can exclude specific scripts from being treated (moved and/ or aggregated) by Autoptimize by adding a string that will match the offending Javascript or excluding it from within your template files or widgets by wrapping the code between noptimize-tags. Identifying the offending JavaScript and choosing the correct exclusion-string can be trial and error, but in the majority of cases JavaScript optimization issues can be solved this way.
|
104 |
* If your theme uses jQuery, you can try either forcing all in head or excluding jquery(-min).js (and jQuery-plugins if needed).
|
105 |
* If you can't get either CSS or JS optimization working, you can off course always continue using the other two optimization-techniques.
|
106 |
* If you tried the troubleshooting tips above and you still can't get CSS and JS working at all, you can ask for support on the [WordPress Autoptimize support forum](http://wordpress.org/support/plugin/autoptimize). See below for a description of what information you should provide in your "trouble ticket"
|
107 |
|
108 |
+
= Help, I have a blank page or an internal server error after enabling Autoptimize!! =
|
109 |
+
|
110 |
+
First of all make sure you're not running other HTML, CSS or JS minification plugins simultaneously with Autoptimize.
|
111 |
|
112 |
In some rare cases the [CSS minification component](https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/) currently used by Autoptimize crashes due to a lack of resources (see [detailed technical explanation here](http://blog.futtta.be/2014/01/14/irregular-expressions-have-your-stack-for-lunch/)). You can in that case either disable CSS optimization, try to exclude specific CSS from being aggregated or activate the legacy minifiers which don't have that problem. The latter can be accomplished by adding this to your wp-config.php:
|
113 |
|
130 |
define('AUTOPTIMIZE_CACHEFILE_PREFIX','aggregated_');
|
131 |
`
|
132 |
|
133 |
+
If you changed your wp-content-folder as per [the WordPress guidelines](http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder), you can tell Autoptimize about that with;
|
134 |
`
|
135 |
define( 'AUTOPTIMIZE_WP_CONTENT_NAME','/content' );
|
136 |
`
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 1.9.3 =
|
163 |
+
* improvement: more intelligent CDN-replacement logic, thanks [Squazz for reporting and testing](https://wordpress.org/support/topic/enable-cdn-for-images-referenced-in-the-css?replies=9)
|
164 |
+
* improvement: allow strings (comments) to be excluded from HTML-optimization (comment removal)
|
165 |
+
* improvement: changed priority with which AO gets triggered by WordPress, solving JS not being aggregated when NextGen Galleries is active, with great [help from msebald](https://wordpress.org/support/topic/js-options-dont-work-if-html-disabled/)
|
166 |
+
* improvement: extra JS exclude-strings: gist.github.com, text/html, text/template, wp-slimstat.min.js, _stq, nonce, post_id (the latter two were removed from the "manual" exclude list on the settings-page)
|
167 |
+
* new in API: autoptimize_filter_html_exclude, autoptimize_filter_css_defer, autoptimize_filter_css_inline, autoptimize_filter_base_replace_cdn, autoptimize_filter_js_noptimize, autoptimize_filter_css_noptimize, autoptimize_filter_html_noptimize
|
168 |
+
* bugfix: remove some PHP notices, as [reported by dimitrov.adrian](https://wordpress.org/support/topic/php-errors-39)
|
169 |
+
* bugfix: make sure HTML-optimalization does not gobble a space before a cite [as proposed by ecdltf](https://wordpress.org/support/topic/%E2%80%9Coptimize-html%E2%80%9D-is-gobbling-whitespace-before-cite-tag)
|
170 |
+
* bugfix: cleaning the cache did not work on non-default directories as [encountered by NoahJ Champion](https://wordpress.org/support/topic/changing-the-wp-content-path-to-top-level?replies=10#post-6573657)
|
171 |
+
* upgraded to [yui compressor php port 2.4.8-4](https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port)
|
172 |
+
* added arabic translation, thanks to the [ekleel team](http://www.ekleel.net)
|
173 |
+
* tested with WordPress 4.2 beta 3
|
174 |
+
|
175 |
= 1.9.2 =
|
176 |
First of all; Happy holidays, all the best for 2015!!
|
177 |
|