Repository navigation
v1.0.2
Map Field — The Event's Venue Map
The block previously had no way to output a map. A new map field renders the map for the event's venue, whichever map the site is set up to show.
mapfield —{"field":"map"}outputs the venue's map through The Events Calendar's owntribe_get_embedded_map(), so the block follows the site's map setup rather than choosing a provider itself.- Google — with TEC's default API key, Google's basic iframe embed; with a custom Google Maps API key, TEC's JavaScript map, with its scripts enqueued.
- Mapbox — with method-tec-mapbox opted in and a token available, the Mapbox GL map that plugin puts in place of TEC's.
- No map — nothing is output when method-tec-mapbox is opted in without a token, when the event has no venue, or when the venue has no address. With Mapbox, a venue without coordinates also has no map.
- Show Map honoured — nothing is output when TEC's Enable Maps setting is off or the event's Show Map checkbox is unchecked (
tribe_embed_google_map()), as in TEC's own templates. - Venue context — when the block's post is a venue rather than an event, that venue's map is output and its own Show Map checkbox is used.
- No empty wrapper — when there is no map the block returns an empty string, without the wrapper element, so a styled wrapper never leaves an empty box. The other fields still output their wrapper when they have nothing to show.
- New
mapWidthandmapHeightattributes — a string holding any CSS length, or a number for pixels. Both are empty by default, which leaves TEC's defaults in place:100%wide and350pxhigh, filterable throughtribe_events_single_map_default_widthandtribe_events_single_map_default_height. Only themapfield reads them. - Responsive heights — set
"mapHeight":"100%"and give the wrapper its height throughwrapperStyleandresponsiveData. - New
method_render_event_map( $event_id, $width, $height )— the function behind the field, usable on its own. Call it while the template is rendering so the map's scripts and styles are enqueued in time.
Fixed — address Field Fatal Error
The address field called tribe_get_venue_address(), which The Events Calendar does not define (checked against 6.17.5), so rendering it stopped the page with a fatal error.
- Now
tribe_get_full_address()— the field outputs TEC's address markup: the street address, city, region, postal code, and country inside<span class="tribe-address">. - No venue — an event without a venue outputs that span empty.
Fixed — Posts That Aren't Events
tribe_get_event() returns any post that exists, so the block was not skipped on other post types: the date fields output the current date and time, and the other fields an empty wrapper.
- Post type check — the block now outputs nothing unless the post is an event (
Tribe__Events__Main::POSTTYPE). mapexcepted — themapfield is left out of the check, so it keeps working in a venue's context. On any other post type it outputs nothing.
Changed — Method Theme No Longer Required
- Responsive wrapper styles are skipped without Method — they are only generated when
method_check_array_key(),method_get_block_responsive_styles(), andmethod_collect_css()all exist. Previously a block with bothwrapperandwrapperClassset caused a fatal error when the Method theme wasn't active. - Unchanged — the wrapper element and its
wrapperId,wrapperClass, andwrapperStyleare output either way, and with Method active the responsive styles are generated as before.
Housekeeping
- CHANGELOG added — this file. The entries for 1.0.0 and 1.0.1 were written retrospectively from the commit history.
- Version bumped to 1.0.2.