=== SDAweb Calendar Sync for Google Calendar ===
Contributors: rstake, sdaweb
Tags: google calendar, calendar, events, agenda, schedule
Requires at least: 6.5
Tested up to: 7.1
Stable tag: 0.24.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Display your Google Calendar events on your site in six views. Theme-aware, accessible, mobile-ready, no duplicate entry.

== Description ==

SDAweb Calendar Sync turns any Google Calendar into a polished, on-brand events display on your WordPress site — without duplicate data entry. Keep scheduling in Google Calendar the way you already do; the plugin pulls those events in and keeps your site in sync automatically.

It's for anyone who already runs their events in Google Calendar and wants them to look like a native part of their site instead of an embedded iframe — businesses, teams, venues, clubs, communities, and organisations of every kind.

Insert a calendar with a Gutenberg block, a shortcode, or a classic widget. All three share one render pipeline, so the output is identical however you add it.

= Six ways to show your calendar =

* **List / Agenda** — chronological, optionally grouped by day, week, or month
* **Month grid** — classic 7×6 calendar with multi-day event ribbons spanning across cells, today highlight (cell or whole-column style), optional ISO 8601 week-number column, and per-feed pastel chips
* **Card grid** — upcoming events as styled cards, responsive
* **Week** — 7 day columns, today highlighted
* **Day** — single-day agenda
* **Mini-month** — compact dot-density grid for sidebars and widgets, with a tap-to-expand event panel showing today + next upcoming events and a "Load more" button

Switch between views with one setting, or expose a visitor-facing view-toggle pill so visitors can switch themselves. Under the hood every view shares the same data layer, the same CSS-variable system, and the same accessibility baseline.

= Smart UX out of the box =

* **Hover popover on event chips** (Month, Week, Mini) — a floating card with date, time, location, calendar, recurrence summary, and a click-through link, so visitors get the full event detail without leaving the page. Desktop hover + keyboard focus only; touch users keep direct click-through.
* **Mobile auto-degrade Month → Mini** — below ~600px the full grid is replaced by the compact Mini-month view, so phone visitors get a clean, tappable calendar with no extra work from you. One wrapper, two layouts, no JS swap.
* **ICS subscribe dropdown** — one tap to add your events to a visitor's own calendar: Google Calendar (web), Apple Calendar / Outlook (webcal), Android Google Calendar app (intent), and Copy-link with toast confirmation. Mobile becomes a bottom sheet.
* **Live search** + **jump-to-date picker** — optional chrome controls so visitors can filter or navigate quickly.
* **Multi-day event ribbons** — week-spanning bars with arrow indicators when an event continues beyond the visible row.
* **Recurring event indicator** — small ↻ icon with a plain-language cadence summary in the tooltip ("Repeats weekly until 31 December 2026").
* **Per-display locale override** — render a calendar in a specific language (e.g. nb_NO) even when the site language differs, so you can run a localized calendar on a site that's in another language.

= Two authentication paths =

* **API key** — for calendars marked "Make available to public" in Google Calendar. One field, paste, done.
* **Service Account JSON** — for **private** calendars without per-user OAuth. Upload the JSON, share the calendar with the service-account email, you're set.

Credentials are encrypted at rest using a key derived from your site's authentication salt. They are never echoed back into the admin UI — only the masked value and (for service accounts) the public service-account email are shown.

= Theme-aware out of the box =

The plugin reads your active theme's `theme.json` color palette and uses your `primary`, `accent`, `foreground`, and `background` colors automatically. Per-display overrides let you set custom primary, accent, today-highlight, and link colors and force light/dark mode without touching code. Every design token is exposed as a CSS custom property so a developer can fully restyle the calendar from their theme stylesheet.

= Five built-in theme presets =

One-click coordinated colour bundles: **Default** (clean blue), **Warm earth** (cream + deep red), **High contrast** (solid black on white for AAA-stricter sites), **Forest** (deep green), **Sunset** (warm coral + amber).

= Accessibility built in =

WCAG 2.2 AA baseline with several AAA touches:

* Live contrast warnings on every colour picker — the admin UI shows the WCAG ratio against both light and dark surfaces with pass/fail markers as you choose colours
* Automatic high-contrast overlay via `prefers-contrast: more`
* Focus-visible halo: a 4px white ring behind the primary outline so focus stays visible against any chip background
* `prefers-reduced-motion` honored everywhere
* ARIA roles and labels on the month grid, navigation, popovers, and view-toggle
* Semantic HTML throughout
* RTL-aware via CSS logical properties
* Tabular numerals for day numbers and time labels so single- and double-digit values don't drift

