Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Khang Minh

    (@oddoneout)

    BWP Minify should already be doing so (there’s a bug with external media files though). Could you please point me to a theme or a plugin that is causing this issue?

    Thread Starter PlywoodMillionaire

    (@plywoodmillionaire)

    It’s possibly this problem only reveals itself when you run wordpress as a submodule. For those of us who do this (git users) our directory structure looks like this:

    /wordpress (unmodified submodule)
    /wp-content

    I am looking into this right now.

    Thread Starter PlywoodMillionaire

    (@plywoodmillionaire)

    I didn’t have a lot of time to fix this so my solution was to simply filter and overwrite $_GET[‘f’] directly in bwp-minify/min/index.php. I also included the following filter class there, for reference:

    class BWPMinify_FilesInputFilter {
    	public static function absoluteLocalize($f, $exclude_port = false) {
    		if (empty($f))
    			return $f;
    
    		// not sure who is responsible for this
    		$_filter_uri = str_replace('://', ':/', self::__uriRoot($exclude_port));
    
    		$_f_parts = explode(',', $f);
    
    		$_result_paths = array();
    		foreach ($_f_parts as $_f_path) {
    			$_result_paths[] = str_replace($_filter_uri, '', $_f_path);
    		}
    
    		return implode(',', $_result_paths);
    	}
    
    	private static function __uriRoot($exclude_port = false) {
    		$s = $_SERVER;
    		$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false;
    		$sp = strtolower($s['SERVER_PROTOCOL']);
    		$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
    
    		$port = $s['SERVER_PORT'];
    		$port = ((!$ssl && $port == '80')
    				|| ($ssl && $port == '443')
    				|| $exclude_port)
    				? '' : ':' . $port;
    
    		$host = isset($s['HTTP_X_FORWARDED_HOST'])
    				? $s['HTTP_X_FORWARDED_HOST'] :
    			isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : $s['SERVER_NAME'];
    
    		return $protocol . '://' . $host . $port;
    	}
    }

    In /bwp-minify/min/index.php you will see an existing comment “// serve!” — under this line I simply filter $_GET[‘f’]

    $_GET['f'] = BWPMinify_FilesInputFilter::absoluteLocalize($_GET['f'], true);

    Thread Starter PlywoodMillionaire

    (@plywoodmillionaire)

    I should add: I discovered something quite strange in that the local css files that were being passed to min/index.php?f= had bad url schemes. There was only a single slash like http:/domain.com/file/etc.css.

    I’m wondering if this was the actual problem and if it’s being caused by something else?

    Plugin Author Khang Minh

    (@oddoneout)

    Hmm you are running WordPress as a submodule? That’s interesting. This is your current setup:

    wordpress (config, wp-includes, etc.)
    wp-content (plugins, cache, etc.)
    index.php

    right?

    Thread Starter PlywoodMillionaire

    (@plywoodmillionaire)

    Yes, fairly similar to this: http://ajk.fi/2013/wordpress-as-a-submodule/ — the idea is to keep /wordpress free of any changes. It allows you to checkout tags for new versions and test against them before committing to a wordpress update.

    Do you know what would cause the single slashes in the f= value? This seemed unusual to me.

    This looks like the same issue I reported awhile back although I haven’t had time to dig into it further:

    http://wordpress.org/support/topic/does-not-work-with-wordpress-in-its-own-directory?replies=1

    https://github.com/OddOneOut/Better-WordPress-Minify/issues/5

    Same issue here. http://143.95.39.117/~tunxised/

    Moving a college site from a local server to a 3rd party host, so right now DNS is not pointed and I’m using a temp URL.

    The BWP links should be getting written as:
    http://143.95.39.117/~tunxised/wp-content/plugins/bwp-minify/min/?f=wp-content/themes/tunxiscc/js/404.js

    but instead they’re being written as
    http://143.95.39.117/~tunxised/wp-content/plugins/bwp-minify/min/?f=~tunxised/wp-content/themes/tunxiscc/js/404.js

    The other problem was that the document root wasn’t set properly, but I manually fixed that in the config.php file.

    Any suggestions?

    I added this to wp-config, so now those work, but it’s a hack i’d liek to not do if possible: $_GET[‘f’] = str_replace(‘~tunxised/’, ”, $_GET[‘f’]);

    Plugin Author Khang Minh

    (@oddoneout)

    Please follow updates here:
    https://github.com/OddOneOut/Better-WordPress-Minify/issues/7

    Version 1.3.0 will fix this bug.

    Plugin Author Khang Minh

    (@oddoneout)

    Hey guys please check out version 1.3.0-beta and see if it fixes this issue: https://github.com/OddOneOut/Better-WordPress-Minify/archive/1.3.0.zip

    Also @james in your case ~tunxised is considered a base so the second URL is actually the correct one, it must have ?f=~tunxised, Minify will complain if the base is missing.

    carlla

    (@carlla)

    Thanks Khang Minh!

    It seems I was fancing the same problem and the beta version fix it.

    The error on firebug was

    404 Bad Request http://my.site.com/wp-content/plugins/bwp-minify/min/?f=http:/my.site.com/wp-content/themes/my-theme/style/custom.css

    (Note the single slash after protocol on “f” parameter)

    And the error on FirePHP was

    Minify: The path "/root/www//http:/my.site.com.br/wp-content/themes/my-theme/style/custom.css" (realpath "") could not be found (or was not a file)

    (Note the protocol and hostname in the path string)

    Now seems everything works well

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Remove absolute url (schema, host name) from f= paths’ is closed to new replies.