=== MKHub Connect ===
Contributors: albertotsn
Tags: crm, marketing automation, contact form 7, woocommerce, lead generation
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send WordPress form submissions, visitors and WooCommerce orders to the Marketing Hub CRM automatically, without changing your forms.

== Description ==

Marketing Hub (https://mkhub.tsnmedia.ro) is a CRM and marketing automation platform for small and medium businesses in Romania. This plugin connects your WordPress site to your Marketing Hub account, without changing your forms or your theme:

* **Existing forms, connected automatically**: Contact Form 7, Elementor Pro Forms, WPForms, Gravity Forms, Fluent Forms, Ninja Forms and Forminator. Every submission creates or updates a contact with its source page and UTM campaign. The form's own email is still sent exactly as before.
* **Smart field detection**: name, email and phone fields are recognised by type and label (English and Romanian). Phone-only forms ("we'll call you back") create contacts too.
* **Marketing consent (GDPR)**: newsletter / SMS opt-in checkboxes are sent as consent (or refusal). A "I have read the privacy policy" checkbox is not treated as marketing consent.
* **Visitor tracking**: the pages a visitor viewed appear on the contact's timeline, including visits before they filled in a form.
* **WooCommerce**: orders (products, value, UTM attribution), new customers and the product catalog, for post-purchase automations and segments by purchased category. Optional newsletter / SMS opt-in checkboxes at checkout.
* **Native forms and landing pages** from Marketing Hub, with the `[mh_form id="..."]` and `[mh_landing id="..."]` shortcodes.

All requests to Marketing Hub are non-blocking and isolated: if the service is unavailable, your site and your forms keep working normally.

The plugin interface is in Romanian.

== External services ==

This plugin connects to **Marketing Hub** (https://mkhub.tsnmedia.ro, operated by TSN MEDIA MK S.R.L.), the CRM service your site sends data to. It only works with a Marketing Hub account and does nothing until you enter your API key / tracking key in Settings → Marketing Hub.

What is sent, and when:

* **When a visitor submits a form** (Contact Form 7, Elementor, WPForms, Gravity Forms, Fluent Forms, Ninja Forms, Forminator or a Marketing Hub form): the submitted fields (for example name, email, phone, message, consent checkboxes), the page URL, the UTM campaign parameters and the anonymous visitor ID. Sent to `/api/connectors/form` or `/api/forms/{form}/submit`.
* **When a WooCommerce order is completed**: order number, status, total, products, the customer's name, email and phone, marketing consent and UTM attribution. Sent to `/api/connectors/order`.
* **Daily, if WooCommerce sync is enabled**: the public product catalog (names, prices, categories, URLs, images). Sent to `/api/connectors/catalog`.
* **On every front-end page, if a tracking key is set**: the Marketing Hub tracking script is loaded from `/api/track/script`; it records page views with an anonymous visitor ID stored in a first-party cookie (`mh_vid`). Only enable tracking if your cookie/consent setup allows it.
* **In the admin area**: the list of your forms and landing pages, and the connection test (`/api/v1/forms`, `/api/v1/landing-pages`).

Terms of service: https://mkhub.tsnmedia.ro/legal/termeni
Privacy policy: https://mkhub.tsnmedia.ro/legal/confidentialitate
Data processing agreement: https://mkhub.tsnmedia.ro/legal/prelucrarea-datelor

== Installation ==

1. In Marketing Hub: Integrations → Add connection (WordPress or WooCommerce), then copy the API key.
2. In WordPress: Plugins → Add New → search for "MKHub Connect" (or upload the zip) → Install → Activate.
3. Settings → Marketing Hub: enter the platform URL, the tracking key and the API key, then click "Test connection".

Full guide (Romanian): https://mkhub.tsnmedia.ro/ghid/wordpress

== Frequently Asked Questions ==

= Do I need to change my forms? =
No. Email, phone, name and consent fields are detected automatically. For Contact Form 7 you can map unusual field names manually, and any form can be excluded in Settings.

= Can I customise or block what is sent? =
Yes, with the `mhc_form_submission( $payload, $provider, $raw )` filter. Return `false` to skip a submission.

= What happens if Marketing Hub is down? =
Nothing visible: requests are non-blocking, so forms, checkout and pages work as usual.

= Does it work without a Marketing Hub account? =
No. The plugin sends data to your Marketing Hub account; there is a 14-day free trial at https://mkhub.tsnmedia.ro.

== Changelog ==

= 1.5.0 =
* Renamed to MKHub Connect (slug `mkhub-connect`) for the WordPress.org directory. Settings are kept: if you used the previous "Marketing Hub Connect" plugin, install this one, then deactivate and delete the old one.

= 1.4.2 =
* Ready for the WordPress.org directory: English readme, license header, tracking script loaded via wp_enqueue_script, stricter input sanitization and output escaping, clean uninstall.

= 1.4.1 =
* The package again includes the CSS and JS files of the native forms (missing in 1.4.0).

= 1.4.0 =
* Elementor Pro, WPForms, Gravity Forms, Fluent Forms, Ninja Forms and Forminator forms connected automatically (field and consent detection).
* Contact Form 7: forms without a name field are sent too (e.g. email-only newsletter forms).
* "Excluded forms" setting for the other form plugins; `mhc_form_submission` filter.

= 1.3.0 =
* WooCommerce catalog, manual CF7 field mapping, marketing consent.

= 1.0.0 =
* Initial release: tracking, native forms, landing page embeds.