= Built for the WordPress.org standard =

* Block editor first-class — server-side rendered, ServerSideRender preview, all the standard `InspectorControls`
* Shortcode and classic widget on the same render pipeline
* No bundled core libraries (no jQuery on front-end, no Guzzle, no Carbon, no Monolog)
* No third-party authentication relay — your credentials only ever talk directly to googleapis.com
* Translation ready via translate.wordpress.org once the plugin is published and indexed (no bundled `.po`/`.mo` — WordPress auto-loads locale files into `wp-content/languages/plugins/` per the WP Plugin Handbook), plurals via `_n()`, JS strings via `wp_localize_script`
* Free and GPLv2

= For developers =

Extension hooks are documented in `docs/hooks.md` inside the plugin folder. The first-release set includes filters for event data, event URLs, query args, cache TTL, render output, palette resolution, plus actions for refresh and uninstall lifecycle.

== Installation ==

1. Upload the plugin to your `/wp-content/plugins/` directory, or install it from the Plugins screen in WordPress.
2. Activate the plugin.
3. Go to **Settings → SDAweb Calendar Sync** to add your first calendar.
4. Choose API key (public calendars) or Service Account (private calendars), follow the in-app setup guide, save.
5. Create a display, choose a view, and copy its shortcode — or insert the **SDAweb Calendar** block in a page.

== Screenshots ==

1. Month grid with multi-day event ribbons and today highlight.
2. Upcoming view with filled date badges and Today / Tomorrow labels.
3. Mini-month compact grid with tap-to-expand event panel.
4. Hover popover with event date, time, location, and click-through link.
5. ICS subscribe dropdown — add events to Google, Apple, or Outlook in one tap.
6. Admin colour picker showing live WCAG contrast warnings.

== Frequently Asked Questions ==

= Do I need a Google account to use this plugin? =

You need a Google Cloud project to generate either an API key (for public calendars) or a service account (for private calendars). The plugin's Help tab walks you through both setups in 7–8 steps each. Setup is one-time per site.

= Does this plugin send my data anywhere other than Google? =

No. Calendar data is fetched directly from `googleapis.com` using the Google Calendar API. The plugin does not contact any SDAweb-controlled servers, analytics endpoints, or third-party relays. There is no telemetry.

= Can I display a private (non-public) calendar? =

Yes. Use the Service Account authentication option. The plugin shows you the service account email; share your private calendar with that email in Google Calendar's sharing settings, and the plugin can read it.

= How often does the plugin refresh events? =

A WP-Cron job refreshes registered calendars in the background every 15 minutes. Cache lifetime is configurable upward in the plugin settings (15 minutes is the enforced minimum). You can also click "Refresh now" on any calendar in the admin to fetch immediately.

= Does it work with caching plugins? =

Yes — the calendar HTML is part of the page output, so any page-cache plugin caches it like any other content. The cache will refresh on its own schedule. If you need immediate refresh after a calendar change, purge the page cache.

= Can I add multiple calendars to one display? =

Yes. Each display picks one or more registered calendars and merges them. Events are color-coded by calendar. A multi-feed legend strip can be enabled above the events; chips can be styled solid (single-feed) or pastel (multi-feed legibility).

= Will it work with my theme? =

The plugin reads your active theme's `theme.json` color palette automatically, so calendar colors match the site by default with zero configuration. If you use a classic theme without `theme.json` (or want to override), every color is exposed as a CSS variable that you can override from your theme stylesheet. Five built-in theme presets give you coordinated palettes with one click.

= Is the plugin accessible? =

Yes — built-in. WCAG 2.2 AA baseline includes `prefers-reduced-motion` and `prefers-contrast: more` support, `:focus-visible` outlines with a white halo (visible on any background), ARIA labelling on the month grid, navigation, popovers, and view-toggle, semantic HTML throughout, RTL-aware via CSS logical properties, and live contrast warnings in the colour-picker UI as you choose values.

= Can I show the calendar in a different language than the rest of the site? =

Yes. Each display has an optional Locale override field — set it to `nb_NO`, `sv_SE`, etc. and that calendar renders weekday names, month names, and built-in labels in that language regardless of the site's language. Useful when an English site hosts Norwegian-audience content.

= Where are the extension hooks documented? =

In `docs/hooks.md` inside the plugin folder. The plugin commits to keeping documented hooks stable within a major version.

== Third-Party Services ==

This plugin connects to the Google Calendar API to retrieve events from calendars you configure.

* Service: Google Calendar API v3
* Website: https://developers.google.com/calendar
* Terms of Service: https://developers.google.com/terms
* Privacy Policy: https://policies.google.com/privacy

