Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tabrisrp/67aa134ea0e7e0057cdf0b55f7bd2c55 to your computer and use it in GitHub Desktop.
Save Tabrisrp/67aa134ea0e7e0057cdf0b55f7bd2c55 to your computer and use it in GitHub Desktop.
Correctly clean cache when front page URL contains page name in Polylang
<?php
function wp_rocket_clean_domain_polylang( $urls, $lang ) {
foreach( $urls as $key => $url ) {
if ( empty( $lang ) ) {
$urls[ $key ] = parse_url( $url, PHP_URL_HOST );
} else {
if ( function_exists( 'PLL' ) ) {
$urls[ $key ] = PLL()->links->get_home_url( $lang, true );
}
}
}
$urls = array_unique( $urls );
return $urls;
}
add_action( 'rocket_clean_domain_urls', 'wp_rocket_clean_domain_polylang', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment