=== AIVision SEO ===
Contributors:      aivisionseo
Tags:              seo, aeo, geo, ai, schema, generative engine optimization, answer engine optimization, structured data, sitemap, llms-txt
Requires at least: 6.0
Tested up to:      6.5
Requires PHP:      8.0
Stable tag:        1.7.21
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

The first all-in-one plugin built for Search Engines (SEO), Answer Engines (AEO), and Generative AI Engines (GEO).

== Description ==

**AIVision SEO** analyzes your WordPress content across the 3 modern discovery pillars and provides a prioritized **Action Plan ("What to Do")**:

* **📊 SEO Score (Search Engine Optimization)** — Classic on-page optimization for Google & Bing: title, meta description, keyword density, heading hierarchy, image alts, and internal linking.
* **💬 AEO Score (Answer Engine Optimization)** — Winning Featured Snippets & Voice Search (Google AI Overviews, Siri, Perplexity): direct 40–60 word answer paragraphs, question-led H2/H3s, step-by-step ordered lists (`<ol>`), and FAQPage schemas.
* **🤖 GEO Score (Generative Engine Optimization)** — Maximizing citation and synthesis in LLMs (OpenAI ChatGPT/SearchGPT & Google Gemini): high statistical data density, authoritative citations, E-E-A-T credentials, `/llms.txt` machine feeds, and AI crawler access.

=== Core Features ===

**🎯 3-Pillar Dual Scoring & Real-time Gauges**
Real-time **SEO**, **AEO**, and **GEO** scores displayed in circular SVG gauges inside the post editor. Every check is weighted, explained, and live-updated as you write.

**💡 Prioritized Action Plan ("What to Do")**
Direct actionable advice categorized into:
* 🔴 **High Priority**: Immediate rank & AI citation boosters (e.g., adding direct answer blocks or critical schemas).
* 🟡 **Medium Priority**: Structural and depth enhancements (e.g., statistical data points, ordered lists).
* 🟢 **Passed Signals**: Factors already meeting top industry standards.

**🤖 Auto-Optimized robots.txt**
1-click automated rule generator that configures the optimal Allow/Disallow policies for 20+ search and AI crawlers (`GPTBot`, `ClaudeBot`, `PerplexityBot`, `Google-Extended`, `Applebot-Extended`, `Meta-ExternalAgent`), while preventing crawler traps.

