=== SiteRoyal Pro – Advanced AI Tools ===
Contributors: theswiftlywp
Tags: ai, mcp, wordpress, theme builder, maintenance
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Extends SiteRoyal AI Site Manager with advanced tools: theme builder, maintenance mode, and search & replace.

== Description ==

**SiteRoyal Pro** is a free add-on that extends the [SiteRoyal – AI Site Manager](https://wordpress.org/plugins/siteroyal-ai-manager/) plugin with advanced tools for power users.

= Features =

* **Theme Builder** — Create child themes, read/write/edit all theme file types (PHP, JS, CSS, HTML, JSON, TXT, SVG), and browse theme directory structures via AI commands. PHP files are validated for syntax errors and function/class redeclarations before saving.
* **Safe Theme Activation** — Activate themes with automatic health check. If the new theme causes a fatal error or white screen, the previous theme is restored automatically within seconds. Your site is never left broken.
* **Maintenance Mode** — Toggle WordPress maintenance mode on and off through your AI assistant.
* **Search & Replace** — Bulk find and replace across post content, titles, and excerpts with dry-run preview and transaction safety.

= Requirements =

* The free [SiteRoyal – AI Site Manager](https://wordpress.org/plugins/siteroyal-ai-manager/) plugin must be installed and active.
* WordPress 6.0 or higher.
* PHP 7.4 or higher.

= Security =

All endpoints require administrator access and are protected by the same permission system as the free plugin:

* Theme file writes support PHP, JS, CSS, HTML, JSON, TXT, and SVG — the same file types accessible via WordPress's built-in Theme File Editor.
* PHP files are validated for syntax errors before saving — bad PHP cannot crash the site.
* PHP redeclaration guard prevents declaring functions/classes that already exist in WordPress, which would cause fatal errors.
* Atomic writes via temp file strategy — files are validated before going live, preventing partial or corrupt writes.
* SVG files are sanitized to remove script tags, event handlers, and other XSS vectors before writing or editing.
* Theme activation includes an automatic health check — if the site returns HTTP 500, a white screen, or fatal error text, the previous theme is restored instantly.
* Search & replace runs in a database transaction — if anything fails, all changes are rolled back.
* Directory traversal and symlink attacks are blocked in all theme file operations (read, write, and list).
* All operations are logged to the SiteRoyal Activity Log for audit.

== Installation ==

1. Install and activate the free **SiteRoyal – AI Site Manager** plugin from wordpress.org.
2. Download the SiteRoyal Pro plugin ZIP from [swiftlymcp.com](https://swiftlymcp.com/pro).
3. Go to **Plugins → Add New → Upload Plugin** and upload the ZIP file.
4. Activate the plugin.

The pro endpoints will be available immediately through your AI assistant.

== Frequently Asked Questions ==

= Is this plugin free? =

Yes, SiteRoyal Pro is completely free. It provides advanced features that are distributed separately from the wordpress.org plugin.

= Can I deactivate the free plugin while Pro is active? =

No. SiteRoyal Pro depends on the free plugin for authentication, permissions, and activity logging. You must deactivate Pro first.

= What file types can the theme builder write? =

PHP, JS, CSS, HTML, JSON, TXT, and SVG files. This matches the same access level as WordPress's built-in Theme File Editor (Appearance → Theme File Editor). All writes require administrator access and are logged to the activity log.

= What happens if a theme activation causes a fatal error? =

SiteRoyal Pro automatically detects the error by fetching your site's front page after activation. If it detects an HTTP 500, white screen, or fatal error text, it switches back to your previous theme within seconds. Your site is never left broken.

== Changelog ==

= 1.0.0 =
* Initial release.
* Theme builder: create child themes, read/write/edit theme files with PHP syntax validation, list theme directory contents.
* Safe theme activation with health check and automatic rollback.
* Maintenance mode: toggle on/off via AI.
* Search & replace: bulk find/replace with dry-run and transactions.
