=== Frontierline Forms – Confirmation & Multi-Step for Contact Form 7 ===
Contributors: frontierline2015, freemius
Tags: contact form 7, confirmation, multi step form, database, csv export
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 3.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add a confirmation page, multi-step forms, and database storage with CSV export to Contact Form 7. Save every submission — no limits.

== Description ==

Frontierline Forms extends Contact Form 7 with the features it is missing out of the box: a confirmation screen (preview submission before sending), multi-step and multi-page forms, conditional logic, and submission history saved to your WordPress database with one-click CSV export. Use it to save Contact Form 7 submissions to the database, add a confirmation page, build multi-step forms, export entries to CSV, or migrate from MW WP Form — all from the WordPress admin, with no usage limits.

This plugin is an add-on for Contact Form 7 and requires Contact Form 7 to be installed and active. It is not affiliated with, endorsed by, or sponsored by the Contact Form 7 project or its author.

= Features =

* **Multi-step forms** — Split a single Contact Form 7 form into multiple steps using a `[step]` tag. No limit on the number of steps.
* **Confirmation screen** — Add an "input -> confirm -> submit" flow that Contact Form 7 does not provide out of the box.
* **Completion screen** — Replace the form with a custom completion message on success, or redirect to a thank-you page (useful for GA4 conversion tracking).
* **Conditional logic** — Show or hide fields based on what the visitor enters, using simple HTML data attributes. No limit on the number of rules.
* **Progress bar** — Three styles (numbered steps, bar, dots).
* **Submission history** — Every submission is saved to your own WordPress database and can be browsed, searched, and viewed in the admin screen.
* **Status tracking** — Mark each submission as Not handled, In progress or Done, filter the list by status and change many at once, so no inquiry is left unanswered.
* **CSV export** — Export your saved submissions to a CSV file (UTF-8 with BOM, Excel-friendly), including the status and the current filter.
* **Japanese postal code lookup** — Enter a postal code and the prefecture, city and town are filled in automatically. The postal code data (Japan Post) is bundled with the plugin, so nothing is sent to an outside service. Uses the same class names as YubinBango, so existing forms keep working.
* **Honeypot** — Built-in spam protection, enabled automatically.
* **MW WP Form migration** — Convert your MW WP Form forms to Contact Form 7 with one click. Fields, validation rules, mail settings, and the confirmation flow are migrated automatically, with a report of anything that needs manual review.
* **Brand colors** — Set primary/secondary colors, border radius, and font family to match your site's design.

= Requirements =

* Contact Form 7 5.7 or later
* WordPress 6.0 or later
* PHP 7.4 or later

= Premium version =

A separate premium version with additional features is available from the developer's website. The premium code is **not** included in this free plugin. See https://frontierline.co.jp/en/plugins/frontierline-forms/ for details.

== External services ==

This plugin connects to one external service.

**Freemius** — This plugin uses the Freemius SDK to manage the optional upgrade to the premium version, license activation, and update delivery. When you opt in to usage tracking (you are asked, and it is optional), or when you activate a premium license, the plugin sends information such as your site URL, WordPress and PHP versions, and the active theme/plugins list to Freemius. No form submission content is ever sent. Freemius is provided by Freemius, Inc.
Terms of Service: https://freemius.com/terms/
Privacy Policy: https://freemius.com/privacy/

The free plugin does not send your form submissions to any external service. Any services used by the separate premium version are documented within that version and are only active when you configure them.

== Installation ==

1. Make sure Contact Form 7 is installed and active.
2. In your WordPress admin, go to Plugins -> Add New, search for "Frontierline Forms", then install and activate it.
3. Open the "Frontierline Forms" menu in the admin sidebar to configure it.

= Creating a multi-step form =

In the Contact Form 7 form editor, insert a `[step]` tag at each step boundary:

