=== KAF WordPress Connector ===
Contributors: simurdigital
Tags: seo, ai-seo, seo-automation, ai-seo-tool
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.4.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

KAF WordPress Connector automates SEO mistakes with AI-driven updates such as titles, meta descriptions, headings, sitemap, and robots.txt.

== Description ==

KAF WordPress Connector seamlessly integrates your WordPress website with the KAF AI SEO Assistant platform, enabling fully automated SEO error detection and correction. By leveraging advanced AI capabilities, this plugin ensures your website's SEO elements are always optimized—without the need for manual intervention.

[youtube https://youtu.be/Yd914SNv9uM]

**Key Features:**

- Automatically updates post and page titles and meta descriptions based on AI-driven SEO analysis.
- Creates new posts and categories directly from the KAF panel.
- Uploads images to your WordPress media library as recommended by the AI assistant.
- Reduces human error and saves time by automating repetitive SEO tasks.
- Improves your website's search engine visibility and overall SEO health.

KAF WordPress Connector is ideal for website owners, agencies, and SEO professionals who want to maintain optimal SEO performance with minimal effort.

For more information and to create a KAF AI SEO Assistant account, visit [KAF AI SEO Assistant](https://kaf.simur.org).

== Installation ==

1. Download and install the plugin via the WordPress admin panel or upload the plugin files to the `/wp-content/plugins/kaf-wordpress-connector` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Navigate to the plugin settings page and enter your KAF AI SEO Assistant API key.
4. Once connected, the plugin will automatically synchronize with your KAF panel and begin optimizing your website.

== Frequently Asked Questions ==

= Do I need a KAF AI SEO Assistant account to use this plugin? =
Yes, an active KAF AI SEO Assistant account and API key are required for the plugin to function.

= What SEO elements does the plugin currently support? =
The current version supports automatic updates for titles and meta descriptions, post/category creation, image uploads, sitemap management, robots.txt editing, and server-side parse-time filters.

= Is my data secure? =
Yes, all communications between your WordPress site and the KAF platform are encrypted and secure.

= Does the plugin work if the site's REST API is disabled? =
Yes. Since v1.4.2, the plugin automatically bypasses REST API restrictions for its own `/wp-json/kaf/` namespace, even when a security plugin or custom code has disabled the REST API site-wide.

== Screenshots ==

1. KAF Connector dashboard — total time saved by automation, top fix categories, most-fixed pages, 7-day activity sparkline, automation mode, and system compatibility status.
2. Active Features panel — apply-batch, crawler bypass, parse-time filters, indexation, link rel policy, hreflang, image attributes, redirect rules, and connection details at a glance.
3. Mutation History — URL-grouped table of every applied fix with category chips, count, time saved, last edit, and one-click access to the diff timeline.
4. Mutation diff timeline for a single page — chronological before/after view across titles, descriptions, JSON-LD schema, Open Graph, canonicals, and headings.
5. Site Policy History — append-only timeline of every plugin policy option change with side-by-side before/after snapshots.
6. KAF panel WordPress integration tab — connection card, automation mode selector, and step-by-step onboarding inside the KAF dashboard.

== Changelog ==

= 1.4.5 =
* **Auto-update self-enable now covers silent updates:** v1.4.4 added the plugin to WordPress's auto-update list only on activation and on KAF Panel reconnection. WordPress does not fire the activation hook on background plugin updates ("Update Now" or auto-update), so sites that updated silently never had auto-updates turned on. The self-enable call now also runs on every `init` (idempotent — does nothing if already enabled), guaranteeing the next admin page load after any update enables auto-updates if it was missing.

= 1.4.4 =
* **Auto-update enabled by default:** KAF Connector now adds itself to the WordPress core auto-update list on activation and on successful KAF Panel connection. Future releases install silently in the background; users can still disable auto-updates from the WP-admin Plugins page at any time. Existing installations gain this behavior the moment they (re)connect to KAF Panel.

= 1.4.3 =
* **New apply-batch category — `post_status_update`:** Flip an existing post's status (e.g. `draft` → `publish`) without touching its content. Body shape: `{post_status_update:[{id, status:'publish'|'draft'|'private'}]}`. Idempotent (no-op when the post is already in the target status) and returns a fresh permalink in `updated:[{id,url,edit_url,status}]`. Powers the KAF panel's one-click "Publish on WordPress" action for Auto SEO Blog drafts.

= 1.4.2 =
* **Bug fix — Sites with REST API disabled could not connect:** When a security plugin or `functions.php` code disabled the WordPress REST API entirely, KAF requests to `/wp-json/kaf/` were also blocked. The plugin now hooks `rest_authentication_errors` at `PHP_INT_MAX` priority to exempt its own namespace; the REST API remains closed site-wide while only KAF endpoints stay accessible.

= 1.4.1 =
* **Bug fix — False "Page Fixes ACTIVE" signal:** The admin status panel and health endpoint's `features.apply_batch` flag were reading `class_exists('KAF_SEO_Repair_Apply')` — because the class always loads at boot, it returned `true` even when SEO Repair was disabled. Fixed to use `kaf_repair_state.enabled` synced from the KAF panel.
* **Submenus hidden when disconnected:** Mutation History, Active Rules, KAF AI Content, and Policy History submenus now return early when `kaf_connection_code` is empty and reappear after a successful connection.

= 1.4.0 =
* **KAF Website Management Module:** New `kaf/v1/manage/*` endpoint group — list and manage WordPress users, passwordless WP Admin login (HMAC SSO).
* **One-Click SSO:** Passwordless access to the WordPress admin panel via a single-use signed token (HMAC-SHA256 + 60s TTL + nonce replay protection).
* **WordPress User Management:** List, create, update, reset password, and delete users with content reassignment support.
* **Plugin & Theme Management:** List, activate/deactivate, remote install, one-click update, auto-update toggle, version lock, and abandoned-plugin scan.
* **WordPress Core + Code Snippets:** Version info, one-click core update, translation packages, DB upgrade. Code snippets CRUD with syntax validation, scope control, and safe eval with fatal protection.
* **Content + Backup:** Post/page listing with filters, status changes, bulk delete. UpdraftPlus integration for backup history and manual triggers.
* **KAF AI Content admin page:** New WP admin sub-menu listing all KAF-generated posts (`_kaf_auto_created=1`) with status, date, author, and batch source filters.
* **Batch Tracking:** New `_kaf_batch_id` post_meta marker; visible under "Batch / Source" in the KAF AI Content page.

= 1.3.2 =
* **Real WP Rollback (T15):** New `POST /seo-repair/restore-batch` endpoint — "Undo" from the KAF panel now writes post_meta and post_content changes back in WordPress within a 7-day window. Covers 9 categories + post_slug + content_body; Yoast / Rank Math / All in One SEO mirror fields reverted synchronously.

= 1.3.0 =
* **Modern Admin Dashboard:** Redesigned settings, history, and policy pages with KAF brand styling and dark mode support; hero panel surfaces total time saved, top categories, top pages, and a 7-day activity sparkline.
* **Mutation History:** New sub-menu with URL- or category-grouped views, search/filter, before/after diff timeline, and one-click "Edit in WordPress" links.
* **Rollback:** Per-mutation revert button restores the previous value including Yoast / Rank Math / All in One SEO mirror fields.
* **Applied Policies Page:** Live configuration of every active server-side policy for full transparency.
* **AI Content & Page Creation:** `content_body` and `page_create` apply-batch actions for full post body rewrites and AI-generated pages.
* **URL Normalization:** `url_redirects` apply-batch category — lowercase, strip trailing `?`, session IDs, parameter whitelist, dedupe, underscore-to-hyphen.
* **EEAT, Video & Slug Schemas:** `business_info`, `VideoObject`, and `post_slug` apply-batch categories.
* **Security Headers & Custom CSS:** `security_headers` (HSTS, X-Frame-Options) and `custom_css` apply-batch categories.
* **Site-Level Autofix:** Automated robots.txt creation/repair, sitemap generation, and sitemap reference patching.
* **Internationalization:** Text Domain `kaf-wp-connector` and `Domain Path: /languages`.
* **Compatibility Fix:** Heading override DOM parser uses `instanceof DOMElement` guard for PHP 8.1+.

= 1.2.0 =
* **KAF SEO Repair Engine:** Batch mutation endpoint for titles, descriptions, OG tags, canonicals, robots directives, headings, image alts, and JSON-LD schema.
* **Crawler Bypass Handshake:** Plugin recognizes the KAF audit crawler via a shared project token and skips mutation output so audit scores reflect raw root causes.
* **Parse-Time HTML Filters:** Server-side defer injection, non-critical CSS preload swap, and mixed-content HTTPS rewrite.
* **Indexation Control:** Pattern-based `wp_robots` filter for noindex directives.
* **Link Rel Policy:** Auto-nofollow for external links with domain whitelist; strips nofollow from internal links.
* **Hreflang Extensions:** Reciprocal hreflang injection with x-default and BCP47 `<html lang>` normalization.
* **Image Attribute Optimization:** `fetchpriority="high"` and `<link rel="preload" as="image">` injection.
* **Redirect Rules:** Trailing-slash normalization and custom 301 redirect map.
* **Health Endpoint:** `GET /seo-repair/health` with dynamic plugin version, active feature flags, and last-batch metadata.

= 1.1.0 =
* **Enhanced SEO Optimization:** Improved automatic generation and updating of titles, meta descriptions, and heading tags.
* **Smart Sitemap Management:** New sitemap generator, automatic error correction, and missing-URL insertion.
* **Robots.txt Control:** New robots.txt generator and editor; automatic sitemap URL addition and SEO-blocking rule removal.
* **Content Update Capability:** Added the ability to update page content to improve SEO performance.

= 1.0.0 =
* Initial release: Automated title and description updates, post/category creation, and image uploads.

== Author ==

Developed and maintained by [Simur Digital](https://simur.org) in partnership with [KAF AI SEO Assistant](https://kaf.simur.org)
