=== Antimanual Builder - Truly AI Powered Visual Page Builder ===
Contributors: spiderdevs, mdjwel, muaz404
Tags: page builder, ai, drag and drop, visual builder, html import
Requires at least: 6.0
Tested up to: 7.0
Stable tag: 0.8.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An AI-powered visual page builder for WordPress. Generate complete pages from a prompt, then refine them with drag-and-drop editing — no Gutenberg required.

== Description ==

**Antimanual Builder** is a truly AI-powered, drag-and-drop visual page builder that brings a Replit/Lovable level website building experience to WordPress. Describe the page you want in plain language and get a complete, editable layout back — then keep refining it by chat or by hand. It's a full-screen design canvas for native WordPress pages, with no Gutenberg, no separate "builder" post type, and no lock-in. Every page you create is a regular WordPress `page` post, so your content stays portable and works with your theme, permalinks, and other plugins.

**Build pages with AI.** Generate whole layouts from a prompt, ask for changes conversationally, and migrate existing pages with AI assistance — all inside the editor. AI runs on **your own provider**: **OpenAI**, **Google Gemini**, **Anthropic**, **xAI Grok**, **DeepSeek**, or **OpenCode Zen**. The AI features are powered by the free, separate **Antimanual** companion plugin, where you connect your provider and API key.

**Or build entirely by hand.** Every AI-generated page is fully editable with drag-and-drop layout tools, inline canvas editing, reusable components, header/footer templates, and a responsive live preview. Manual editing, page migration, and HTML/ZIP import all work **standalone — no API key and no external service required.** Install the AI companion when you want it; Builder keeps working fully without it.

= Build With AI =

* **Generate from a prompt** — Describe the page you want and get a complete, fully editable layout back inside the editor.
* **Refine conversationally** — Ask for changes in chat and watch the page update, section by section.
* **AI-assisted migration** — Redesign or restructure an existing WordPress page with AI help.
* **Bring your own provider** — Works with **OpenAI**, **Google Gemini**, **Anthropic**, **xAI Grok**, **DeepSeek**, and **OpenCode Zen**.
* **Your keys, your control** — Builder reads the provider, model, and API key you configure in the free Antimanual companion plugin; keys are never managed or exposed by Builder itself.

= Build Visually =

* **Full-screen visual editor** — A distraction-free canvas for native WordPress pages, with no Gutenberg required.
* **Drag-and-drop & inline editing** — Arrange sections and edit text directly on the canvas, entirely without AI.
* **Structured block system** — Layout, content, and advanced blocks power both manual editing and generated pages.
* **Responsive preview** — Check layouts in Desktop, Tablet, Large Mobile, and Small Mobile widths before you publish.
* **Code editor tabs** — Inspect and tweak HTML, CSS, and JavaScript alongside the visual canvas.
* **Undo/Redo** — Full editing history with keyboard shortcuts.
* **Version history** — Every save keeps the previous version, restorable from a History panel.
* **Crash recovery** — Unsaved changes are backed up in your browser and offered back if the tab closes before you save.

= Reuse & Scale =

* **Component library** — Save any section as a reusable component and insert it on any page, with live previews, search, and category filters.
* **Push updates to components** — Update a saved component and roll the change out to the pages that use it, while leaving hand-edited copies alone.
* **Header & footer templates** — Build and assign reusable templates through a visual picker with live thumbnails.
* **Design Defaults** — Set the tone, design system, typography, spacing, corners, and brand colors applied to new pages.

= Bring In Existing Content =

* **Page migration** — Migrate an existing WordPress page into Builder as a faithful, fully editable copy — replace the original or keep a copy.
* **HTML & ZIP import** — Import a single HTML file with its assets, or analyze and create whole pages from a ZIP project, with chunked upload and a progress bar for large sites.
* **Dynamic content binding** — Bind a section to your real site content so it updates automatically, or turn a section into a live navigation menu.
* **CDN libraries** — Attach external CSS and JavaScript libraries from a CDN, controlling load position and async/defer behavior.

= How It Works =

1. Open **AM Builder** from the WordPress admin menu and create a new page (or migrate an existing one).
2. Build your layout with drag-and-drop sections, saved components, and inline editing — or, with the Antimanual plugin active, describe it in chat.
3. Preview across device sizes, then publish. The page is a standard WordPress page, live on your site with your theme's header and footer.

Generated and imported assets are stored in `wp-content/uploads/antimanual-builder/`.

== Installation ==

