=== Farmacie di Turno – FarmaciaDiTurno.it ===
Contributors: mygest
Tags: farmacie, farmacia di turno, pharmacy, widget, local news
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

The list of on-duty and open-right-now pharmacies of an Italian town, on your site, kept up to date by itself. A service by MyGEST Srl.

== Description ==

This plugin prints the list of pharmacies that are **on duty or open right now** in an Italian town (comune) directly into the HTML of your page: status (on duty, open until…, closed), address and a "Chiama" (call) button that leads to the pharmacy page. Because the list is part of the page, search engines read it as your own content. The data comes from FarmaciaDiTurno.it, the Italian on-duty pharmacies portal online since 2000, and keeps itself up to date: the plugin downloads it at most every 2 hours and refreshes it hourly with WP-Cron, while the widget script updates each status to the reader's clock without downloading anything.

For local news sites: you decide every how many pharmacies one of your banners appears, and you sell that space with your own advertising.

You need an **embed key**, free of charge: request it at [farmaciaditurno.it/widget](https://farmaciaditurno.it/widget) and paste it into the guide the plugin opens after activation (Settings → Farmacie di turno). The guide also has a shortcode builder. The plugin interface is in Italian, as is the service.

Three ways to use it:

* **Shortcode**: `[fdt_farmacie comune="lecce" layout="elenco" max="10"]`
* **Block** "Farmacie di turno" in the editor, with the same fields in the right-hand panel.
* **Classic widget** "Farmacie di turno (FarmaciaDiTurno.it)" for the sidebar.

Shortcode parameters: `comune` (town slug, e.g. `lecce`; `scelta` = the reader picks the town), `layout` (elenco · colonna · griglia · compatto — list, sidebar column, grid, compact), `filtri` (turno, aperte, h24 — on duty, open now, 24h), `max` (1–20), `ogni` (one banner every N pharmacies, 2–20; empty = no banners), `tema` (chiaro · scuro · auto — light, dark, automatic; light if omitted), `banner` (banner HTML, no scripts), `chiave` (only to use a key other than the one saved in the settings).

**Banners and ad servers.** The `banner` content is filtered by WordPress (no `<script>`): put the container in it (`<div id="gpt-farmacie-{n}"></div>`, `{n}` becomes 1, 2, 3…) and let your ad tag, already in your theme, fill it. For every slot inserted the widget dispatches the `fdt:annuncio` event on `window`, with `detail.elemento` and `detail.posizione`.

**The FarmaciaDiTurno.it logo.** The logo with a link to the FarmaciaDiTurno.it home page, above the list, is an option you choose in the guide (off until you turn it on). The terms of use of the key ask you to keep it visible, as it is what the free service asks in return: without the logo the service does not load the list.

= External services =

This plugin relies on **FarmaciaDiTurno.it** (https://farmaciaditurno.it), a service by MyGEST Srl, for the following:

* **Pharmacy data**: your server downloads `https://farmaciaditurno.it/api/v1/widget/{comune}.json` (at most every 2 hours per town, plus an hourly background refresh). The request carries your site URL in the user agent, like every WordPress HTTP request. No data about your readers is sent.
* **Widget script**: the page loads `https://farmaciaditurno.it/embed/v1.js` (and the logo `https://farmaciaditurno.it/embed/v1/logo.svg` when the option is on). The script updates each pharmacy status to the reader's clock and handles the filters. When the town is `scelta`, it downloads the JSON of the town the reader picks.
* **Aggregate counting**: the script sends a beacon to `https://farmaciaditurno.it/widget/b` with your key, the town, the widget layout and the event (loaded / seen). No cookies, no reader identifier, no personal data: these are the figures your site receives.

Terms of use: https://farmaciaditurno.it/widget#condizioni — Privacy policy: https://farmaciaditurno.it/privacy

== Installation ==

1. Upload the zip from Plugins → Add New → Upload Plugin and activate it: the guide opens.
2. Request your key at https://farmaciaditurno.it/widget and paste it into the guide (Settings → Farmacie di turno).
3. Build your shortcode with the guide and paste it into a page; or use the block in the editor, or the widget in the sidebar.

== Frequently Asked Questions ==

= How much does it cost? =

Nothing. The key is free; what the service asks in return is the FarmaciaDiTurno.it logo with a link to its home page above the list (an option in the guide).

= Where does the data come from, and how fresh is it? =

From FarmaciaDiTurno.it, which collects it from pharmacies, pharmacy chains and trade bodies and describes its sources at https://farmaciaditurno.it/come-verifichiamo-i-dati. The time of the last update is printed under the list; the plugin refreshes the data every hour.

= What is my town's slug? =

The name as it appears in the URL of the town page on farmaciaditurno.it (e.g. `lecce`, `reggio-emilia`). With `comune="scelta"` the reader picks the town inside the widget.

= The list does not show up =

In the guide, under the key, the plugin tells you whether your server can reach farmaciaditurno.it; if not, ask your hosting provider to allow outgoing HTTPS connections. If the logo is off, the service does not load the list: it is one of the terms of use.

= Does it use cookies or collect readers' data? =

No. The widget sets no cookies and sends no personal data: it only counts, in aggregate, how many times it was loaded and seen with your key.

= Can I change the colours? =

Yes, with CSS variables on the container (`--fdt-accento`, `--fdt-raggio`, …): the list inherits the font and colours of your page. Details at https://farmaciaditurno.it/widget.

== Screenshots ==

1. The guide after activation: key, logo option, shortcode builder.
2. The list in a page, "elenco" layout, with each pharmacy's status and the "Chiama" button.
3. The "Farmacie di turno" block in the editor.

== Changelog ==

= 1.2.0 =
* Guide after activation (Settings → Farmacie di turno): key saved once for the whole site, connection test, shortcode builder.
* The FarmaciaDiTurno.it logo is an explicit option, off until you turn it on (WordPress.org directory guidelines).
* Clean uninstall; translatable strings; block icon.

= 1.1.1 =
* The phone number is no longer shown: a "Chiama" button leads to the pharmacy page instead. Light theme when none is set.

= 1.1.0 =
* Server-side rendering: the list is in the page HTML (indexable); 2-hour cache in transients, hourly refresh with WP-Cron, one-day fallback copy if the download fails.

= 1.0.0 =
* First release: shortcode, block, widget.