`[step "Basic info"]
[text* your-name]
[email* your-email]

[step "Your message"]
[textarea your-message]

[step "Confirm" confirmation]
Please review your input and submit.

[submit "Send"]`

= Using conditional logic =

Wrap the fields you want to toggle with HTML data attributes:

`<div data-cf7mp-show-if="contact-type" data-cf7mp-show-value="estimate">
  [text estimate-amount placeholder "Budget"]
</div>`

= Postal code data =

The Japanese postal code data in assets/zipdata is based on Japan Post's postal code data (https://www.post.japanpost.jp/zipcode/download.html), converted via yubinbango-data (https://github.com/yubinbango/yubinbango-data). Japan Post allows free redistribution of this data.

== Frequently Asked Questions ==

= How do I use the postal code lookup? =

Add classes to your Contact Form 7 tags: `[text your-zip class:fl-zip]`, `[select your-pref class:fl-pref ...]` (or a text field), `[text your-city class:fl-city]` and, if you want the town in its own field, `[text your-town class:fl-town]`. To put the whole address into one field use `class:fl-address`. The YubinBango class names (`p-postal-code`, `p-region`, `p-locality`, `p-street-address`) work too. Full-width digits and hyphens are accepted, and a field the visitor has already typed in is never overwritten.

= Do I need Contact Form 7? =

Yes. Contact Form 7 5.7 or later must be installed and active. This plugin is an add-on for it.

= Is the confirmation screen on by default? =

No. Enable it under Settings -> General. It is off by default.

= Where are submissions stored? =

In your own WordPress database, in tables created by this plugin. Nothing is sent to an external service.

= Premium: where is the encryption key stored, and what should I do when moving servers? =

By default the premium version creates the key with the first encrypted submission and saves it in the WordPress options table as `cf7mp_encryption_key`. Since 2.2.0 you can keep the key outside the database instead: add `define( 'FRONTIERLINE_FORMS_ENCRYPTION_KEY', 'a-long-random-string' );` to wp-config.php, or set an environment variable with the same name. Settings > Security shows where the key is, re-encrypts existing entries with the new key, and deletes the database copy once nothing depends on it (also available as `wp frontierline-forms encryption status|reencrypt`). When moving servers, move the key together with the database (or keep the same wp-config.php line). Encrypted entries cannot be decrypted without the key, not even by us. Only the submitted fields are encrypted; the IP address, user agent and referrer are stored as plain text.

= Can I migrate from MW WP Form? =

Yes. Open Frontierline Forms -> MW WP Form Migration and convert each form with one click. Fields, validation rules, mail settings, and the input -> confirm -> submit flow are converted to Contact Form 7 automatically, and a report lists anything that needs manual review. The premium version can also import your saved MW WP Form inquiry data and convert all forms at once.

= Does the plugin keep what a visitor typed in their browser? =

By default, no. Nothing is written to cookies or to localStorage. Temporary saving of entries is off by default. If you turn it on under Settings -> General, entries are held in sessionStorage only: they are removed as soon as the browser tab is closed, discarded after the time limit you set, and cleared once the form is submitted. Moving back from the confirmation screen keeps the entries either way, because the values simply stay in the form.

= Does it work with file uploads? =

Yes. Use Contact Form 7's [file] tag as usual. The confirmation screen lists the selected file names, and the file is sent with the submission in the normal Contact Form 7 way. For security reasons browsers never let a script re-attach a file, so an uploaded file is not part of the temporary save.

= Do I need to exclude the form page from page caching? =

The form itself is rendered by Contact Form 7, which handles caching plugins on its own. If your cache plugin serves the page to logged-out visitors from a static copy, exclude the pages that contain the form so that each visitor receives a fresh security token.

= Is my data removed when I delete the plugin? =

Not by default. Deactivating or deleting the plugin keeps your saved submissions and settings, so nothing is lost by accident. If you are removing the plugin for good, turn on Settings > General > "Data on uninstall" first: deleting the plugin then removes all submissions and settings. Back up your database before you do this.

== Screenshots ==

1. The Input -> Confirm -> Complete flow in action, with English and Japanese labels included.
2. Set up in minutes: add a [step] tag in the Contact Form 7 editor and enable the confirmation screen.
3. Every submission is saved to your own database, with keyword search and CSV export.
4. Match your site's design: brand colors, corner radius, font, and 3 progress bar styles.
5. Dashboard overview: submissions this month, today, and conversion rate at a glance.
6. Upgrade to Pro for Slack and Chatwork notifications plus automatic email replies.

== Changelog ==

= 3.0.0 =
* New: status tracking for submissions (Not handled / In progress / Done). Filter the list by status, change many submissions at once, or change one on its detail screen. The CSV export follows the current filter and includes the status.
* New: Japanese postal code lookup. Add `class:fl-zip` to the postal code field and `fl-pref`, `fl-city`, `fl-town` or `fl-address` to the address fields. YubinBango class names are supported. The data (Japan Post, about 143,000 codes) is bundled, so no address data leaves your site.
* New: a "Templates" tab in the Contact Form 7 editor lists industry form templates (available in Pro).
* Pro – New: AI triage. New submissions are sorted into Quote, Support, Sales pitch, Spam or Other with a priority, shown in the list, the detail screen and Slack/Chatwork notifications. You use your own Claude or OpenAI API key. Name, email, phone, address and file fields are never sent, and email addresses, phone numbers, postal codes and URLs in the message are masked. A monthly limit (300 by default) caps your API usage, and failed calls are not counted. If the AI service is down, the submission is saved and notified as usual.
* Pro – New: form improvement report. Views, starts, submissions, conversion rate and start rate with the change from the previous period, a step-by-step funnel, the fields where visitors leave, and traffic sources, for 7, 30 or 90 days. The weekly email report shows the same figures.
* Pro – New: furigana is filled in automatically from the name field (`fl-name` with `fl-kana` or `fl-katakana`), and email, phone, URL and postal code fields are converted to half-width characters automatically.
* Pro – New: 8 industry form templates (web design quote, renovation, professional services consultation, salon booking, recruitment, B2B document request, seminar registration, real estate viewing) with matching mail bodies, inserted with one click.
* Improved: the suggested privacy policy text now covers the Pro form statistics and AI triage when they are in use.

= 2.3.0 =
* Security: the visitor's IP address can no longer be faked with X-Forwarded-For or CF-Connecting-IP headers. Behind a reverse proxy the plugin reads X-Real-IP or the address added by your own proxy (the right-most public address in X-Forwarded-For), and trusts CF-Connecting-IP only when the request really comes through Cloudflare (now detected automatically, including sites where Cloudflare connects directly). Behind another CDN or load balancer, list its addresses with the cf7mp_trusted_proxies filter. This protects the stored IP and, in Pro, the IP block list and the rate limit.
* Security: fields made optional by conditional logic are now checked on the server too. A required field that is not inside a hidden conditional section (for example a consent checkbox) can no longer be skipped by editing the request.
* New: WordPress privacy tools support. Tools > Export Personal Data and Erase Personal Data now find form submissions by email address (encrypted entries included), and a suggested privacy policy text is added under Settings > Privacy.
* New: Settings > General > "Who can view submissions" lets editors view, search and export submissions without access to the settings.
* New: Settings > General > "Data on uninstall" (off by default) deletes all submissions and settings when the plugin is deleted.
* New: the submissions list is split into pages of 50, so large lists open quickly.
* Fixed: on multi-step forms the progress line now runs through the centre of the step circles on every theme. It used to run below them, and steps without a title sat lower than the others, so the circles looked out of line. The "Dots" and "Bar" styles in Settings > Design now actually show dots and a bar.
* Fixed: [step "Confirm" confirmation] (title before the option) is now read the same as [step confirmation "Confirm"]. Before, Contact Form 7 dropped both the title and the confirmation role.
* Pro – New: retention period (Settings > General). Submissions older than the number of days you set are deleted automatically once a day. It is off (0 = keep forever) until you set it, including on sites that saved the old, unused retention setting.
* Pro – New: auto-reply sender name, sender address and Reply-To, with a warning when the sender address is on another domain (a common reason replies land in spam).
* Pro – Security: values typed by visitors can no longer trigger Slack mentions or links, Chatwork tags, or Google Sheets formulas in notifications.
* Pro – Security: the auto-reply is sent at most 3 times an hour to the same address, so the form cannot be used to send mail to someone else. Stored entries and admin notifications are not affected.
* Pro – Security: reCAPTCHA tokens issued for another site or another action are rejected (add extra domains with the cf7mp_recaptcha_allowed_hostnames filter). The Slack and Google Sheets webhooks use WordPress's safe HTTP API. Saved secrets (Chatwork token, reCAPTCHA secret key) are no longer printed in the settings page source.

= 2.2.2 =
* Security: updated the bundled Freemius SDK to 2.13.5. It adds a permission check before opt-in and escapes values shown in admin notices.
* Tested with PHP 8.5.

= 2.2.1 =
* New: Settings > Design > "Base field style" gives text fields, selects, checkboxes, radio buttons and the submit button a clean default look (full-width fields, 16px text so phones do not zoom in, a visible focus ring). It is on for new installs and off for existing sites, so updating does not change how your forms look. Your theme's form styles always take priority.
* New: add class:cf7mp-field--s or class:cf7mp-field--m to a form tag to make that field shorter (for example a postal code or a name split into two fields).
* Fixed: the corner radius and font family set in Settings > Design are now applied to the buttons, the confirmation screen and the fields.

= 2.2.0 =
* Fixed: the spam trap (honeypot) now works on every form layout. On multi-step forms it was silently ignored by Contact Form 7. Pro: the same fix applies to blocked IPs, blocked words, the rate limit and reCAPTCHA.
* Fixed: when Contact Form 7 rejects a submission (for example an invalid email address or a missing required checkbox), the form now jumps to the step that has the error and shows the message. Required checkbox groups, the acceptance checkbox and email/URL formats are also checked before moving to the next step.
* Fixed: pressing Enter in a text field no longer skips the remaining steps or the confirmation screen.
* Fixed: with nested conditional fields, inputs inside a hidden outer group are no longer sent.
* Fixed: submissions are saved (and Pro notifications are sent) even when Contact Form 7 fails to send the email.
* Fixed: internal values (conditional-logic control values, CAPTCHA tokens) are no longer saved or shown in the submission details, search and CSV, including entries saved earlier.
* Improved: the CSV export now includes every submitted field as its own column and follows the current search. Values that start with =, +, - or @ are prefixed so spreadsheet apps do not run them as formulas.
* Improved: the sender IP address is taken from the X-Forwarded-For header only when the site is behind a local reverse proxy (filter: cf7mp_trust_proxy_headers). Overlong UTM values no longer prevent a submission from being saved.
* Improved: the dashboard counts use the site's time zone, compare with the same point last month, and no longer show a fixed 0.0% conversion rate.
* Fixed (Pro): reCAPTCHA v3 now sends its token (it was never attached, so submissions failed or were not checked).
* Fixed (Pro): importing saved inquiries from MW WP Form now imports the submitted values. Inquiries imported by 2.1.x without their values are repaired when you run the import again (no duplicates).
* Fixed (Pro): an invalid CIDR line in the blocked IP list no longer blocks everyone or stops submissions; IPv6 addresses and ranges are supported.
* Improved (Pro): Slack, Chatwork and Google Sheets requests time out sooner so a slow service does not make the form look like it failed.
* Improved (Pro): scheduled auto-replies store only the submission ID, so no personal data is kept in the WordPress schedule. Unknown [tags] typed into the auto-reply text are kept; only empty form fields are removed.
* Improved (Pro): form analytics work with page caching, are limited per visitor, count a drop-off once per visit, and records older than about 13 months are removed daily.
* Improved (Pro): notifications and the weekly report are in English on non-Japanese sites.
* Removed: unused payment integration code from the package.
* New (Pro): the encryption key can be set outside the database with `FRONTIERLINE_FORMS_ENCRYPTION_KEY` in wp-config.php or as an environment variable. Without it, the key stays in the database as before.
* New (Pro): Settings > Security shows where the key is stored, how many entries use each key, re-encrypts existing entries with the current key (100 at a time, each entry verified, resumable), and deletes the database copy of the key once no entry needs it.
* New (Pro): WP-CLI commands `wp frontierline-forms encryption status` and `wp frontierline-forms encryption reencrypt`.
* New (Pro): `FRONTIERLINE_FORMS_ENCRYPTION_KEY_PREVIOUS` keeps an old key readable while you rotate keys.
* Improved (Pro): new entries are encrypted with AES-256-GCM (authenticated encryption with a full 256-bit key). Entries saved by earlier versions are still read and can be converted with the re-encryption tool.
* Improved (Pro): Site Health reports when the key is stored in the database or is too short.
* Fixed (Pro): sites that switched from the free version to Pro without reactivating the plugin now get the analytics, IP block and rate-limit tables automatically (previously analytics events failed with a database error).
* Updated: Freemius SDK 2.13.4.
* Note (Pro): entries saved or re-encrypted by 2.2.0 cannot be read by 2.1.x or earlier, so downgrading is not supported.

= 2.1.4 =
* Fixed: the keyword search on the Submissions screen now filters entries. It searches the date, form name and submitted values, including encrypted entries in Pro.
* Fixed: settings turned on with a checkbox (confirmation screen, temporary saving of entries) can be turned off again.
* Removed: the "Data retention (days)" setting. It never deleted anything; entries are kept until you delete them.
* Removed: the Priority and Category columns and the priority filter on the Submissions screen, which showed the same value for every entry. The CSV export is unchanged.
* Changed (Pro): the auto-reply to the submitter is now off by default. Turn it on under Settings > Email, where the subject and body can now be edited ([field-name] and [_site_title] tags are supported). Previously every form with an email field sent a fixed reply, which could duplicate a Contact Form 7 Mail (2) reply.
* Fixed (Pro): auto-reply sending hours were offset by the site's time zone. Overnight hours (for example 22:00 to 06:00) now work, and leaving the hours empty sends replies immediately.
* Fixed (Pro): the personal data encryption setting can be turned off again.
* Improved (Pro): the weekly report can be turned off, and its recipient field is labelled clearly.

= 2.1.3 =
* Fixed (Pro): with encrypted storage enabled, Slack, Chatwork and Google Sheets notifications now include the submitted fields.
* Fixed (Pro): reading encrypted entries no longer creates a new encryption key when none is found, so existing encrypted data cannot be orphaned by an accidental key reset.
* Fixed (Pro): internal values such as CAPTCHA tokens (Cloudflare Turnstile, reCAPTCHA, hCaptcha) and the spam-trap field are no longer included in Slack, Chatwork and Google Sheets notifications.

= 2.1.2 =
* Fixed: on multi-step forms the Next button could look unresponsive. When a required field was empty the step refused to advance without saying why; empty fields are now highlighted, a message is shown, and focus moves to the first one.
* Fixed: required fields hidden by conditional logic no longer block the step, so forms that use conditional rules can always be completed.
* Changed: entries are no longer stored in localStorage. Temporary saving of entries is now off by default; when enabled it uses sessionStorage with a time limit, so nothing a visitor typed survives closing the browser tab. Drafts left behind by earlier versions are deleted on update.
* Added: a setting for temporary saving of entries, with a configurable time limit.
* Improved: the confirmation screen now lists uploaded file names instead of the browser's fake path, and ships with readable default styling.
* Improved: Next / Back and the confirmation and completion labels are translatable, and fall back to Japanese on Japanese sites until translations are published.
* Improved: tested with WordPress 7.1.

= 2.1.1 =
* Updated the plugin listing (name, description) and product links. No functional changes.

= 2.1.0 =
* New: MW WP Form migration wizard. Convert MW WP Form forms to Contact Form 7 with one click — fields, validation rules, mail settings, and the confirmation flow are migrated automatically, with a Japanese/English report of anything to review manually.
* Improved: encrypted submission storage is now decoded with a fixed-length header, making decryption robust for all stored records.
* Improved: corrupted legacy records are skipped with a notice during data import (premium) so they can be re-imported after repair.

= 2.0.5 =
* Added a "Free vs Pro" comparison and upgrade overview to the plugin's own dashboard screen.
* Internal hardening (safer module loading) and small admin style additions.

= 2.0.4 =
* Fixed: the multi-step progress bar, Back/Next buttons, and confirmation/completion text now follow the site language instead of always showing Japanese.

= 2.0.3 =
* The admin interface is now in English by default, with a bundled Japanese translation. Additional languages can be contributed on translate.wordpress.org.

= 2.0.2 =
* Added an optional review request shown only on the plugin's own admin screens. It appears after the plugin has been used and is permanently dismissible.

= 2.0.1 =
* Added a "Complete" step to the progress bar so multi-step and confirmation forms show the standard Input -> Confirm -> Complete (3-step) flow.
* The progress bar now stays visible on the completion screen with the final step highlighted.

= 2.0.0 =
* Renamed the plugin and made all built-in features fully functional with no usage limits.
* Multi-step forms and conditional logic are now unlimited.
* Submission history and CSV export available with no limits.
* Removed the arbitrary custom-CSS input; brand styling is now done with discrete color/typography settings.
* Moved all admin scripts to properly enqueued assets and added nonce verification to the CSV export.
* Documented external services.

== Upgrade Notice ==

= 3.0.0 =
Adds submission status tracking and Japanese postal code lookup to the free version. Pro adds AI triage, the form improvement report, furigana and industry templates.

= 2.3.0 =
Security hardening (IP address spoofing, conditional required fields) and WordPress privacy tools support. Recommended for all users.

= 2.2.2 =
Security update of the bundled Freemius SDK (2.13.5). Recommended for all users.

= 2.2.0 =
Fixes the spam trap on multi-step forms, error display on steps, the Enter key and CSV export. Pro: the encryption key can now be kept in wp-config.php. Existing entries stay readable. Take a database backup before re-encrypting; after updating, do not downgrade to 2.1.x.

= 2.1.4 =
Fixes the admin keyword search and settings that could not be turned off. Pro: the auto-reply to submitters is now off by default; if you use it, turn it on under Settings > Email after updating.

= 2.1.2 =
Important fixes for multi-step forms: the Next button no longer stalls without explanation, and entries are no longer kept in localStorage. Update recommended.

= 2.1.1 =
Listing and link updates only. Safe to update.

= 2.1.0 =
New: one-click MW WP Form migration wizard, plus more robust encrypted-data handling.

= 2.0.5 =
Minor update. Adds a Free vs Pro overview to the plugin dashboard.

= 2.0.4 =
Front-end step labels and messages are now translatable (previously always Japanese regardless of site language).

= 2.0.3 =
Admin UI is now English by default with a bundled Japanese translation.

= 2.0.2 =
Minor update. Adds a dismissible review request on the plugin's own screens.

= 2.0.1 =
Adds the Input -> Confirm -> Complete 3-step progress display. Recommended update.

= 2.0.0 =
All built-in features are now fully functional with no limits. Recommended update.
