Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 35 replies, has 3 voices.

Last updated by Ankit 4 years, 7 months ago.

Assigned support staff: David.

Author Posts
February 6, 2017 at 5:55 pm #1200828

David
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

It seems like these lines of code in functions.php from your child theme is causing this:

/* Remove query strings from static resources
======================================================*/
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

Try removing them and it should work as expected.
Let me know how it goes.

February 6, 2017 at 7:35 pm #1200920

Kristof

Hi,
Yes, I also figured this out myself that removing this code snippet resolves the problem, but we have this snippet also on other sites combined with W3TC and there we don't have this issue.
Example:
hidden link (without WPML)
hidden link (without WPML)
hidden link (with WPML)

February 8, 2017 at 2:58 pm #1203124

David
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Do you have the "Use directory for default language" option enabled on those sites?

February 8, 2017 at 3:12 pm #1203155

Kristof

Only the enbro.com website has WPML installed but no directory for default language. We have 6 WP sites with WPML, but only this itinerainstitute.org has a directory for the default language.

February 8, 2017 at 10:04 pm #1203497

David
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Thats it.

You have to choose between removing the script version or using the directory for the default language if you want minify to work correctly.

Let me know if you need anything else.

February 9, 2017 at 8:18 am #1203675

Kristof

Any idea why directory for the default language is incompatible with this code snippet (removing scrip version)?

February 9, 2017 at 7:29 pm #1204532

David
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

I've been looking into this a bit more.

The issue seems to be in w3-total-cache. My current theory is that the regexp to search for the CSS files is based on home_url which includes the language directory. I think that if we switch this code to use site_url instead it should work.

Let me escalate this to the compatibility team.
I will update you when I get some feedback.

February 15, 2017 at 6:19 am #1208589

Ankit

Hi,

This is Ankit from second tier support team. I will assist you with the issue further, hope this is fine with you. 🙂

We've managed to reproduce this issue and escalated it to our team. Our team compatibility team members are currently looking into the problem and will take action accordingly to fix this issue.

However, as a temporary workaround could you please add following code to functions.php file of your active theme?

function otgs_w3tc_url_to_docroot_filename( $data ) {
        $home_url = $data['home_url'];

        if ( substr( $data['url'], 0, strlen( $home_url ) ) != $home_url ) {
            $data['home_url'] = get_option( 'home' );
        }

        return $data;
}
add_filter( 'w3tc_url_to_docroot_filename', 'otgs_w3tc_url_to_docroot_filename' );

Save the file and upload again.

Clear the cache of site and check if issue gets resolved.

Regards,
Ankit

February 16, 2017 at 1:40 pm #1210141

Kristof

I have added your code to my child themes functions.php but it does not change anything. I have minified the first 6 .css files you see in the html source and the minified css file is there at the top of the code, but the 6 css files are still present (so duplicate) in the html source.

February 16, 2017 at 2:19 pm #1210201

Ankit

Can you please clear Minify Cache and check again?

February 16, 2017 at 4:19 pm #1210373

Kristof

Did that, but no result, sorry.

February 17, 2017 at 9:47 am #1210887

Ankit

Hi,

You've added 3 files to minify as shown in screenshot. Those 3 files are getting combined and the minified file is present on top of the source of page. Those 3 files are not getting added as duplicate css elsewhere.

I've checked this on staging site provided and it seems to be working as expected.

Regards,
Ankit

February 17, 2017 at 10:07 am #1210913

Kristof

Staging site may not be up to date anymore, David Garcia worked on the live site last time.
Look at: hidden link
hidden link is being minified into hidden link but is still visible in the html code on line 50. Can you confirm?

February 17, 2017 at 3:37 pm #1211255

Kristof

Please IMMEDIATELY fix the site because now people see the root page instead of the default /nl folder. If you need a staging, ask us!!

February 17, 2017 at 3:56 pm #1211284

Kristof

I have added these lines to the htaccess which you removed

RewriteCond %{HTTP_HOST} ^itinerainstitute\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.itinerainstitute\.org$
RewriteRule ^/?$ "http\:\/\/itinerainstitute\.org\/nl\/" [R=302,L]

The topic ‘[Closed] Compatibility issue: W3TC minified files are not removed from source code’ is closed to new replies.