=== Clautron ===
Contributors: dudaster
Tags: capability, automation, security, no-code, ai
Requires at least: 7.0
Tested up to: 7.0
Stable tag: 1.2.0
Requires PHP: 8.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Get the feature. Not the plugin. Add exactly the WordPress capability you need — inspectable, secure, reversible.

== Description ==

WordPress can do almost anything, and that flexibility built a bad habit: every small feature becomes a full plugin install. One feature becomes one plugin. Thirty features become thirty plugins — each with its own code, dependencies, updates, and attack surface, for functionality you might use once.

**Get the feature. Not the plugin.**

Clautron is the capability layer for WordPress. Describe what you need — an admin column, a 301 redirect, a WooCommerce rule, a login-form tweak, a scheduled report — and Clautron adds exactly that, built from small, inspectable, reusable building blocks called primitives. Nothing more.

**One secure layer. Thousands of capabilities.**

Every capability Clautron builds can be activated, deactivated, and rolled back the same predictable way. Before you turn one on, you can see what it reads, what it writes, what it connects to, and how much it changes.

**Key features:**

* **Capabilities, not plugins** — get exactly the functionality you asked for, composed from small, auditable primitives instead of one more oversized plugin
* **Search first, generate second** — Clautron checks what already exists before generating anything new; when it does generate something, you review it before it runs
* **Know what runs on your site** — every capability is built from a declared, inspectable set of primitives
* **Reversible by design** — activate, deactivate, or roll back any capability without digging through code
* **Scheduled jobs and reports** — recurring automations and on-demand data queries, without a separate plugin for each
* **Safe by construction** — a safety policy layer blocks dangerous operations before they run

== Installation ==

1. Upload the `clautron` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Navigate to **Clautron** in the admin menu.
4. Go to **Settings** and enter your AI provider API key.

== Frequently Asked Questions ==

= Which AI providers are supported? =

Clautron uses the WordPress AI Client (built into WordPress 7.0+). The provider is configured at the WordPress level — go to your WordPress AI settings to choose and configure a provider. No API keys are stored by this plugin.

= Is my data sent to third-party services? =

Only the natural language prompts you type in the AI Assistant are sent to your AI provider, via the WordPress AI Client. Clautron does not directly connect to any external AI service — all communication is handled by WordPress core. No WordPress content, posts, users, or site data is transmitted.

= What are primitives, and what's a capability? =

Primitives are the small, reusable building blocks Clautron composes things from — custom post types, meta fields, admin columns, scheduled tasks, and more. A capability is what you actually get: a specific piece of functionality (a redirect, an admin column, a WooCommerce rule) built from one or more primitives, that you can activate, deactivate, or roll back as one unit.

= Does this plugin store data in the database? =

Yes. Clautron creates its own database tables (prefixed with `wp_clautron_`) to store blueprints, conversation history, scheduled jobs, workflow state, and execution logs. All data is removed if you uninstall the plugin.

= What permissions are required? =

Clautron is accessible only to administrators (`manage_options` capability). No frontend functionality or public-facing pages are added to your site.

== External Services ==

This plugin uses the WordPress AI Client (built into WordPress 7.0+) to generate blueprint configurations from natural language descriptions. Clautron does not directly connect to any external AI service.

All AI requests are routed through the WordPress AI Client. The provider that receives your prompts is determined by the AI provider configured in your WordPress installation's AI settings. Please refer to the terms of service and privacy policy of your configured AI provider.

== Screenshots ==

1. AI Assistant — describe the functionality you want in plain language and Clautron generates a blueprint from primitives.
2. Blueprints — manage saved features, their primitives, triggers, status, and last run.
3. Primitives — the catalog of composable building blocks, grouped by category.
4. Scheduled Jobs — one-time or recurring tasks defined with cron expressions.

== Changelog ==

