=== FormFork Connect ===
Contributors: rmahsan
Tags: forms, contact form, form builder, headless forms, elementor
Requires at least: 5.8
Tested up to: 7.1
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Build multi-step forms with conditional logic, sync with FormFork, and embed via Elementor widget, Gutenberg block, or shortcode.

== Description ==

**FormFork Connect** adds a top-level **FormFork** studio menu to WordPress Admin pre-configured for `https://formfork.io`:

1. **Top-Level FormFork Menu & Guided 3-Step Onboarding Wizard**:
   * **60-Second Setup Wizard**: Connect your `ff_live_...` API key in one click, launch a ready-made form from **4 Starter Templates** (*Contact & Inquiry*, *Lead Capture & Project Quote*, *Customer Experience Survey*, *Client Intake & Digital Sign-Off*), and auto-generate a draft WordPress page with the form pre-embedded.
   * **All Forms**: View all synced workspace forms with **1-Click Copy** buttons for both Native and Hosted Iframe shortcodes, **Edit Authority Lock** badges (`Editable Everywhere`, `Locked: WordPress Only`, `Locked: Dashboard Only`), a **Sync Now** cache refresh button, and **+ Create New Form**. (Form deletion is safely restricted to the FormFork Web Dashboard).
   * **Form Builder**: Full-featured visual Form Builder with **Multi-Step Wizard support**, 15 field types (including **Digital Signature Pad**, **Evaluation Matrix**, and **File Upload** with size & format limits), **Edit Authority Lock** selector, half/full column widths, dropdown/radio/checkbox options, conditional visibility logic (`Show when Field X equals Y`), 7 visual theme presets, and a side-by-side **Live Interactive Form Preview**.
   * **Settings**: Pre-configured with `https://formfork.io` as the default Platform URL, live **Test API Connection** diagnostics, and automatic **Scoped Key** detection (displaying project group and allowed domain restrictions).
2. **Gutenberg Block, Elementor Widget & Classic Editor Form Picker**:
   * **Elementor Page Builder**: Drag and drop the native **FormFork Form** widget (`eicon-form-horizontal`), choose any synced form from the Elementor sidebar dropdown, pick from 7 visual themes, and preview it live inside the Elementor canvas.
   * **Block Editor (Gutenberg)**: Search for **FormFork Form** (`formfork/form-embed`) to select any synced form from a dropdown and customize render mode or theme in the block sidebar.
   * **Classic Editor**: Click the **Add FormFork Form** button next to *Add Media* to pick a form and insert the shortcode automatically.
3. **Server-Side WordPress AJAX Proxy & Transient Caching**:
   * Routes schema fetches and form submissions (including binary `multipart/form-data` file attachments) through WordPress `admin-ajax.php` so your `ff_live_...` API key stays private on the server and cross-origin CORS issues are eliminated.
   * Caches synced workspace forms and form schemas for 60 seconds using WordPress Transients for fast admin and frontend performance.

== Installation ==

1. Download `formfork-connect.zip` from your FormFork Dashboard (**Websites & Embed Tokens** or **Developer Docs**) or install directly from the WordPress Plugin Directory.
2. In WordPress Admin, go to **Plugins -> Add New** and activate **FormFork Connect**.
3. Click **Launch 60-Second Setup Wizard** on the welcome banner (or open **FormFork -> All Forms**) to connect your API key, create a starter form in 1 click, and publish it on a WordPress page.

== Shortcode Usage ==

* **Standard Native Embed**: `[formfork id="your-form-id"]`
* **Override Theme / Button Label**: `[formfork id="your-form-id" theme="frosted-crystal" button_text="Get Started"]`
* **Hosted Iframe Embed**: `[formfork id="your-form-id" mode="iframe" height="620"]`

== External Services ==

This plugin connects your WordPress site to the **FormFork** form backend and visual form platform (`https://formfork.io`).

* **Service Provider**: FormFork (`https://formfork.io`)
* **When & What Data is Sent**:
  1. **Workspace Sync & Form Builder (WP Admin)**: No external requests are made until an administrator configures a FormFork API key (`ff_live_...`). Once configured, the plugin sends your API key (`X-API-Key`), your site's hostname (`X-Site-Domain`), and form schema configurations to `https://formfork.io/api/v1/forms` when viewing synced forms, testing the connection, or saving a form in the Form Builder.
  2. **Frontend Form Rendering & Visitor Submissions**: When a visitor views a page containing a `[formfork]` shortcode, Gutenberg block, or Elementor widget, WordPress fetches the form schema from `https://formfork.io/api/v1/forms/{id}` (cached for 60 seconds via WordPress Transients). When a visitor submits a form, the submitted field values, any uploaded files, and standard request headers (`Origin`, `Referer`, `User-Agent`, `X-Forwarded-For`) are transmitted to `https://formfork.io/f/{id}` (or `/api/v1/submit`). In `iframe` mode, the browser loads the hosted form from `https://formfork.io/share/{id}`.
* **Terms of Service**: [https://formfork.io/terms](https://formfork.io/terms)
* **Privacy Policy**: [https://formfork.io/privacy](https://formfork.io/privacy)

== Frequently Asked Questions ==

= Do I need a FormFork account to use this plugin? =
Yes. You can connect a free or paid FormFork workspace (`https://formfork.io`) using either a full Workspace Server API Key or an Agency Domain-Scoped API Key (`ff_live_...`).

= Can I restrict whether a form is edited in WordPress or on the FormFork Web Dashboard? =
Yes. Each form includes an **Edit Authority Lock** setting (`Editable Everywhere`, `Locked to WordPress Only`, or `Locked to FormFork Dashboard Only`). Form deletion is restricted to the FormFork Web Dashboard to prevent accidental removal from client sites.

== Changelog ==

= 1.0.0 =
* Initial public release of **FormFork Connect**.
* Top-level **FormFork** WordPress Admin studio menu (`All Forms`, `Form Builder`, `Settings`) with a **3-Step Guided Onboarding Wizard** (`Connect Workspace` -> `1-Click Starter Templates` -> `Auto-Create Draft WordPress Page`).
* Full-featured **Visual Form Builder** with multi-step wizards, 15 field types (including **Digital Signature Pad**, **Evaluation Matrix**, and **File Upload**), conditional visibility logic, 7 visual theme presets (`modern-minimal`, `frosted-crystal`, `midnight-neon`, `warm-editorial`, `emerald-forest`, `sunset-coral`, `corporate-saas`), and a side-by-side live interactive preview.
* **Edit Authority Lock** (`unlocked`, `wordpress_only`, `dashboard_only`) and safe dashboard-only form deletion.
* Native **Elementor Widget** (`FormFork Form`), **Gutenberg Block** (`formfork/form-embed`), **Classic Editor Form Picker**, and `[formfork]` shortcode.
* Server-side WordPress AJAX proxy supporting JSON and `multipart/form-data` binary file uploads, 60-second WordPress Transient caching, live **Test API Connection** diagnostics, and **Agency Domain-Scoped Key** support.
