=== Spellmatic ===
Contributors: cmolyn, spellmatic, freemius
Tags: spell check, grammar, proofreading, page builder, elementor
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.3.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Scan and fix spelling and grammar errors across your entire WordPress site in one click — including Elementor, Avada, Divi, and WPBakery content.

== Description ==

**Spellmatic scans your entire WordPress site for spelling and grammar errors, then lets you fix them in one click — including content built with Elementor, Avada, Divi, WPBakery, and more.**

Most grammar tools only check what you're currently editing. Spellmatic scans every post, page, product, and comment on your site — even content stored inside page builder data structures.

= Features =
* Full-site scan across all posts and pages — no error cap
* Privacy-first local grammar engine powered by Harper WASM — no data ever leaves your server
* All errors shown per scan with fix / dismiss actions
* Error dashboard with error type badges and in-context display
* Custom dictionary — add words to ignore globally
* Scheduled email digests with scan summaries
* BYOK AI integration with OpenAI — contextual AI proofreading using your own API key

= Premium Features =
Premium plans add powerful extras for professionals and agencies. Available at [spellmatic.com](https://spellmatic.com).

* Bulk auto-fix — fix all errors across your site in one click
* Smart fix — AI-powered contextual corrections
* Additional AI providers — Claude, Gemini, Grok, and OpenRouter
* Priority support

**Pro ($79/year)**
* All premium features
* Dedicated account management

**Agency ($149/year)**
* Everything in Pro
* Up to 10 WordPress sites / multisite network support

= Page Builder Compatibility =
Spellmatic scans content inside:
* **Elementor** — reads JSON widget data (`_elementor_data`)
* **Avada / Fusion Builder** — parses Fusion shortcodes and page options
* **Divi Builder** — strips and scans Divi shortcode content
* **WPBakery Page Builder** — scans all WPBakery shortcode text
* **Beaver Builder** — reads serialized layout data
* **Bricks Builder** — parses JSON element data
* **Oxygen Builder** — reads builder meta
* **Brizy** — reads JSON layout data
* **Gutenberg / Block Editor** — native support
* **Kadence Blocks** — native block support

= Privacy First =
The free tier uses Harper WASM — a blazing-fast, privacy-respecting grammar engine that runs entirely in your browser (client-side WebAssembly). Zero external API calls. Zero data sent anywhere. Your content stays yours.

The optional BYOK AI layer uses your own API key. Your key is stored encrypted on your server and all API calls go directly from your server to your chosen AI provider — Spellmatic never sees your content or your key.

== External Services ==

This plugin connects to the following third-party services. Full details are also available on the Open Source & Services page inside the plugin (Spellmatic → Open Source).

= Grammar Engine — Harper (Bundled) =
The Harper grammar engine (Apache 2.0 licensed) is bundled with the plugin and runs entirely in your browser. No external connections are made during scanning.

You may optionally update the grammar engine to get improved dictionaries and grammar rules. No external connections are made by the plugin for grammar engine updates — all updates are performed manually by the site administrator:

1. Download the latest `harper.js` from the Harper npm package at [https://www.npmjs.com/package/harper.js](https://www.npmjs.com/package/harper.js) — the file is located in the `dist/` folder of the package.
2. Upload the file to `wp-content/uploads/spellmatic/harper.js` on your server (create the `spellmatic` folder if it does not exist).
3. The plugin will automatically detect and use the uploaded file on the next page load.
4. To revert, simply delete the file from `wp-content/uploads/spellmatic/` — the plugin will fall back to the bundled version.

* Harper project: [https://github.com/Automattic/harper](https://github.com/Automattic/harper)
* Harper license: [Apache License 2.0](https://github.com/Automattic/harper/blob/master/LICENSE)
* Harper website: [https://writewithharper.com](https://writewithharper.com)

= AI-Powered Grammar Analysis (Optional, BYOK) =
When you enable the BYOK AI feature and initiate an AI scan, post and page text is sent to your chosen AI provider for contextual grammar analysis. This only occurs when you explicitly click "Scan" with AI enabled. API keys are encrypted with AES-256-CBC and stored on your server.

**OpenAI**
* Service: [https://openai.com](https://openai.com)
* Terms of Use: [https://openai.com/policies/terms-of-use](https://openai.com/policies/terms-of-use)
* Privacy Policy: [https://openai.com/policies/privacy-policy](https://openai.com/policies/privacy-policy)

**Anthropic (Claude)**
* Service: [https://www.anthropic.com](https://www.anthropic.com)
* Terms of Use: [https://www.anthropic.com/legal/consumer-terms](https://www.anthropic.com/legal/consumer-terms)
* Privacy Policy: [https://www.anthropic.com/legal/privacy](https://www.anthropic.com/legal/privacy)

**Google (Gemini)**
* Service: [https://ai.google.dev](https://ai.google.dev)
* Terms of Use: [https://ai.google.dev/gemini-api/terms](https://ai.google.dev/gemini-api/terms)
* Privacy Policy: [https://policies.google.com/privacy](https://policies.google.com/privacy)

**xAI (Grok)**
* Service: [https://x.ai](https://x.ai)
* Terms of Use: [https://x.ai/legal/terms-of-service](https://x.ai/legal/terms-of-service)
* Privacy Policy: [https://x.ai/legal/privacy-policy](https://x.ai/legal/privacy-policy)

**OpenRouter**
* Service: [https://openrouter.ai](https://openrouter.ai)
* Terms of Use: [https://openrouter.ai/terms](https://openrouter.ai/terms)
* Privacy Policy: [https://openrouter.ai/privacy](https://openrouter.ai/privacy)

= Licensing & Analytics — Freemius =
Spellmatic uses the Freemius SDK for license validation, plan management, and optional opt-in usage analytics. You are asked for consent during plugin activation.

* Service: [https://freemius.com](https://freemius.com)
* Terms of Use: [https://freemius.com/terms/](https://freemius.com/terms/)
* Privacy Policy: [https://freemius.com/privacy/](https://freemius.com/privacy/)

= Perfect For =
* **Agencies** managing multiple client WordPress sites
* **Bloggers** with large back-catalogues who want to clean up old posts
* **WooCommerce stores** where typos hurt credibility and conversions
* **Content publishers** who need a quick pre-launch proofread

== Installation ==

1. Upload the `spellmatic` folder to `/wp-content/plugins/`
2. Activate the plugin through the **Plugins** menu in WordPress
3. Navigate to **Spellmatic** in the admin sidebar
4. Click **Scan Entire Site** to run your first scan
5. Review errors and click **Fix** or **Dismiss** for each one

== Frequently Asked Questions ==

= Does this work with Elementor? =
Yes. Spellmatic reads Elementor's JSON data structure and extracts all text from your widgets and sections.

= Does it work with Avada / Fusion Builder? =
Yes. Avada's Fusion Builder shortcodes are parsed and all text content is scanned.

= Will it send my content to an external server? =
No — not by default. The Harper grammar engine runs as WebAssembly in your browser. No data leaves your site. The optional BYOK AI feature makes direct calls from your server to your chosen AI provider using your own API key. See the External Services section for full details.

= What is BYOK (Bring Your Own Key)? =
Instead of routing your content through our servers and charging you for AI usage, Spellmatic lets you paste in your own API key from OpenAI, Anthropic (Claude), Google Gemini, xAI (Grok), or OpenRouter. You pay only for what you use — AI inference costs for grammar checking are fractions of a cent per post.

= How does the free version differ from paid? =
The free version includes full-site scanning with no error cap, individual fix/dismiss for every error, and AI-powered proofreading with OpenAI. Premium plans add bulk auto-fix, smart fix, additional AI providers (Claude, Gemini, Grok, OpenRouter), priority support, and multisite licensing.

= Is bulk fix available in the free version? =
Bulk auto-fix is a premium feature. The free version lets you fix errors one at a time with no limit.

= What are scan credits? =
The Site Scan ($19) and 3-Pack ($39) one-time plans include 1 and 3 scan credits respectively. Each full scan uses one credit. Credits don't expire.

== Screenshots ==

1. Dashboard — one-click full-site scan with AI ON/OFF toggle
2. Results view — errors listed with context, type badge, and fix/dismiss actions
3. AI scan — AI provider results appended to base scan
4. Settings — scan targets, BYOK AI key management, and digest scheduling
5. Upgrade page — plan comparison with pricing

== Changelog ==

= 1.3.8 =
* Version bump — clean build for WordPress.org submission

= 1.3.7 =
* Removed remaining "premium only" and "pricing" references from PHP docblocks and code comments
* Renamed "Pricing basis" column header to "Rate basis" in AI cost reference table
* Cleaned section comment on plans page renderer

= 1.3.6 =
* Deep clean: moved all plan badge, banner, and fix-limit CSS to separate stylesheet
* Moved plan display data into a method — empty array returned by default
* Settings page only shows OpenAI provider by default (additional providers loaded separately)
* Removed marketing language, plan descriptions, and upgrade references from code
* Cleaned comments referencing plan details

= 1.3.5 =
* Wrapped Pricing subnav link in premium block — was visible in free version pointing to non-existent page

= 1.3.4 =
* Removed bulk fix and smart fix REST endpoints from free version — routes no longer registered
* Moved premium JS to __premium_only file so Freemius excludes it from free version zip
* Removed all pro badges, locked states, and upgrade prompts from free version UI
* Cleaned up dead code (free fix limits, unused premium helpers)
* Renamed isPro variable in editor sidebar to publishGateActive
* Wrapped plan badges, upgrade URLs, and checkout methods in premium blocks

= 1.3.3 =
* Fixed missing translators comment for i18n string flagged by Plugin Check
* Added phpcs ignore comments for intentional set_time_limit and WP_DEBUG error_log usage
* Replaced interpolated $table variable in DB query with inline $wpdb->prefix for Plugin Check compliance

= 1.3.2 =
* Fixed Freemius PHP preprocessor pattern matching — removed function_exists() wrapper from premium-only checks so code blocks are properly stripped from the free version

= 1.3.1 =
* Added missing has_premium_version flag to Freemius SDK init

= 1.3.0 =
* WordPress.org compliance: Restructured premium features so the free version contains no locked or disabled functionality
* Removed error cap and fix limit — all users see all results and can fix without limits
* Premium features (bulk fix, smart fix, additional AI providers) cleanly separated via Freemius SDK
* Extracted inline CSS and JS from the onboarding wizard into separate enqueued files
* Removed WordPress.org directory assets (banner, icons) from the plugin distribution
* Updated readme to accurately reflect free vs. premium capabilities

= 1.2.0 =
* Removed Harper grammar engine self-updating — updates are now manual only (download from npm, upload to wp-content/uploads/spellmatic/)
* Restructured Freemius SDK init to follow all dashboard integration recommendations
* Version bump for Freemius redeployment

= 1.0.7 =
* Upgraded Freemius SDK to 2.13.1
* Moved uninstall logic to Freemius after_uninstall hook for .org compliance
* Fixed output escaping on Results page counters
* Added translators comments for all i18n strings with placeholders
* Escaped AI provider exception messages in BYOK module
* Added phpcs:ignore for legitimate php://output stream in CSV export
* Updated "Tested up to" to WordPress 6.9
* Dismissed items now visible and restorable on the Results page
* Dismissed results excluded from re-scan duplicate detection

= 1.0.2 =
* Security: Server-side plan gate on AI scan endpoint
* Added uninstall.php with optional full data cleanup
* Added "Delete data on uninstall" toggle in Settings
* Expanded translatable strings for JS UI (27 localized strings)
* Generated .pot translation template (168 strings)
* Created /languages/ directory for i18n support
* Fixed ungated console.log on dashboard init
* Version and authorship consistency across all files

= 0.8.3 =
* Fix: Position-aware fix replacement — no longer replaces all occurrences of a word (critical bug fix)
* Fix: Builder fixer support for Divi, WPBakery, and Avada (previously scan-only)
* Custom dictionary now wired to Harper engine
* AI result deduplication against Harper findings
* Fix undo / revert with revision history
* CSV export on Results page
* Real-time fix preview with inline diff
* Site health score + WP dashboard widget
* Pre-publish spell check in Gutenberg editor sidebar
* Multiple ranked suggestions per error
* Per-post scan from editor sidebar

= 0.8.2 =
* Fix: Apply Fix and Dismiss buttons non-functional on the dedicated Results page
* Pro dashboard UI — scope selector, grouped collapsible result cards, post-level pagination, filter bar, Fix All per post
* Harper.js CDN fallback via Cloudflare R2 (strips WASM from zip, keeps it under 5 MB)
* Dynamic public post-type support in scope selector
* Version bump to 0.8.2

= 0.8.0 =
* Phase 6: Freemius full integration — class-license.php central plan/credit management
* One-time scan credit plans (Site Scan, 3-Pack) with credit consumption after scan
* Free-tier cap fixed: credit-plan users now see all results
* Upgrade / pricing page (5-tier grid with feature lists and Freemius checkout links)
* Dashboard banner now shows remaining credits for credit-plan users
* Removed legacy inline is_pro() stubs — all plan checks centralised in Spellmatic_License

= 0.7.1 =
* Phase 5: BYOK AI pass — 5 providers (OpenAI, Claude, Gemini, Grok, OpenRouter)
* Encrypted API key storage, Test Connection per provider
* Native PHP cURL transport — fixes Expect: 100-continue timeout with OpenAI/Cloudflare
* AI ON/OFF toggle on dashboard scan panel
* Configurable AI max items (1–50) with per-provider cost estimates
* All 5 providers verified working end-to-end

= 0.6.0 =
* Phase 4: Custom dictionary (add/remove words to ignore globally)
* Scheduled scan digests — weekly or monthly email with error summary
* Filter by error type in results view
* Settings page with scan target controls

= 0.5.0 =
* Phase 3: Page builder content extraction
* Elementor JSON widget data extraction
* Avada / Fusion Builder shortcode parsing
* Divi shortcode stripping
* WPBakery shortcode text extraction
* Builder-aware edit links (Edit with Elementor / Divi / Avada Live)

= 0.4.0 =
* Phase 2b: Pro error cap (10 errors free; unlimited Pro)
* Bulk fix endpoint and UI

= 0.3.0 =
* Phase 2: Browser-side Harper WASM scan flow
* Scan start / submit REST endpoints
* Per-error fix and dismiss actions
* Result cards with context and type badges

= 0.2.0 =
* Admin menu, dashboard, results, and settings pages
* Freemius SDK integration
* Database schema (spellmatic_scans + spellmatic_results)

= 0.1.0 =
* Initial release
* Project scaffold, REST API architecture, Harper WASM groundwork

== Upgrade Notice ==

= 0.8.2 =
Fixes Fix/Dismiss buttons on the Results page. Includes Pro dashboard UI overhaul and harper.js CDN fallback.

= 0.8.0 =
Adds one-time scan credit plans and a new upgrade/pricing page. No breaking changes for existing Pro users.
