=== Snapshot Results ===
Contributors: snapshotscoring
Tags: shooting sports, match results, cowboy action, scoring, competitions
Requires at least: 6.0
Tested up to: 6.5
Stable tag: 2.11.7
Requires PHP: 8.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Display match results from Snapshot Scoring on your club's WordPress site.

== Description ==

Snapshot Results connects your WordPress site to the Snapshot Scoring Application,
allowing you to display match results, club information, and announcements directly
on your website.

**Features:**

* OAuth 2.0 secure connection with PKCE support
* Multi-club support - connect multiple shooting clubs
* Automatic results sync from Snapshot Scoring
* Shortcode components you place on your own pages: club directory, club
  details and image, upcoming matches, recent results, full match results,
  announcements, circuit standings
* "Create starter pages" builds ordinary, editable pages pre-filled with
  shortcodes if you want it done for you
* No plugin-owned public pages: your theme and page builder decide the design
* Rate-limited API endpoints for security

**Perfect for:**

* Cowboy Action Shooting clubs
* USPSA/IPSC shooting clubs
* IDPA clubs
* Any club using Snapshot Scoring

== Installation ==

1. Upload the `snapshot-results` folder to `/wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to Settings > Snapshot to configure the connection
4. Click "Connect with Snapshot" and sign in with your Snapshot Scoring account
5. Choose which of your clubs to connect to this site
6. Either click "Create starter pages" (Settings > Snapshot > Pages), or add the
   shortcodes below to pages of your own and pick your Results page and club
   pages in the same section

== Frequently Asked Questions ==

= How do I connect my club? =

1. In WordPress, go to Settings > Snapshot and click "Connect with Snapshot"
2. Sign in with your Snapshot Scoring account (club owner or manager)
3. Approve the connection and pick the club(s) to publish on this site

= Can I connect multiple clubs? =

Yes! The plugin supports multiple club connections. Each club can have independent
sync settings for matches and results.

= How often do results sync? =

Results sync when:
* Matches are finalized in Snapshot Scoring (if auto-push is enabled)
* You manually trigger a sync from the WordPress admin
* The Snapshot backend pushes updates

= Can I customize the results display? =

Yes, completely. Since 2.9.0 the plugin creates no public pages and ships no page
templates. Everything is a shortcode you place on your own pages, so your theme,
block editor or page builder controls the layout. The output is plain semantic
HTML with stable `snapshot-*` classes and no colors. An optional base stylesheet
(layout and spacing only) can be turned off under Settings > Snapshot > Pages >
"Load base styles".

= Where did the /clubs/ and /matches/ pages go? =

They were removed in 2.9.0. Old links redirect (301) to the pages that now show
the same content: a club's link goes to the page you assigned to that club, a
match's link to your Results page (`?match=<id>`), and the old list pages to the
Clubs / Upcoming Matches starter pages, or your home page if none exist. Click
"Create starter pages" to get those pages in one step; the club pages it creates
keep the old `/clubs/<club>/` addresses.

= Does the plugin send any data to SnapshotScoring? =

If a bug in this plugin causes an error, an anonymous error report is shared with
SnapshotScoring to help fix bugs (no personal data). Reports contain only technical
details: the error message and code location, the plugin version, your WordPress
and PHP versions, and your site's hostname. No visitor data, user accounts, or
page content is ever included, and errors from WordPress core, your theme, or
other plugins are never reported.

= How do I turn error reporting off? =

Go to Settings > Snapshot > Advanced Settings and uncheck "Share anonymous error
reports with SnapshotScoring to help fix bugs (no personal data)". It is enabled
by default.

== Shortcodes ==

Club ids are shown under Settings > Snapshot > Pages. A match id is the number in
a Results link (`?match=345`). On a page assigned to a club, `club_id` can be left
out. Every list accepts `empty="…"` for the text shown when there is nothing.

**Clubs**

* `[snapshot_club_directory image_size="medium"]` — a card per synced club: image,
  name, location, regular shoots, linked to the club's page
* `[snapshot_club_image club_id="12" size="large" class=""]` — the club's image
  from the app (alt text = club name)
* `[snapshot_club_name]`, `[snapshot_club_location]`, `[snapshot_club_general_date]`
  (regular shoots), `[snapshot_club_contact]`, `[snapshot_club_tg]`,
  `[snapshot_club_general_info]`, `[snapshot_club_abbreviation]`,
  `[snapshot_club_email]`, `[snapshot_club_website]`, `[snapshot_club_member_count]`,
  `[snapshot_club_match_dates limit="10" format="F j, Y"]` — all take `club_id="12"`

**Matches and results**

* `[snapshot_upcoming_matches club_id="12" limit="10" show_club="1" date_format=""]`
  — today and later, soonest first; each links to the Results page
* `[snapshot_recent_results club_id="12" limit="10" show_club="1" date_format=""]`
  — final results, newest first; each links to the Results page
* `[snapshot_match_results]` — put this on your Results page. Shows the match in
  `?match=<id>`: header (name, date, club, shooters, stages, ruleset), the overall
  table and the by-category tables. `match_id="345"` pins one match;
  `show_categories="0"`; `empty=`, `not_found=`, `pending=` texts
* `[snapshot_results]`, `[snapshot_results_by_category]` — plain tables for one
  match (`match_id=`, or `?match=` on the Results page)
* `[snapshot_match_name]`, `[snapshot_match_date]`, `[snapshot_match_type]`,
  `[snapshot_match_club]`, `[snapshot_match_stage_count]`,
  `[snapshot_match_shooter_count]` — take `match_id=` or read `?match=`

**Circuit** (`circuit=` can be left out when the site is linked to one circuit)

* `[snapshot_circuit_standings circuit="<uuid>" season="" division="" limit="0"]`
* `[snapshot_circuit_schedule circuit="<uuid>" season="" when="upcoming" limit="" title="full"]`
  — every member club's matches for the season, grouped by month, with the club
  name; `when="upcoming|past|all"`, `title="short"`, `date_format=""`, `empty=""`
* `[snapshot_circuit_clubs circuit="<uuid>"]` — member club cards (name, town, website)
* `[snapshot_circuit_calendar circuit="<uuid>" label=""]` — Google Calendar and
  Apple / Outlook links for the circuit's match calendar

**Announcements**

* `[snapshot_announcements club_id="12" limit="5"]` — active announcements inline.
  The automatic site-wide banner is a separate setting (on for sites upgrading
  from 2.8, off for new installs).

== Screenshots ==

1. Admin settings page
2. Club connection management
3. Match results display
4. Single match detail view

== Changelog ==

= 2.11.7 =
* The upcoming-match page shows the match start time (and gates-open time) and, when the club makes it public, the range address with a maps link.

= 2.11.6 =
* Unranked rows show the status that removed the shooter (SDQ, DNF, DQ, MDQ) when the backend sends it.

= 2.11.5 =
* Wide results tables show that they scroll: an always-visible scrollbar, a fade on the side with more columns, ◀ ▶ buttons, and arrow keys once the table has focus. On wide screens the expanded table widens out of a narrow theme column.
* Standings start with a "Leaders" line per division, the key is a short list, and your club's rows stand out more.
* "Lower total time is better" shows under the results headings on phones.
* The schedule's Past section lists the most recent match first, under a larger heading.
* A failed plugin update says so in plain words, with the technical reason in a details line, and the auto-push switches explain what they do.

= 2.11.4 =
* Standings and results tables fit the column they sit in: low-value columns fold under the alias only when the table really does not fit (also with large text), so #, Alias and Points / Total are never cut off.
* The "Scroll the table sideways" hint shows whenever a table overflows, and # / Alias stay in place while you scroll.
* The standings key appears once above the tables and explains shooters who list two clubs.
* The circuit schedule (when="all") has "Upcoming" and "Past" sections.
* Results Total explains "seconds, lower is better". Upcoming matches show the club's location, and an upcoming match page offers newcomers the club's contact link when the club has one.

= 2.11.3 =
* Circuit standings: new Club column; this site's club highlighted; Counted / Best explained.
* Results tables: Total sits next to Alias, stage times fold behind "Show stage times and penalties", and nothing is cut off on phones. A legend explains MDQ, M, P, B, Raw and Clean.
* Upcoming matches open an "Upcoming match" page with date, club, location, stage count and a Register link, not "Results are not yet available".
* Upcoming Matches links to the circuit schedule; circuit schedule entries for other clubs' matches link to the match in the app.
* Settings: a status box at the top shows connection, last sync, version and updates. A failed sync reads "Connected, last sync failed". New "Settings" link under the Snapshot menus. The confusing Save button next to the auto-push switches is gone. The page no longer scrolls sideways on phones.

= 2.11.2 =
* Fix: sites running both Snapshot plugins no longer crash with "Cannot declare class Snapshot_HTTP_Client".

= 2.11.1 =
* Fix: circuit standings now refresh after a sync from the app (they kept a separate ten-minute cache the sync did not clear).
* Fix: the "could not connect to update server" message after Check for Updates never showed.
* Fix: a replayed or stale connect callback no longer crashes the settings page.
* Security: sync and connection error messages are no longer read from the page address; Apply Update only downloads from Snapshot servers.
* Faster: match lists, the club directory, announcements and the circuit schedule load their data in a few queries instead of one or more per row; the update check no longer retries a down server on every settings page load.

= 2.11.0 =
* Added: [snapshot_circuit_schedule], [snapshot_circuit_clubs] and [snapshot_circuit_calendar] for circuit websites. The Settings box is now called "Circuit" and lists all four shortcodes per circuit.

= 2.10.3 =
* Added: circuit standings for a season that has ended are labelled Archived (and an upcoming one Upcoming).

= 2.10.2 =
* Fixed: an auto-push switch flipped in Settings > Snapshot could look on without being saved (Sync Now discarded it). Switches now save as soon as they are flipped, and Sync Now saves them first.

= 2.10.1 =
* Fixed: pages cached by LiteSpeed Cache, WP Rocket, W3 Total Cache, WP Super Cache, WP Fastest Cache, SiteGround or Breeze now refresh as soon as the app pushes results, matches, club details or announcements.

= 2.10.0 =
* Added: search and share information for club and results pages (description, share picture, schema.org events), on by default; SEO plugins keep control of their tags.
* Added: [snapshot_add_to_calendar] subscribe links for a club's match calendar.
* Fixed: each match's results page now has its own canonical link; [snapshot_club_calendar_url] no longer 404s.

= 2.9.4 =
* Fixed: circuit standings show division names (Cattle Baron, B-Western) instead of codes, and tables scroll sideways on phones.

= 2.9.3 =
* Added: title="short" for the upcoming/recent match lists (drops the club name; links the date when the title is just the date).
* Fixed: a club's multi-line location (an address on several lines) is shown on separate lines again instead of one run-on line.

= 2.9.2 =
* Fixed: Disconnect now fully disconnects the site. It also revokes the refresh token, so Snapshot stops sending data to the site.
* Added: the site's connection is renewed automatically every week, so it no longer expires during the off-season.
* Added: Settings shows when the connection was renewed and when it expires, and a "reconnect" notice if it has expired.
* Fixed: a temporary network error while renewing the connection no longer disconnects the site.

= 2.9.1 =
* Fixed: the Results page returned "not found" for ?match=<id> on sites that have their own post type called "match".

= 2.9.0 =
* Changed: the plugin no longer creates public pages. Clubs, matches and announcements are private data; show them with shortcodes on your own pages.
* Added: component shortcodes — [snapshot_club_directory], [snapshot_club_image], [snapshot_upcoming_matches], [snapshot_recent_results], [snapshot_match_results], [snapshot_announcements].
* Added: "Create starter pages" — ordinary, editable pages pre-filled with shortcodes (Clubs, Upcoming Matches, Results, one per club). Never overwrites a page.
* Added: Results page and per-club page settings; optional layout-only base stylesheet.
* Changed: old /clubs/ and /matches/ links redirect (301) to the new pages.
* Removed: plugin templates, the "Use plugin templates" setting and the template stylesheet.

= 2.8.18 =
* Added: Manage clubs — add or remove connected clubs without disconnecting the site.
* Added: club featured image synced from the Snapshot app; club pages show it.
* Added: circuit standings box in Settings with a ready-to-paste shortcode; [snapshot_circuit_standings] works without a circuit id when there is one circuit.
* Added: matches and results can be removed from the site (unpublish, deleted or unlocked matches).
* Fixed: category labels instead of raw keys in results; live member count; upcoming match dates on club pages.
* Fixed: trashed matches/clubs are restored instead of duplicated on the next sync; the matches list is ordered by match date and ?club= filters it.

= 2.8.17 =
* Fixed: the plugin no longer stops the whole site when installed from the built zip; the sign-in code now finds its bundled HTTP client. If a bundled file is ever missing, an admin notice asks to reinstall the plugin instead.

= 2.8.16 =
* Security: a site connection for one club can no longer overwrite or take over another club's match or announcement posts by sending their ids.

= 2.8.15 =
* Security: removed the unused /snapshot/v1/oauth/clubs and /snapshot/v1/oauth/sync-status REST endpoints. Any Snapshot account token could use them to add club connections or read this site's connection list.

= 2.8.11 =
* Stage cells now show every penalty on a published match: misses (M), procedurals (P), minor safety violations (MSV), spirit of the game (SOG) and bonuses (B). Published matches previously printed stage times with no marks at all.

= 2.8.4 =
* Added: Anonymous error reporting to SnapshotScoring to help fix bugs (no personal data)
* Added: Opt-out toggle in Settings > Snapshot > Advanced Settings (enabled by default)
* Changed: A crashing shortcode or banner now renders as empty output instead of breaking the page

= 2.8.3 =
* Security: Plugin updates now default to the production server (api.snapshotscoring.com)
* Security: Update packages are verified against a sha256 checksum before installation
* Security: Update server setting restricted to official Snapshot backends over https
* Security: OAuth access and refresh tokens are now encrypted at rest
* Changed: OAuth token validation cache reduced from 5 minutes to 60 seconds
* Removed: Non-functional organizations/sync REST endpoint

= 2.8.2 =
* Added: Sport-aware match meta fields now exposed via WordPress REST API
* Added: Fields include org_code, scoring_type, ruleset info, and column definitions

= 2.8.1 =
* Fixed: Manual sync now uses correct club-based endpoint

= 2.8.0 =
* Added: In-admin plugin updates - check for and apply updates directly from Settings > Snapshot
* Added: Current vs available version display in Advanced Settings
* Added: "Check for Updates" and "Apply Update" buttons

= 2.7.2 =
* Fixed: Plugin update checker URL configuration

= 2.7.0 =
* Added: Rate limiting for REST API endpoints
* Added: X-RateLimit response headers
* Security: IP-based request tracking for abuse prevention

= 2.6.1 =
* Fixed: Improved null safety in API response handling
* Fixed: Token validation caching improvements

= 2.6.0 =
* Added: Organization hierarchy sync (organizations, leagues, rulesets)
* Added: Sport-aware column rendering
* Added: Results table column visibility settings
* Added: Announcement banner system
* Changed: Migrated to shared HTTP client

= 2.5.0 =
* Added: Multi-club OAuth support with PKCE
* Added: Connections table for tracking synced clubs
* Added: Auto-push settings per club
* Changed: Deprecated legacy API key authentication

= 2.4.0 =
* Added: Custom post types for clubs, matches, and announcements
* Added: Template system with theme override support
* Added: Shortcodes for club and match fields

= 2.3.0 =
* Added: OAuth 2.0 client registration flow
* Added: PKCE support for secure authorization
* Security: Timing-safe comparison for pairing codes

= 2.2.0 =
* Added: Database migration system

= 2.1.0 =
* Added: REST API endpoints for data ingestion

= 2.0.0 =
* Complete rewrite with OAuth support
* Multi-club management capabilities
* Breaking: New database schema (automatic migration)

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 2.9.0 =
The plugin's own /clubs/ and /matches/ pages are removed. After updating, go to Settings > Snapshot > Pages and click "Create starter pages" (or build your own pages with the shortcodes). Old links redirect automatically. The announcement banner keeps working.

= 2.7.0 =
This version adds rate limiting to prevent API abuse. No action required.

= 2.0.0 =
Major update with new OAuth authentication. Your existing connections will be
migrated automatically, but you may need to re-authorize if issues occur.
