=== Email Gated Downloads ===
Contributors: coreessentials
Tags: email-gate, gated-content, lead-magnet, gated-download, download-form, pdf, zip, email, form, contact-form, lead-generation
Requires at least: 5.0
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Require visitors to enter their email before downloading your PDF or ZIP files.  Build your email list, gate content and offer lead magnets with simple, secure download forms.

== Description ==

**Email Gated Downloads** is a lightweight, GDPR‑compliant plugin for WordPress that lets you **gate any downloadable file behind an email capture form**.  Use it to deliver PDFs, eBooks, guides or other ZIP archives as lead magnets while you grow your subscriber list and protect your content from bots and abuse.

### Why use Email Gated Downloads?

- **Grow your email list** by exchanging a free resource for a valid email address.  Gated content is one of the simplest ways to build relationships with visitors and collect qualified leads.
- **Protect your downloads** with secure, one‑time links that expire after use.  Files are stored in a private directory and never exposed directly.
- **Comply with GDPR** with built‑in consent checkboxes and customizable messages.  Decide whether to collect just an email or also a name.
- **Track & export leads** with a built‑in download log.  View who downloaded your file, then export the data to CSV for your CRM or email marketing service.

### Quick setup (3 steps)

1. **Upload your file**: After activating the plugin, go to **Settings > Email Gated Downloads** and upload a PDF or ZIP file you want to gate.
2. **Configure your form**: Choose whether to display a name field, enable a GDPR consent checkbox and customize messages.  You can also adjust styling via CSS variables or disable the included stylesheet for full control.
3. **Place the form**: Insert the shortcode `[spdfed_download_form]` on any page, post or widget.  Visitors will see a clean form and, upon submission, receive a download link inline or via email.

That’s it!  Your download is now gated and you’ll start collecting emails.

= ✅ FREE FEATURES =

- **Email gate / download form** – Show a simple form requiring visitors to enter their email (and optional name) before downloading your PDF or ZIP file.
- **Secure file storage** – Files are stored in a protected directory. Download links are one‑time, time‑limited tokens.
- **Download logging & analytics** – Track every download with email, name, file name, IP address and timestamp.  Export logs to CSV for import into third-party services like Mailchimp, ConvertKit, HubSpot or any CRM.
- **GDPR compliant consent** – Built‑in consent checkbox with customizable text helps you meet privacy regulations.
- **Rate limiting** – Gated downloads are protected from repeated downloads or bot abuse.
- **Customizable styling** – Modify colours, borders and spacing using CSS variables, or disable the plugin’s stylesheet entirely and add your own CSS.
- **Lightweight & fast** – Minimal code and clean database usage ensure high performance on any site.

= 🚀 PREMIUM FEATURES =

Upgrade to Premium and unlock powerful features for marketers and content creators:

- **Unlimited gated files** – Create multiple download offers using the "Gated Files" Custom Post Type.  Gate ebooks, checklists, templates and more without limits.
- **Per‑file customization** – Override global form settings for each file.  Set a unique name field requirement, GDPR message or confirmation message per download.
- **Advanced analytics dashboard** – View total downloads, top files and download trends at a glance.  Spot your best‑performing lead magnets with charts and graphs.
- **Individual shortcodes** – Use `[spdfed_download_form id="123"]` to embed specific files anywhere on your site.

