=== TargetScore Events Calendar ===
Contributors: targetscore
Donate link: https://donate.stripe.com/aEU5lHenb6K81jy147
Tags: events, calendar, shooting sports, targetscore
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show a TargetScore club's upcoming events on a WordPress page in a Calendar and List view, with an in-site event detail page.

== Description ==

Given a single Club ID, this plugin displays that club's upcoming events (fetched from the TargetScore API) in two switchable views:

* **Calendar** — a month grid with one color per event category and multi-day events shown as continuous bars.
* **List** — the same upcoming events, chronological.

Clicking an event opens an event detail page rendered inside your site. A Register button opens the external TargetScore registration page in a new tab. A separate sidebar/footer **widget** shows a compact list of upcoming events.

All API calls are made server-side (proxied + cached via WordPress transients), so nothing hits the browser cross-origin and payloads stay small.

= How it works =

* Configure a **Club ID** under **Settings → TargetScore Events Calendar**.
* On activation the plugin creates a published **Events** page (slug `events`) containing the `[targetscore_calendar]` shortcode. You can rename, move, or delete it freely.
* Add the calendar to any page/post with the shortcode:

  `[targetscore_calendar]`

  Optional per-instance default view: `[targetscore_calendar view="list"]`.

* The event detail page uses the same page with a `?event={id}` query parameter — no rewrite rules needed.
* Add the **"TargetScore: Upcoming Events"** widget to any sidebar/footer for a compact list.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` and activate it.
2. Go to **Settings → TargetScore Events Calendar** and enter your **Club ID**.
3. Visit the auto-created **Events** page (or add `[targetscore_calendar]` to any page).

== Frequently Asked Questions ==

= Where does the data come from? =
The public TargetScore API (default base `https://api.targetscore.com`), proxied through this plugin's own REST routes under `/wp-json/targetscore/v1/`.

= How do I clear cached events? =
**Settings → TargetScore Events Calendar → Clear cache now.** The cache is also cleared automatically when you change the Club ID.

== External services ==

This plugin connects to the TargetScore API to retrieve the configured club's public event data, and links to the TargetScore website for event registration.

**TargetScore API (api.targetscore.com)**
The plugin makes server-side GET requests to `https://api.targetscore.com` to fetch:

* the club's upcoming events — `/api/events/by-club/{clubId}`
* club information and event categories/colors — `/api/club/{clubId}`
* a single event's details — `/api/event/{eventId}`

These requests are triggered when a visitor loads a page containing the events calendar, list, or the Upcoming Events widget. The only data sent is the Club ID you configure (and, for the detail view, an event ID from the page URL). No personal visitor data is transmitted. Responses are cached in WordPress transients.

**TargetScore website (targetscore.com)**
Event "Register" buttons and links open `https://targetscore.com/{eventId}` in the visitor's browser (a normal outbound link; no data is sent by the plugin itself).

Service provider: TargetScore.
Terms of Service: https://docs.targetscore.com/docs/legal/terms-of-service
Privacy Policy: https://docs.targetscore.com/docs/legal/privacy-policy

== Screenshots ==

1. Calendar (month grid) view with per-category colors and multi-day events.
2. List view of upcoming events.
3. In-site event detail page with a Register button.
4. Upcoming Events sidebar/footer widget.
5. Admin settings screen (Club ID, accent color, cache).

== Developer notes ==

The front-end bundle (`assets/js/dist/targetscore-calendar.iife.js` + `.css`) is compiled from `assets/js/src/` via esbuild:

    cd build
    npm install
    npm run build     # produce the bundle
    npm test          # run the normalizeEvent unit tests

All event-date parsing lives in one adapter (`assets/js/src/normalize.js`) so the upcoming upstream change (splitting `dates` into `startDate`/`endDate`) is a single-function edit.

== Changelog ==

= 1.0.0 =
* Initial release.
* Calendar (month grid) and list views with per-category colors and multi-day bars.
* In-site event detail page with sanitized rich-text overview and a popup-safe Register button.
* "Upcoming Events" sidebar/footer widget (server-rendered list).
* Admin settings: Club ID, accent color (Register button, view toggle, today highlight), cache TTLs, clear cache, and a connection test.
* PHP proxy with transient caching for all TargetScore API calls.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