1. Upload the `antimanual-builder` folder to `/wp-content/plugins/`.
2. Activate **Antimanual Builder**.
3. Open **AM Builder** from the WordPress admin menu and start building pages — manual editing, HTML import, components, and templates work out of the box.
4. (Optional) To enable AI generation/refinement, also install and activate the free **Antimanual** plugin and configure your AI provider and API key there.

== Frequently Asked Questions ==

= How do I build my first page? =

Open **AM Builder** from the WordPress admin menu, create a new page, and start adding sections with the drag-and-drop tools. You can edit text inline on the canvas, insert saved components, preview across device sizes, and publish — all without an AI key or any external service.

= Do I need the Antimanual plugin? =

No. Antimanual Builder works fully standalone for manual editing, direct migration, HTML/ZIP import, components, and templates. The separate Antimanual plugin is needed only for the optional AI features — it connects your AI provider and sets up the knowledge base used for generation, refinement, and AI-based migration.

= Do I need an AI API key? =

Only for the optional AI features such as generation, refinement, and AI-based migration. Manual editing, direct migration, components, templates, and HTML import work without an AI key.

= Which AI provider should I use? =

When the Antimanual plugin is installed, Builder uses whichever provider you have configured in it. Supported providers include OpenAI, Google Gemini, Anthropic, xAI Grok, DeepSeek, and OpenCode Zen.

= Where do I configure AI providers? =

In the optional Antimanual plugin. When it is installed and active, Builder reads the active provider, model, and API key status from there. Without it, the AI features are simply unavailable but the rest of Builder works.

= Can I use this alongside other page builders? =

Yes, but Builder edits native WordPress pages rather than a separate builder page post type. Use migration intentionally on the pages you want Builder to manage.

= What happens to my pages if I deactivate the plugin? =

Your pages remain in WordPress because they are standard `page` posts. The Builder editing layer is what's removed, but the published content stays part of your site. Uninstalling cleans up what the plugin created while keeping your content (pages, templates, designs, chat history) unless you opt in to full removal.

= Will my pages match my theme? =

Yes. Builder pages render as native WordPress pages, so they appear inside your active theme with its header and footer. You can also assign your own Builder header/footer templates per page.

= Does it load any external fonts or trackers? =

No. The editor and generated pages use your operating system's native font stack, and the plugin does not load fonts from any third-party CDN. AI providers are contacted only when you explicitly trigger an AI action, and only if you've installed the optional Antimanual plugin. See the "External services" section for full details.

= Where are generated assets stored? =

Generated/imported assets are stored in `wp-content/uploads/antimanual-builder/`.

== External services ==

This plugin connects to third-party AI services to generate, refine, and migrate page content. No data is sent unless the user explicitly initiates an AI action (e.g., sending a chat message or generating a page).

= OpenAI API =

Used when OpenAI is selected as the AI provider in the optional Antimanual plugin.

* **What it does:** Generates and refines page HTML/CSS from user prompts.
* **What is sent:** The user's chat message, current page HTML/CSS (if editing an existing page), page design settings, and optionally Knowledge Base context.
* **When:** Only when the user sends a message in the AI chat or triggers page generation/refinement.
* **Service URL:** [https://api.openai.com](https://api.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)

= Google Gemini API =

Used when Google Gemini is selected as the AI provider in the optional Antimanual plugin.

* **What it does:** Generates and refines page HTML/CSS from user prompts.
* **What is sent:** The user's chat message, current page HTML/CSS (if editing an existing page), page design settings, and optionally Knowledge Base context.
* **When:** Only when the user sends a message in the AI chat or triggers page generation/refinement.
* **Service URL:** [https://generativelanguage.googleapis.com](https://generativelanguage.googleapis.com)
* **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)

= Anthropic API =

Used when Anthropic is selected as the AI provider in the optional Antimanual plugin.

* **What it does:** Generates and refines page HTML/CSS from user prompts.
* **What is sent:** The user's chat message, current page HTML/CSS (if editing an existing page), page design settings, and optionally Knowledge Base context.
* **When:** Only when the user sends a message in the AI chat or triggers page generation/refinement.
* **Service URL:** [https://api.anthropic.com](https://api.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)

= xAI Grok API =

Used when xAI Grok is selected as the AI provider in the optional Antimanual plugin.

* **What it does:** Generates and refines page HTML/CSS from user prompts via the xAI Grok API (OpenAI-compatible).
* **What is sent:** The user's chat message, current page HTML/CSS (if editing an existing page), page design settings, and optionally Knowledge Base context.
* **When:** Only when the user sends a message in the AI chat or triggers page generation/refinement.
* **Service URL:** [https://api.x.ai](https://api.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)

= DeepSeek API =

Used when DeepSeek is selected as the AI provider in the optional Antimanual plugin.

* **What it does:** Generates and refines page HTML/CSS from user prompts via the DeepSeek API (OpenAI-compatible).
* **What is sent:** The user's chat message, current page HTML/CSS (if editing an existing page), page design settings, and optionally Knowledge Base context.
* **When:** Only when the user sends a message in the AI chat or triggers page generation/refinement.
* **Service URL:** [https://api.deepseek.com](https://api.deepseek.com)
* **Terms of Use:** [https://cdn.deepseek.com/policies/en-US/deepseek-terms-of-use.html](https://cdn.deepseek.com/policies/en-US/deepseek-terms-of-use.html)
* **Privacy Policy:** [https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html](https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html)

= OpenCode Zen API =

Used when OpenCode Zen is selected as the AI provider in the optional Antimanual plugin.

* **What it does:** Generates and refines page HTML/CSS from user prompts via the OpenCode Zen API (OpenAI-compatible).
* **What is sent:** The user's chat message, current page HTML/CSS (if editing an existing page), page design settings, and optionally Knowledge Base context.
* **When:** Only when the user sends a message in the AI chat or triggers page generation/refinement.
* **Service URL:** [https://opencode.ai/zen](https://opencode.ai/zen)
* **Terms of Use:** [https://opencode.ai/legal/terms-of-service](https://opencode.ai/legal/terms-of-service)
* **Privacy Policy:** [https://opencode.ai/legal/privacy-policy](https://opencode.ai/legal/privacy-policy)

= Placehold.co (Placeholder Images) =

AI-generated pages may include placeholder images served by Placehold.co.

* **What it does:** Provides temporary placeholder images (solid-color rectangles with optional text) that appear in AI-generated page layouts until the user replaces them with real images.
* **What is sent:** The visitor's browser requests images from `placehold.co` when viewing a page that still contains placeholder image URLs. Only the requested image dimensions and optional label text are included in the URL — no user data or personal information is transmitted by the plugin itself.
* **When:** Only when a generated page contains unreplaced placeholder image URLs and a visitor (or the admin previewing the page) loads that page.

= Fonts =

The plugin does **not** load fonts from Google Fonts, Bunny Fonts, Adobe Typekit, Font Awesome, or any other third-party font CDN.

* The editor UI uses the operating system's native font stack (`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif`).
* AI-generated pages are instructed to use the same system font stack. The AI is explicitly told not to add `@import` rules or `<link>` tags pointing at remote font hosts.
* As a defensive measure, any `@import` or `<link>` that references a known font CDN is stripped from saved page CSS/HTML on the server before it is persisted, even if the AI model ignores the prompt.
* If a user imports their own HTML (e.g. via the ZIP importer), the original markup — including any font references the user authored themselves — is preserved as-is, because that content is owned by the user, not generated by the plugin.

== Security / Arbitrary Code ==

The builder does **not** support arbitrary PHP, JavaScript, or CSS insertion. There is no code-editor UI that accepts raw CSS, JS, or PHP and no REST endpoint that persists author-supplied stylesheets or scripts.

* **No arbitrary CSS:** Page CSS is generated programmatically from block style values and from a structured `styleMap` of selector/property pairs collected through the visual editor's form controls. The plugin does not store free-form CSS authored by users.
* **No arbitrary JavaScript:** Only hard-coded interactive scripts that ship with the plugin (tabs, accordion, counter, etc.) are emitted, and they are gated on the corresponding block being present on the page. There is no input surface for user-supplied JavaScript.
* **No arbitrary PHP:** There is no PHP code input in the UI and no REST endpoint that accepts or executes PHP supplied by users.
* **REST sanitization:** The `customCss` / `customJs` request parameters are stripped from all save endpoints (`/wp-json/ambld/v1/pages`, `/components`, `/templates`). Inline `<style>`, `<script>`, and `on*=` event-handler attributes are removed from `renderedHtml` and from imported documents before storage.
* **Render-time defence-in-depth:** Frontend output is passed through `wp_kses()` with a strict allowlist that excludes `<script>` and `<style>`, so any data that may have been persisted by older versions of the plugin cannot be served.
* **Legacy cleanup:** On upgrade, the plugin removes any `_ambld_custom_css` / `_ambld_custom_js` post meta and any per-post `src/post-{ID}.css` / `.js` files left behind by earlier releases.

== Source Code ==

The human-readable source code for all compiled JavaScript and CSS assets is included in the `src/` directory of this plugin.

* **Source files:** `src/editor/`, `src/admin/`, `src/page-editor/`
* **Build tool:** [wp-scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) (WordPress webpack configuration)
* **Build command:** `npm install && npm run build`
* **Compiled output:** `build/editor.js`, `build/admin.js`, `build/page-editor.js` and their corresponding CSS files

The `webpack.config.js` at the plugin root defines three entry points. All dependencies are managed via `package.json`.

== Changelog ==

= 0.8.0 =
Introduces Antimanual Builder Pro. HTML/ZIP import and dynamic content move to the premium add-on; the free builder keeps all manual editing, components, templates, page migration, and design tools.

* Changed: HTML & ZIP import is now part of Antimanual Builder Pro — the Import screen shows an upgrade prompt without an active Pro license.
* Changed: Dynamic content is now a Pro feature — binding a section to live posts, terms, or page meta, and connecting a section to a live WordPress navigation menu.
* Added: Licensing, upgrade, and 14-day trial handling via Freemius.
* Added: Settings now shows a clear notice when the free Antimanual companion plugin is inactive, with a one-click button to install or activate it so AI providers can be connected.
* Improved: Admin screens — the header banner now spans full width consistently across Pages, Templates, Import, and Settings for a cleaner, unified layout.
* Improved: Pages that already use dynamic content stay clean without Pro — bound sections fall back to their static layout instead of showing raw template placeholders.
* Fixed: Admin screens could fail to load ("Cannot read properties of undefined") when a dependency printed a PHP notice into an Inertia response; admin responses are now emitted as clean JSON.
* Developer: The premium import and dynamic-content backend ships only in the Pro plugin, shrinking the free build.

= 0.7.0 =
First public release of Antimanual Builder — an AI-assisted visual page builder for native WordPress pages that also works fully by hand, with no AI or API key required.

* Added: A full-screen visual builder for native WordPress pages, with a live editing canvas and no Gutenberg required.
* Added: Manual drag-and-drop and inline canvas editing that works fully without AI or an API key.
* Added: Optional AI page generation and refinement from a chat prompt, using your own provider through the free Antimanual companion plugin.
* Added: Optional AI works with OpenAI, Google Gemini, Anthropic, xAI Grok, DeepSeek, and OpenCode Zen.
* Added: A reusable component library — save any section and insert it on any page, with live previews, search, and category filters.
* Added: Push an update to a saved component out to the pages that use it, choosing which pages and leaving hand-edited copies alone.
* Added: A header and footer template system with a visual picker that shows a live thumbnail of each template.
* Added: Import a single HTML file, or analyze and create whole pages from a ZIP project, with chunked upload and a progress bar for large sites.
* Added: Migrate an existing page into the builder as a faithful copy, choosing to replace the original or keep a copy.
* Added: Bind a section to your real site content so it updates automatically, or turn a section into a live navigation menu.
* Added: Attach external CSS and JavaScript libraries from a CDN, controlling load position and async/defer behavior.
* Added: Set Design Defaults for new pages — tone, design system, typography, spacing, corners, and brand colors.
* Added: Preview layouts across Desktop, Tablet, and Large and Small Mobile.
* Added: Undo and redo with keyboard shortcuts.
* Added: Automatic crash recovery that offers back unsaved changes if the tab closes before you save.
* Added: Page version history — every save keeps the previous version, restorable from a History panel.
* Added: HTML, CSS, and JavaScript code-editor tabs alongside the visual canvas.
* Security: Custom page JavaScript runs on the live site only when added by a user allowed to publish code.
* Security: Imported markup is sanitized with a script-free allowlist, and event-handler attributes are stripped so imported pages can't run injected scripts.

= 0.4.0 =
* Added: Save any block to your library and reuse it on any page.
* Added: Push an update to a saved component out to every page that uses it — choosing which pages, and leaving individually edited copies untouched.
* Added: Pages now flag when a saved component has a newer version, so you can refresh it in one click.
* Added: Turn a static section into a repeating loop bound to your real content, so it updates automatically as your data changes.
* Added: Convert a static section into a live navigation menu bound to your site's content.
* Added: Attach external CSS and JavaScript libraries from a CDN so they load on your page.
* Added: Control where each CDN script loads (head or end of body) and its async/defer behavior, editable right from the list.
* Added: Set a custom URL slug per page when importing, with live conflict checking.
* Added: A visual header/footer picker shows a live thumbnail of each template in page settings and global design, instead of just a name.
* Added: Page version history — every save keeps the previous version, and a History panel lets you load any earlier version back into the canvas.
* Added: Automatic crash recovery — unsaved changes are backed up in your browser and offered back if the tab closes or crashes before you save.
* Added: Restored the full HTML/CSS/JS code editor tabs in the page editor.
* Added: A floating View/Edit toggle above the canvas.
* Added: Per-section add and remove controls, plus a Clear Content action.
* Added: A Knowledge Base on/off toggle that the AI respects when generating pages.
* Improved: The component insert menu now has live previews, search, category filters, and paging.
* Improved: You're warned before deleting a saved component that's still used on a page.
* Improved: Migrating an existing page is now a faithful, one-step copy that reproduces the page exactly, even on large pages.
* Improved: When migrating, you choose up front whether to replace the original or make a copy (copy is the default), with a clear "Migrating…" progress screen.
* Improved: Imported pages now come in as faithful, fully editable clones with their JavaScript preserved and running on the live page.
* Improved: Deleting a header/footer template now warns which pages and defaults rely on it, and falls back to the default gracefully.
* Improved: Private templates can now be selected as a page's header or footer.
* Improved: Page template options now explain what each one does.
* Improved: Timestamps across the app now show friendly relative times like "5 minutes ago".
* Improved: The AI writes section-scoped styles your theme can't override.
* Improved: The AI inspects the real page before planning broad requests, breaking them into clear per-section steps.
* Improved: The main action button now reflects page status — "Save Draft" for drafts, "Update" for published pages — instead of always saying "Publish".
* Improved: Confirmation prompts (deleting a page, leaving with unsaved changes, clearing import history) now use consistent in-app dialogs instead of browser pop-ups.
* Improved: The canvas right-click menu uses consistent icons and closes with Escape or an outside click.
* Improved: Deleting a page now removes its generated style and script files.
* Improved: Uninstalling the plugin cleans up everything it created, while keeping your content (pages, templates, designs, chat history) unless you opt in to full removal.
* Improved: Interface polish across the editor and admin screens — a unified accent color, consistent buttons, fields, dropdowns and tables, keyboard-accessible menus, resizable panels, clearer icons, and better text contrast.
* Fixed: Large site imports that previously failed now work — big ZIP files upload in chunks with a progress bar.
* Fixed: Sites with many pages now analyze reliably during import.
* Fixed: Choosing a theme template now actually renders the page — including imported pages — inside your active theme with its header and footer.
* Fixed: The AI no longer gets stuck repeating the same fix.
* Fixed: Pages now look the same on the live site as in the editor — element styles, fonts, and embedded form shortcodes (Contact Form 7, Gravity Forms, etc.) behave consistently.
* Fixed: Pages shown through a theme template no longer leak raw placeholder text or shortcode markers.
* Fixed: Saving no longer alters your content — backslashes, dollar signs, and other special characters are preserved exactly as typed.
* Fixed: A single AI edit is now one undo step.
* Fixed: Undo no longer clears a page's custom code.
* Fixed: Stopping an AI generation now stops cleanly without freezing the editor.
* Fixed: Deleted chat conversations stay deleted.
* Fixed: A failed deletion now reports the error instead of silently doing nothing.
* Fixed: The canvas right-click menu now acts on the exact element you clicked.
* Fixed: The canvas no longer flickers or jumps the scroll position.
* Fixed: The blank Templates page now works, and Templates appears in the builder navigation.
* Fixed: The New Component and New Template buttons no longer open the wrong editor or save your work as a normal page.
* Security: Custom page JavaScript runs on the live site only when added by a user allowed to publish code.
* Security: Imported documents are sanitized more strictly so unsafe markup can't be stored or served.
* Removed: The unreliable AI-rewrite option when migrating a page, replaced by the faithful one-step copy.

= 0.3.0 =
* Removed the custom CSS and custom JavaScript editors and their backing REST fields. Page styles are now generated programmatically from block settings and the visual style inspector; no free-form CSS or JS is stored by the plugin.
* Inline `<script>`, `<style>`, and `on*=` event-handler attributes are stripped from saved HTML, imported head/footer markup, and the stored import document, regardless of the saving user's capability.
* Frontend output is filtered through `wp_kses()` with a script-free allowlist as a defence-in-depth measure.
* Added a one-shot upgrade routine that removes any custom CSS/JS post meta and per-post source files left over from earlier versions.

= 0.1.0 =
* Initial release.
* Full-screen Builder editor with AI chat and manual editing.
* Internal builder block system for layouts, content, and advanced elements.
* Component library.
* Page migration tools with AI/direct modes and replace/duplicate behavior.
* Single HTML and ZIP project import tools.
* Shared Antimanual AI provider integration.
* Design defaults and responsive preview modes.
