Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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