=== Clixx CRM - Formulários para Captação de Leads ===
Contributors: clixxcrm
Tags: crm, forms, leads, embed, lead-capture
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.5.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your Clixx CRM account to WordPress and embed your campaign forms in any page or post.

== Description ==

The Clixx CRM plugin connects your WordPress site to your Clixx CRM account so you can insert lead capture forms from your campaigns into any page or post using:

* Shortcode: `[clixxcrm_formulario hash="..."]`
* Gutenberg block: "Clixx CRM Form"
* Standalone HTML embed snippet (with built-in style customizer)

The connection is established by entering the email of your Clixx CRM account and the API token generated inside the CRM. The token is validated server-side against the company associated with it; if the email does not belong to that company, or the company does not have an active subscription, the connection is refused.

Submissions are sent directly from the visitor's browser to your Clixx CRM. The plugin does not store any visitor data on your WordPress site.

== Installation ==

1. Upload the `clixxcrm` folder to `/wp-content/plugins/`, or install the plugin through the WordPress plugins screen.
2. Activate the plugin from the Plugins screen.
3. Go to "Clixx CRM" in the admin menu and enter your email and API token.
4. After connecting, open "Clixx CRM > Forms" to copy the shortcode, iframe code or standalone HTML embed of each form.

== External services ==

This plugin connects to the Clixx CRM SaaS (https://app.clixx.com.br), which is the service the plugin exists to integrate with. The connection happens in three situations:

1. **Connecting your account (admin only).** When you submit your email and API token on the "Clixx CRM > Connection" screen, the plugin sends a POST request from your server to `https://app.clixx.com.br/api/auth/verify` containing your email and the API token. This is required to validate the token, identify your company in the CRM and confirm the subscription is active.

2. **Listing your forms (admin only).** When you open the "Clixx CRM > Forms" screen, the plugin sends a GET request from your server to `https://app.clixx.com.br/api/anuncios` using your API token. The response (list of your campaigns / forms) is cached for 5 minutes in a WordPress transient. No visitor data is involved.

3. **Form submissions from visitors (front-end).** The shortcode `[clixxcrm_formulario]` renders an iframe pointing to `https://app.clixx.com.br/inscricao/{hash}`, and the standalone "Embed HTML" snippet contains JavaScript that, on submit, sends the visitor-typed form fields (name, e-mail, phone, plus any custom fields you configured in the CRM, and any UTM parameters present in the URL) via `fetch()` directly from the visitor's browser to `https://app.clixx.com.br/api/webhook/inscricao/{hash}`. The plugin does NOT store this data on your WordPress site.

The service is provided by Clixx CRM. See its terms of use at https://app.clixx.com.br/terms-of-use.html and its privacy policy at https://app.clixx.com.br/privacy-policy.html.

== Frequently Asked Questions ==

= Where do I get the API token? =

Inside Clixx CRM, go to Settings > API and generate a token.

= Does the plugin store visitor data on my WordPress database? =

No. Form submissions are sent directly from the visitor's browser to your Clixx CRM via the public webhook endpoint.

= Can I customize the look of the embedded form? =

Yes. The "Embed HTML" tab in each form has a built-in customizer with controls for button text, colors, spacing and typography, plus a live preview. The generated HTML is fully self-contained and can be pasted into any site (WordPress or not).

= Is the plugin compatible with the block editor? =

Yes. The "Clixx CRM Form" block lets you pick a form from a dropdown and adjust the iframe height in the inspector panel.

== Changelog ==

= 1.5.1 =
* Plugin review compliance: (1) the admin menu icon CSS is no longer injected via `admin_head` — it is now registered via `wp_register_style` / `wp_enqueue_style` and `wp_add_inline_style`, attached to a dedicated `clixxcrm-menu-icon` handle that loads on every admin page; (2) added `== External services ==` section to the readme documenting the connection to `app.clixx.com.br` (`/api/auth/verify`, `/api/anuncios`, `/api/webhook/inscricao/{hash}`), what data is sent and when, plus links to the Clixx CRM Terms of Use and Privacy Policy; (3) the inline `<style>` / `<script>` tags inside the standalone Embed HTML snippet (which is meant to be COPY-PASTED into any external page, not enqueued by WordPress) are now assembled via concatenation and explicitly commented so they are not mistaken for WordPress front-end output.

= 1.5.0 =
* Bug fix: o customizador JS (admin/js/admin.js) ignorava os campos personalizados e regenerava o embed só com nome/email/celular, sobrescrevendo o HTML gerado pelo PHP. Agora o JS lê os campos via `data-campos-extras` no container e injeta os campos extras no preview ao vivo e no código copiado. Cores/sliders preservam os campos.

= 1.4.9 =
* Nome do plugin renomeado para "Clixx CRM - Formulários para Captação de Leads" (mais descritivo no diretório do WordPress.org). Menu interno e marca seguem como "Clixx CRM".

= 1.4.8 =
* Embed HTML do anúncio agora inclui os campos personalizados configurados no CRM (Cidade, Data de Nascimento, etc.). Suporta tipos: text, email, phone, cpf, cnpj, cep, number, date, textarea, select e checkbox. Requer CRM atualizado para retornar `campos_personalizados` em `/api/anuncios` (já incluso). Limpe o cache do plugin (transient `clixxcrm_anuncios`) para puxar os campos novos.

= 1.4.7 =
* Text domain renamed from `clixxcrm` to `clixx-crm` to match the plugin slug on WordPress.org. All `__()`, `_e()`, `esc_html__()`, `esc_attr_e()`, etc. calls and the `Text Domain:` header + block.json `textdomain` were updated. Internal slugs (menu URL, option keys, postMessage protocol) kept as `clixxcrm`.

= 1.4.6 =
* Removed `Plugin URI` from the plugin header (it pointed to the same URL as `Author URI`, which the WordPress.org submission validator rejects). Once the plugin is published, the canonical plugin page is `wordpress.org/plugins/clixxcrm/`.

= 1.4.5 =
* Cleaned up the diagnostic instrumentation from 1.4.3/1.4.4: yellow debug bar removed from the live preview, console marker on script load removed, try/catch wrapper around `renderPreview` removed. The cache-busting fix from 1.4.4 stays.

= 1.4.4 =
* Fixed a bug in the build script where the `CLIXXCRM_VERSION` PHP constant was never being updated past `1.0.0` because of a too-strict regex (it required `')` with no whitespace between, but the source file had `' )`). Result: every release since 1.0.1 was shipped with the constant stuck at 1.0.0, which caused `wp_enqueue_script(..., CLIXXCRM_VERSION)` to always emit `?ver=1.0.0`, so browsers reused the cached `admin.js` from the very first install. **All previous "preview not updating" reports were caused by browsers serving the old admin.js**.

= 1.4.3 =
* Added a visible build marker in the live preview (yellow bar with render counter and timestamp) and a console.log on script load. This is purely diagnostic for users who report the preview not updating — if the bar is missing, the browser/WordPress is serving a cached old `admin.js`.
* Wrapped `renderPreview` in try/catch with `console.error` to surface any silent failures.

= 1.4.2 =
* Live preview rebuilt with a third strategy: each preview container gets a unique ID, and every `.clx2-form` selector in the embed CSS is rewritten to `#unique-id .clx2-form` before being injected. This gives the embed rules a specificity of `(1,2,1)+`, beating any WordPress admin rule. No iframe, no Shadow DOM, no CSP edge cases — just plain DOM with rewritten selectors.

= 1.4.1 =
* Live preview rebuilt on top of Shadow DOM. The previous iframe srcdoc approach failed silently in some hosting / CSP setups; Shadow DOM is native browser CSS isolation with no iframe and no timing dependency, so the preview now updates instantly when colors, sliders or font are changed.

= 1.4.0 =
* Plugin Check / WordPress.org compliance pass: readme rewritten in English, "Tested up to" bumped to 6.9, output escaping audited (`esc_attr` on every echo), `$_POST` inputs run through sanitization helpers, view variables prefixed with `clixxcrm_`, heredoc strings replaced with concatenation, `load_plugin_textdomain()` removed (auto-loaded by core since 4.6).
* Preview now uses `iframe.srcdoc` instead of `document.write()` for reliability across security plugins / CSP setups.

= 1.3.2 =
* Preview rendered inside an `<iframe>` to isolate the embedded form from WordPress admin global CSS rules. Without isolation, admin rules on `input`, `form`, `button` were overriding the embed's own styles, so only text changes were visible.
* Sidebar menu icon now loads as URL (not data URI) so the original Clixx logo colors are preserved instead of WordPress applying its default `opacity: 0.6` overlay.

= 1.3.1 =
* Live preview event listeners moved to document-level delegation. They are now reliable even when the customizer markup is inside collapsed panels or inactive tabs.
* Automatic re-render when expanding the codes panel or switching to the Embed HTML tab.

= 1.3.0 =
* Embed HTML tab gained a full visual customizer (button text, colors, spacing, typography) with live preview and auto-generated code, identical to the one available inside the CRM.
* Tab labels rendered with `mb_strtoupper` so accented characters such as `Ã/Á` are uppercased correctly.

= 1.2.0 =
* Full visual rewrite: header with logo, pill-style tabs (Connection / Forms / About) and a clean content card with rows.
* Fixed CSS parsing bug from 1.1.0 caused by an inline SVG data URI in a CSS rule.
* New About tab with version, license and feature summary.

= 1.1.0 =
* Modern indigo palette across the connect and forms screens.
* Sidebar menu icon uses the official Clixx logo.
* Forms screen lists each campaign with Shortcode, Iframe and Embed HTML tabs and a copy button.

= 1.0.1 =
* The Clixx CRM URL is fixed to `https://app.clixx.com.br`. Override at development time via `define('CLIXXCRM_API_URL', '...')` in `wp-config.php`.

= 1.0.0 =
* Initial release: connection by email + API token, `[clixxcrm_formulario]` shortcode and Gutenberg block.
