=== FormGate AI - Antispam ===
Contributors: simonesaggese
Tags: spam, form, contact form, lead, ai
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 1.3.12
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Classifies WordPress contact form submissions with FormGate AI before delivery.

== Description ==

FormGate AI connects supported WordPress contact forms to the FormGate service. You can define a custom prompt to receive in your inbox only the type of messages you actually want. FormGate classifies each submitted message as valid, spam, not relevant, or suspicious, then applies the delivery rules configured in the FormGate dashboard.

The plugin supports:

* Contact Form 7
* WPForms Lite and Pro
* Gravity Forms
* Elementor Pro Forms
* Custom forms through the PHP function `wwfgai_send( $fields )`

FormGate handles delivery and quarantine for configured forms. If FormGate is unreachable, the native WordPress form email remains active.

An active FormGate account is required. You can create or manage an account at https://app.formgate.it/.

== External service disclosure ==

This plugin connects to the external FormGate AI service operated by Wonder Web.

Service endpoints used by the plugin:

* `https://api-formgate.wonder-web.it`
* `https://app.formgate.it`

The plugin does not contact FormGate immediately on activation. Network requests to FormGate happen only after a site administrator explicitly starts the automatic connection flow, manually tests/saves API credentials, disconnects an existing connection, or after the plugin has been configured and a supported form is submitted.

Data sent to FormGate may include:

* During automatic connection: the WordPress site domain and site name.
* During manual connection or connection test: the Site ID and API key entered by the administrator.
* During form processing: the mapped form fields `name`, `email`, `phone`, and `message`, when present in the submitted form. The `message` field is required for classification.

FormGate uses the submitted data to classify the lead, manage delivery/quarantine, show the submission in the FormGate dashboard, and provide service diagnostics. The FormGate backend sends only the message text to its AI classifier.

Terms of service: https://app.formgate.it/terms

Privacy policy: https://app.formgate.it/privacy-policy

== Privacy ==

FormGate AI is a SaaS integration. Site owners should disclose this processing in their own privacy policy before enabling the plugin on live forms.

The local WordPress plugin stores the FormGate API credential encrypted in the WordPress options table using Sodium when available, with AES-256-GCM as fallback. The raw API key is never printed back into the admin page after it is saved.

If the plugin is not configured, form submissions are not sent to FormGate.

== Installation ==

1. Upload the `formgate-ai` folder to `/wp-content/plugins/`, or install the ZIP from Plugins -> Add New -> Upload Plugin.
2. Activate the plugin.
3. Open Settings -> FormGate AI.
4. Connect the site automatically from the FormGate dashboard, or connect manually with your Site ID and API key.
5. Keep FormGate AI active and optionally enable the honeypot anti-bot check.

== Frequently Asked Questions ==

= Do I need a FormGate account? =

Yes. FormGate AI is an external service. Register or sign in at https://app.formgate.it/.

= Does the plugin send data to FormGate before setup? =

No. The plugin does not send form submissions to FormGate until an administrator connects the site with FormGate credentials and keeps the plugin enabled.

= What happens if FormGate is unreachable? =

The plugin is fail-open. Supported forms keep their native email delivery when the FormGate API cannot be reached.

= Can I exclude a single form? =

Yes, with the `wwfgai_should_process` filter:

`add_filter( 'wwfgai_should_process', function ( $process, $integration, $form ) {
    if ( 'cf7' === $integration && 123 === $form->id() ) {
        return false;
    }
    return $process;
}, 10, 3 );`

= Can I correct automatic field mapping? =

Yes, with the `wwfgai_payload` filter:

`add_filter( 'wwfgai_payload', function ( $payload, $fields ) {
    $payload['message'] = $fields['project-description'] ?? $payload['message'];
    return $payload;
}, 10, 2 );`

== License ==

FormGate AI is licensed under GPLv2 or later.

All PHP, JavaScript, CSS, inline SVG icons, and image assets included in this plugin package are licensed under GPLv2 or later, or are GPL-compatible assets owned by Wonder Web and distributed with this plugin under GPLv2 or later.

== Changelog ==

= 1.3.12 =
* Renamed the plugin to "FormGate AI - Antispam".
* Added a review call-to-action below the diagnostics section.
* Clarified the description with custom prompt filtering.

= 1.3.11 =
* Added English (en_US) translation and bundled language files.
* Restored plugin text domain loading so the bundled translations are applied.

= 1.3.10 =
* Moved AJAX nonce checks into each handler before request data is read.

= 1.3.9 =
* Added translator comments for placeholder strings.
* Hardened admin output escaping and settings nonce handling.

= 1.3.8 =
* Fixed disconnect so legacy connection options cannot be migrated back after the site is unlinked.

= 1.3.7 =
* Renamed internal prefixes for constants, classes, options, transients, AJAX actions, nonces, script handles, and public hooks to `wwfgai`.
* Added migration from legacy option keys.
* Removed explicit translation loading for WordPress.org language pack compatibility.

= 1.3.6 =
* Updated the WordPress.org submission metadata.

= 1.3.5 =
* Removed the Analysis only mode from the admin UI. Configured forms now always use full filtering with fail-open delivery.

= 1.3.4 =
* Removed the private update endpoint and private updater code. Updates are intended to be handled through the WordPress.org plugin repository.
* Added explicit SaaS, external service, data transfer, Terms, Privacy Policy, and asset license disclosures.
* Added a standard text domain path and made the admin UI strings translatable.
* Raised public requirements to WordPress 6.0 and PHP 8.1.

= 1.3.3 =
* Elementor recognizes text fields named "Nome Cognome", "Nome e Cognome", "Nome completo", and equivalent English variants.
* Improved shared field label normalization.

= 1.3.2 =
* Updated the dashboard link to `https://app.formgate.it/`.

= 1.3.1 =
* Improved update detection in private distributions.

= 1.3.0 =
* Redesigned the WordPress admin interface.
* Added inline SVG icons and responsive layout improvements.

= 1.2.6 =
* Improved Elementor, WPForms, Gravity Forms, and Contact Form 7 handling for full filtering and fail-open delivery.

= 1.2.0 =
* Added secure automatic connection from the FormGate dashboard.
* Added manual connection with credential verification.
* Encrypted the local API key in WordPress options.
* Moved admin JavaScript and honeypot JavaScript into local asset files.

= 1.1.0 =
* Added honeypot and time-trap bot checks.
* Added connection test support.

= 1.0.0 =
* Initial release.
