Widgets: Add Google Maps API key field to Contact Info widget settings#4562
Widgets: Add Google Maps API key field to Contact Info widget settings#4562
Conversation
Since the site may have grandfathered permission to display a map without an API key
Since multiple widget forms can be present on the same page at the same time
|
This seems to work in my tests. LGTM imo! @kraftbj Since you worked on this as well, would you mind giving it another look, and merge if you like what you see? Thanks! |
|
It reads well, but latest master and this branch is WSOD on my sandbox without an error. Going to merge and noting we need to update documentation. |
|
Hello, |
|
@petrk94 : The form field will be included in Jetpack 4.2, which is expected to be released very soon. 4.1.1 does include the option to specify your own API key, but requires that you use filters to do so. Specifically, adding the following to your theme's function mytheme_google_maps_key() {
return 'insert-your-api-key-here';
}
add_filter( 'jetpack_google_maps_api_key', 'mytheme_google_maps_key' ); |
Closes #4240
This pull request seeks to add a new "Google Maps API Key" field to the widget settings for Contact Info Widget. See #4240 for more context; specifically that Google now requires a key to be included in all maps products API requests.
It also changes the existing behavior of map output to always try to display a map, even if an API key is not configured. The hope here is that sites with grandfathered usage can continue to show a map without an API key (see #4242 (comment)).
Testing instructions:
Verify that when configuring a Contact Info Widget, a "Google Maps API Key" field is shown if the "Show Map" option is checked. Save an API key and observe both that the key setting is persisted, and that the key is included in the
srcof theiframethat is displayed on the front-end of the site.Follow-up Tasks:
The linked documentation article in the help text does not currently include any instructions on obtaining an API key and should be updated.
/cc @jeherve , @kraftbj