Support » Plugin: Autoptimize » Layout breaks after file moving

  • Resolved Josef Seidl

    (@blogitsolutions)


    Hi futtta,

    me again and a second problem: I moved my wordpress installation from the root folder to a subfolder. After activating the option “Optimize CSS Code?” the whole page is broken. If I am logged in on wordpress the layout is fine (because Autoptimize doesn’t work).

    Do you have any idea what is not correct? Could it be a permission problem?

    Here is the link to my page: Blog IT-Solutions

    Thanks, Josef

    http://wordpress.org/extend/plugins/autoptimize/

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Author Frank Goossens

    (@futtta)

    Layout looks OK now? It’s important to change the “wordpress url” (which would be in that case be different from the “site url”).

    Josef Seidl

    (@blogitsolutions)

    At the moment yes, because I set Optimize CSS Code to OFF. If I set the option to ON then the whole layout will break. Yes, the wordpress url is different from the site url. All other things are working fine again. I only have problems with the layout if I active the Optimize CSS Code option in Autoptimize.

    But I want to active the option again.

    Plugin Author Frank Goossens

    (@futtta)

    OK, best way forward would be to very briefly activate the option again so we can look at the HTML (and specifically the full URL of the aggregated CSS-file). Could you do that for 5 minutes at let’s say 12h45, so I can have a look?

    Josef Seidl

    (@blogitsolutions)

    Ok, can we do it at 12h30? I will post an entry here if I have done it. Ok?

    Josef Seidl

    (@blogitsolutions)

    Ok, lets take 12h45. Ok?

    Plugin Author Frank Goossens

    (@futtta)

    had lunch, ready when you are 🙂

    Josef Seidl

    (@blogitsolutions)

    done 🙂 Let’s go 😉

    Plugin Author Frank Goossens

    (@futtta)

    ok, you can turn it back off now.

    Josef Seidl

    (@blogitsolutions)

    ok, thanks. Do you have found the problem?

    Plugin Author Frank Goossens

    (@futtta)

    not yet, looking at source now, i’ll keep you posted 🙂

    Plugin Author Frank Goossens

    (@futtta)

    Can you describe step by step how you “moved my wordpress installation from the root folder to a subfolder”?

    Plugin Author Frank Goossens

    (@futtta)

    disregard the previous question 🙂

    the problem is probably caused by the fact that “/bits/” is not in the URL, but is in ABSPATH. if so, this confuses Autoptimize’s getpath-function (in classes/autoptimizeBase.php), causing Autoptimize to look for /var/www/yoursite/bits/bits/wp-content/theme/whatever.css instead of /var/www/yoursite/bits/wp-content/theme/whatever.css.

    can you open up /wp-content/plugins/autoptimize/autoptimize.php and after the header comment block add:

    echo WP_CONTENT_DIR."<br />";
    echo ABSPATH."<br />";

    load your blog and post these values here? you can (off course) remove those lines immediately after 🙂 based on the output of the above, I should be able to confirm my hypothesis and re-write the getpath function.

    Plugin Author Frank Goossens

    (@futtta)

    Well, nothing like a good night’s sleep to find the most simple of solutions! Forget about all the above, just open up wp-content/plugins/autoptimize/classes/autoptimizeBase.php and at the bottom replace

    //Converts an URL to a full path
    	protected function getpath($url)
    	{
    		$path = str_replace(get_settings('home'),'',$url);
    		if(preg_match('#^(https?|ftp)://#i',$path))
    		{
    			//External script (adsense, etc)
    			return false;
    		}
    		$path = str_replace('//','/',ABSPATH.$path);
    		return $path;
    	}

    with the much more solid

    //Converts an URL to a full path
    	protected function getpath($url)
    	{
            	$path = str_replace(WP_CONTENT_URL,'',$url);
    	        if(preg_match('#^(https?|ftp)://#i',$path))
            	{
                    	/**
    			External script/css (adsense, etc)
    			Or script/ css just not in wp_content
    			*/
                		return false;
                	}
            	$path = str_replace('//','/',WP_CONTENT_DIR.$path);
            	return $path;
    	}

    I’m 99% sure this solves the -slightly obscure 😉 – bug you found.

    Josef Seidl

    (@blogitsolutions)

    Thanks for your response 🙂

    Now I replaced the getpath-function with the new one. But it still doesn’t work. After replacing the function I implemented the echo commands you mentioned two post above. I received the following results:

    /var/www/yoursite/html/bits/wp-content
    /var/www/yoursite/html/bits/

    In fact, it seems that the paths are correct now. But the layout still breaks.
    But I found a new hint in the network logs of firebug:

    http://www.blog-it-solutions.de/wp-content/themes/iblog/css/custom.css 404 Not found

    This problem also occurs for all other css-files. In result, there must be another function which is using the wrong path. Do you still have any ideas?

    Plugin Author Frank Goossens

    (@futtta)

    damn, I hoped I had nailed this one 🙂

    anyway, can you:

    • add the following to wp-content/plugins/autoptimize/autoptimize.php:
      echo WP_CONTENT_DIR."<br />";
      echo WP_CONTENT_URL."<br />";
      $bloginfourl = get_bloginfo('url');
      echo $bloginfourl."<br />";
    • re-enable css optimization?
    • clear both autoptimize & wp super cache cache?
    • send me the resulting html (futtta at gmail dot com)
Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Layout breaks after file moving’ is closed to new replies.