I’ll look into that, a solution for that might just still make it into 1.8.2. Now that I come to think of it; maybe I should switch to protocol-less URL’s. What do you think?
Great, thanks, would be good to see this in 1.8.2 🙂
I believe that the advantage of using the protocol-less urls are that it allows them to inherit the pages current protocol (http / https) preventing the need for any logic in the code to work out the current pages protocol. Which all sounds good..
Found this article which goes over the topic in more detail http://www.paulirish.com/2010/the-protocol-relative-url
Thanks,
Ross
Hi Ross;
Not going to change output for now, but regarding aggregating protocol-less JS/CSS-links, could you try this?
1. Open up /wp-content/plugins/autoptimize/classes/autoptimizeBase.php
2. On line 26 change:
//Converts an URL to a full path
protected function getpath($url) {
if ((strpos($url,'//')===false) && (strpos($url,parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST))===false)) {
$url = AUTOPTIMIZE_WP_SITE_URL.$url;
}
$path = str_replace(AUTOPTIMIZE_WP_ROOT_URL,'',$url);
if(preg_match('#^((https?|ftp):)?//#i',$path)) {
/** External script/css (adsense, etc) */
return false;
}
$path = str_replace('//','/',WP_ROOT_DIR.$path);
return $path;
}
into:
//Converts an URL to a full path
protected function getpath($url) {
if (strpos($url,'//')===0) {
$url = "http:".$url;
} else if ((strpos($url,'//')===false) && (strpos($url,parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST))===false)) {
$url = AUTOPTIMIZE_WP_SITE_URL.$url;
}
$path = str_replace(AUTOPTIMIZE_WP_ROOT_URL,'',$url);
if(preg_match('#^((https?|ftp):)?//#i',$path)) {
/** External script/css (adsense, etc) */
return false;
}
$path = str_replace('//','/',WP_ROOT_DIR.$path);
return $path;
}
3. save file
4. empty Autoptimize Cache (and whatever page caching plugin you use).
Based on (limited) local tests this should do the trick. If this indeed does work, it’ll be included in 1.8.2.
frank
Hey futtta
Thanks for the reply. I’ve added in the updated function and it looks like it’s working great!
Thanks,
Ross
great, thanks for the feedback. enjoy your weekend!
frank
by the way, get regular questions about how to configure autoptimize for woocommerce, would you mind sharing your configuration?
Hey
Sure, although I have not needed to do much in order to get Autoptimize working with WooCommerce….
My current setup is a standard WooCommerce install (2.1.5) with latest WordPress (3.8.1).
My Autoptimize settings are:
- Optimize HTML Code?: true
- Optimize JavaScript Code?: true (exclude jQuery.js)
- Optimize CSS Code?: true
- Save aggregated script/css as static files?: true
(all other fields are unchecked)
If anyone has any specific questions relating to a working WooCommerce + Autoptimize setup feel free to ask.
Thanks,
Ross
Thanks for the feedback Ross!