=== PopHonest ===
Contributors: pophonest
Tags: popup, opt-in form, email capture, floating bar, lead generation
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.2.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Local-only popups, floating bars and inline opt-in forms with leads and stats in your own WordPress database. No remote code, no limits.

== Description ==

PopHonest adds popups, floating bars and inline opt-in forms to any WordPress site. The markup is rendered on the server, the CSS and the JavaScript ship inside the plugin, and every lead and every statistic stays in your own database. Nothing is loaded from a remote server and no request is sent to us.

There is a separate paid add-on sold outside WordPress.org. This plugin is complete on its own: none of its features is disabled, time limited or gated behind a paid upgrade.

= Campaign formats =

* Popup: a dialog on a dimmed overlay. It closes with the close button, the Escape key or a click on the overlay.
* Floating bar: a bar pinned to the edge of the screen that stays visible while the visitor scrolls.
* Inline: a card placed in your content with the [pophonest_inline id="1"] shortcode, where 1 is the campaign ID.

= Triggers =

* After a time delay in seconds.
* After the visitor scrolls a chosen percentage of the page.
* When an element matching a CSS selector is clicked.
* Exit intent: on desktop the pointer leaves the top of the window; on mobile a fast upward swipe, the tab becoming hidden or the back button. The desktop and the mobile half can each be switched off per campaign.

= Targeting =

* Show on every page, only on the selected pages, or everywhere except the selected pages.
* Logged-out visitors, logged-in visitors or both.
* First-time visitors or returning visitors. One first-party cookie remembers a visitor for 1 to 365 days, 30 by default.
* Desktop, tablet and mobile, detected from the browser user agent.

= Forms and leads =

* Up to three fields per campaign. The email field is always present and required; additional fields can be a name, a phone number or a custom text field.
* After a submission the campaign can show a success message, close itself or redirect to a URL.
* Leads are stored in your own database, can be filtered by campaign and date, and can be downloaded as CSV.
* Each campaign can also send its leads to Mailchimp, Kit, MailerLite, Brevo, ActiveCampaign or a webhook of your choice, using your own API credentials.
* The webhook receives one JSON POST per submission and can be unauthenticated, protected by one custom header, or signed with an HMAC-SHA256 signature of the request body.
* A failed delivery is retried, up to three attempts in total. The 50 most recent attempts are kept and listed under Settings, Recent sync activity.

= Statistics =

Views and submissions are aggregated per campaign and per day in your own database, and the Reports screen shows the conversion rate for each campaign and each day. No per-visit record, IP address or user agent is stored for statistics.

= Privacy =

* No remote JavaScript, CSS, font or image is loaded on the front end or in the admin.
* No tracking script, no phone-home call and no account is created for you.
* Campaigns only reach the email service or webhook endpoint that you configure yourself.
* Data is deleted on uninstall only when you tick that option in the settings.

== Installation ==

1. Install PopHonest through Plugins, Add New, or upload the plugin folder to /wp-content/plugins/.
2. Activate the plugin through the Plugins screen.
3. Open PopHonest, Add New to build your first campaign: pick a format, write the content, choose a trigger and the pages it should appear on.
4. Optional: open PopHonest, Settings to connect an email service or a webhook. Every campaign then picks the connection it sends its leads to.
5. Publish the campaign and set its status to Active.

For an inline card, place [pophonest_inline id="1"] in a post, a page or a widget and use the campaign ID shown in the campaign list.

== Frequently Asked Questions ==

= Does it work without an email service? =

Yes. Every lead is written to your own database before anything else happens, so the plugin is fully useful with no connection at all. Connecting a service only adds a copy of each new lead to that provider.

= Where does the data go? =

Leads, campaign settings and statistics are stored in your own WordPress database and are never sent to us. A submission is forwarded only when you have connected an email service or a webhook for that campaign, and then only to the endpoint whose credentials you entered. The plugin loads no remote scripts, styles, fonts or images, runs no analytics and makes no call to any PopHonest server.

= How much does the paid add-on cost, and what happens after the first year? =