[Upgrade to Premium →](https://your-plugin-website.com/pricing/)

= 🎯 Perfect For =

- **Lead magnets** – eBooks, checklists, templates, webinars and worksheets.
- **Gated content marketing** – Offer exclusive PDFs or ZIPs in exchange for email addresses.
- **Building email lists** – Capture qualified leads for newsletters or product launches.
- **Digital product samples** – Share a preview while protecting your premium content.
- **Resource libraries & content upgrades** – Deliver companion downloads for blog posts and courses.
- **Newsletter incentives** – Grow your subscription list with irresistible freebies.

== Installation ==

### Free Version Setup

1. Install and activate the plugin from the **Plugins** menu in WordPress.
2. Go to **Settings > Email Gated Downloads**.
3. In **File Settings**, upload your PDF or ZIP file.
4. Configure **Form Settings**:
   - Show or hide the name field and choose whether it’s required.
   - Enable or disable the GDPR consent checkbox and customise its message.
5. Save your settings.
6. Insert `[spdfed_download_form]` on any page, post or widget where you want the download form to appear.
7. View your **Download Logs** on the same settings page and export them to CSV anytime.

### Premium Version Setup

After upgrading to Premium:

1. Navigate to **Gated Files** in your WordPress admin menu.
2. Click **Add New**, give your file a title and upload your PDF or ZIP.
3. Adjust form settings for this file (or use global defaults).
4. Copy the generated shortcode `[spdfed_download_form id="123"]` and paste it anywhere on your site.
5. Access **Analytics** to view download statistics and charts.

== Third-Party Libraries & Source Code ==

This plugin includes human-readable source code and uses the following third-party library:

= Chart.js =
- **File**: `assets/js/chart.js`
- **Version**: 4.4.4
- **Purpose**: Powers the analytics charts in the premium version
- **License**: MIT License
- **Source Code**: https://github.com/chartjs/Chart.js
- **CDN Reference**: https://cdn.jsdelivr.net/npm/chart.js@4.4.4/dist/chart.umd.js

All other JavaScript and CSS files in this plugin are written by the plugin author and are provided in uncompressed, human-readable format. No build tools or compilation is required.

== Frequently Asked Questions ==

= What file types are supported? =

Currently PDF (`.pdf`) and ZIP (`.zip`) files are supported.  Premium users can also gate other file types via custom hooks.

= Is the free version really free? =

Yes!  The free version is fully functional for gating a single file.  There are no time limits or hidden fees.

= What's the difference between free and premium? =

**Free version:** One gated file with all form options, download logs and CSV export.

**Premium version:** Unlimited files, per‑file customization, analytics dashboard and individual shortcodes.

= How are files stored? =

Files are stored in a protected directory. The download link uses a one‑time token so the real file URL is never exposed.

= Are download links secure? =

Yes.  Download links are generated as unique tokens that expire after use or after a set time.  Tokens cannot be reused.

= Is this GDPR compliant? =

Yes.  A customizable consent checkbox is included.  You are still responsible for your privacy policy and data handling.

= How can I customise the look of the form? =

Two options:

1. **CSS Variables (recommended)** – In the settings page, open the help panel to see all available CSS variables.  Copy them into `Appearance > Customize > Additional CSS` and adjust colours, borders and spacing.
2. **Disable Stylesheet** – Check the option to disable the plugin’s stylesheet and add your own CSS in your theme or custom plugin.

= Can I place the same shortcode on multiple pages? =

Yes.  You can place `[spdfed_download_form]` on multiple pages or posts; all forms will point to your gated file.  If you need different files, upgrade to Premium and use unique IDs.

= Can I place the multiple shortcodes on the same page? =

Yes. You can place as many `[spdfed_download_form id=""]` shortcodes on a page or post type as you like.

= Where can I see who downloaded my file? =

Navigate to **Settings > Email Gated Downloads** and scroll to **Download Logs**.  Each submission records the email, name, file name, IP address and timestamp.  Click **Export to CSV** to import the data into your email marketing platform.

= Can I integrate this with my email marketing service? =

Yes, you can export the CSV and import it into any third-party email marketing service such as Mailchimp, ConvertKit, ActiveCampaign, or others.

== Screenshots ==

1. **Settings Page** – Upload your file, configure form settings (name field, GDPR) and view download logs in one place.
2. **Download Form** – Clean form that collects email (and optional name) before allowing a download.
3. **Download Logs** – Track every download with email, name, file, IP address and timestamp.  Export to CSV anytime.
4. **Form Customisation** – Use CSS variables to match your theme colours and styling perfectly.
5. **Premium: Gated Files CPT** – Create unlimited gated downloads with individual form settings.
6. **Premium: Analytics Dashboard** – See total downloads, top files and trends with charts.

== Changelog ==

= 1.0.0 =
* Initial public release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.  Gate your downloads behind an email form.  Free version includes one file; Premium adds unlimited files, per‑file customization, analytics and CSV export.