Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/gavinrunsdavies/ipswich-jaffa-events-results/archive/refs/heads/main.zipWordPress plugin to surface JAFFA event results from a separate results database.
Overview
This plugin exposes a small read-only REST API, shortcodes, and a set of pretty URLs to view meetings, races and race results (CSV → JSON) and to download PDFs stored as blobs in the results DB.
Configuration
Set the following environment variables (or define them as constants before activating the plugin):
EVENTS_RESULTS_DB_HOST— database host (default:DB_HOSTorlocalhost)EVENTS_RESULTS_DB_NAME— results database nameEVENTS_RESULTS_DB_USER— results database userEVENTS_RESULTS_DB_PASSWORD— results database password
After installing or updating the plugin, visit Settings → Permalinks (or reactivate the plugin) to flush rewrite rules so the pretty URLs work.
Shortcodes
[ipswich-jaffa-events-results event-id="<id>" rows="<count>"]— renders a table of meetings for the given event, with links to race results (PDF or HTML results page). Userows="all"(orrows="-1") to show all meeting rows, or pass an integer likerows="100"to force a specific page length. Default is100rows per page.
REST API
Base path: /wp-json/ipswich-events-api/v1
-
GET /events- Returns: array of events
{ id, name, info }.
- Returns: array of events
-
GET /events/{eventId}/meetings- Returns: array of meetings. Each meeting object contains
meetingId,meetingName,meetingDate,meetingVenue, andresults(array of{ id, name, type }).
- Returns: array of meetings. Each meeting object contains
-
GET /events/{eventId}/meetings/{meetingId}/races- Returns: array of races for the meeting (
id,name,type).
- Returns: array of races for the meeting (
-
GET /events/{eventId}/meetings/{meetingId}/races/{raceId}/results- If the stored result
typeisCSV, the plugin parses the CSV payload and returns a JSON array (rows as objects using the CSV header). If no results are present or the type is notCSV, an empty array is returned. - The endpoint validates that the provided
meetingIdandeventIdmatch the race record; otherwise a404error is returned.
- If the stored result
Notes: the API is read-only; there is no authentication implemented in this plugin.
Pretty URLs / Templates
-
Results HTML page (DataTables) is served via a pretty URL and the plugin template:
/events/{eventId}/meetings/{meetingId}/races/{raceId}/results- This route renders
html/DisplayRaceResults.phpand loads the client assets (DataTables / ag-grid) via WordPress enqueues.
-
PDF download route (streams PDF binary from DB):
/events/{eventId}/meetings/{meetingId}/races/{raceId}/results/pdf- This route renders
html/DisplayRacePdf.phpwhich streams the PDF withContent-Type: application/pdf.
Development / CI
- A simple GitHub Actions workflow is included at
.github/workflows/php-lint.ymlto runphp -lon repository PHP files. composer.jsoncontains a classmap autoload for theapi/classes.
Notes / Troubleshooting
- If you change rewrite rules or install the plugin, flush rewrite rules by visiting Settings → Permalinks.
- Ensure the results DB is reachable from your WordPress host and that the
wp_ije_*tables exist and contain expected columns:wp_ije_events(id, name, info)wp_ije_meetings(id, event_id, name, date, venue)wp_ije_race_results(id, meeting_id, name, type, results)