=== Unjacketed Ebook Lead Magnets ===
Contributors: unjacketed
Tags: lead magnet, ebook, email, download, opt-in
Requires at least: 6.3
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Deliver a free ebook via email opt-in with daily availability limits, social proof toasts, and Brevo integration.

== Description ==

Ebook Lead Magnet lets you gate a PDF or EPUB download behind an email opt-in form. Features include:

* Shortcode-based opt-in form with a modal pop-up
* PDF and EPUB delivery via a secure tokenised download link
* Per-magnet daily availability limits with live countdown
* Real-time social proof toasts showing recent downloads
* Brevo (Sendinblue) list integration
* Per-magnet and global email templates with TinyMCE editor
* ipgeolocation.io integration for state/province display in toasts
* CSV export of subscribers
* Unsubscribe flow with Brevo sync

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`.
2. Activate the plugin through the Plugins menu in WordPress.
3. Go to **Lead Magnet** in the admin menu to create your first magnet.

== External Services ==

This plugin relies on the following external services. By activating this plugin and configuring the relevant API keys you agree to the respective terms of service and privacy policies.

= Brevo (api.brevo.com) =

**What it is:** Brevo (formerly Sendinblue) is a third-party transactional email service used to deliver download emails to subscribers.

**Endpoints used:**

* `POST https://api.brevo.com/v3/smtp/email` — sends the download link email to each new subscriber.
* `POST https://api.brevo.com/v3/contacts` — creates or updates a contact in your Brevo account when a subscriber opts in.
* `PUT https://api.brevo.com/v3/contacts/{email}` — marks a contact as blacklisted when they unsubscribe, and lifts that blacklist flag if they later submit the opt-in form again.
* `POST https://api.brevo.com/v3/contacts/lists/{id}/contacts/remove` — removes an unsubscribed contact from your Brevo list.
* `POST https://api.brevo.com/v3/contacts/import` — bulk-imports subscribers to a Brevo list when the admin triggers a CSV export to Brevo.
* `GET https://api.brevo.com/v3/contacts/lists` — fetches your Brevo lists for the list selector in the magnet settings and for the connection test.

**Data sent:** subscriber first name, email address, and rendered email content (subject and HTML body) are transmitted to Brevo when a download email is sent. No data is transmitted until a subscriber successfully submits the opt-in form. Your Brevo API key is stored in your WordPress database and is never sent to any service other than Brevo.

* [Brevo Terms of Service](https://www.brevo.com/legal/termsofuse/)
* [Brevo Privacy Policy](https://www.brevo.com/legal/privacypolicy/)

= ipgeolocation.io (api.ipgeolocation.io) =

**What it is:** ipgeolocation.io is a third-party IP geolocation service used to look up the state or province of recent downloaders for the real-time social proof toast ("M. from California just downloaded…"). This feature is optional and requires you to provide your own API key.

**Endpoint used:**

* `GET https://api.ipgeolocation.io/ipgeo?apiKey={key}&ip={ip}&fields=state_prov` — called at poll time (every 30 seconds per active visitor) to resolve the state/province of each new downloader's IP address. Results are cached in WordPress transients for 5 minutes per IP address to minimise API usage.
* `GET https://api.ipgeolocation.io/ipgeo?apiKey={key}&ip=1.1.1.1&fields=state_prov,country_name` — sent once when the admin clicks **Test connection** on the Settings page, using a fixed public IP (Cloudflare's `1.1.1.1`) rather than any subscriber's address, purely to confirm the API key works.

**Data sent:** the IP address of each new subscriber is transmitted to ipgeolocation.io at poll time. The returned state/province string is used only for display in the social proof toast and is never stored in the database. No geolocation lookup is performed if no API key is configured; the toast will omit the location in that case.

* [ipgeolocation.io Terms of Service](https://ipgeolocation.io/tos.html)
* [ipgeolocation.io Privacy Policy](https://ipgeolocation.io/privacy.html)

== Changelog ==

= 0.1.0 =
* Initial release.
