=== Autocomplete Google places === Contributors: chroudakais Tags: google address autocomplete, autocomplete google address, address autocomplete, autocomplete Requires at least: 5.6 Tested up to: 7.0 Stable tag: 3.3.0 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Add Google Places address autocomplete to your address fields and auto-fill city, state and postcode. == Description == This plugin enables Google Places address auto-completion on text input fields (order, checkout and registration pages). When a user starts typing an address and picks a suggestion, the plugin auto-fills the street, city, state, postcode and country fields. You only need a valid Google Places API key. The plugin targets the standard WooCommerce-style billing and shipping address fields (for example `billing_address_1` and `shipping_address_1`). As of version 3.0.0 the front-end script is written in modern, dependency-free vanilla JavaScript (no jQuery required) and the bundled CMB2 settings library has been updated for security. == External services == This plugin connects to the Google Maps JavaScript API (Places library) to provide address autocomplete and suggestions. This is required for the plugin to function. When a visitor types in an address field, the text entered is sent to Google to return address predictions, and the selected address details are returned to fill the form. The plugin loads the Google Maps script from Google's servers using the API key you configure on the settings page, along with your site's language and region. No data is sent until a visitor interacts with an address field on a page that contains a supported field. You must provide your own Google API key. - Service provider: Google Maps Platform - Terms of Service: https://cloud.google.com/maps-platform/terms - Privacy Policy: https://policies.google.com/privacy == Installation == 1. Upload the plugin files to the `/wp-content/plugins/autocomplete-google-places` directory, or install the plugin through the WordPress Plugins screen directly. 2. Activate the plugin through the **Plugins** screen in WordPress. 3. Open the **Google Places** admin menu (location-pin icon) and enter your Google Places API key. 4. Save. Autocomplete is now active on pages that contain the supported address fields. == Frequently Asked Questions == = Is this a paid plugin? = No, it is completely free. = Do I need a Google API key? = Yes. As of 3.0.0 there is no built-in fallback key. Create a key in the Google Cloud Console with the Maps JavaScript API and the Places library enabled, then enter it on the **Google Places** settings page. = Does it still require jQuery? = No. As of 3.0.0 the front-end script is pure vanilla JavaScript and no longer enqueues jQuery. = Which fields are supported? = The standard WooCommerce-style billing and shipping address fields. When an address is selected, address line 1, city, state, postcode and country are filled automatically. = Can I use it on custom form fields? = Yes. In the "Custom fields (Form ID / class)" setting you can target address fields on most forms (Contact Form 7, Gravity Forms, Elementor, and other standard HTML forms) by ID and/or CSS class. Fields added dynamically (Ajax, modals, multi-step forms) are detected automatically. = It does not work on a field built with React or Vue. Why? = Some plugins and themes build their address fields with a JavaScript framework such as React or Vue, where the field value is fully controlled by the framework. On those fields, no external autocomplete (including this one) can attach reliably, because the framework re-renders the input and overrides external changes. This is a limitation of how those frameworks work, not of this plugin. Standard HTML fields are fully supported. Improved support for framework-based fields is planned for a future release. == Screenshots == 1. The "Google Places" settings page where you enter your API key. 2. Address fields auto-filled after selecting a Google Places suggestion. == Changelog == = 3.3.0 = * New: custom field targeting now works with dynamically added fields. A MutationObserver detects address inputs that appear after page load (React/Ajax modals, multi-step forms, dynamically rendered checkouts) and attaches autocomplete to them automatically. * Improved: auto-filled values are now written in a way that React and other controlled-input frameworks register correctly, so the filled address is no longer reverted on the next render. = 3.2.0 = * New: multilingual support. The autocomplete now follows your WordPress site language and region (e.g. fr_FR), so suggestions and the predictions UI appear in the visitor's locale. * New: "Suggestion type" setting. Choose what Google suggests — street addresses (default), addresses & areas, cities only, regions, or businesses & places. * New: "Custom fields (Form ID / class)" option. Target address inputs on any form (Contact Form 7, Gravity Forms, custom forms) by ID and/or CSS class, separated by commas. When a suggestion is selected, the matched field is filled with the full street address and nearby city and postcode fields are auto-filled when present. This restores and improves the old "Form ID" targeting from the 1.x line. = 3.1.0 = * New: choose the autocomplete country scope from the admin settings. Default is Worldwide (works in all of Europe, USA, Canada, Japan and everywhere else); optionally restrict to up to 5 countries (Google's maximum). * New: redesigned admin settings screen built with React (WordPress' bundled wp.element), including a one-click "Test API key" button that verifies your Google Places key live. * Changed: replaced the bundled CMB2 library with a lightweight custom settings page (saved via the WordPress Settings API). This removes the vendored library entirely. = 3.0.0 = * Major release. * Rewrote the front-end script in modern vanilla JavaScript (ES6); removed the jQuery dependency from the script and its enqueue. * Security: upgraded the bundled CMB2 library from 2.10.1 to 2.12.0 (addresses CVE-2024-1792) and removed the dead root CMB2 loader. * Security: removed the hardcoded Google Maps API key fallback; the Maps script now loads only when an API key is configured. * Security: the Google Maps URL is now built with rawurlencode() and escaped with esc_url_raw(). * Hardening: moved the direct-access guard ahead of all includes, removed unused example files, and added a directory-listing guard to /js. * Added uninstall cleanup of stored plugin options. * Compatibility: raised the minimum PHP requirement to 7.4 (required by CMB2 2.12.0); updated "Tested up to". == Upgrade Notice == = 3.0.0 = Requires PHP 7.4+ (bundles CMB2 2.12.0). You must enter your own Google Places API key on the settings page; the old hardcoded fallback key has been removed. If you used a publicly exposed key from an older version, rotate or revoke it in Google Cloud. = 1.3.4 = * WordPress 5.9 version compatibility.