=== DraftPilot AI Site Editor ===
Tags: ai, website builder, site generator, blocks, pages
Requires at least: 7.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.0
Author:            Simbe1
Author URI:        https://profiles.wordpress.org/simbe1/
Donate link:       https://paypal.me/HBesim
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Describe your business in a sentence and DraftPilot AI plans the pages, writes the copy, and builds them as editable drafts.

== Description ==

DraftPilot AI Site Editor turns one sentence about your business into a complete, editable website.

Write a short brief ("A family-run plumbing company in Austin offering repairs, installation and 24/7 emergency service") and the plugin will:

* Plan 3–6 pages (Home, Services, About, Contact, and more) that make sense for the business.
* Write specific, believable copy for every section.
* Apply a cohesive color palette and font pairing.
* Create every page as a draft, then wire up a navigation menu and set the front page.
* Let you refine any page in the block editor, or add a whole new section with one sentence.

**Built on the WordPress core AI Client.** DraftPilot AI Site Editor uses the core AI Client introduced in WordPress 7.0, so the plugin never stores API keys or provider credentials. Install an AI provider plugin of your choice and connect it under **Settings → Connectors** — the core AI Client handles models, keys, and billing.

**Safe by design.**

* **Block registry** — the AI may only emit a whitelist of block types (core blocks + 8 DraftPilot designer blocks). Everything is validated before it is saved; nothing raw from the LLM reaches the database.
* **No prompt injection** — page content generated by the AI is stored as data (JSON block attributes), never executed as code.
* **Sanitized output** — design tokens are validated against an allowlist before they are output as inline CSS, and all admin/editor scripts are properly enqueued.

== Installation ==

1. Requires WordPress 7.0 or newer.
2. Upload and activate the plugin.
3. Install an AI provider plugin and connect it under **Settings → Connectors** (e.g. a provider for OpenAI, Google, or Anthropic).
4. Open **DraftPilot AI** in the admin menu, describe your business, and click **Generate site**.

== Frequently Asked Questions ==

= Do I need my own API key? =

The plugin does not store API keys. Connect an AI provider under **Settings → Connectors**; the provider plugin manages credentials and any associated costs.

= Which AI models does it use? =

The model is chosen by whichever provider you connect through the WordPress core AI Client. The plugin is provider-agnostic.

= Does it work on WordPress 6.x? =

No — this version requires WordPress 7.0 or newer, because it uses the core AI Client (`wp_ai_client_prompt()`).

= Where are generated pages stored? =

Generated pages are normal WordPress pages, created as drafts. They are tagged with a `_simbe_ai_generated` meta flag so the plugin can list, trash, or delete them. Nothing is sent to any third-party server except the AI provider you connected.

== REST API ==

All endpoints live under `/wp-json/draftpilot-ai/v1` and require `manage_options`:

* `POST /generate-site` `{ "brief": "..." }` → create a generation job
* `GET /job/{id}` → poll job status
* `POST /add-section` `{ "page_id": 4, "prompt": "..." }` → append AI blocks to a page
* `GET /pages` → list generated pages
* `POST /pages/delete-all` → permanently delete generated pages
* `POST /pages/trash` `{ "page_id": 4 }` → trash one page
* `GET /nav-menu` → list menus
* `POST /nav-menu` `{ "page_ids": [4,5], "name": "DraftPilot Site", "location": "primary" }` → create or update a menu

== Privacy ==

DraftPilot AI transmits data to the AI provider you connect. Review how your provider handles your data before generating.

* **Data you send.** The business brief you type, your site name and description, and the content generated from them are sent to the AI provider connected under **Settings → Connectors** using the WordPress core AI Client. The plugin does not transmit anything to the plugin author.
* **What is stored.** Plugin settings (creativity level, site slug) and your generated pages. No API keys or provider credentials are stored by the plugin.
* **Full text.** See the **Privacy** tab in the DraftPilot AI admin for the complete Terms of Service, Privacy Policy, and data provider list.

== Changelog ==

= 1.3.0 =
* Renamed the plugin to **DraftPilot AI Site Editor**.
* Migrated all AI calls to the WordPress core AI Client (`wp_ai_client_prompt()`); provider credentials are now managed by core **Settings → Connectors**.
* Replaced inline `<script>` in the admin with enqueued JavaScript.
* Sanitized and escaped all inline design CSS (colors, fonts, radii are allowlisted).
* Added a changelog and privacy documentation.

= 1.2.0 =
* Added a Privacy tab (Terms of Service, Privacy Policy, Data Providers) and readme privacy section.
* Added `uninstall.php` so all plugin data is removed on uninstall.
* Added a version badge and this changelog.

= 1.1.0 =
* Added an "Add section" sidebar panel for the block editor.
* Added block registry validation and JSON-safe generation.
