=== FindLocal Events ===
Contributors: findlocal
Tags: events, calendar, local events, the events calendar, listings
Requires at least: 6.4
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 0.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Publish the local events feed you curate on FindLocal on your own site, as event pages or in The Events Calendar.

== Description ==

FindLocal Events brings the events feed you curate in the FindLocal portal (findlocal.community) into your WordPress site. Magazines, newsletters and business associations use it to publish their listings without retyping them.

* **Event pages or The Events Calendar.** By default each event gets its own page (a "FindLocal event" post) with a details box and schema.org Event data for search engines. If The Events Calendar is active you can publish into it instead: one calendar event per date, venues created once, your categories mapped.
* **A block and a shortcode.** The "FindLocal Events" block (or `[findlocal_events]`) lists the coming days the way print listings do: music by day, theater by show ("Runs Dec 15 - 20"), galleries by venue. Readers can open a single day, where every section merges by time and exhibitions on view come last.
* **Fast pages.** Lists are rendered on your server from a local copy of the feed. Page views never contact FindLocal, and the front end loads no JavaScript.
* **Your edits win.** If you edit a synced event in WordPress, the sync stops overwriting its text (cancellations still come through). "Resync from FindLocal" on the post list undoes that.
* **No duplicates.** If you already entered events in The Events Calendar, the Adopt tab matches them to the feed (same date, same venue, similar title) and links them instead of creating copies. Nothing changes until you confirm.
* **Instant updates.** FindLocal pings your site when you approve events; the site also checks every hour.

Everything in the plugin is free. What a feed contains, and any limits of your FindLocal plan, are set in the FindLocal portal; when FindLocal refuses a request the plugin shows FindLocal's own message.

= Getting started =

1. Install and activate the plugin.
2. Go to **Settings → FindLocal** and click **Connect to FindLocal**. Sign in, choose your feed, and you are sent back. (You can also paste a site key from the Sites page of the portal.)
3. Add the **FindLocal Events** block to a page, or the shortcode `[findlocal_events]`.

== External services ==

This plugin connects to **FindLocal** (https://findlocal.community), the service where you curate your events feed. It is needed to receive the feed. **The plugin makes no request to FindLocal until an administrator connects the site** (clicks Connect or saves a site key). It sends no analytics or telemetry.

What is sent, when, and why:

* **Connect** (when an administrator clicks Connect): the administrator's browser is sent to `https://findlocal.community/dashboard/publisher/connect` with this site's home URL, the URL of the settings page to return to, and a one-time random state value. After sign-in, the plugin sends the one-time code it received and this site's home URL to `https://findlocal.community/api/publisher/v1/connect/exchange` to receive the site key, site ID, ping secret and the feed's name.
* **Feed requests** (every hour by WP-Cron, after a ping, and when an administrator clicks Sync now, Test connection or Run dry run): the plugin requests `https://findlocal.community/api/publisher/v1/feed` with the site key (as an `Authorization: Bearer` header) and a cursor (the position reached in the feed). The response is the events of your feed.
* **Acknowledgements** (after each sync that read the feed): the plugin sends `https://findlocal.community/api/publisher/v1/ack` the cursor reached, the publishing mode (event pages or The Events Calendar), the number of events created, updated, removed, held because they were edited locally, and failed, up to 20 short error messages, and the versions of the plugin, WordPress and PHP. FindLocal uses this to show you in the portal whether your site is up to date and to troubleshoot.
* **Adoption report** (only when an administrator runs the Adopt dry run with The Events Calendar): the plugin sends `https://findlocal.community/api/publisher/v1/report` the list of matched, ambiguous and unmatched events: for each, its title, date and WordPress post ID, and the FindLocal event ID when there is one. This lets FindLocal show the same report in the portal.
* **Category list** (only when an administrator opens the Category mapping tab with The Events Calendar): the plugin requests `https://findlocal.community/api/publisher/v1/terms` with the site key.
* **Pings** (inbound): after you approve events, FindLocal sends a POST request to this site's REST route `/wp-json/findlocal/v1/ping` containing the feed ID, site ID, a sequence number and a timestamp, signed with the ping secret. The plugin verifies the signature, rejects old or repeated pings, and then pulls the feed as above. No data is sent back except an HTTP status.

FindLocal terms of service: https://findlocal.community/terms
FindLocal privacy policy: https://findlocal.community/privacy

**Maps (OpenStreetMap, on by default).** When an event's venue has coordinates, event pages and venue pages show a map embedded from OpenStreetMap (`https://www.openstreetmap.org/export/embed.html`), with "Directions" and "View larger map" links to openstreetmap.org. The map is an iframe that the visitor's browser loads directly from openstreetmap.org when the page is viewed, so OpenStreetMap receives the visitor's IP address, browser user agent and the venue's coordinates; the plugin itself sends nothing. Turn it off with "Show a map on event pages" under Settings → FindLocal → Display. OpenStreetMap Foundation terms of use: https://osmfoundation.org/wiki/Terms_of_Use and privacy policy: https://osmfoundation.org/wiki/Privacy_Policy

**Images (optional, off by default).** If you turn on "Copy each new event's image" under Display, the plugin downloads each new event's image from the address given in the feed (usually the venue's own website or an image host such as Wikimedia Commons) into your Media Library. Only a normal download request is made to that host; no data about your site or visitors is sent beyond what any download sends (your server's IP address and a WordPress user agent). Those hosts' own terms and privacy policies apply.

== Frequently Asked Questions ==

= Does the plugin contact FindLocal before I connect? =

No. Until you connect (or save a site key), the plugin makes no external requests at all.

= Do I need The Events Calendar? =

No. By default events are published as the plugin's own event pages. The Events Calendar is optional; when it is active you can choose it under Settings → FindLocal → Sync.

= Does it use The Events Calendar Pro recurring events? =

No. Each date is its own event, which keeps cancellations and changes to single dates simple.

= What happens if I edit a synced event? =

The plugin notices that the title, text, dates or venue changed in WordPress and stops overwriting the text of that event. Cancellations, postponements and removals still apply. Use "Resync from FindLocal" in the post list to go back to the feed's version.

= Where do the event page URLs come from? =

FindLocal event pages live under /listings/ by default. Change the base under Settings → FindLocal → Display.

= Can I change how the lists look? =

Copy any file from the plugin's `templates/` folder to `findlocal/` in your theme and edit it there: `events-list.php`, `events-day.php`, `entry.php`, `parts-filters.php`. The stylesheet is small and inherits your theme's fonts and colours.

= Is there a credit link? =

Only if you turn it on. "Events by FindLocal" under the lists is off by default (Settings → FindLocal → Display).

= What happens when I disconnect or uninstall? =

Disconnecting keeps everything already published and stops syncing. Uninstalling deletes the plugin's settings, its local copy of the feed and its event pages. Events created in The Events Calendar are deleted only if you ticked "Also delete the events this plugin created" under Sync; events you adopted are never deleted.

== Screenshots ==

1. The events list block: music by day, theater by show, galleries by venue.
2. A single day: every section in time order, exhibitions on view at the bottom.
3. A FindLocal event page with its details box.
4. Settings → FindLocal → Connection.
5. The Adopt dry run report for The Events Calendar.
6. Category mapping for The Events Calendar.

== Changelog ==

= 0.2.1 =
* Event pages no longer repeat the first sentence when the feed shows the venue's own description.

= 0.2.0 =
* Layouts: list, image cards, and a compact "Upcoming events" box for sidebars and footers.
* A month calendar view, with a day view for each date.
* A filter bar (kind, venue, dates, search) that works without JavaScript and on phones.
* Event pages with add-to-calendar (Google and .ics), share links and an optional OpenStreetMap map.
* Venue and organizer pages.
* A "Submit your event" form (block and [findlocal_submit]); submissions wait for your approval on FindLocal.
* An accent colour setting.

= 0.1.2 =
* Approvals made in quick succession all arrive: a ping that lands during a sync makes it read again, and a sync that finds another running retries shortly after.
* Sync now is on the Connection tab.

= 0.1.1 =
* Settings link under the FindLocal events menu, and a Connect notice until the site is connected.

= 0.1.0 =
* First release: Connect, hourly and ping-triggered sync, FindLocal event pages, The Events Calendar adapter with category mapping and adoption, block and shortcode with range and single-day views, local edit protection, optional image copying and credit link.

== Upgrade Notice ==

= 0.2.1 =
Event pages show the venue's own description without repeating its first sentence.

= 0.2.0 =
Cards, month calendar, filters, event maps, venue pages and visitor submissions.

= 0.1.2 =
Fixes approvals that waited for the hourly sync.

= 0.1.1 =
Easier to find the Connect button.

= 0.1.0 =
First release.
