=== LeadMachine Connector ===
Contributors: leadmachinefyi
Tags: leads, crm, contact form, lead generation, gravity forms
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 2.5.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WordPress site to LeadMachine to capture and manage leads seamlessly. Supports native forms and Gravity Forms.

== Description ==

LeadMachine Connector allows you to easily capture leads from your WordPress website and automatically send them to your LeadMachine CRM account.

= Features =

* **Easy setup** - just enter your Company ID and API Key
* **Native lead capture forms** - customizable shortcode-based contact forms
* **Newsletter signup forms** - lightweight form with just name, email, and opt-in
* **Analytics & tracking** - automatic UTM, ad click IDs, and browser data collection
* **Gravity Forms integration** - connect any Gravity Form to LeadMachine
* **Spam protection** - built-in honeypot and time-based bot detection
* **Responsive design** - works on all devices
* **AJAX form submission** - smooth user experience without page reloads
* **Automatic lead creation** - leads instantly appear in your LeadMachine dashboard
* **Tag support** - automatically tag leads from different forms
* **Customizable styling** - colors, button text, success messages
* **Blog post sync** - sync posts to LeadMachine for automated email newsletters
* **Conversion tracking** - fires events for Google Analytics, Facebook Pixel, LinkedIn, TikTok, and more

= Native Form Usage =

1. Install and activate the plugin
2. Go to **LeadMachine** settings in your WordPress admin
3. Enter your LeadMachine Company ID and API Key
4. Customize your form settings
5. Add the shortcode `[leadmachine_form]` to any page or post

= Gravity Forms Integration =

Already using Gravity Forms? Connect your existing forms to LeadMachine:

1. Go to **LeadMachine** settings > **Gravity Forms** tab
2. Enable Gravity Forms integration
3. Select a form and map fields to LeadMachine:
   - First Name
   - Last Name
   - Email
   - Phone
   - Company
   - Message
4. Optionally add tags for each form
5. Save settings - submissions now flow to LeadMachine automatically!

= Shortcode Options =

Customize individual forms using shortcode attributes:

`[leadmachine_form title="Contact Us" description="We'd love to hear from you!" tags="Contact Form,Website"]`

**Available attributes:**

* `title` - Form title (overrides global setting)
* `description` - Form description text
* `button_text` - Submit button text
* `button_color` - Button background color (hex)
* `tags` - Comma-separated tags to apply to leads
* `background` - Form background color (use "transparent" for none)
* `title_color` - Title text color
* `description_color` - Description text color
* `label_color` - Form label text color

**Examples:**

Contact form: `[leadmachine_form tags="Contact Form,High Priority"]`

= Newsletter Form =

For simple newsletter signups, use the dedicated newsletter shortcode:

`[leadmachine_newsletter]`

This form only collects:
* Full Name
* Email Address
* Opt-in checkbox

**Newsletter shortcode attributes:**

* `title` - Form title (default: "Subscribe to Our Newsletter")
* `description` - Form description text
* `button_text` - Submit button text (default: "Subscribe")
* `tags` - Comma-separated tags (default: "newsletter")
* `optin_text` - Opt-in checkbox text (supports HTML for links)
* `name_label` - Label for name field
* `email_label` - Label for email field
* All color attributes from the contact form

**Examples:**

Newsletter signup: `[leadmachine_newsletter title="Stay Updated" tags="newsletter,blog"]`

Simple signup: `[leadmachine_newsletter button_text="Sign Up" button_color="#22c55e"]`

= Analytics & Tracking =

Both forms automatically collect browser and tracking data:

* **UTM parameters** - utm_source, utm_medium, utm_campaign, utm_term, utm_content
* **Ad platform click IDs** - Google Ads (gclid), Facebook (fbclid), LinkedIn, TikTok, Microsoft/Bing
* **Browser data** - device type, screen size, language, timezone
* **Referrer** - where the visitor came from
* **Tracking cookies** - Google Analytics, Facebook Pixel, HubSpot, LinkedIn

Form submissions also fire conversion events for:
* Google Analytics 4 (gtag.js)
* Google Analytics Universal (legacy)
* Facebook Pixel
* LinkedIn Insight Tag
* TikTok Pixel
* Microsoft/Bing UET
* Google Tag Manager dataLayer

== Installation ==

1. Download the plugin zip file
2. Go to WordPress Admin > Plugins > Add New
3. Click "Upload Plugin" and choose the zip file
4. Click "Install Now" and then "Activate"
5. Go to LeadMachine settings and enter your Company ID and API Key

== Frequently Asked Questions ==

= Where do I find my Company ID and API Key? =

Log in to your LeadMachine dashboard at https://app.leadmachine.fyi and go to **Settings > Company > WordPress Plugin** to find your credentials.

= Does this work with Gravity Forms? =

Yes! Version 2.0+ includes full Gravity Forms integration. You can map any Gravity Form fields to LeadMachine and automatically send submissions as leads.

= Can I use multiple forms on the same site? =

Absolutely. You can use the native `[leadmachine_form]` shortcode on multiple pages with different settings, and/or connect multiple Gravity Forms - each with their own field mappings and tags.

= How does spam protection work? =

The plugin uses two methods: a honeypot field (invisible to humans but bots fill it) and time-based validation (forms submitted too quickly are rejected). No CAPTCHA required.

= Will this work with my theme? =

Yes! The plugin is designed to work with any WordPress theme. Form styling is minimal and adapts to your theme's styles.

= Is the form submission secure? =

Yes. All submissions use WordPress nonces for CSRF protection and are transmitted securely to your LeadMachine account via HTTPS.

== Screenshots ==

1. Main settings page - configure your LeadMachine connection
2. Form settings page - customize colors, text, and styling
3. Gravity Forms integration - map form fields to LeadMachine
4. Example form on the frontend of your site
5. Lead data synced to your LeadMachine dashboard

== Changelog ==

= 2.5.1 =
* FIX: Default form background is now transparent (was incorrectly white)
* FIX: Opt-in checkbox links now inherit label color instead of hardcoded blue
* FIX: Newsletter form labels now left-justified with their fields
* FIX: Opt-in text now uses muted styling (smaller, reduced opacity)

= 2.5.0 =
* NEW: Full-width form layout by default
* Newsletter form now displays inline on desktop (Name, Email, Button side by side)
* Stacks responsively on mobile devices
* NEW: Input styling settings in Contact Form tab
* Input background color, border color, and text color now customizable
* Newsletter form styling now shared from Contact Form settings
* Added styling info link in Newsletter settings tab
* Improved overall form responsiveness

= 2.4.0 =
* NEW: Newsletter signup form shortcode [leadmachine_newsletter]
* NEW: Lightweight form with just Full Name, Email, and Opt-in fields
* NEW: Analytics & tracking data collection for all forms
* Captures UTM parameters, ad click IDs (Google, Facebook, LinkedIn, TikTok, etc.)
* Collects browser data (device type, screen size, language, timezone)
* Records tracking cookies (GA, Facebook Pixel, HubSpot, LinkedIn)
* NEW: Conversion tracking events for major ad platforms
* Fires events for GA4, Facebook Pixel, LinkedIn, TikTok, Microsoft/Bing
* Pushes events to Google Tag Manager dataLayer
* Form view and submit events for analytics attribution
* All tracking data included in lead notes for attribution analysis

= 2.3.0 =
* NEW: Blog Post Sync for email campaigns
* Automatically sync posts to LeadMachine when published
* Bulk sync existing posts with one click
* Category sync for targeted newsletter campaigns
* Posts are summarized by AI for engaging email content
* Select which categories to include in nurture campaigns

= 2.2.0 =
* NEW: Advanced spam detection for Gravity Forms submissions
* Blocks known spam bot name patterns (e.g., "taics" suffix bots)
* Detects gibberish names, repeating patterns, suspicious email TLDs
* Filters disposable email domains and spam keywords in messages
* Respects Gravity Forms spam status for entries marked as spam
* Debug logging for blocked spam (when WP_DEBUG is enabled)

= 2.1.2 =
* Added wp_unslash() before all input sanitization per WordPress coding standards
* Prefixed all global variables with leadmachine_ for namespace compliance
* Wrapped debug logging in WP_DEBUG checks
* Improved $_SERVER variable sanitization
* Reduced readme tags to maximum of 5

= 2.1.1 =
* Fixed output escaping for improved security
* Improved JSON field sanitization with content validation
* Security hardening for WordPress.org compliance

= 2.1.0 =
* Added spam protection with honeypot field
* Added time-based bot detection (rejects instant submissions)
* Spam attempts are logged with IP address for monitoring
* Forms expire after 1 hour for additional security

= 2.0.1 =
* Bug fixes and stability improvements
* Improved error handling for API responses

= 2.0.0 =
* NEW: Gravity Forms integration
* Map any Gravity Form to LeadMachine fields
* Per-form tag configuration for Gravity Forms
* Default tags option for all Gravity Forms submissions
* AJAX field loading for Gravity Forms mapping
* Improved admin UI with tabbed settings

= 1.1.5 =
* Enhanced admin instructions with step-by-step Quick Start Guide
* Added clear instructions on where to find Company ID in LeadMachine
* Added dedicated "Using Tags" section with examples
* Improved sidebar documentation for better user onboarding

= 1.1.4 =
* Moved color customization to WordPress admin settings page
* Added color pickers for: Form Background, Title Color, Description Color, Label Color
* Colors can now be set globally in settings and optionally overridden per-form via shortcode
* Improved user experience - configure once, use everywhere

= 1.1.3 =
* Form now hides after successful submission, showing only success message
* Added `background` attribute - supports hex colors or "transparent"
* Added `title_color` attribute for custom title text color
* Added `description_color` attribute for custom description text color
* Added `label_color` attribute for custom form label color
* Improved styling flexibility to match any website design

= 1.1.2 =
* Added Terms of Service and Privacy Policy consent checkbox (required)
* Records opt-in timestamp in database for GDPR/compliance
* Captures IP address and consent confirmation in lead notes

= 1.1.1 =
* Fixed JavaScript form validation bug for split name fields
* Resolved "First name, last name, and email are required" error

= 1.1.0 =
* Added tag support - automatically tag leads from different forms
* Split name field into first_name and last_name for better data accuracy
* Source field now shows the actual page URL where form was submitted
* Improved note formatting - cleaner, more professional structure
* Fixed all database column mismatches
* Mobile responsive split fields

= 1.0.1 =
* Improved error handling and logging
* Added detailed error messages for debugging
* Better API error reporting

= 1.0.0 =
* Initial release
* Lead capture form with customizable fields
* Admin settings page
* Integration with LeadMachine API
* Responsive design
* AJAX form submission

== Upgrade Notice ==

= 2.5.0 =
Improved form layouts: full-width by default, inline newsletter form on desktop, and customizable input styling.

= 2.3.0 =
New Blog Post Sync feature! Automatically sync WordPress posts to LeadMachine for AI-powered email newsletters.

= 2.1.2 =
WordPress coding standards compliance: proper input unslashing, variable prefixing, and debug logging.

= 2.1.1 =
Security improvements for output escaping and data sanitization. Recommended for all users.

= 2.1.0 =
Adds spam protection to reduce unwanted form submissions. Recommended for all users.

= 2.0.0 =
Major update with Gravity Forms integration! Connect your existing Gravity Forms to LeadMachine.
