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 11 replies, has 2 voices.

Last updated by lilyB 1 month, 3 weeks ago.

Assigned support staff: Raja Mohammed.

Author Posts
August 19, 2019 at 1:10 pm #4416275

lilyB

I am having the issue described here: https://wpml.org/errata/w3tc-is-not-minifying-files/
The minified files still show up in secondary languages.
The provided fix no longer seems to work. Is there an updated solution?
Thanks

August 20, 2019 at 10:38 am #4422787

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi there,

I see that the fix suggested in the errata works with pro version and not with the free version of W3 total cache. I can see a related discussion in the WordPress support forum where another client has a similar issue https://wordpress.org/support/topic/intended-incompatibility-with-wpml-causes-disfunction/ .

I am checking this issue with the support manager if I could find any solution for this case. I will keep you posted once I have an update.

Kind Regards
Raja

August 20, 2019 at 12:21 pm #4423487

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue needs to be isolated please install W3TC plugin in the sandbox site

One-Click Login:hidden link.

Setup WPML and W3TC in the sandbox site similar to your site and try to reproduce the issue.

Let me know once done. This will help me escalate this direct to developers.

Kind regards
Raja

August 20, 2019 at 12:59 pm #4423809

lilyB

Hi, thanks for your help.

I set up the site like you said, & I'm able to reproduce the issue.
You can see on the home page that when you're viewing the page in the primary language (french), the minified file (hidden link) is present in the source code.

However when you view the page in the secondary languages, the minified file isn't present. Instead the original non-minified .js file shows up.

August 21, 2019 at 6:22 am #4428195

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I have added the below workaround in theme functions.php file which seems to work fine for the secondary language. Can you please verify the same. I am not able to see the minified files in the secondary language.

function wpml_comp_2347( $data ){
	if ( did_action( 'wpml_loaded' ) ) {
		$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', 'wpml_comp_2347', 20 );
August 21, 2019 at 8:23 am #4429071

lilyB

Yes, I see it works in the demo! Unfortunately, I just tried it on my website & it doesn't work. The minified file shows up, but the non-minified files still show also, loading everything twice 🙁

August 21, 2019 at 8:39 am #4429171

lilyB

Aha, I just figured out that the issue happens when the minifying is set to manuel instead of automatic in the Total Cache settings.
I can still reproduce the issue on the test site when I change these settings. You can see it happening here: view-source:hidden link

August 21, 2019 at 10:46 am #4430441

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

With manual mode, I see the results are the same in the default language. hidden link

But still, I see some parts of the scripts are minified in the source. If I'm not mistaken with the manual mode the settings need to be set in Minify to add the scripts manually to be minified.

Can you please confirm this again?

August 21, 2019 at 11:33 am #4430839

lilyB

I added a plugin so there would be more scripts and I added all four scripts manually in W3TC.

On the default language page, you can see that these scripts don't show in the source code, as they are combined in the minified file:
hidden link

However, on the secondary language page (hidden link) you can still see all four .js files still showing on top of the minified file 00155.default.include-footer.bca5c1.js

August 22, 2019 at 5:57 am #4436511

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thanks for the clarification, The errata has two parts, One is to fix the minification in the second language and another is to remove the minified files from the list https://wpml.org/errata/w3tc-is-not-minifying-files/

Fix removing minified files from the queue, change following function in W3TC code:
wp-content/plugins/w3-total-cache/Util_Environment.php

        /**
         * Returns home url regexp
         *
         * @return string
         */
        static public function home_url_regexp() {
                $home_url = get_option('home');
                $regexp = Util_Environment::get_url_regexp( $home_url );

                return $regexp;
        }

I have applied both the code suggested in the errata to the sandbox site it's now displaying only the minified files in the secondary language. hidden link

I hope this helps you better.

Kind regards
Raja

August 22, 2019 at 7:52 am #4437371

lilyB

Ok, now the test site works, but for some reason the second code doesn't work on my real website.
I changed the function in wp-content/plugins/w3-total-cache/Util_Environment.php, but the .js files are showing.

August 22, 2019 at 8:21 am #4437473

lilyB

So my page cache simply wasn't emptying correctly on my website, so I couldn't see the changes.
I manually deleted the cache & the new cached pages no longer have the .js files! Everything seems to be working fine.
Thanks for your help!