=== Prozen AI Proofreader ===
Contributors: fromgate
Tags: proofreading, spellcheck, grammar, ai, gutenberg
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Proofread posts directly in WordPress with any AI chat or an OpenAI-compatible API. You approve every fix — formatting and links stay intact.

== Description ==

**Prozen AI Proofreader** brings precise, distraction-free proofreading directly into your WordPress editor. It catches spelling mistakes, typos, punctuation errors, and grammatical slips — proposing point, character-level fixes while keeping your formatting, links, and layout completely intact.

You maintain full control: review each suggested correction side-by-side, jump straight to the word in the editor with a single click, and accept only the changes you approve.

### Two flexible ways to proofread:

* **Manual mode (100% Free, Zero Setup):** One click copies your post text along with an optimized proofreading prompt to your clipboard. Paste it into any AI chat interface (ChatGPT, Claude, DeepSeek, Gemini, etc.), paste the response back into the sidebar, and inspect the fixes. No API keys, no billing accounts, and zero data sent by the plugin.
* **API mode (Direct Integration):** Connect directly to any OpenAI-compatible API endpoint — commercial cloud providers or your own private, self-hosted models (such as Ollama, LM Studio, or vLLM). Click "Check via API" and watch suggestions appear in the editor sidebar automatically.

### Key Highlights

* **Surgical precision:** Targets only genuine errors (spelling, grammar, punctuation). Broad rewriting and stylistic overhauls are strictly blocked.
* **Formatting stays intact:** Hyperlinks, bold, italics, quotes, and block styling are preserved. Corrected words remain seamlessly within their existing links.
* **Interactive navigation:** Click any suggestion in the sidebar to automatically scroll the editor and select the target word in context.
* **Visual diff:** Changes are presented as intuitive "original → suggested" comparisons with individual checkboxes.
* **Protected terms:** Designate custom terms, brand names, product SKUs, and technical acronyms that the AI is forbidden to modify.
* **Full undo support:** Every applied change integrates with standard WordPress history and can be instantly reverted with `Ctrl+Z`.
* **Zero lock-in & privacy-first:** No proprietary intermediary servers. You decide exactly where your content is processed.

== How It Works ==

1. Open the **Prozen AI Proofreader** sidebar in the editor.
2. Click **"Copy for AI chat"** (or **"Check via API"** if configured).
3. Review the suggestions in the sidebar. Click any item to jump directly to that word in your text.
4. Select the fixes you wish to accept and click **"Apply selected"**.

In API mode, longer articles are processed in manageable parts with an active progress indicator and Cancel button, ensuring reliability even with slower local hardware.

== External services ==

**The plugin author collects no data whatsoever.** Prozen AI Proofreader operates without any proprietary backend, telemetry, tracking, or analytics.

**You control data destination:**
* In **Manual mode**, you manually paste the text into whichever AI chat service you choose.
* In **API mode**, requests are sent exclusively to the endpoint specified by the site administrator in Settings. The prompt is assembled on your server, ensuring API keys are never exposed to client browsers.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/prozen-ai-proofreader/` or install via the WordPress Plugins screen.
2. Activate the plugin.
3. Open any post or page in the editor and click the proofreader icon in the top toolbar.

== Frequently Asked Questions ==

= Does it work with the Classic Editor? =

No. Prozen AI Proofreader is engineered specifically for the modern WordPress block editor. It relies on block structures and rich-text parsing to safeguard your formatting, images, and links.

= How can I connect to a local AI server (Ollama, LM Studio, LAN)? =

To prevent Server-Side Request Forgery (SSRF), the plugin uses `wp_safe_remote_post()` and `wp_safe_remote_get()`. By default, WordPress blocks requests to private/loopback IP addresses (`localhost`, `127.0.0.1`, `192.168.x.x`) and non-standard ports.

If you run an AI server locally, add the following filters to your theme's `functions.php` or a Must-Use (MU) plugin:

    // Allow requests to local AI host
    add_filter( 'http_request_host_is_external', function( $is_external, $host ) {
        if ( in_array( $host, array( 'localhost', '127.0.0.1' ), true ) ) {
            return true;
        }
        return $is_external;
    }, 10, 2 );

    // Allow custom ports (e.g. 11434 for Ollama, 1234 for LM Studio)
    add_filter( 'http_allowed_safe_ports', function( $ports ) {
        $ports[] = 11434; // Ollama default port
        $ports[] = 1234;  // LM Studio default port
        return array_unique( $ports );
    } );

= Do I need a paid API key to use this plugin? =

No. Manual mode is completely free and requires no API keys or third-party accounts. You can use any free chat interface you already have access to.

= Which AI models work best? =

Any modern instruction-following model produces great results. Leading frontier models (such as GPT-4o, Claude 3.5 Sonnet, or DeepSeek-V3) offer exceptional accuracy, while smaller local models (such as Llama 3 or Qwen 2.5) also perform reliably due to the plugin's strict prompt validation rules.

= Does it alter links or formatting? =

No. The plugin modifies only the exact characters requiring correction. If an error is located within a link or styled phrase, the link destination and typography are fully preserved.

= What are Protected Words? =

Under **Settings > Prozen AI Proofreader**, you can list terms that must never be altered (such as brand names, trademarks, product SKUs, or technical acronyms like API, SaaS, CTR). The AI prompt explicitly instructs the model to leave them untouched, and the plugin will automatically discard any suggested replacement that touches them.

= What about custom or third-party blocks? =

Standard WordPress text blocks (Paragraphs, Headings, Lists, Quotes, Buttons, etc.) are supported out of the box. For blocks provided by other plugins, you can register their text attribute names under **Settings > Prozen AI Proofreader > Third-party Gutenberg blocks**.

= Which languages are supported? =

Your post content can be in any language. The prompt is provided in English because modern LLMs follow technical instructions best in English, while proofreading according to the language of your text. Ready-to-use rule templates are included for English, Spanish, and Russian, and custom instructions can be tailored to any language.

== Screenshots ==

1. AI Prompt settings: general proofreading rules, language presets, and protected words.
2. API Mode settings: endpoint configuration, model selection, and request timeout.
3. WordPress editor sidebar with proposed corrections and interactive diffs.
4. AI chat session showing the exported proofreading prompt and structured response format.

== Changelog ==

= 1.0.1 =
* Fixed: single-letter typo corrections inside a word (e.g. helllo → hello) are no longer treated as text deletions and stay selected by default.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
