Repository navigation
Changed — Opting In No Longer Requires a Token
Hooking method_mapbox_token is now what opts a site in, whether or not the callback has a token to return. Previously the plugin did nothing until the filter returned a non-empty token, so a site that had hooked the filter but not yet entered a token kept showing The Events Calendar's Google maps.
- Opted in, no token — TEC's Google Maps scripts and embedded maps are disabled and no map is output in their place:
tribe_get_option_google_maps_js_api_keyreturns an empty string,tribe_is_using_basic_gmaps_apireturnsfalse, andtribe_get_embedded_mapreturns an empty string. Geocoding, pin sync, the ECP geocoder replacement, and thewp method geocode-venuescommand are not registered until a token is available. - Opted in, token present — unchanged: Mapbox maps replace TEC's embeds.
- Not opted in — unchanged: with nothing hooked to
method_mapbox_tokenthe plugin does nothing, and TEC's own maps are left alone. - Not affected — the per-event and per-venue Show Map and Show Map Link checkboxes are never modified, and the "+ Google Map" link controlled by Show Map Link is not filtered.
Stale Coordinates — Unset When an Address Can't Be Geocoded
Previously, when a venue's address changed and the new address could not be geocoded, the coordinates found for the old address were left in place and the map kept showing the previous location.
- Unset on failure — when a lookup returns no match, returns a match below
method_mapbox_min_confidence, or the request fails,_VenueLat,_VenueLng,_VenueGeoAddress, and the cmb2-mapbox pin are deleted. The same happens when a venue's address is removed entirely. A venue without coordinates renders no map, and its next save tries geocoding again. - Kept when placed by hand — coordinates are left alone when the venue has a manual pin (below), when ECP's
_VenueOverwriteCoordsis set, or when the cmb2-mapbox pin holds coordinates that TEC's keys don't mirror (a pin saved before this plugin was active). - Kept when still correct — a failed lookup of the same address the coordinates were cached for, such as a request error during
wp method geocode-venues --force, does not unset them. method_venue_geocode_failed— still fires on every failed lookup, now after any stale coordinates have been unset.
Manual Pins — Tracked and Protected
- New
_VenueManualPinmeta — set on a venue when its pin is dropped or moved by hand in the cmb2-mapbox field. It is removed when the pin is deleted, and when the plugin writes coordinates itself (a successful geocode, or ECP's manual coordinates). - Same-save precedence — a pin dropped in the same save as an address change takes precedence over the geocoder, whether or not the new address can be geocoded, and the geocode cache is pinned to the new address.
- Address changes — changing the address of a venue with a manual pin re-geocodes it, and a successful result replaces the pin. This is the behaviour documented since 1.0.1, but with the pin field on the venue edit screen it did not take effect: the form's pin always won (see the fix below).
- Deleting a pin — as before, clears the venue's coordinates so that the venue is geocoded again.
Fixed — Geocoded Coordinates Lost With the Pin Field on the Venue Edit Screen
With a cmb2-mapbox field on the venue edit screen, CMB2 saves the form's copy of the pin after the geocoder has run. In 1.0.1 that copy was always treated as a pin change:
- A new venue, or one without a pin, had its freshly geocoded coordinates cleared, because the form's empty pin was read as a deletion.
- A venue whose address changed kept its old coordinates, because the form's old pin overwrote the new result.
The pin sync now compares the saved pin with the pin as the request found it, and with TEC's coordinates, and only treats it as a change when the pin was actually moved. A pin re-saved at the same coordinates (within 0.0000001°) is ignored.
Both save orders are handled. TEC normally saves a venue's meta before CMB2 runs, but when it is given a venue title it runs a nested post update first, which lets CMB2 save before the geocoder as well as after.
Upgrade Notes
- Pins dropped before 1.0.2 are not flagged. They were mirrored into TEC's keys without
_VenueManualPin, so they are treated as geocoded coordinates and will be unset if the venue's address later fails to geocode. To protect one, move the pin and save, or set the flag directly withwp post meta update <venue-id> _VenueManualPin 1. - Existing stale coordinates are only corrected when a venue is next saved.
wp method geocode-venuesre-checks every venue whose address differs from the one its coordinates were cached for, and unsets the coordinates of those that can't be geocoded. - Sites that hook
method_mapbox_tokenwithout a token stop showing Google maps as soon as they update.
Internal
get_coords()now composes the newget_tec_coords(),get_pin(), andas_point()helpers;same_point()compares two points.write_coords()hands the cmb2-mapbox write to a newwrite_pin(), so the pin can be restored without touching TEC's keys.- New
clear_stale_coords(),is_pinned(), andremember_pin()helpers, and two per-request properties ($pin_before,$pin_moved) that carry pin state between the TEC and CMB2 save hooks. - Plugin header documentation updated to describe the opt-in and stale-coordinate behaviour.
- Version bumped to 1.0.2.