Data sent: the calendar ID(s) you configure, plus either your API key or a JSON Web Token signed with your service account credentials. Event data is returned to your server and cached locally as WordPress transients. No event data is sent to any third party.

The ICS subscribe feature, when enabled, serves a self-hosted iCalendar (.ics) feed from your own site — built from the same calendar data already fetched via the Google Calendar API above — so subscribers can add it in Google Calendar, Apple Calendar, Outlook, or any other app that supports calendar subscriptions. No data is sent to any third party beyond the Google Calendar API connection already disclosed.

== Changelog ==

The most recent releases are listed here. The complete history is in
`docs/CHANGELOG.md` bundled with the plugin.

= 0.24.0 =
* Changed: an event whose description carries an "Info: <link>" line used to show a small ⓘ in front of its title — easy to miss, and it said nothing about what it meant. It now shows a "Read more ↗" badge after the title, in the display's accent colour, in List, Cards, Day, Week, Upcoming, the hover popover and the "+N more" list; the compact Month and mini-calendar chips show just the arrow. The text can be changed per display under Localisation & overrides (e.g. "Les mer"), and the badge can get its own colour under Event links. Nothing changes for events without a marked link.
* New: "Only link events with a marked link" under Event links. Tick it to link only the events that have an "Info:" line — every other event is shown as plain text, with no link to Google Calendar. Off by default, so nothing changes until you tick it.
* Changed: in the display editor the two "open in" menus under Event links looked like duplicates; they are now "Open Google Calendar links in" and "Open "Read more" links in", and the link settings are greyed out when the option they depend on is off.

= 0.23.6 =
* Fixed: on a site whose timezone lies west of the calendar's — any site in the Americas with a Google calendar left on its default timezone, for example — every all-day event was shown one day early, in all views and in the hover popover. All-day events are now placed on their own date in the display's timezone. Sites in Europe and further east were not affected and see no change.
* Fixed: in the Subscribe popover, the "Android (Google Calendar app)" choice had an empty link, so on an Android phone it never opened the Calendar app; it reloaded the page or landed on Google's "Add by URL" page instead. It opens the app again. The other three choices were unaffected.

= 0.23.5 =
* Fixed: a busy Month, Week, Day or mini calendar silently lost its last days. "Max events" (default 50) was applied to the calendar grids as well, so everything after the 50th event of the period was left out. The grids now always show every event in their date range; "Max events" applies to List and Cards, as its new description says. If a calendar of yours had more events than the limit, the missing ones appear after this update.
* Accessibility: on phones the view switcher (List / Month / Cards …) shows icons only, and the hidden labels were removed in a way that also hid them from screen readers, so VoiceOver and TalkBack announced five unnamed links. The labels are now hidden visually only. Nothing changes on screen.
* Fixed: on a server without PHP's mbstring extension the mini calendar (also used as the phone version of every Month display), the Upcoming list and any display with a saved search filter stopped with a fatal error. They now work without it; on servers that have mbstring — nearly all — nothing changes.
* Fixed: a calendar or display whose name WordPress cannot turn into plain letters — a name starting with an emoji, or written in Cyrillic, Greek, Chinese, Japanese … — was saved under an address the plugin could not find again: it could not be edited or deleted, and its shortcode showed nothing. New ones get a usable address ("📅 Kalender" → `kalender`), renaming a display does too, and records already stuck are repaired automatically on update. Names in Norwegian and other Latin-alphabet languages were never affected.

== Upgrade Notice ==

= 0.24.0 =
Events with a marked "Info:" link now show a clear "Read more ↗" badge after the title instead of a small ⓘ in front of it. The badge text can be set per display.

= 0.23.6 =
All-day events no longer show one day early on sites in a timezone west of the calendar's (e.g. the Americas). The Subscribe popover's Android choice opens the Google Calendar app again.

= 0.23.5 =
Busy Month/Week/Day/mini calendars no longer lose their last days to the "Max events" limit. View-switcher links get their names back for screen readers on phones. No more fatal error on servers without mbstring.

= 0.23.4 =
Upcoming now shows today's all-day events and running multi-day events; Day view shows multi-day events; events ending at midnight no longer spill into the next day. "Hide past events" now works and is switched off on existing displays so nothing changes.

= 0.23.3 =
Security hardening: the Google API key is no longer shown in admin debug details when WP_DEBUG is on. Also keeps the saved events when Google answers with something that is not calendar data.

