Open DahmaniAdame opened 3 years ago
Reproduce the problem :heavy_multiplication_x: I can see the issue
Identify the root cause
we need to use the pll_home_url
to get the correct URL instead ofhome_url()
Scope a solution
wp-rocket/inc/3rd-party/plugins/i18n/polylang.php
function rocket_exclude_js_disqus( $config ) {
rtrim(pll_home_url(), '/');
return $config;
}
add_filter( 'rocket_preload_links_config', 'polylang_preload_links_config' );
Estimate the effort [M]
A consequence of this issue is that the RUCSS generates the home_url()
used css for all the domains.
still? sad
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug When Polylang uses multiple domains, the
home_url()
used on https://github.com/wp-media/wp-rocket/blob/40ecc6c70de1995295a1994fb77a6ecb93885287/inc/Engine/Preload/Links/Subscriber.php#L132 returns the wrong language home URL.Example: Main language = domain.com Additional language = domain.com.au
home_url()
will return domain.com for both.To Reproduce Steps to reproduce the behavior:
Expected behavior WP Rocket referencing the right home URL for each language site even if it uses a different domain.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Polylang has a constant
PLL_FILTER_HOME_URL
set to true by default - reference https://polylang.pro/doc/php-constants/ But it didn't helphome_url()
to serve the right language home URL.The following fixed the issue:
Replacing
home_url()
byrtrim(pll_home_url(), '/')
on https://github.com/wp-media/wp-rocket/blob/40ecc6c70de1995295a1994fb77a6ecb93885287/inc/Engine/Preload/Links/Subscriber.php#L132rtrim()
is needed because Polylang adds a trailing slash after the URL when usingpll_home_url()
.Removing
siteUrl
from the$config
array and adding conditionally like this one should work:Backlog Grooming (for WP Media dev team use only)