**📄 Standard LLMs.txt & LLMs-Full.txt Feeds**
Dynamic `/llms.txt` and `/llms-full.txt` endpoints adhering to the official [llmstxt.org](https://llmstxt.org/) specification, including automatic sitewide FAQ extraction from schemas.

**🏷️ Schema.org Generator (14 types)**
One-click JSON-LD generation for:
FAQPage, Article, BlogPosting, LocalBusiness, MedicalBusiness, Product, Service, HowTo, BreadcrumbList, Organization, Person (Author/Expert), WebSite, Review, Event, VideoObject.

**🗺️ Native XML Sitemap**
Built-in dynamic `/sitemap.xml` with automatic homepage duplicate suppression and fast cached SQL queries.

**⚡ Auto-Pilot Blog Generator**
Automated keyword, topic, and YouTube transcript-based content creation optimized for both search rankings and GEO visibility.

**📣 Social / Open Graph**
OG image picker with featured image fallback, Twitter Card settings, and live SERP preview.

**📈 Content Dashboard & Post Columns**
Overview of all published posts with `SEO | AEO | GEO` score badge columns directly inside the standard WordPress "All Posts" and "All Pages" list tables.

== Installation ==

1. Upload the `aivision-seo` folder to `/wp-content/plugins/`
2. Activate the plugin through the **Plugins** menu
3. Visit **AIVision SEO → Settings** to configure your site type and Site AI Bio
4. Click **⚡ Auto-Optimize robots.txt** to set optimal crawler policies
5. Open any post/page and use the **AIVision SEO** meta box to view your SEO, AEO, and GEO scores and follow the **Action Plan**

== Frequently Asked Questions ==

= What is the difference between SEO, AEO, and GEO? =
* **SEO**: Ranks your pages in classic search engine result pages (Google, Bing).
* **AEO**: Optimizes content for direct answers, featured snippets, and voice assistants (Siri, Alexa, Google AI Overviews).
* **GEO**: Optimizes content to be synthesized, cited, and referenced by LLMs (OpenAI ChatGPT & Google Gemini).

= Does it include standard /llms.txt and /llms-full.txt feeds? =
Yes! AIVision SEO dynamically generates both `/llms.txt` (curated index with aggregated FAQs) and `/llms-full.txt` (full markdown body feed) conforming to the llmstxt.org standard.

= Does this conflict with RankMath or Yoast? =
AIVision SEO can be used alongside other SEO plugins, but you should disable duplicate meta tag output. We recommend using AIVision SEO as your primary SEO, AEO, and GEO optimizer.

== Changelog ==

= 1.7.21 =
* Pages built with BeTheme's Muffin Builder are now scored on their real content. Before, the SEO/AEO/GEO checklist read these pages as 0 words with no headings or links, because Muffin Builder keeps the page outside the normal WordPress content.
* Pages from other page builders that leave the WordPress content empty are scored from the published page's main area. That copy is cached until the page changes.
* Word counts and keyword density now count words with accented letters (ë, ç) as one word.

= 1.7.20 =
* Auto-Fix can now be run from the AIVisibility SEO dashboard on the posts you choose. It does exactly what the Auto-Fix button in the post editor does, including undoing any change that would lower a score.
* A dashboard-started Auto-Fix never stops to ask for business facts; items that need real facts (statistics, author bio, first-hand experience) are left for you to fill in from the editor.

= 1.7.19 =
* Commands sent from the AIVisibility SEO dashboard now do exactly what the matching buttons in WordPress do.
* "Optimize robots.txt" from the dashboard applies the same best-practice preset as the 1-Click button here. It used to keep only three AI bots, which blocked Google, Bing and the other search and AI crawlers.
* Updating the site bio or enabling llms.txt from the dashboard now rewrites robots.txt and llms.txt on disk, like saving Settings here, so a stale file is no longer served. Updating the bio no longer resets your site type to "General".
* "Generate feeds" from the dashboard now regenerates sitemap.xml, llms.txt, llms-full.txt and robots.txt, like the Generate buttons here. Before, it did nothing.
* SEO titles, descriptions and focus keywords set from the dashboard (published articles and post optimizations) are now saved where the post editor saves them, so they show up in the page head, the editor and the scores. Values saved the old way are moved over automatically.
* Disconnecting on either side now disconnects both.

= 1.7.18 =
* Auto-Fix on the home page now publishes your business schema (LocalBusiness or its subtype) from your AIVisibility SEO business profile -- the same schema the dashboard pushes -- replacing any older copy, and tells you which profile fields (address, phone, hours...) are still missing.
* When the page has no FAQ schema, Auto-Fix adds a FAQPage built from the question headings and answers actually shown on the page (at least two), never invented ones.
* The FAQ and multi-schema checks now count the schemas really printed on the page, including site-wide ones, so a published business schema is no longer ignored by the score.

= 1.7.17 =
* Auto-Fix now works on Elementor pages: it adds its section as an Elementor Text Editor widget in its own section at the bottom of the page (matching the page's containers or classic sections), editable in Elementor like any other block. Rollback restores the Elementor layout too.
* Auto-Fix on the home page and page-builder pages can now fix GEO: it asks once for real business facts (year founded, customers served, response time, vehicles/team, areas, official profile links, a short bio -- pre-filled from your AIVisibility SEO business profile) and adds a "why choose us" section built only from them. Facts are saved and reused; resubmitting replaces that section. "Skip" fixes the other items instead.
* GEO/AEO scoring understands Albanian: statistics with Albanian units (vite, minuta, makina...), first-person phrases ("ekipi ynë", "ne ofrojmë"...) and definitions ("është një", "quhet"...) now count, and words with ë/ç are counted correctly.
* The front page is scored as a home page: at least 300 words instead of 1,000, and a business bio instead of an article author bio.
* Running Auto-Fix again on a page that already has an Auto-Fix section now adds the still-missing items to it, instead of replacing it and losing the items it had already fixed.

= 1.7.16 =
* Auto-Fix on the homepage and on page-builder pages (Avada, WPBakery, Divi, block editor) now adds one new section -- a question heading with a direct answer, numbered steps, a definition and a comparison table, written in the page's own language -- instead of rewriting the whole page, so the existing layout is never touched. Running it again replaces that section rather than adding another.
* Items that need real business facts (statistics, sources, author details, longer content) are no longer sent for AI generation; Auto-Fix lists them for you to add by hand.
* Elementor pages get a clear message instead of an invisible change.

= 1.7.15 =
* Pushing schema (or the AEO block) from the platform now clears the site page cache (LiteSpeed, WP Rocket, W3 Total Cache, WP Super Cache, SiteGround), so the change shows up immediately instead of after the cached page expires.
* The homepage no longer prints an older editor-saved LocalBusiness block next to the platform-pushed one, and a page's own FAQPage is preferred over the generic site-wide one (Google allows one FAQPage per page).
* JSON-LD output drops empty values (e.g. blank address fields) instead of printing them.

= 1.7.14 =
* The platform-pushed LocalBusiness schema (built from the Business NAP settings) now replaces the previous one instead of stacking: it is stored as a single business entity even when the subtype changes, any LocalBusiness block saved on the homepage itself is removed, and it is printed on the homepage only (not repeated on every page).

= 1.7.13 =
* The LocalBusiness schema generator no longer invents opening hours ("Mo-Fr 09:00-18:00") or a "$$" price range; both are now only emitted when the owner supplies them.

= 1.7.12 =
* The LocalBusiness form no longer saves blank fields: empty phone/email/price/image are omitted, and an address with no values is dropped instead of being written as an empty PostalAddress (which triggered Google "missing field" warnings).

= 1.7.11 =
* Fixed the post schema editor showing only raw code (no form) for a schema whose stored JSON had unescaped quotes, such as a street address containing "quoted" text. The editor now repairs the JSON on load, so the form appears and saving writes valid JSON.

= 1.7.10 =
* Fixed invalid JSON-LD reaching the page (Google Rich Results: "Parsing error: Missing , or }"). Hand-edited schema with unescaped double quotes inside text values is now repaired on save and at output; anything still unparseable is no longer printed. Saving an unparseable schema in the editor is now rejected with a clear message.
* Removed the made-up default address (Rruga e Durresit / Tirana / 1001 / AL) that the LocalBusiness editor pre-filled.
* The plugin no longer prints a second canonical tag alongside WordPress core's.
* Platform: published articles no longer carry their own LocalBusiness schema block (it duplicated, and conflicted with, the site-wide one).
* Fixed "medicalSpecialty" being added to LocalBusiness schema for non-medical businesses (e.g. a recycling company). The property is now only emitted for medical types (MedicalBusiness, Dentist, Physician, etc.); the editor field is labelled accordingly, and any already-saved schema with the property on a non-medical type is cleaned at output time.

= 1.7.9 =
* Added WPML and Polylang support: the sitemap now covers every language and emits hreflang alternates (with x-default); llms.txt and llms-full.txt label each entry with its language; schema output includes inLanguage; the platform sync reports each post's language_code; publish-post accepts a language parameter; and a wpml-config.xml copies the SEO meta to new translations.

= 1.7.8 =
* Fixed publishing from the platform crashing the WordPress site with a "critical error". The publish-post endpoint called wp_create_category(), an admin-only function that is not loaded in REST requests; categories are now created/looked up with the core term API (term_exists / wp_insert_term).

= 1.7.7 =
* Fixed "Auto-Fix All" lowering scores instead of raising them (e.g. AEO 84 -> 29). The platform was told to rewrite the post "in Markdown", but WordPress stores HTML -- so the AI returned literal Markdown (`## Heading`, `1. item`) that got saved as plain text, destroying the real `<h2>`/`<ol>`/`<blockquote>` tags the analyzer scores. The prompt now requires HTML output.
* Added a safety net: Auto-Fix All now compares SEO/AEO/GEO scores before and after the rewrite and automatically restores the original content if any score drops by more than 5 points.

= 1.7.6 =
* Fixed "Auto-Fix All" getting permanently stuck on "Fixing..." with no error or recovery. The AJAX request had no client-side timeout, so if the response was ever dropped or delayed past the server's own 60s AI-provider timeout, the button just sat there forever. Added a 90s client-side timeout that now surfaces a clear "Request timed out" error and re-enables the button.

= 1.7.5 =
* Fixed "The link you followed has expired" when clicking "Update Automatically Now" / the AJAX update-check flow. `wp_nonce_url()` HTML-escapes its output (`&` -> `&amp;`) for use in an `href` attribute, but `admin.js` was assigning it straight to `window.location.href`, so the browser navigated to the literal `&amp;` text and WordPress never found the `_wpnonce` parameter. Both call sites now decode the entities before the URL is used outside an HTML attribute.

= 1.7.4 =
* Fixed "Auto-Fix All" (per-post Action Plan tab) always failing with "AIVisibility SEO platform API key is not configured" on a fully connected site. It was reading the connection key from the wrong WordPress option (`aivision_settings`, used for feature toggles like robots/llms/schema) instead of the one the connection handshake actually saves it to (`aivision_seo_settings`).

= 1.7.3 =
* Added a 301 redirect manager (`set_redirect`/`remove_redirect` REST fix_types + a `template_redirect` hook) and a reversible "unpublish" action (`unpublish_post` -- sets to draft, never deletes) for the URL-cleanup phase of a site audit (retiring old/duplicate pages without losing content or breaking links unexpectedly).

= 1.7.2 =
* Added a `the_content` filter that actually renders the `direct_answer` and `faqs` meta (set via the `optimize_post` 1-Click Fix) onto the post as a visible blockquote and FAQ section. Previously these fields were only written to meta and read back for internal scoring -- applying that fix never changed what a visitor or AI crawler actually saw on the page.

= 1.7.1 =
* Added a `rename_post_title` REST fix_type (`wp_update_post` on title only, slug untouched) so the AIVisibility SEO dashboard can retitle already-published posts still using the old "The Complete..." template without a full content rewrite.

= 1.7.0 =
* Added a homepage AEO direct-answer block fix (`set_aeo_block` REST action, rendered via `wp_footer` on the front page) so the "Apply Automatically to WordPress" button in the AIVisibility SEO dashboard can push it live, not just copy/paste it.

= 1.6.9 =
* Added a "⚡ Auto-Fix All" button to the Action Plan tab -- rewrites the post's content via the AIVisibility SEO platform to address every open high/medium-priority check (headings, lists, direct-answer blockquote, keyword placement, etc.), then applies the update and refreshes the scores. Statistics/data-point requests are handled honestly: real named authorities may be cited for general facts, but no numbers are invented for this specific business.

= 1.6.8 =
* Fixed the publish-post endpoint dropping the "schemas" param entirely -- FAQPage and LocalBusiness JSON-LD generated by the platform was never actually saved to the post, so every published article scored 0 schemas in the GEO analyzer's multi-schema check regardless of what was sent.

= 1.6.7 =
* The publish-post endpoint now actually applies what the platform sends: categories (it previously read a "category" param that was never sent, so posts never got categorized), tags (previously not read at all), and SEO title/description/keyword (previously expected a nested shape the platform never sent).
* Added featured image support to the publish-post endpoint: accepts a generated image (base64) or a remote URL, sideloads/attaches it, and sets it as the post's featured image.

= 1.6.6 =
* Fixed 1-Click Fix admin actions (Generate Sitemap XML, llms.txt, robots.txt, etc.) showing the unhelpful message "Error generating [x]: error" whenever the AJAX request itself failed. Now shows the real HTTP status and response snippet (e.g. a 403 from a security plugin, a 500 from a PHP error, or a timeout) so the actual cause is visible instead of jQuery's generic "error" placeholder.

= 1.6.5 =
* Fixed "Unknown fix_type" errors on every 1-Click Fix / Auto-Fix All on WordPress action -- the AIVisibility SEO dashboard was calling this plugin's apply-fix endpoint with fix type names it never recognized, so schema, robots.txt, and llms.txt fixes always failed.
* Fixed the Schema.org 1-Click Fix silently doing nothing on the live site -- it saved settings that nothing ever read back out. Site-wide LocalBusiness/Organization/FAQPage JSON-LD now actually renders in the page head.
* Multiple site-wide schema types (e.g. LocalBusiness and FAQPage) can now be active at the same time instead of the latest one overwriting the other.

= 1.6.4 =
* Fixed a fatal PHP error in the /status and /telemetry REST endpoints on any request without a valid API token (hash_equals() was called with a non-string argument on PHP 8, crashing the site instead of returning a clean 401).
* Fixed telemetry sync calling a removed AIVision_Analyzer::analyze() method, which fatally crashed every /telemetry request since v1.6.2 -- content SEO/AEO/GEO scores were never actually reaching the AIVisibility SEO dashboard even though they computed correctly in the WordPress admin.

= 1.6.3 =
* Added native WordPress Core automatic updates integration with remote version checker.
* Direct integration with pre_set_site_transient_update_plugins and plugins_api for seamless 1-click updates.
* Enabled automated background updates via WordPress WP-Cron (auto_update_plugin).
* Added 1-Click "Check for Updates" button and "Auto-Updates Enabled" status badge in Settings.
* In-app admin update banner notifications when a new release is available on AIVisibility Cloud.

= 1.6.2 =
* Added dynamic version indicator badge next to plugin and cloud integration titles in admin settings.
* Enhanced UI clarity displaying active plugin release across all administration views.

= 1.6.1 =
* Rebranded all cloud integration interfaces, cards, and endpoints to AIVisibility SEO.
* Replaced BrandOS integration module with unified AIVisibility_Integration controller.
* Seamless migration preserving existing active API keys and connection tokens.
* Added bidirectional telemetry sync and remote fix dispatcher under AIVisibility SEO branding.

= 1.6.0 =
* Integrated autonomous AIVisibility SEO platform-side audit remediation with 1-click execution.
* Added Autonomous Content Autopilot execution engine with scheduled background sync via BullMQ.
* Added live REST bridge endpoint for bidirectional audit synchronization and status telemetry.
* Standardized version tracking registry (versions.json) and versioned zip distribution archives (aivision-seo-v1.6.0.zip).

= 1.5.0 =
* Streamlined GEO LLM Platform scoring to focus on OpenAI (ChatGPT/SearchGPT) and Google Gemini.
* Removed legacy Perplexity and Claude platform readiness cards to maintain parity with AIVisibility SEO SaaS platform.
* Updated AI crawler recommendations to prioritize GPTBot, OAI-SearchBot, and Google-Extended.
* Automated version control across plugin metadata and build artifact filenames.

= 1.4.1 =
* Added dynamic Content Optimization & Quality filter center to Dashboard.
* Filter content by Quality / Score Status (Low Quality < 50%, Needs Optimization, Fair 50-74%, Highly Optimized 75%+, Missing Schema, Missing Focus Keyword).
* Filter content by Post Type (Posts, Pages, or All).
* Sort content by Lowest Overall Score, Lowest SEO, Lowest AEO, Lowest GEO, Highest Score, or Latest Date.
* Live real-time title & keyword search with responsive counts and quick-filter pills.

= 1.4.0 =
* Streamlined Dashboard: unified Overview with 3-Pillar core stats, recent content optimization table, and actionable AEO/GEO guidelines.
* Removed legacy Auto-Pilot blog module and standalone Schema Generator page in favor of the direct in-editor visual and code schema builder on single post/page views.
* Enhanced asset versioning and cache busting for instant live admin updates.

= 1.3.0 =
* Full 3-Pillar Content Analysis (SEO, AEO, GEO) with real-time SVG circular scoring gauges.
* Added Prioritized Action Plan ("What to Do") with actionable High, Medium, and Good recommendations.
* Added 1-Click Auto-Optimized `robots.txt` generator and preview for top AI bots and search engines.
* Added `/llms.txt` and dynamic `/llms-full.txt` feeds conforming to the llmstxt.org standard.
* Added SEO, AEO, and GEO score columns to standard WordPress "All Posts" and "All Pages" list tables.
* Added generator tag removal hook, default robots fallback, and automatic featured image OpenGraph fallback.
* Added UTF-8 multibyte character support and phrase-weighted keyword density analysis.
* Hardened post meta saving against autosaves and revisions, and ensured clean schema deletion.

= 1.2.0 =
* Added AI Auto-Pilot generator and schema enhancements.
* Added support for Applebot-Extended, OAI-SearchBot, and Claude-Web crawler directives.

= 1.1.0 =
* Added dynamic XML Sitemap and robots.txt preview tool.
* Added OpenGraph and Twitter Card social preview metadata.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.4.1 =
Added dynamic Content Optimization & Quality filtering and sorting to the Dashboard with real-time search and quality status pills.
