=== Badhub Widget ===
Contributors: badhub
Tags: badminton, sport, table, schedule, club
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 8.1
Stable tag: 0.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show live league tables and match schedules for badminton clubs — directly on your website.

== Description ==

**Badhub Widget** lets badminton clubs embed their current league table and match schedule on their own website. No technical knowledge required.

= Features =

* **Live league table** — always up to date, directly from badhub.de
* **Match schedule** — upcoming fixtures and past results with match reports
* **Table + Schedule combined** — both widgets in one
* **Automatic height adjustment** — the iframe resizes to fit its content
* **Theme support** — light mode, dark mode, or auto (follows the visitor's system preference)
* **Highlight your own club** — your club's row is visually emphasised
* **Promotion/relegation markers** — coloured indicators for promotion and relegation zones
* **Club logos** — optional logo display next to each team name
* **Federation mode** — display a full federation table (for federation websites)
* Works with any WordPress theme via shortcode or Gutenberg block

= How it works =

1. Install and activate the plugin
2. Go to **Settings → Badhub Widget**
3. Enter your free API key (get one at [plugin.badhub.de](https://plugin.badhub.de))
4. Select your federation and club
5. Insert `[badhub_widget]` into any page or post

= Shortcode options =

`[badhub_widget]` — league table (default)
`[badhub_widget type="matches"]` — match schedule
`[badhub_widget type="combined"]` — table + schedule combined
`[badhub_widget type="table" pool_id="12345"]` — specific league pool
`[badhub_widget theme="dark"]` — dark mode
`[badhub_widget highlight="0"]` — disable own-club highlight
`[badhub_widget promotion="0"]` — hide promotion/relegation markers
`[badhub_widget logos="0"]` — hide club logos

= Federation league system shortcode (`[badhub_liga]`) =

Federations with an active Federation-tier license can embed the **complete league system** — all divisions, all tables, full match schedule with built-in 3-level navigation — using a single shortcode:

`[badhub_liga federation="bvbb"]` — full league widget for the BVBB federation
`[badhub_liga federation="bvbb" ga="G-XXXXXXXX"]` — with Google Analytics 4 tracking
`[badhub_liga min_height="700"]` — set initial iframe height (default 500)

The federation slug is required. If your Plugin Settings already specify a federation, the attribute can be omitted. Only federations with a valid Federation-tier license on badhub.de are served — other slugs return 403.

= External service =

This plugin connects to **badhub.de** to retrieve league tables and match data, and to **plugin.badhub.de** to render the widget iframe.

* Service website: [https://badhub.de](https://badhub.de)
* Privacy policy: [https://badhub.de/datenschutz](https://badhub.de/datenschutz)
* Terms of use: [https://badhub.de/nutzungsbedingungen](https://badhub.de/nutzungsbedingungen)

Data is fetched when a page containing the widget shortcode is loaded by a visitor. No personal visitor data is transmitted to badhub.de.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/badhub-widget/`, or install via **Plugins → Add New** and search for "Badhub Widget"
2. Activate the plugin
3. Go to **Settings → Badhub Widget**
4. Enter your API key (free at [plugin.badhub.de](https://plugin.badhub.de))
5. Select your federation and club
6. Add `[badhub_widget]` to any page or post

== Frequently Asked Questions ==

= Where do I get an API key? =

Visit [plugin.badhub.de](https://plugin.badhub.de) and register for free. You will receive your API key by email immediately.

= Is the plugin free? =

Yes. The free tier includes the full league table with the "Powered by badhub.de" badge. A Pro upgrade (no badge, priority support) is available for a small annual fee.

= Which federations are supported? =

Currently supported: BVBB, BVRP, HBV, BWBV, BBV, NBV. More federations are being added.

= The widget shows nothing / an error — what do I do? =

* Make sure your API key is entered correctly under **Settings → Badhub Widget**
* Check that the API key is registered for your website's domain
* Make sure you have selected your federation and club

= Can I use the widget without WordPress? =

Yes. Visit [plugin.badhub.de](https://plugin.badhub.de) to generate a script tag embed code that works on any website.

= Can I display multiple widgets on one page? =

Yes. Each `[badhub_widget]` shortcode generates an independent iframe. You can use different `pool_id` or `type` attributes for each.

== Screenshots ==

1. League table widget on a club website
2. Match schedule with clickable match reports
3. Plugin settings page
4. Widget Generator on plugin.badhub.de

== Changelog ==

= 0.2.0 =
* "Prüfen" button next to API key field — auto-fills the registered federation and club, locks them for free/pro keys (federation tier still has full freedom). Lock now persists across saves (15-min transient cache, server-side rendered)
* Fixed critical PHP TypeError when saving settings without selecting all fields (sanitize callbacks now accept null/empty values)
* New "Transparent background" option (`transparent="1"` shortcode attribute) — widget background becomes transparent so the host page background shows through; theme (light/dark/auto) still drives text and border colours
* New API endpoint `/api/v1/key-info` returns tier, federation and registered club for the calling key

= 0.1.0 =
* Initial release
* League table widget (shortcode + Gutenberg block)
* Match schedule widget (`type="matches"`)
* Combined table + schedule widget (`type="combined"`)
* Dark mode and auto theme support
* Promotion/relegation markers and club logo display
* Federation mode for federation websites
* Live preview in plugin settings
