Skip to content

Instantly share code, notes, and snippets.

@tnchuntic
Created October 24, 2018 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnchuntic/56f46c3eaa7310c061743dba93bca5d8 to your computer and use it in GitHub Desktop.
Save tnchuntic/56f46c3eaa7310c061743dba93bca5d8 to your computer and use it in GitHub Desktop.
/*
* -----------------------------------------------------------------------------
*
* google map acf fixes
*
* -----------------------------------------------------------------------------
*/
add_filter('script_loader_tag', 'add_async_defer_attribute', 10, 2);
function add_async_defer_attribute($tag, $handle) {
if ('acf_google_map' !== $handle):
return $tag;
endif;
$script = sprintf('//maps.googleapis.com/maps/api/js?key=%s', _ID_CLIENT_MAP_API_KEY_);
$tag = str_replace(' src', ' async defer src', $tag);
$tag = str_replace($script, $script . '&libraries=places', $tag);
return $tag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment