Autoptimize - Version 1.5.1

Version Description

  • bugfix: add CSS before opening title-tag instead of after closing title, to avoid CSS being loaded in wrong order, as reported by fotofashion and blogitsolutions (thanks guys)
Download this release

Release Info

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

Code changes from version 1.5 to 1.5.1

autoptimize.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Autoptimize
4
  Plugin URI: http://blog.futtta.be/category/autoptimize/
5
  Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
6
- Version: 1.5
7
  Author: Frank Goossens (futtta)
8
  Author URI: http://blog.futtta.be/
9
  Released under the GNU General Public License (GPL)
3
  Plugin Name: Autoptimize
4
  Plugin URI: http://blog.futtta.be/category/autoptimize/
5
  Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
6
+ Version: 1.5.1
7
  Author: Frank Goossens (futtta)
8
  Author URI: http://blog.futtta.be/
9
  Released under the GNU General Public License (GPL)
classes/autoptimizeConfig.php CHANGED
@@ -13,6 +13,7 @@ class autoptimizeConfig
13
  //Add the admin page and settings
14
  add_action('admin_menu',array($this,'addmenu'));
15
  add_action('admin_init',array($this,'registersettings'));
 
16
  //Set meta info
17
  if(function_exists('plugin_row_meta'))
18
  {
@@ -49,22 +50,7 @@ class autoptimizeConfig
49
  <div class="wrap">
50
  <h2><?php _e('Autoptimize Settings','autoptimize'); ?></h2>
51
 
52
- <div style="position:absolute;right:50px;background:#FFFFE0;border:1px solid #E6DB55;padding:5px;text-align:center;">
53
- Like Autoptimize?
54
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
55
- <input type="hidden" name="cmd" value="_donations">
56
- <input type="hidden" name="business" value="webmaster@turl.com.ar">
57
- <input type="hidden" name="lc" value="AR">
58
- <input type="hidden" name="item_name" value="Autoptimize">
59
- <input type="hidden" name="item_number" value="autoptimize">
60
- <input type="hidden" name="currency_code" value="USD">
61
- <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_SM.gif:NonHostedGuest">
62
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
63
- <img alt="" border="0" src="https://www.paypal.com/es_XC/i/scr/pixel.gif" width="1" height="1">
64
- </form>
65
- Buy the original <br /> author a coffee :-)
66
- </div>
67
-
68
  <form method="post" action="options.php">
69
  <?php settings_fields('autoptimize'); ?>
70
 
@@ -190,14 +176,69 @@ Buy the original <br /> author a coffee :-)
190
  </p>
191
 
192
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  </div>
194
  <?php
195
  }
196
 
197
  public function addmenu()
198
  {
199
- add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize',8,'autoptimize',array($this,'show'));
 
 
200
  }
 
 
 
 
 
 
 
 
 
 
201
 
202
  public function registersettings()
