Created
October 3, 2017 20:14
-
-
Save remyperona/67aa134ea0e7e0057cdf0b55f7bd2c55 to your computer and use it in GitHub Desktop.
Correctly clean cache when front page URL contains page name in Polylang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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