Created
October 24, 2018 00:56
-
-
Save tnchuntic/56f46c3eaa7310c061743dba93bca5d8 to your computer and use it in GitHub Desktop.
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 characters
/* | |
* ----------------------------------------------------------------------------- | |
* | |
* 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