203
  {
13
  //Add the admin page and settings
14
  add_action('admin_menu',array($this,'addmenu'));
15
  add_action('admin_init',array($this,'registersettings'));
16
+
17
  //Set meta info
18
  if(function_exists('plugin_row_meta'))
19
  {
50
  <div class="wrap">
51
  <h2><?php _e('Autoptimize Settings','autoptimize'); ?></h2>
52
 
53
+ <div style="float:left;width:70%;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  <form method="post" action="options.php">
55
  <?php settings_fields('autoptimize'); ?>
56
 
176
  </p>
177
 
178
  </form>
179
+ </div>
180
+ <div style="float:right;width:30%" id="autoptimize_admin_feed">
181
+ <div style="margin-left:10px;margin-top:-5px;">
182
+ <h3>
183
+ <?php _e("futtta about","autoptimize") ?>
184
+ <select id="feed_dropdown" >
185
+ <option value="1"><?php _e("Autoptimize","autoptimize") ?></option>
186
+ <option value="2"><?php _e("WordPress","autoptimize") ?></option>
187
+ <option value="3"><?php _e("Web Technology","autoptimize") ?></option>
188
+ </select>
189
+ </h3>
190
+ <div id="futtta_feed"></div>
191
+ </div>
192
+ </div>
193
+
194
+ <script type="text/javascript">
195
+ var feed = new Array;
196
+ feed[1]="http://feeds.feedburner.com/futtta_autoptimize";
197
+ feed[2]="http://feeds.feedburner.com/futtta_wordpress";
198
+ feed[3]="http://feeds.feedburner.com/futtta_webtech";
199
+ cookiename="autoptimize_feed";
200
+
201
+ jQuery(document).ready(function() {
202
+ jQuery("#feed_dropdown").change(function() { show_feed(jQuery("#feed_dropdown").val()) });
203
+
204
+ feedid=jQuery.cookie(cookiename);
205
+ if(typeof(feedid) !== "string") feedid=1;
206
+
207
+ show_feed(feedid);
208
+ })
209
+
210
+ function show_feed(id) {
211
+ jQuery('#futtta_feed').rssfeed(feed[id], {
212
+ <?php if ( is_ssl() ) echo "ssl: true,"; ?>
213
+ limit: 4,
214
+ date: true,
215
+ header: false
216
+ });
217
+ jQuery("#feed_dropdown").val(id);
218
+ jQuery.cookie(cookiename,id,{ expires: 365 });
219
+ }
220
+ </script>
221
+
222
  </div>
223
  <?php
224
  }
225
 
226
  public function addmenu()
227
  {
228
+ $hook=add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize',8,'autoptimize',array($this,'show'));
229
+ add_action( 'admin_print_scripts-'.$hook,array($this,'autoptimize_admin_scripts'));
230
+ add_action( 'admin_print_styles-'.$hook,array($this,'autoptimize_admin_styles'));
231
  }
232
+
233
+ public function autoptimize_admin_scripts() {
234
+ wp_enqueue_script('jqzrssfeed', plugins_url('/external/jquery.zrssfeed.min.js', __FILE__), array(jquery),null,true);
235
+ wp_enqueue_script('jqcookie', plugins_url('/external/jquery.cookie.min.js', __FILE__), array(jquery),null,true);
236
+ }
237
+
238
+ public function autoptimize_admin_styles() {
239
+ wp_enqueue_style('zrssfeed', plugins_url('/external/jquery.zrssfeed.css', __FILE__));
240
+ }
241
+
242
 
243
  public function registersettings()
244
  {
classes/autoptimizeStyles.php CHANGED
@@ -313,14 +313,14 @@ class autoptimizeStyles extends autoptimizeBase
313
  if(!empty($this->restofcontent))
314
  {
315
  $this->content .= $this->restofcontent;
316
- $this-> nt = '';
317
  }
318
 
319
  //Add the new stylesheets
320
  foreach($this->url as $media => $url)
321
  {
322
- // fgo: these were added before </head> but that overrides iehack-stylesheets, so adding after </title> for now
323
- $this->content = str_replace('</title>','</title><link type="text/css" media="'.$media.'" href="'.$url.'" rel="stylesheet" />',$this->content);
324
  }
325
 
326
  //Return the modified stylesheet
313
  if(!empty($this->restofcontent))
314
  {
315
  $this->content .= $this->restofcontent;
316
+ $this->restofcontent = '';
317
  }
318
 
319
  //Add the new stylesheets
320
  foreach($this->url as $media => $url)
321
  {
322
+ // fgo: these were added before </head> but that overrides iehack-stylesheets, so adding before <title>
323
+ $this->content = str_replace('<title>','<link type="text/css" media="'.$media.'" href="'.$url.'" rel="stylesheet" /><title>',$this->content);
324
  }
325
 
326
  //Return the modified stylesheet
classes/external/index.html ADDED
@@ -0,0 +1 @@
 
1
+ <html><body><p><a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/">WP-YouTube-Lyte</a> is a WordPress plugin that inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but don't use Flash unless clicked on, thereby <a href="http://blog.futtta.be/2010/04/23/high-performance-youtube-embeds/" title="performance tests comparing youtube embeds with lyte embeds">reducing download size & rendering time substantially</a>. The plugin can optionally use <a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">YouTube's new experimental HTML5 embed code</a>, meaning you can have an entirely flash-less YouTube experience on your blog.</p><p>Up to date info on WP-YouTube-Lyte <a href="http://blog.futtta.be/tag/lyte/" title="more about Lyte on my blog">can be found on blog.futtta.be</a>, where you can also find <a href="http://blog.futtta.be/tag/wordpress" title="blog.futtta.be about WordPress">posts about WordPress</a> and <a href="http://blog.futtta.be/category/internet/" title="about browsers, development and mobile web on blog.futtta.be">Web Technology in general</a>.</p></body></html>
classes/external/jquery.cookie.js ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*jslint browser: true */ /*global jQuery: true */
2
+
3
+ /**
4
+ * jQuery Cookie plugin
5
+ *
6
+ * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
7
+ * Dual licensed under the MIT and GPL licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ *
11
+ */
12
+
13
+ // TODO JsDoc
14
+
15
+ /**
16
+ * Create a cookie with the given key and value and other optional parameters.
17
+ *
18
+ * @example $.cookie('the_cookie', 'the_value');
19
+ * @desc Set the value of a cookie.
20
+ * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
21
+ * @desc Create a cookie with all available options.
22
+ * @example $.cookie('the_cookie', 'the_value');
23
+ * @desc Create a session cookie.
24
+ * @example $.cookie('the_cookie', null);
25
+ * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
26
+ * used when the cookie was set.
27
+ *
28
+ * @param String key The key of the cookie.
29
+ * @param String value The value of the cookie.
30
+ * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
31
+ * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
32
+ * If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
33
+ * If set to null or omitted, the cookie will be a session cookie and will not be retained
34
+ * when the the browser exits.
35
+ * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
36
+ * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
37
+ * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
38
+ * require a secure protocol (like HTTPS).
39
+ * @type undefined
40
+ *
41
+ * @name $.cookie
42
+ * @cat Plugins/Cookie
43
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
44
+ */
45
+
46
+ /**
47
+ * Get the value of a cookie with the given key.
48
+ *
49
+ * @example $.cookie('the_cookie');
50
+ * @desc Get the value of a cookie.
51
+ *
52
+ * @param String key The key of the cookie.
53
+ * @return The value of the cookie.
54
+ * @type String
55
+ *
56
+ * @name $.cookie
57
+ * @cat Plugins/Cookie
58
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
59
+ */
60
+ jQuery.cookie = function (key, value, options) {
61
+
62
+ // key and value given, set cookie...
63
+ if (arguments.length > 1 && (value === null || typeof value !== "object")) {
64
+ options = jQuery.extend({}, options);
65
+
66
+ if (value === null) {
67
+ options.expires = -1;
68
+ }
69
+
70
+ if (typeof options.expires === 'number') {
71
+ var days = options.expires, t = options.expires = new Date();
72
+ t.setDate(t.getDate() + days);
73
+ }
74
+
75
+ return (document.cookie = [
76
+ encodeURIComponent(key), '=',
77
+ options.raw ? String(value) : encodeURIComponent(String(value)),
78
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
79
+ options.path ? '; path=' + options.path : '',
80
+ options.domain ? '; domain=' + options.domain : '',
81
+ options.secure ? '; secure' : ''
82
+ ].join(''));
83
+ }
84
+
85
+ // key and possibly options given, get cookie...
86
+ options = value || {};
87
+ var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
88
+ return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
89
+ };
classes/external/jquery.cookie.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery.cookie=function(key,value,options){if(arguments.length>1&&(value===null||typeof value!=="object")){options=jQuery.extend({},options);if(value===null){options.expires=-1;}if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}return(document.cookie=[encodeURIComponent(key),'=',options.raw?String(value):encodeURIComponent(String(value)),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}options=value||{};var result,decode=options.raw?function(s){return s;}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null;};
classes/external/jquery.zrssfeed.css ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ /*
3
+ * Example of zRSSFeed Styling
4
+ *
5
+ * Version: 1.1.5
6
+ * (c) Copyright 2011, Zazar Ltd
7
+ *
8
+ */
9
+
10
+ /* body {
11
+ margin: 1em 3em;
12
+ font-family: Tahoma, Genevam, sans-serif;
13
+ } */
14
+
15
+ .rssFeed {
16
+ font-family: Arial, Helvetica, sans-serif;
17
+ font-size: 90%;
18
+ /* margin: 2em 3em; */
19
+
20
+ }
21
+ .rssFeed a {
22
+ color: #444;
23
+ text-decoration: none;
24
+ }
25
+ .rssFeed a:hover {
26
+ color: #000;
27
+ text-decoration: underline;
28
+ }
29
+
30
+ .rssHeader { padding: 0.2em 0; }
31
+
32
+ .rssBody { border: 1px solid #999; }
33
+ .rssBody ul { list-style: none; }
34
+ .rssBody ul, .rssRow, .rssRow h4, .rssRow p {
35
+ margin: 0;
36
+ padding: 0;
37
+ }
38
+
39
+ .rssRow { padding: 0.8em; }
40
+ .rssRow h4 { font-size: 1.1em; }
41
+ .rssRow div {
42
+ font-size: 90%;
43
+ color: #666;
44
+ margin: 0.2em 0 0.4em 0;
45
+ }
46
+
47
+ .odd { background-color: #e8e8fc; }
48
+ .even { background-color: #d4d4e8; }
49
+
50
+ .rssRow .rssMedia {
51
+ padding: 0.5em;
52
+ font-size: 1em;
53
+ }
classes/external/jquery.zrssfeed.min.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ (function(h){h.fn.rssfeed=function(q,f,r){f=h.extend({limit:10,header:!0,titletag:"h4",date:!0,content:!0,snippet:!0,media:!0,showerror:!0,errormsg:"",key:null,ssl:!1,linktarget:"_self"},f);return this.each(function(s,l){var p=h(l),d="";f.ssl&&(d="s");p.hasClass("rssFeed")||p.addClass("rssFeed");if(null==q)return!1;d="http"+d+"://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+encodeURIComponent(q);null!=f.limit&&(d+="&num="+f.limit);null!=f.key&&(d+="&key="+f.key);h.getJSON(d+"&output=json_xml",
2
+ function(b){if(200==b.responseStatus){var e=b.responseData,b=f,g=e.feed;if(g){var a="",d="odd";if(b.media){var j=e.xmlString;"Microsoft Internet Explorer"==navigator.appName?(e=new ActiveXObject("Microsoft.XMLDOM"),e.async="false",e.loadXML(j)):e=(new DOMParser).parseFromString(j,"text/xml");j=e.getElementsByTagName("item")}b.header&&(a+='<div class="rssHeader"><a href="'+g.link+'" title="'+g.description+'">'+g.title+"</a></div>");a+='<div class="rssBody"><ul>';for(e=0;e<g.entries.length;e++){var c=
3
+ g.entries[e],i;c.publishedDate&&(i=new Date(c.publishedDate),i=i.toLocaleDateString()+" "+i.toLocaleTimeString());a+='<li class="rssRow '+d+'"><'+b.titletag+'><a href="'+c.link+'" title="View this feed at '+g.title+'">'+c.title+"</a></"+b.titletag+">";b.date&&i&&(a+="<div>"+i+"</div>");b.content&&(a+="<p>"+(b.snippet&&""!=c.contentSnippet?c.contentSnippet:c.content)+"</p>");if(b.media&&0<j.length){c=j[e].getElementsByTagName("enclosure");if(0<c.length){for(var a=a+'<div class="rssMedia"><div>Media files</div><ul>',
4
+ k=0;k<c.length;k++)var m=c[k].getAttribute("url"),n=c[k].getAttribute("type"),o=c[k].getAttribute("length"),m='<li><a href="'+m+'" title="Download this media">'+m.split("/").pop()+"</a> ("+n+", ",n=Math.floor(Math.log(o)/Math.log(1024)),o=(o/Math.pow(1024,Math.floor(n))).toFixed(2)+" "+"bytes,kb,MB,GB,TB,PB".split(",")[n],a=a+(m+o+")</li>");a+="</ul></div>"}a+="</li>"}d="odd"==d?"even":"odd"}h(l).html(a+"</ul></div>");h("a",l).attr("target",b.linktarget)}h.isFunction(r)&&r.call(this,p)}else f.showerror&&
5
+ (g=""!=f.errormsg?f.errormsg:b.responseDetails),h(l).html('<div class="rssError"><p>'+g+"</p></div>")})})}})(jQuery);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: turl, futtta
3
  Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, minimize
4
  Requires at least: 2.7
5
  Tested up to: 3.5
6
- Stable tag: 1.5
7
 
8
  Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
9
 
@@ -21,6 +21,10 @@ I also recommend using WP Super Cache in conjuction with Autoptimize to speed up
21
 
22
  == Frequently Asked Questions ==
23
 
 
 
 
 
24
  = What does the plugin do to help speed up my site? =
25
 
26
  It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head, and scripts to the footer. It also minifies the HTML code itself, making your page really lightweight.
@@ -32,6 +36,9 @@ You can report problems on the [wordpress.org support forum](http://wordpress.or
32
 
33
  == Changelog ==
34
 
 
 
 
35
  = 1.5 =
36
  * first bugfix release by [futtta](http://blog.futtta.be/2013/01/07/adopting-an-oss-orphan-autoptimize/), thanks for a great plugin Turl!
37
  * misc bug fixes, a.o. support for Twenty Twelve theme, admin bar problem in WP3.5, data-uri breaking CSS file naming
3
  Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, minimize
4
  Requires at least: 2.7
5
  Tested up to: 3.5
6
+ Stable tag: 1.5.1
7
 
8
  Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
9
 
21
 
22
  == Frequently Asked Questions ==
23
 
24
+ = Autoptimize doesn't work when I'm logged on? =
25
+
26
+ Correct; given the recurring problems with the WordPress admin bar, Autoptimize only works for anonymous users starting from version 1.5.
27
+
28
  = What does the plugin do to help speed up my site? =
29
 
30
  It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head, and scripts to the footer. It also minifies the HTML code itself, making your page really lightweight.
36
 
37
  == Changelog ==
38
 
39
+ = 1.5.1 =
40
+ * bugfix: add CSS before opening title-tag instead of after closing title, to avoid CSS being loaded in wrong order, as reported by [fotofashion](http://fotoandfashion.de/) and [blogitsolutions](www.blog-it-solutions.de) (thanks guys)
41
+
42
  = 1.5 =
43
  * first bugfix release by [futtta](http://blog.futtta.be/2013/01/07/adopting-an-oss-orphan-autoptimize/), thanks for a great plugin Turl!
44
  * misc bug fixes, a.o. support for Twenty Twelve theme, admin bar problem in WP3.5, data-uri breaking CSS file naming