Last active
March 5, 2019 21:16
-
-
Save glueckpress/1c49dde98a361ec043fa to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket] Edge case for mapped domains within the same installation. Clears an additional URL from cache when a given URL is cleared.
This file contains 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 | |
/** | |
* Plugin Name: WP Rocket | Clear Additional URLs | |
* Description: Clears an additional URL from cache when a given URL is cleared. | |
* Version: 0.1 | |
* Author: WP Rocket Support Team | |
* Author URI: http://wp-rocket.me/ | |
* Plugin URI: https://gist.github.com/glueckpress/1c49dde98a361ec043fa | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
/** | |
* Clear additional URLs from cache when a given URL is cleared. | |
* @param array $urls URLs being cleared from cache | |
* @return array Altered array of URLs | |
*/ | |
function wp_rocket_160322__clear_additional_urls( $urls ) { | |
// If this URL is cleared from the cache… | |
$check_for_this_url = 'http://your-url-here.com'; | |
// …clear this URL, too. | |
$clear_this_url_too = 'http://your-other-url-here.com'; | |
if ( in_array( $check_for_this_url, $urls ) ) { | |
$urls[] = $clear_this_url_too; | |
} | |
return $urls; | |
} | |
add_filter( 'rocket_clean_files', 'wp_rocket_160322__clear_additional_urls' ); | |
add_filter( 'rocket_clean_domain_urls', 'wp_rocket_160322__clear_additional_urls' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment