=== MEGA AI ===
Contributors: MEGA
Tags: seo, ai, automation, content management, api
Requires at least: 4.4
Tested up to: 6.8
Stable tag: 1.7.0
Requires PHP: 7.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Plugin URI: https://gomega.ai

Connect your WordPress website to MEGA's AI-powered SEO platform for automated content optimization and growth.

== Description ==

MEGA is an AI-powered growth platform that automates SEO and content management for your WordPress website. This plugin enables MEGA's AI agent "Lindsay" to manage your content, optimize for search engines, and continuously improve your site's performance - all without manual intervention.


**Get started at [gomega.ai](https://gomega.ai/seo)**

= What MEGA Does =

MEGA provides a fully managed SEO service that automates end-to-end SEO processes, delivering enterprise-level optimization at a fraction of the cost. Our AI agents work 24/7 to research, strategize, and execute SEO tasks that typically require a full marketing team.

= Key Benefits =

* **AI-Powered Content Creation**: Automatically generates and publishes SEO-optimized content
* **Continuous Optimization**: Real-time content updates based on Google Search Console data
* **Technical SEO Automation**: Automated audits, fixes, and performance improvements
* **Keyword Research & Strategy**: AI-driven keyword discovery and implementation
* **Link Building**: Automated backlink acquisition and management
* **Conversion Rate Optimization**: Improves user engagement and conversions
* **Local SEO**: Optimizes for local search visibility
* **LLM Placement**: Optimizes content for AI search engines and featured snippets

= How It Works =

1. Install and activate the MEGA plugin
2. Connect your WordPress site to MEGA's platform
3. Our AI agent Lindsay begins analyzing your site
4. Content is automatically created, optimized, and published
5. Continuous monitoring and optimization improve results over time

= Features =

* **Secure Authentication**: Military-grade encryption ensures only authorized MEGA agents can access your site
* **Full Content Management**: Create, update, and optimize posts automatically
* **SEO Plugin Integration**: Works seamlessly with Yoast SEO, Rank Math, and All in One SEO (AIOSEO)
* **Autopilot Mode**: 85% of users enable full automation for 2x faster results
* **Multi-Platform Support**: Integrates with 50+ platforms beyond WordPress
* **Performance Tracking**: Comprehensive analytics and reporting
* **Human Oversight**: Complex tasks reviewed by SEO experts when needed

= Expected Results =

Most users see organic traffic growth within 3 to 9 months. MEGA's AI continuously learns and improves, providing ongoing optimization that adapts to search engine changes.

Learn more on our [website](https://gomega.ai/seo).

== External Services ==

This plugin connects to MEGA's external service to provide AI-powered SEO optimization for your WordPress website.

= MEGA SEO Platform =

The plugin communicates with MEGA's platform (gomega.ai) to enable automated SEO optimization and content management. This connection is essential for the core functionality of the plugin.

**What data is sent**: The plugin sends website content, metadata, and site configuration information to MEGA's platform for analysis and optimization.

**When data is sent**: Data is transmitted when MEGA's AI agents perform content creation, updates, or SEO optimization tasks on your behalf.

**Purpose**: This data exchange enables MEGA's AI to analyze your site, generate SEO-optimized content, track performance, and continuously improve your website's search engine rankings.

**Service provider**: [MEGA](https://gomega.ai) (gomega.ai)
[Terms of Service](https://www.gomega.ai/legal/terms-of-use)
[Privacy Policy](https://www.gomega.ai/legal/privacy-policy)

By using this plugin, you acknowledge that your website data will be processed by MEGA's platform in accordance with their terms of service and privacy policy.

== Installation ==

1. Create your MEGA account at [gomega.ai](https://gomega.ai/pricing)
2. Upload the `mega-ai` folder to the `/wp-content/plugins/` directory
3. Activate the plugin through the 'Plugins' menu in WordPress
4. In your MEGA dashboard, add new feed from media accounts and select WordPress
5. Our agents will automatically connect to your WordPress site and begin optimization

== Configuration ==

After creating your MEGA account and installing this WordPress plugin, our agents will automatically be able to access your WordPress and optimize it.

No manual configuration required - just install the plugin and our AI agents handle the rest!

== Frequently Asked Questions ==

= What is MEGA? =

MEGA is an AI-powered SEO platform that uses intelligent agents to automate your entire SEO strategy. Our AI agent "Lindsay" handles keyword research, content creation, technical SEO, link building, and continuous optimization - delivering results that typically require a full marketing team.

= How much does MEGA cost? =

MEGA's SEO service starts at $999/month (or $799/month billed annually). This includes full SEO automation, unlimited content updates, and all features. Learn more at https://gomega.ai/pricing

= Is this plugin secure? =

Yes, the plugin uses military-grade RSA encryption with public/private key cryptography. Only MEGA's authorized AI agents can access your site, and all communications are cryptographically signed and verified.

= What can MEGA's AI do with my WordPress site? =

MEGA can:
- Create new SEO-optimized blog posts and pages
- Update existing content based on performance data
- Optimize meta titles and descriptions
- Fix technical SEO issues
- Manage internal linking
- Track and improve keyword rankings
- Monitor competitor strategies
- And much more, all automatically

= Does it work with my SEO plugin? =

Yes, MEGA seamlessly integrates with Yoast SEO, Rank Math, and All in One SEO (AIOSEO), enhancing rather than replacing their functionality.

= How long until I see results? =

Most users see organic traffic growth within 3 to 9 months. MEGA works continuously, and results compound over time as the AI learns your market and optimizes your content.

= Can I review content before it's published? =

Yes! You can choose between full autopilot mode (85% of users) for fastest results, or review mode where you approve content before publication.

= Will it affect my site's performance? =

No, the plugin is lightweight and only adds a small optimization script. All heavy processing happens on MEGA's servers, not your WordPress site.

= Can I use this with other CMS platforms? =

Yes, MEGA supports 50+ platforms including Shopify, Webflow, Wix, HubSpot, and more. This plugin is specifically for WordPress integration.

== Changelog ==
= 1.7.0 =
* Feature: builder-aware widget edit surface. New `GET /mega/v1/editor/widgets/<id>`, `PATCH /mega/v1/editor/widgets/<id>/<widget_id>`, and `POST /mega/v1/editor/revisions/<id>/restore` endpoints expose a unified scalar-edit API across Elementor, Gutenberg, and Classic WP. The plugin auto-detects which page builder owns each post and dispatches to the matching `MegaEditorAdapter`. Every `PATCH` snapshots a WP revision first so the MEGA bot CLI can issue a single-call `undo` after a bad edit. Elementor support is pinned to major version <= 3 as a safety guard. Returns 404 with `code: editor_builder_unsupported` when an unknown builder is detected so callers can fall back gracefully.

= 1.6.2 =
* Feature: `?diagnostic=1` query param on `POST /mega/v1/pages/<id>`. When set, skips the `mega_managed=1` postmeta write so the MEGA SEO platform's CMS diagnostic worker can run a non-destructive page text-revert probe on a customer's most-recent published page without permanently tagging it as MEGA-owned. No effect on production write paths (which call without the flag); the platform's diagnostic Inngest worker passes `diagnostic=1` and the bot's normal publishing code does not.

= 1.6.1 =
* Removed self-update mechanism to comply with WordPress.org Plugin Directory guideline #8 (no loading executable code from external sources). Updates now flow exclusively through the WordPress.org plugin directory. No functional changes to /pages, /cache/flush, or any other endpoint shipped in 1.6.0.

= 1.6.0 =
* Feature: dedicated `/mega/v1/pages` REST surface — `GET|POST /mega/v1/pages` (list/create) and `GET|PUT|DELETE /mega/v1/pages/<id>` (read/update/delete) pinned to `post_type=page`. Mirrors the existing `/posts` handler shape (same response keys, same `meta` / `schema_jsonld` / `seo_title` / `meta_description` write semantics) so platform clients can use one parser for both. Returns 404 if the requested ID is not a page so callers can't accidentally mutate a post via the pages route. Unblocks the CMS diagnostic worker's page-revert probe and the page on-page-SEO bot path, both of which previously had to fall back to direct WP REST + Basic Auth.
* Feature: `POST /mega/v1/cache/flush` — purges Yoast indexables, Rank Math sitemap, WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache, and WP core object cache. Each backend is detected at runtime and wrapped in try/catch so a mis-behaving cache plugin can't cascade-fail the whole flush. Optional `post_id` param scopes WP-core post-cache invalidation to a single post. Returns a `{cleared: {...}}` summary so callers can log which backends fired. Lets writer pipelines force-revalidate freshly-written content/meta without waiting on each cache backend's natural TTL.

= 1.5.2 =
* Maintenance release: republish of 1.5.1 to refresh the WordPress.org plugin directory metadata. No code change vs 1.5.1 — the schema-adapter fix below is the substantive change customers should care about. (1.5.1 was committed to SVN but the WordPress.org directory's metadata-refresh pipeline did not pick it up; 10up's deploy action refuses to re-push an already-tagged version, so a new tag is required to nudge the directory.)

= 1.5.1 =
* Fix: per-page JSON-LD schema for body-bearing `@type` values now persists with its full body on Yoast and AIOSEO sites.
  * Yoast: `FAQPage` and `QAPage` are no longer promoted to `_yoast_wpseo_schema_page_type` (the bare-`@type` slot). They fall through to the existing extras path (`_mega_yoast_schema_extra`) so `mainEntity` (questions/answers) is preserved.
  * AIOSEO: `FAQPage`, `Recipe`, `Product`, `ProductReview`, `Course`, `Dataset`, `Movie`, `Service`, `Car`, `SoftwareApplication`, `HowTo`, and `Person` are no longer promoted to `wp_aioseo_posts.schema.default.graphName`. They fall through to extras (`_mega_aioseo_schema_extra`) so `mainEntity` / `recipeIngredient` / `offers` / `jobTitle` / `worksFor` / etc. are preserved.
  * Both extras paths render verbatim via the existing `wpseo_schema_graph` / `aioseo_schema_output` filters — the same path `Organization` and `BreadcrumbList` have used since 1.3.0.
  * Previously these types were reduced to a bare `{"@type":"…"}` on storage and the host SEO plugin rendered an empty stub node.
  * No-op for Rank Math sites (its adapter already wrote full bodies per `@type`).
  * No-op for `Article` / `WebPage` / `BlogPosting` / `NewsArticle` on either adapter — those keep using native promotion because the host plugin reconstructs their body from the WP post record.

= 1.4.0 =
* Feature: AIOSEO (All in One SEO) schema adapter — `GET|PUT|DELETE /mega/v1/posts/<id>/schema` now works on sites running AIOSEO Lite or Pro, in addition to Rank Math and Yoast.
  * The first JSON-LD node whose `@type` matches an AIOSEO-known graph (Article, BlogPosting, NewsArticle, WebPage, FAQPage, Product, Recipe, Service, Person, Course, Dataset, Movie, ProductReview, Car, SoftwareApplication) is promoted to `wp_aioseo_posts.schema.default.graphName` and shows up in AIOSEO's post-editor schema metabox.
  * Remaining nodes are stashed in `_mega_aioseo_schema_extra` and merged into AIOSEO's rendered `@graph` at request time via the official `aioseo_schema_output` filter — same extension pattern Yoast uses.
  * A sentinel postmeta key (`_mega_aioseo_default_owner`) tracks which `default.graphName` slot we own so we never overwrite a manual selection a customer made in the AIOSEO metabox.
  * AIOSEO's user-authored `graphs[]` and `customGraphs[]` arrays are read but never written by this plugin — they remain entirely under customer control.
* Feature: AIOSEO SEO title and meta description support — `seo_title` and `meta_description` on `GET|POST|PUT /mega/v1/posts[/<id>]` now read from and write to the `wp_aioseo_posts.title` / `wp_aioseo_posts.description` columns when AIOSEO is the active SEO plugin.
* Updated: `mega_schema_no_seo_plugin` error message now mentions AIOSEO alongside Rank Math and Yoast.

= 1.3.0 =
* Feature: per-post JSON-LD schema via host SEO plugin (Rank Math / Yoast).
  * New endpoints `GET|PUT|DELETE /mega/v1/posts/<id>/schema` and inline `schema_jsonld` field on `POST|PUT /mega/v1/posts[/<id>]`. REPLACE-ALL semantics — read before writing to preserve.
  * Rank Math adapter writes one `rank_math_schema_<Type>` post meta row per JSON-LD node; Rank Math renders them as part of its native schema graph and they appear in the Rank Math editor UI.
  * Yoast adapter maps page-type / article-type nodes to `_yoast_wpseo_schema_page_type` / `_yoast_wpseo_schema_article_type` (visible in the Yoast UI). Nodes that don't fit those selectors are stashed in `_mega_yoast_schema_extra` and rendered into Yoast's runtime graph via the `wpseo_schema_graph` filter.
  * `GET /mega/v1/posts` accepts a new `post_type` query parameter (single, comma-separated list, or `any`) and a free-text `search` parameter so the platform can enumerate pages and custom post types, not just blog posts.
* Removed: the `_mega_jsonld_schema` self-rendered `wp_head` injection shipped in 1.2.2. Replaced by the adapter above so the host SEO plugin owns rendering — avoids duplicate `<script type="application/ld+json">` tags and makes schema visible in Yoast / Rank Math UIs. The `_mega_jsonld_schema` post_meta key is no longer read; legacy values can be removed with `DELETE /mega/v1/posts/<id>/schema` after migrating to the new path.

= 1.2.2 =
* Feature: render bot-managed JSON-LD schema in `<head>` on singular views. Reads the `_mega_jsonld_schema` post_meta key (written through the existing `meta:{}` field on `POST /mega/v1/posts/<id>`) and emits it as `<script type="application/ld+json" data-mega-managed="1">` at `wp_head` priority 99. Lets the MEGA platform deploy LocalBusiness / RealEstateAgent / FAQ / Service schema on sites that don't have Yoast or Rank Math controlling the relevant schema type. A site-wide schema slot is planned for a follow-up release.

= 1.2.1 =
* Compatibility: defer Prism's `template_redirect` hook to priority 20 so plugins like WP Fusion (default priority 10) can run their auth and membership gates first. Prevents authenticated users from being redirected away from archive pages on sites that gate content via `template_redirect`.

= 1.1.1 =
* Maintenance release

= 1.1.0 =
* New Feature: Prism - Reverse proxy functionality
* Serve external content through your WordPress site with configurable routes
* Support for custom headers per route
* Intelligent caching with configurable TTL
* Admin UI for managing proxy routes

= 1.0.8 =
* Bug fixes

= 1.0.7 =
* Fixed WordPress coding standards compliance
* Added proper cache headers to REST API responses
* Tweaks and improvements

= 1.0.0 =
* Initial release
* Secure authentication system
* Full REST API for content management
* SEO plugin integration (Yoast & Rank Math)
* Embed preservation support
* Webhook support for cache invalidation
* MEGA optimizer script injection

== Upgrade Notice ==
= 1.6.2 =
Adds `?diagnostic=1` opt-in flag on `POST /mega/v1/pages/<id>` for non-destructive page probes. Purely additive — no change to existing write semantics. Production write paths are unaffected.

= 1.6.1 =
Removes self-update mechanism for WordPress.org compliance. No functional or endpoint changes.

= 1.6.0 =
Adds dedicated `/pages` REST endpoints (list/get/create/update/delete) and a `/cache/flush` endpoint that purges Yoast, Rank Math, WP Rocket, W3TC, LiteSpeed, WP Super Cache, and WP core object cache. Purely additive — no behavior change to existing routes. Auto-installs via the plugin's self-update mechanism.

= 1.5.2 =
Republish of 1.5.1 with no code changes. If you are on 1.5.1 already, this update is purely cosmetic — it exists so the WordPress.org plugin directory listing reflects the 1.5.1 schema-adapter fix described below.

= 1.5.1 =
Fixes per-page JSON-LD schema for body-bearing `@type` values on Yoast (FAQPage, QAPage) and AIOSEO (FAQPage, Recipe, Product, Person, HowTo, …) sites — their full body (`mainEntity`, `recipeIngredient`, `offers`, `jobTitle`, …) is now preserved end-to-end instead of being reduced to an empty stub. No behavior change for `Article` / `WebPage` / `BlogPosting` / `NewsArticle` on either adapter, for Rank Math sites, or for sites with no SEO plugin. No customer action required — the MEGA platform's self-update mechanism (introduced in 1.5.0) rolls this version to managed sites automatically.

= 1.4.0 =
Adds full AIOSEO (All in One SEO) support: per-page JSON-LD schema, SEO titles, and meta descriptions now route through AIOSEO's native storage on sites that use it. Purely additive — no behavior change for sites running Rank Math, Yoast, or no SEO plugin.

= 1.3.0 =
**Behavior change** for sites running 1.2.2: the legacy `_mega_jsonld_schema` post meta + `wp_head` injection is **removed** in 1.3.0. Per-page JSON-LD schema now routes through Rank Math or Yoast SEO via a new adapter (visible in their native editor UIs, no duplicate `<script type="application/ld+json">` tags). Any schema previously stored only in `_mega_jsonld_schema` will stop rendering after upgrade until it is rewritten through the new `GET|PUT|DELETE /mega/v1/posts/<id>/schema` endpoint, which the MEGA platform handles automatically for managed sites on the next bot pass.