= 0.23.2 =
Fixes view switching (dead "+N more" and popovers after switching to Month, broken Back button, stale mini calendar), "Refresh now" not reaching visitors, and calendars broken by a configuration import (repaired automatically).

= 0.23.1 =
Privacy fix: the Subscribe (ICS) feed now respects the display's search and hide filters. Also keeps showing the last saved events when Google is unreachable, and fixes a page-truncation bug from unusual event titles. Recommended for all sites.

= 0.23.0 =
Only ordinary events are shown now: birthdays, Gmail reservations and Workspace working-location / out-of-office entries no longer appear on public calendars. Service-account scope narrowed to events.readonly; no action needed.

= 0.22.1 =
Fixes the Upcoming (compact list) view showing multi-day all-day events as single-day. It now shows the date range instead of "All day". Front-end fix.

= 0.21.6 =
Fixes the styled hover popover falling back to the browser's plain tooltip after paging between months via the arrow navigation. Front-end fix; the styled popover now survives instant month navigation (and browser back/forward).

= 0.21.4 =
Fixes the Upcoming view showing fewer events than "Maximum events to show" when the calendar has events earlier the same day. Front-end fix; the view now reliably shows the configured number of upcoming events.

= 0.21.3 =
The Displays editor's Live preview now shows a "Showing N events" count of what it rendered (the same as the front-end), so you can confirm a display's event count at a glance. Admin-only; no front-end change.

= 0.21.2 =
Clearer Upcoming options: "Event time size" greys out (with a reason) when the meta line is off, and the event-name size/weight controls are renamed to avoid confusion with the time control. Admin-only; no front-end change.

= 0.21.1 =
Accessibility polish on the Displays view-filter: each button now announces its section count to screen readers, with correct singular/plural. Admin-only; no front-end change.

= 0.21.0 =
The Displays editor's view chips become a single filter bar that truly hides (not dims) settings that don't apply to the chosen view, with per-view counts and a live status line. Admin-only; all fields still save while filtered. No front-end change.

= 0.20.0 =
Splits "Event chip style" into two independent settings — "List view: event row style" and "Month view: event chip style" — so you can style both views on one display. Existing displays, blocks, and shortcodes migrate automatically with no visual change.

= 0.19.1 =
Fixes List view styling (week-heading pills + event accent bars) vanishing after an instant view-swap; a stray focus box around a heading after a swap on iOS / touch; and the Month/Week/Day/Mini prev/next arrows could switch the view instead of just changing the period.

= 0.19.0 =
Polishes the List view's week/day section headings (clearer typography) and removes a stray focus box that could appear around the first heading after an instant view-swap. Visual refinement only — no settings to change.

= 0.18.1 =
Adds an optional dedicated colour for the Upcoming "Today / Tomorrow" pill. Default is unchanged (the pill follows the event colour) until you set it.

= 0.18.0 =
Adds two opt-in Upcoming-view options: a time/All-day text size and a dedicated date-badge colour. Defaults are unchanged, so existing displays look exactly the same until you set them.

= 0.17.0 =
Adds three opt-in Upcoming-view options: date-badge size, Today/Tomorrow labels, and day/week grouping. Defaults are unchanged, so existing displays look exactly the same until you enable them.

= 0.16.4 =
Adds an admin "Event text size" (and optional weight) control for the Upcoming view. Defaults are unchanged, so existing displays look exactly the same until you opt in.

= 0.16.3 =
Completes the 0.16.2 fix for the mobile/instant-view-swap path: the toggle date guard now lives in the shared anchor resolver, and the render cache is version-keyed so an upgrade self-busts stale HTML. Clear the calendar render cache once after updating.

= 0.16.2 =
Bug fix: the view-toggle links could send a view switch to a garbage date (with no events) on the default no-date render, locking every view onto it. Toggles now follow the same resolved date as the grid and Prev/Today/Next, with a guard against out-of-range dates. No action required.

= 0.16.1 =
New per-display "Link event titles" toggle — turn it off to show event titles as plain text (no link) when the Google event page isn't useful to visitors. Default on; existing displays unchanged.

= 0.16.0 =
Internal hardening: the per-Display settings now flow through one shared schema, preventing the recurring class of "works in the admin preview but not on the front-end" bugs. No action required.

= 0.15.1 =
Bug fix: the per-display Chip text color setting now applies on the front-end (not just in the admin preview). Also redacts the API key from error-log lines and tidies up leftover options on uninstall. No action required.

= 0.15.0 =
Bug fix: long unspaced event titles no longer overflow the box in the Cards view. Also bundles the 0.14.x additions — Upcoming "Link placement" control, optional date-badge style, and the touch-device tagged-link fix. No action required.

