Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
stop CloudFlare Rockscript messing up WP Flexible Map plugin!
Plugin Name: Flxmap No Rocketscript
Plugin URI:
Description: stop CloudFlare Rockscript messing up the map plugin!
Version: 3
Author: WebAware
Author URI:
* output a script tag that won't be replaced by Rocketscript
* @param string $handle
function flxmap_no_rocketscript($handle) {
global $wp_scripts;
$script = $wp_scripts->query($handle);
$src = $script->src;
if ( !empty($script->ver) ) {
$src = add_query_arg('ver', $script->ver, $src);
$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
echo "<script data-cfasync='false' type='text/javascript' src='$src'></script>\n";
* intercept call to print footer scripts,
* replace Google Maps API and Flexible Map script
add_action('wp_print_footer_scripts', function() {
if (wp_script_is('flxmap')) {
}, 1);
* add data-cfasync attribute to Flexible Map script tag
* @param string $html
* @return string
add_filter('flexmap_shortcode_html', function($html) {
$html = str_replace('<script', '<script data-cfasync="false"', $html);
return $html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment