Last active
August 29, 2015 13:56
-
-
Save webaware/8946050 to your computer and use it in GitHub Desktop.
WP Flexible Map plugin addon to force Google to reload KML maps every hour. NB: this solution won't work with page caching plugins, e.g. WP Super Cache / W3 Total Cache. The next version of WP Flexible Map will have a better solution that will work with caching plugins
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: Flxmap KML cache buster | |
Plugin URI: https://gist.github.com/webaware/8946050 | |
Description: force Google to reload KML maps every hour | |
Version: 1 | |
Author: WebAware | |
Author URI: http://webaware.com.au/ | |
NB: this solution won't work with page caching plugins, e.g. WP Super Cache / W3 Total Cache | |
The next version of WP Flexible Map will have a better solution that will work with caching plugins | |
*/ | |
add_filter('flexmap_shortcode_attrs', function($attrs) { | |
if (isset($attrs['src'])) { | |
$buster = (int) (time() / (60 * 60)); | |
$attrs['src'] = add_query_arg('nocache', $buster, $attrs['src']); | |
} | |
return $attrs; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment