=== Formii ===
Contributors: spiraledge
Tags: contact form, form builder, inquiry management, japan, japanese
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A contact form plugin for Japanese business sites. Drag-and-drop form builder, Japan-specific fields, and built-in inquiry management.

== Description ==

**Formii** is a contact form plugin designed for Japanese business websites. It provides an intuitive drag-and-drop form builder and built-in inquiry management in one plugin — no external service required.

= Key Features =

**Form Builder**

* Drag-and-drop form creation
* Create as many forms as you need — each form gets its own shortcode
* Form status management (draft / published)
* Real-time save indicator in the editor
* Live preview tab (see your form before publishing)

**Japan-Specific Fields**

* Postal code field (auto-inserts hyphens as you type)
* Phone number field (auto-inserts hyphens as you type)
* Address field — postal code, a 47-prefecture select, and city / town / building inputs (all offline; the prefecture list is bundled)
* Furigana, full name (last / first), birthdate, gender, and confirmation-email fields
* Standard field types: text, email, textarea, select, radio, checkbox, and privacy consent

> **Note:** Postal-code **address auto-fill** (fills prefecture / city / town from the postal code) is part of **Formii Pro** (Small Business plan and above). The free plugin makes no external network requests.

**Validation**

* Required field check
* Min/max character length
* Regular expression validation
* Custom error messages per field

**Inquiry Management**

Formii stores every submission in your own WordPress database and gives you a built-in inbox:

* Inquiry list with keyword search and pagination
* Inquiry detail view — see all submitted data at a glance
* Read / unread tracking — new inquiries stay highlighted until you open them

**Email Notifications**

* Admin notification email on new inquiry
* Auto-reply email to the submitter
* Customizable subject and body per form
* Optional "Powered by Formii" credit in auto-reply emails — off by default; you can turn it on in Settings

**Thank You Page**

* Show a custom message after submission
* Or redirect to a URL of your choice

**Security**

* Nonce verification on all endpoints
* Permission checks (manage_options / edit_posts)
* `$wpdb->prepare()` for all database queries
* Output escaping (`esc_html`, `esc_attr`, `esc_url`)
* ABSPATH guard (prevents direct file access)

**Accessibility**

* Follows WCAG 2.1 AA guidelines — keyboard navigation, ARIA attributes, focus management, and sufficient color contrast

= Shortcode =

Embed a form in a post or page using:

`[formii_form id="1"]`

The form ID is shown in the Forms list in the admin panel.

If your form redirects to a separate thank-you page, place the following shortcode on that page:

`[formii_notice]`

It shows a notice only when it is needed — for example, when the auto-reply email was not sent because the sending limit was reached. Otherwise it outputs nothing.

= Formii Pro =

Formii Pro is a separate add-on that will be available from https://formii.net/ (coming soon). It adds team workflow and extra field types on top of the free plugin: inquiry status tracking for your team (in progress / completed / spam, plus custom statuses), starred inquiries, advanced field types (date/time, number, rating, confirmation, section, hidden, file upload), internal memos, bulk operations, CSV export (UTF-8 & Shift_JIS), postal-code address auto-fill, spam protection (reCAPTCHA v3, honeypot, rate limiting), submission periods and capacity limits, and conditional logic. Formii Pro is optional — the free plugin above works fully on its own, with no limit on the number of forms.

= External Services =

This free plugin does **not** connect to any external services. All data stays in your WordPress site, and no outbound network requests are made.

(Formii Pro, a separate add-on not distributed here, uses external services for some of its features — the zipcloud API for postal-code address auto-fill and Google reCAPTCHA v3 for spam protection. Those services are loaded only by Formii Pro, and their disclosure is provided with Formii Pro.)

= Credits & Bundled Libraries =

This plugin bundles the following third-party resource locally (no external CDN is used):

* **Font Awesome Free 7.1.0** (https://fontawesome.com) — icon library bundled under `admin/fontawesome/`. Licensed under CC BY 4.0 (icons), SIL OFL 1.1 (fonts), and MIT (code), all of which are GPL-compatible. The full license text is included at `admin/fontawesome/LICENSE.txt`.

= Source Code & Build =

The admin screens are built with React. The compiled files in `build/` are generated from the human-readable source code in `src/`, which is included in this plugin.

To rebuild them, install Node.js 22 or later and run the following commands in the plugin directory:

1. `npm install`
2. `npm run build`

The build uses `@wordpress/scripts` (webpack); the entry points are defined in `webpack.config.js`, and the CSS is processed with PostCSS (`postcss.config.js`, `tailwind.config.js`).

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/formii`.
2. Activate the plugin from the WordPress **Plugins** menu.
3. Go to **Formii → Forms** and create your first form.
4. Copy the generated shortcode (e.g. `[formii_form id="1"]`) and paste it into any post or page.

== Frequently Asked Questions ==

= Can I create multiple forms? =

Yes. The free plugin has no limit on the number of forms, and each form has its own shortcode.

= Where is inquiry data stored? =

All inquiry data is stored in your own WordPress database (`wp_formii_inquiries` table). The free plugin makes no external network requests at all — no submission data or any other data ever leaves your site.

= Does the address field work offline? =

Yes. In the free plugin the prefecture list is bundled and the address field works entirely offline (no external requests). Postal-code **address auto-fill** — which looks up the address from the postal code — is a Formii Pro feature (Small Business plan and above) and uses an external API.

= Does it work with PHP 8.x? =

Yes. Formii has been tested with PHP 8.0, 8.1, and 8.2.

= Is the plugin accessible? =

Yes. The plugin follows WCAG 2.1 AA guidelines — keyboard navigation, ARIA attributes, focus management, and sufficient color contrast are all implemented.

== Screenshots ==

1. Form Builder — drag and drop fields to build your form
2. Form List — manage your forms and copy their shortcodes
3. Inquiry List — browse and search inquiries by keyword
4. Inquiry Detail — view submitted data
5. Settings — configure forms and notifications

== Changelog ==

= 1.2.0 =
* Security: auto-reply emails are now limited to 10 per recipient per day and 200 per site per hour, so the form cannot be abused to send mass email to third parties. Limits can be changed with filters (`formii_auto_reply_recipient_limit`, `formii_auto_reply_site_limit`, and related window filters)
* When an auto-reply is skipped because of the limit, the inquiry is still received and the completion screen shows a notice. Use the new `[formii_notice]` shortcode to show the same notice on a separate thank-you page
* Security: database error messages are no longer included in the response to the submitter when an inquiry fails to save
* Fixed: checkbox default values now pre-check the matching options (multiple values can be given, separated by commas)
* Fixed: the confirmation screen no longer shows "C:\fakepath\" for file attachments
* Fixed: the default label of consent and add-on fields is now the field name
* The Settings screen now shows the save result in the save bar
* Extension settings panels now receive the form ID

= 1.1.0 =
* Deleting a single inquiry now also deletes its attachments (including the uploaded files) and memos
* Unified inquiry deletion for all delete paths, with new hooks for extensions (`formii_after_delete_inquiries`)
* Personal data erasure: the WordPress "Erase Personal Data" tool now deletes a person's Formii inquiries (including attachments and memos)
* Security: sanitize submission data before passing it to the spam-protection filter, and restrict the HTML allowed from the address-field filter
* The free plugin no longer loads any reCAPTCHA script itself (Formii Pro handles it)
* The source code for the compiled admin scripts (`src/`) and the build configuration are now included

= 1.0.0 =
* Initial release
* Drag-and-drop form builder with live preview
* Unlimited forms, each with its own shortcode
* Optional "Powered by Formii" credit in auto-reply emails (off by default)
* Japan-specific fields: postal code (auto-hyphenation), phone hyphenation, prefecture select, address, furigana, full name, birthdate, gender, confirmation email
* Inquiry management: automatic saving, list, keyword search, detail view
* Admin notification and auto-reply emails
* Thank you page: message or URL redirect
* Accessibility: WCAG 2.1 AA compliant
* Full GPL v2 license

== Upgrade Notice ==

= 1.2.0 =
Limits auto-reply emails to prevent abuse and fixes checkbox default values.

= 1.1.0 =
Deleting an inquiry now also removes its attachments and memos.

= 1.0.0 =
Initial release. No upgrade needed.
