• 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

    https://www.ads-software.com/extend/plugins/autoptimize/

Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter Josef Seidl

    (@blogitsolutions)

    I have sent you a mail with the results ??

    Plugin Author Frank Goossens

    (@futtta)

    Did you get my latest mail Josef? I’d like to have a look at the resulting HTML source when CSS optimization is activated, can you mail that to me?

    Thread Starter Josef Seidl

    (@blogitsolutions)

    Hey, sorry for the late response. I answered you via e-mail (including the html source code) a few minutes ago ??

    Plugin Author Frank Goossens

    (@futtta)

    OK, we’re on to something; the problem is related to the fact that the imports in themes/iblog/style.css are relative.

    Now this in handled in wp-content/plugins/autoptimize/classes/autoptimizeStyles.php in the fixurls function at the bottom.

    So … can you replace the code there with this and see if that fixes things:

    private function fixurls($file,$code)
            {
                    $file = str_replace(WP_CONTENT_DIR,'/',$file);
                    $dir = dirname($file); //Like /wp-content
    
                    if(preg_match_all('#url\((.*)\)#Usi',$code,$matches))
                    {
                            $replace = array();
                            foreach($matches[1] as $k => $url)
                            {
                                    //Remove quotes
                                    $url = trim($url," \t\n\r\x0B\"'");
                                    if(substr($url,0,1)=='/' || preg_match('#^(https?|ftp)://#i',$url))
                                    {
                                            continue;
                                    }else{
                                            $newurl = WP_CONTENT_URL.str_replace('//','/',$dir.'/'.$url);
                                            $hash = md5($url);
                                            $code = str_replace($matches[0][$k],$hash,$code);
                                            $replace[$hash] = 'url('.$newurl.')';
                                    }
                            }
    
                            $code = str_replace(array_keys($replace),array_values($replace),$code);
                    }
    
                    return $code;
            }

    (crossing my fingers now)

    Thread Starter Josef Seidl

    (@blogitsolutions)

    Awesome! It works great again ?? Thanks a lot for your help.

    Plugin Author Frank Goossens

    (@futtta)

    You’re welcome Josef, thanks for you patience & continuous feedback. I’ll make sure to mention you in the release notes of the next version (which I’m working on now).

    Plugin Author Frank Goossens

    (@futtta)

    Hi Josef;
    I’m finalizing 1.6.0 and ran into a problem with the getpath-function I posted above. Can you replace with this one and report if that works for you as well?

    protected function getpath($url)
            {
                    $path = str_replace(site_url(),'',$url);
                    if(preg_match('#^(https?|ftp)://#i',$path))
                    {
                            /**
                            External script/css (adsense, etc)
                            */
                            return false;
                    }
                    $path = str_replace('//','/',ABSPATH.$path);
                    return $path;
            }

    thanks!

    Plugin Author Frank Goossens

    (@futtta)

    Nah, that won’t work, as $path will start with /bits/ and ABSPATH will end with that same string. I’ll have to think some more.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Layout breaks after file moving’ is closed to new replies.