PopHonest Core is $149 per year and PopHonest Pro is $249 per year, both in USD. The first year is the renewal price on both plans: there is no promotional first-year price that later jumps, and a renewal costs the same $149 or $249 you signed up at. Both are separate paid add-ons distributed outside WordPress.org; this free plugin needs neither of them.

= Is there a limit on campaigns or impressions? =

No. You can create as many campaigns as you need and show them as often as you need. There is no cap on campaign views, submissions or stored leads, no per-visit metering and no traffic-based pricing.

= Can I export the leads? =

Yes. The Leads screen has an Export CSV button that writes the rows currently matching your filters: one row per lead with the date, the campaign, the email, the name, the page URL, the referrer, the sync status and any extra field values.

= Will it slow my site down? =

The CSS and the JavaScript are local files that are only enqueued when at least one active campaign matches the current request or an inline shortcode is on the page, so unrelated pages load nothing. The front end makes one request to this site's own REST route when a campaign is shown and one when it is submitted; no third-party host is contacted by the browser.

= Which data is stored about visitors? =

Statistics are one row per campaign and day holding a view count and a submission count, with no per-visit record. A lead stores the values the visitor typed plus the page URL, the referrer, the submission time and a hash of the IP address (the address itself is never stored). For the returning-visitor rule, one first-party cookie holds a random flag for 1 to 365 days.

= What happens when I uninstall the plugin? =

Deactivating or updating the plugin never deletes anything. When you tick "Delete campaigns, leads and statistics when the plugin is deleted" in the settings, deleting the plugin removes its tables and options; when the option is off, all data stays in your database.

== Screenshots ==

1. The campaign list: name, type, trigger, status, all-time views and submits, conversion, placement and the row actions for each campaign.
2. The campaign editor: the Trigger panel with the four ways a campaign can be shown (delay, scroll depth, click selector, exit intent with its desktop and mobile switches), page and visitor targeting, and the form fields with their labels and input types.
3. Settings, Email service connections: one card each for Mailchimp, Kit, MailerLite, Brevo, ActiveCampaign and the webhook, with the credential fields, the list selector and the Test connection button.
4. Reports: daily totals and per-campaign figures for views, submissions and conversion rate.
5. A popup on the front end with its title, its fields, the submit button and the close button.
6. A floating bar on the front end with its message, its field and the close button.

== External services ==

This plugin runs on your own server and has no server of its own. Every connection listed below is optional and off by default: nothing leaves your site until a site administrator has entered their own credentials for that service and enabled it on a campaign. A lead is always saved in your WordPress database first, and a request is only made when a new submission arrives. With no service configured, the plugin makes no outbound request at all.

Requests are sent by your WordPress server, never by the visitor's browser, so the provider sees your site's address rather than the visitor's. A failed request is retried up to three times, and the sync status of every lead is shown in the Leads list, where you can filter by it and retry a failed one.

= Mailchimp =
Host: your data-centre subdomain, https://<dc>.api.mailchimp.com/3.0, where <dc> is the part of your API key after the dash (us1 when there is none).
Data sent: the subscriber's email address, the status "subscribed", the submitted name as merge field FNAME, and the campaign's tags in a second request to the same host. Your audience ID chooses the list.
Terms: https://mailchimp.com/legal/terms/ - Privacy: https://mailchimp.com/legal/privacy/

= Kit =
Host: https://api.kit.com/v4
Data sent: the email address and the first name. When you picked a form, its ID goes in the path; otherwise the subscriber is created or updated. This API cannot add tags, which is why the settings screen hides the tag field for Kit.
Terms: https://kit.com/terms - Privacy: https://kit.com/privacy

= MailerLite =
Host: https://connect.mailerlite.com/api
Data sent: the email address, the name as fields.name, and your group IDs in the groups list. This API accepts neither tags nor a subscription status: your MailerLite account's own double opt-in setting decides that.
Terms: https://www.mailerlite.com/legal/terms-of-service - Privacy: https://www.mailerlite.com/legal/privacy-policy

