Last active January 31, 2020 16:29
-
-
Save webaware/8949605 to your computer and use it in GitHub Desktop.
Revisions
-
webaware revised this gist
Feb 16, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,7 @@ @ref: http://wordpress.org/support/topic/map-wont-appear @ref: http://stackoverflow.com/a/10611827/911083 @ref: https://support.cloudflare.com/hc/en-us/articles/200169436 */ /** -
webaware revised this gist
Feb 16, 2014 . 1 changed file with 38 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,53 @@ <?php /* Plugin Name: Flxmap No Rocketscript Plugin URI: https://gist.github.com/webaware/8949605 Description: stop CloudFlare Rockscript messing up the map plugin! Version: 3 Author: WebAware Author URI: http://webaware.com.au/ @ref: http://wordpress.org/support/topic/map-wont-appear @ref: http://stackoverflow.com/a/10611827/911083 */ /** * 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')) { wp_dequeue_script('flxmap'); wp_dequeue_script('google-maps'); flxmap_no_rocketscript('google-maps'); flxmap_no_rocketscript('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; }); -
webaware revised this gist
Feb 12, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ <?php /* Plugin Name: Flxmap No Rocketscript Plugin URI: Description: stop CloudFlare Rockscript messing up the map plugin! Version: 2 Author: WebAware Author URI: http://webaware.com.au/ @@ -17,7 +17,7 @@ // only for WP Flexible Map scripts $plugin = FlxMapPlugin::getInstance(); if (preg_match('#maps.google.com/maps/api/js|' . $plugin->urlBase . '.*\.js#', $url)) { // it's one of our JavaScript URIs, so tell CloudFlare to bugger off! $url .= "' data-cfasync='false"; } -
webaware revised this gist
Feb 12, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php /* Plugin Name: Flxmap No Rocketscript Plugin URI: https://gist.github.com/webaware/8949605 Description: stop CloudFlare Rockscript messing up the map plugin! Version: 1 Author: WebAware -
webaware created this gist
Feb 12, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ <?php /* Plugin Name: Flxmap No Rocketscript Plugin URI: Description: stop CloudFlare Rockscript messing up the map plugin! Version: 1 Author: WebAware Author URI: http://webaware.com.au/ @ref: http://wordpress.org/support/topic/map-wont-appear @ref: http://stackoverflow.com/a/10611827/911083 @ref: http://wordpress.stackexchange.com/a/38335/24260 */ add_filter('clean_url', function($url) { if (class_exists('FlxMapPlugin')) { // only for WP Flexible Map scripts $plugin = FlxMapPlugin::getInstance(); if (stripos($url, $plugin->urlBase) !== false && stripos($url, '.js') !== false) { // it's one of our JavaScript URIs, so tell CloudFlare to bugger off! $url .= "' data-cfasync='false"; } } return $url; });