Quantcast
Channel: WordPress.org Forums » [Autoptimize] Support
Viewing all articles
Browse latest Browse all 14094

Frank Goossens on "[Plugin: Autoptimize] CSS and JS files are ignored during minification"

$
0
0

OK, have a first draft version of an updated getpath (in wp-content/plugins/autoptimize/classes/autoptimizeBase.php;

protected function getpath($url) {
		// normalize
		if (strpos($url,'//')===0) {
			if (is_ssl()) {
				$url = "https:".$url;
			} else {
				$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;
		}

		// first check; hostname wp site should be hostname of url
		if (parse_url($url,PHP_URL_HOST)!==parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST)) {
			return false;
		}

		// try to remove "wp root url" from url while not minding https?
		$tmp_ao_root = preg_replace('/https?/','',AUTOPTIMIZE_WP_ROOT_URL);
		$tmp_url = preg_replace('/https?/','',$url);
        $path = str_replace($tmp_ao_root,'',$tmp_url);

		// final check; if path starts with :// or //, this is not a URL in the WP context and we have to assume we can't aggregate
	    if(preg_match('#^((https?|ftp))?:?//#i',$path)) {
            /** External script/css (adsense, etc) */
			return false;
       	}

        $path = str_replace('//','/',WP_ROOT_DIR.$path);
        return $path;
	}

could you replace the old getpath with this one and provide me with your feedback?

thanks,
frank


Viewing all articles
Browse latest Browse all 14094

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>