= Brevo =
Host: https://api.brevo.com/v3
Data sent: the email address, the name as the attribute FIRSTNAME, your list ID, and updateEnabled set to true so that an existing contact is updated instead of rejected. Brevo contacts carry attributes rather than tags, so tags are not sent.
Terms: https://www.brevo.com/legal/termsofuse/ - Privacy: https://www.brevo.com/legal/privacypolicy/

= ActiveCampaign =
Host: the account URL you enter, for example https://youraccount.api-us1.com
Data sent: the email address, the first name and the campaign's tags. The sync endpoint updates an existing contact instead of failing, and the list you chose is applied in a second request to the same host.
Terms: https://www.activecampaign.com/legal/terms-of-service - Privacy: https://www.activecampaign.com/legal/privacy-policy

= Webhook (your own endpoint) =
Host: any HTTPS URL you enter. You can require a shared header, or an HMAC-SHA256 signature of the request body computed with a secret you choose.
Data sent: the event name (lead.created), the source, the email address, the name, the campaign ID and name, the page URL the form was submitted on, the referrer, the submission time and the campaign's tags.
Terms and privacy: whatever your own endpoint has.

= What is not sent =
Form fields other than the email and the name stay in your database. IP addresses are stored as a one-way hash, never in clear text, and no IP address is ever sent to a provider. Statistics stay on your site; only the webhook you configure receives the page URL and referrer of a submission.

= No first-party server =
There is no PopHonest server to call: the plugin does not contact `pophonest.com`, loads no script, style, font or image from it, and reports no usage data, error or statistic to anyone. It contains no analytics, no telemetry and nothing that phones home.

== Changelog ==

= 0.2.2 =

* Escaping moved to the print site. Each template view now escapes every value where it echoes it: `esc_html()` for text, `esc_url()` for the image URL, `esc_attr()` for an attribute value, `wp_kses_post()` for the body and `wp_kses()` for the opt-in form against an explicit allow list of the tags and attributes the plugin emits. The renderer no longer pre-escapes the values it hands to a view, and the coding-standard suppressions that used to sit on those `echo` statements are gone.
* The campaign wrapper and the form markup are printed through `wp_kses()` with that allow list, so a value added to a template can never leave an unescaped attribute behind. The delivered markup is unchanged: the DOM of all six templates, with and without an image, a headline or a form, was compared against 0.2.1 and diffed clean.

= 0.2.1 =

* WordPress.org review pass over every request handler and every output point: each handler that changes data or runs a sensitive action verifies a nonce and checks the `manage_options` capability before it reads the request, and every printed value is escaped at the point where it is printed. The pass found nothing to change in either area.
* Removed the redundant `load_plugin_textdomain()` call: WordPress.org loads the translations of a hosted plugin itself.
* Lead CSV export: a cell a spreadsheet would read as a formula (a leading `=`, `+`, `-`, `@`, tab or carriage return) is written with a leading text marker, so a submitted name can never run as a formula in Excel or Sheets.

= 0.2.0 =

* Three campaign formats (popup, floating bar, inline shortcode) and four triggers (time delay, scroll, click, exit intent).
* Email service connections for Mailchimp, Kit, MailerLite, Brevo and ActiveCampaign, plus a webhook with custom header or HMAC-SHA256 authentication, retries and a sync log.
* Leads stored in your own database with filters and CSV export.
* Local statistics per campaign and per day, with conversion rate.
* Page, login status, new or returning visitor and device targeting, plus a configurable returning-visitor cookie window.
* Accessible front end: dialog roles, focus handling, Escape to close, a polite live status message for form feedback and a labelled close button.

== Upgrade Notice ==

= 0.2.2 =
Escaping moved to the print site: each template view escapes its own values where they are echoed and the campaign markup goes through wp_kses() with an explicit allow list. The rendered markup is identical to 0.2.1.

= 0.2.1 =
Security hardening, no front-end change: every handler that changes data was audited for its nonce and capability check and every printed value for escaping, the redundant load_plugin_textdomain() call is gone, and the CSV export no longer runs a submitted value as a formula.

= 0.2.0 =
First public release: popups, floating bars and inline forms, four triggers, local leads and statistics with CSV export, and Mailchimp, Kit, MailerLite, Brevo, ActiveCampaign and webhook delivery. No remote resources and no limits.
