Last active
January 8, 2018 00:13
-
-
Save strarsis/c2242cc5ab122990faceb1df3c6237d8 to your computer and use it in GitHub Desktop.
Set Google Maps key for ACF and ACF PRO
This file contains 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
<?php | |
// Add this code to plugin or theme | |
// Authorize API for project: | |
// see https://console.developers.google.com/apis/api/places_backend?project=_ | |
const GOOGLE_API_KEY = 'the-API-key'; | |
// ACF | |
add_filter('acf/fields/google_map/api', function ($value) { | |
return array( | |
'libraries' => 'places', | |
'key' => GOOGLE_API_KEY | |
); | |
}); | |
// ACF PRO | |
function my_acf_init() { | |
acf_update_setting('google_api_key', GOOGLE_API_KEY); | |
} | |
add_action('acf/init', 'my_acf_init'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment