Skip to content

Commit 20b972d

Browse files
fix(integration): add venue/promoter accessor functions to public API (#248)
Three more public wrapper functions for term-meta accessors that downstream consumers (extrachill-events templates, location-meta, abilities) call frequently and would otherwise need to keep using class_exists() guards against \DataMachineEvents\Core\Venue_Taxonomy and Promoter_Taxonomy directly. - data_machine_events_get_venue_data(int $term_id): ?array - data_machine_events_get_venue_address(int $term_id, ?array): string - data_machine_events_get_promoter_data(int $term_id): ?array All declared idempotently with function_exists() guards. Degrade to null/empty when the underlying classes are missing. Refs #244 Co-authored-by: homeboy-ci[bot] <266378653+homeboy-ci[bot]@users.noreply.github.com>
1 parent 4672482 commit 20b972d

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

docs/integration-api.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ Pass-through parameters mirror the underlying ability:
169169

170170
Returns `[ 'posts' => WP_Post[], 'total' => int, … ]`.
171171

172+
### `data_machine_events_get_venue_data( int $term_id ): ?array`
173+
174+
Return the structured venue data array stored against a `venue` term —
175+
address fields, lat/lng, website, etc. Returns `null` when the term does
176+
not exist or has no venue data. Use this instead of calling
177+
`Venue_Taxonomy::get_venue_data()` directly.
178+
179+
### `data_machine_events_get_venue_address( int $term_id, ?array $venue_data = null ): string`
180+
181+
Return the formatted single-line address for a venue term. Pass
182+
`$venue_data` if you already have it to avoid an extra meta read. Use this
183+
instead of `Venue_Taxonomy::get_formatted_address()`.
184+
185+
### `data_machine_events_get_promoter_data( int $term_id ): ?array`
186+
187+
Return the structured promoter data array stored against a `promoter` term.
188+
Use this instead of `Promoter_Taxonomy::get_promoter_data()`.
189+
172190
### `data_machine_events_get_event_datetime( int $post_id ): string`
173191

174192
Return the start datetime string for an event, or empty string when no row

inc/public-api.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,74 @@ function data_machine_events_query_events( array $params ): array {
190190
}
191191
}
192192

193+
if ( ! function_exists( 'data_machine_events_get_venue_data' ) ) {
194+
/**
195+
* Get raw venue term metadata.
196+
*
197+
* Returns the structured venue data array stored against a venue term —
198+
* address, lat/lng, city, region, country, website, etc. Returns null when
199+
* the term does not exist or has no associated venue data.
200+
*
201+
* @since 0.32.1
202+
*
203+
* @param int $term_id Venue term ID.
204+
* @return array|null Venue data array or null.
205+
*/
206+
function data_machine_events_get_venue_data( int $term_id ): ?array {
207+
if ( ! class_exists( '\DataMachineEvents\Core\Venue_Taxonomy' ) ) {
208+
return null;
209+
}
210+
211+
$data = \DataMachineEvents\Core\Venue_Taxonomy::get_venue_data( $term_id );
212+
return is_array( $data ) ? $data : null;
213+
}
214+
}
215+
216+
if ( ! function_exists( 'data_machine_events_get_venue_address' ) ) {
217+
/**
218+
* Get the formatted single-line address string for a venue term.
219+
*
220+
* Combines street, city, region, postal code, and country into a
221+
* comma-delimited human-readable address.
222+
*
223+
* @since 0.32.1
224+
*
225+
* @param int $term_id Venue term ID.
226+
* @param array|null $venue_data Optional pre-fetched venue data array
227+
* to avoid an extra term meta lookup.
228+
* @return string Formatted address or empty string.
229+
*/
230+
function data_machine_events_get_venue_address( int $term_id, ?array $venue_data = null ): string {
231+
if ( ! class_exists( '\DataMachineEvents\Core\Venue_Taxonomy' ) ) {
232+
return '';
233+
}
234+
235+
return (string) \DataMachineEvents\Core\Venue_Taxonomy::get_formatted_address( $term_id, $venue_data );
236+
}
237+
}
238+
239+
if ( ! function_exists( 'data_machine_events_get_promoter_data' ) ) {
240+
/**
241+
* Get raw promoter term metadata.
242+
*
243+
* Returns the structured promoter data array stored against a promoter term.
244+
* Returns null when the term does not exist or has no associated data.
245+
*
246+
* @since 0.32.1
247+
*
248+
* @param int $term_id Promoter term ID.
249+
* @return array|null Promoter data array or null.
250+
*/
251+
function data_machine_events_get_promoter_data( int $term_id ): ?array {
252+
if ( ! class_exists( '\DataMachineEvents\Core\Promoter_Taxonomy' ) ) {
253+
return null;
254+
}
255+
256+
$data = \DataMachineEvents\Core\Promoter_Taxonomy::get_promoter_data( $term_id );
257+
return is_array( $data ) ? $data : null;
258+
}
259+
}
260+
193261
if ( ! function_exists( 'data_machine_events_get_event_datetime' ) ) {
194262
/**
195263
* Get the start datetime for an event, formatted as a string.

0 commit comments

Comments
 (0)