Skip to content

Instantly share code, notes, and snippets.

@webaware
Last active August 29, 2015 13:56
Show Gist options
  • Save webaware/8946050 to your computer and use it in GitHub Desktop.
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
<?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