= 1.2.0 =
* Added 8 new primitives: redirect (301 redirects), cookie (read/write first-party cookies), filter_query_by_language (multilingual query filtering), read_request_param (GET/POST input), register_payment_webhook (signed webhook receiver), filter_query_by_params (faceted product/content filtering), rate_limit_check (abuse throttling), register_sitemap (dynamic XML sitemaps).
* Added configure_smtp, handle_file_upload, log_all_emails, and log_activity primitives for SMTP relay configuration, file uploads, outgoing email logging, and site activity/audit logging.
* Extended add_metabox's fields template and added add_options_page with select, radio, image, and repeater field types — structured custom fields and site-wide settings pages, no new plugin required.
* Extended register_cpt and register_taxonomy with additional registration options: capability_type, menu_position, show_in_menu, exclude_from_search, show_admin_column, show_in_quick_edit, show_tagcloud.
* Fixed query_posts, count_posts, and query_users to resolve {{variable}} placeholders inside meta_query/tax_query — dynamic filters (e.g. a price range from a URL parameter) now actually work.
* Fixed inject_wp_footer to render on every frontend page (not just singular views) when post_types is left empty, and added suppress_if_cookie so a banner can hide itself after being dismissed.
* Fixed register_shortcode's HTML allowlist silently stripping form/input/textarea/select elements, breaking any shortcode-rendered form.
* Fixed register_cpt to auto-grant a custom capability_type's resulting capabilities to the administrator role — previously even admins got a 403 on the new post type.

= 1.1.0 =
* Added Elementor widget primitive — create custom Elementor widgets from blueprints with full controls and template rendering.
* Added WordPress widget primitive — create classic sidebar widgets from blueprints with text, textarea, select, number, URL, and checkbox controls.
* Fixed missing nonce on the New Widget link in the Widgets admin page.
* Updated admin menu icon to a custom SVG logo.

= 1.0.9 =
* Hardened write_option primitive: added comprehensive denylist blocking WordPress core options and any option name containing sensitive substrings (password, secret, api_key, token, salt, private_key).
* Hardened read_option primitive: added denylist blocking reads of auth keys, salts, passwords, and API credential options to prevent exposure of sensitive data.

= 1.0.8 =
* Migrated AI integration to WordPress AI Client (WordPress 7.0+) — removed direct Anthropic, OpenAI, Grok, and Ollama provider integrations.
* Added missing nonce checks to handle_delete_blueprint, handle_rollback_version, handle_get_blueprint_preview AJAX handlers.
* Added nonce to admin list table filter (primitive-ui) and verified on parse_query.
* Fixed unsafe SQL in DB uninstall and migration: DROP TABLE, SHOW COLUMNS, ALTER TABLE now use wpdb::prepare() with %i placeholder.
* Updated minimum WordPress requirement to 7.0.

= 1.0.7 =
* Fixed SQL query builders: replaced dynamic WHERE/ORDER concatenation with fully literal SQL strings and bypass conditions to satisfy WordPress.DB.PreparedSQL.NotPrepared.
* Moved tests/ directory outside the plugin folder (development-only, not distributed).
* Removed stray .DS_Store file.

= 1.0.6 =
* Fixed EscapeOutput: use JSON_HEX_TAG instead of str_replace for JSON-LD script output.
* Fixed SQL preparation: refactored query/aggregate builders to use %i table placeholder and single prepare() call with explicit placeholders.
* Fixed input handling: replaced direct $_GET/$_POST access with filter_input() throughout.
* Renamed non-prefixed page-scope variables to use clautron_ prefix.

= 1.0.4 =
* Replaced all external policy deep-links with root domain URLs to avoid Cloudflare-blocked automated checks.

= 1.0.3 =
* Updated external service URLs in readme (OpenAI policy links).
* Confirmed compatibility with WordPress 7.0.

= 1.0.2 =
* Security: added explicit nonce checks in all AJAX handlers.
* Security: added capability checks in admin page callbacks.
* Removed create_user primitive per wp.org review guidelines.
* Author URI updated to WordPress.org profile.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.1.0 =
Adds Elementor and WordPress widget primitives. No breaking changes.

= 1.0.9 =
Security hardening for the read_option and write_option primitives. Recommended for all users.
