=== 1Platform Content AI – AI Blog Writer, SEO & Internal Linking for WordPress ===
Contributors: 1platform
Tags: ai content, ai writer, seo, internal links, keyword research
Requires at least: 5.9
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 2.35.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI blog post generator with SEO meta, keyword research, internal linking, tables of contents, and guided site setup — cloud-powered.

== Description ==

1Platform Content AI connects your WordPress site with the [1Platform](https://1platform.pro) cloud platform to bring AI-powered content creation and optimization tools directly into your admin dashboard.

**How it works:** The plugin acts as a client interface to the 1Platform API. All AI processing (content generation, keyword extraction, image selection, comment generation) happens securely on 1Platform external servers via encrypted HTTPS communication. You connect your site using an API key, and the plugin handles the rest.

**Free local tools** (no API key required): Table of Contents and Internal Links work entirely on your WordPress site without any external service connection.

= What You Can Do =

* **Generate blog posts with AI** — Create complete, SEO-optimized articles with images and metadata from target keywords. Content is generated by the 1Platform cloud service and published to your WordPress site.
* **Extract keywords from competitors** — Analyze competitor websites to discover valuable keywords for your content strategy. Extraction is performed by the 1Platform service.
* **Automate internal linking** — Automatically build internal link relationships between your posts to improve SEO and navigation. (Local feature, no API key required.)
* **Add tables of contents** — Automatically generate and insert hierarchical tables of contents into your posts. (Local feature, no API key required.)
* **Set up an entire site in minutes** — Use the Site Wizard to configure your theme, generate content, create legal pages, and set up integrations in one guided workflow.
* **Monitor background jobs** — Track all content generation and processing tasks in real time from a dedicated job dashboard.
* **Manage your posts in bulk** — Optimize and maintain existing posts with batch operations.
* **Generate comments** — Create AI-powered comments for your blog posts via the cloud service.
* **Create legal pages** — Generate privacy policy, terms of service, and other legal pages with a cookie consent banner.

= Integrations =

* **Google Analytics** — Connect your GA4 property with OAuth2 and inject the tracking tag with GDPR Consent Mode v2 (analytics denied by default until user consent).
* **Google Search Console** — Connect your site to Google Search Console through 1Platform to pull performance data.
* **Publisuites** — Connect your website to Publisuites to explore content monetization opportunities.
* **Ads Manager** — Configure your AdSense publisher ID, auto-generate your ads.txt file, and inject custom header code.

= SaaS & Data Processing =

1Platform Content AI is a SaaS (Software as a Service) plugin. This means:

* The plugin connects your WordPress site to the **1Platform** cloud platform.
* AI content generation, keyword extraction, and other processing happen on **1Platform external servers**, not on your WordPress hosting.
* An **API key** is required to authenticate your site with the platform for cloud features. Without an API key, all admin pages are accessible and display a connection prompt. Local features (TOC, Internal Links) work without any API key.
* All communication between your site and 1Platform uses **secure HTTPS encryption**.
* The plugin **does not expose any public endpoints** on your WordPress site.
* Your WordPress installation acts solely as the **client interface** — no modifications are made to WordPress core files.
* No data is transmitted to any external service until you configure your API key and explicitly trigger a feature.

By using the cloud features of this plugin, you agree to the 1Platform [Terms of Service](https://1platform.pro/terms) and [Privacy Policy](https://1platform.pro/privacy).

== External Services ==

This plugin relies on the following external services:

= 1Platform Content AI API =

This plugin connects to the 1Platform Content AI service for all AI-powered features. No AI processing occurs locally — the plugin sends requests and receives processed results.

**Service URL:** https://api.1platform.pro/api/v1
**Website:** https://1platform.pro

**Data sent:**
* API key (for authentication)
* Site URL and metadata (domain, language, category)
* Content prompts, keywords, and language preferences (for content generation)
* Competitor URLs (for keyword extraction)
* Image prompts or keywords (for image generation/selection via Pexels/Pixabay proxy)
* Post title and content snippets (for comment generation)
* Owner name and site niche (for profile generation)
* User ID (for billing and subscription management)

**When data is sent:**
* On authentication: when verifying your API key and obtaining access tokens
* On content generation: when you click "Generate" for posts, keywords, comments, images, or legal pages
* On site wizard: when using the automated site setup workflow
* On integration setup: when connecting Google Search Console or Publisuites
* On billing: when checking credit balance or initiating top-ups

**Image and profile downloads:** The 1Platform API returns image URLs (for post featured images, site icons, and author profile pictures) as part of its responses. The plugin downloads these images from the URLs provided by the API and saves them to your WordPress Media Library using the WordPress `download_url()` function. These URLs point to resources hosted or proxied by 1Platform (including images from Pexels or Pixabay when selected as image provider). No additional data beyond the standard HTTP request is sent during these downloads.

**Data retention:** See the 1Platform privacy policy for data retention details.

* Terms of Service: https://1platform.pro/terms
* Privacy Policy: https://1platform.pro/privacy

= Google AdSense (Optional) =

When configured, the plugin loads Google AdSense scripts from https://pagead2.googlesyndication.com to display advertisements on your site's front-end pages.

**Data sent:** Publisher ID embedded in the script tag. Google's script may collect page content and visitor data per Google's policies.
**When sent:** On every front-end page load when an AdSense publisher ID is configured in the Ads Manager.
**No data is sent unless you explicitly configure a publisher ID.**

* Terms of Service: https://www.google.com/adsense/new/localized-terms
* Privacy Policy: https://policies.google.com/privacy

= Pexels / Pixabay (Via 1Platform API) =

When generating content with images, you can choose Pexels or Pixabay as the image provider. Image requests are routed through the 1Platform API — the plugin does not connect to these services directly. No direct connection from your WordPress site to Pexels or Pixabay occurs.

* Pexels Terms: https://www.pexels.com/terms-of-service/
* Pixabay Terms: https://pixabay.com/service/terms/

== Installation ==

1. Upload the plugin folder to the `/wp-content/plugins/` directory, or install it directly through the WordPress plugin screen.
2. Activate the plugin through the "Plugins" screen in WordPress.
3. Navigate to **1Platform Content AI > License** in your admin menu.
4. Enter your API key from [1platform.pro](https://1platform.pro) to connect cloud features.
5. Local features (Table of Contents, Internal Links) work immediately without an API key.
6. Once connected, configure your site settings under **Settings** (topic, language, category, and theme).
7. Start generating content from the **Content** menu or use the **Site Wizard** for a guided full-site setup.

== Frequently Asked Questions ==

= What is 1Platform? =

1Platform is a cloud platform that provides AI-powered content generation and optimization tools for WordPress websites. The plugin connects your site to this platform so you can manage everything from your WordPress dashboard.

= Does it require an API key? =

Only for cloud features (content generation, keyword extraction, etc.). You need an API key from [1platform.pro](https://1platform.pro) to use these features. Local features like Table of Contents and Internal Links work independently without any API key.

= Where is my data processed? =

All AI processing (content generation, keyword extraction, etc.) happens on 1Platform external servers. Your WordPress site sends requests over secure HTTPS and receives the results. No AI processing runs on your hosting server. Table of Contents and Internal Links process data locally on your server.

= Is my content secure? =

Yes. All communication between your site and 1Platform uses HTTPS encryption. The plugin follows WordPress security best practices: nonce verification for all forms, capability checks for admin access, and input sanitization and output escaping throughout.

= Does it modify WordPress core? =

No. The plugin does not modify any WordPress core files. It uses standard WordPress APIs, hooks, and database tables with a custom prefix.

= Does it work with any theme? =

Yes. 1Platform Content AI is theme-independent and works with any properly coded WordPress theme. Features like Table of Contents and Internal Links are injected into post content using standard WordPress filters.

= What are background jobs? =

Content generation and other tasks run as background jobs processed by WordPress cron. The Job Monitor page lets you track the status of all tasks in real time, including pending, processing, completed, and failed jobs.

= What data is sent to external services? =

The plugin sends your site URL, API key, and content generation parameters (keywords, language, image provider) to the 1Platform API over HTTPS. If you configure Google AdSense, the AdSense script is loaded on your front-end. No data is sent to any external service without your explicit configuration. See the "External Services" section for full details.

== Screenshots ==

1. Content Generator — Generate AI-powered blog posts from target keywords.
2. Keyword Extractor — Analyze competitor sites and extract valuable keywords.
3. Site Wizard — Set up your entire site with a guided step-by-step workflow.
4. Job Monitor — Track all background tasks in real time.
5. Internal Links — Configure automatic internal linking between posts.
6. Table of Contents — Automatic TOC generation settings.
7. Tools — Google Analytics, Google Search Console, Publisuites, and Ads Manager integrations.

== Changelog ==

= 2.35.1 =
* Changed: Site Wizard now sets `posts_per_page` to 15 (raised from 10) so generated sites surface more entries per blog/archive page out of the box. Existing sites are unaffected (#112)
* Added: Regression test pinning the new default

= 2.34.2 =
* Fixed: Missing CSS on Tools panels (Internal Links, Publisuites, Search Console, AdSense Account) after the UI redesign — assets now enqueue per-screen on the Apps pages (#111)
* Added: Regression tests for Admin Apps asset enqueue

= 2.34.1 =
* Fixed: Missing component styles on apps panel and stale readme assets after the UI redesign rollout (#108)

= 2.34.0 =
* Changed: Full admin UI redesign — 12 screens migrated to the new design system (Jobs, Settings, Post Generator, Site Wizard, Billing Overview, Billing History, Keyword Extractor, Keywords List, License, Logs, Post Maintenance, Legal Pages)
* Added: Design token + component CSS foundation (27 scoped components, Toast/Modal/Table helpers) now active on all admin screens, no feature flag
* Removed: Legacy per-screen CSS files (~17K lines) replaced by unified component library
* Removed: Beta UI toggle, `contai_ui_v3` user meta/site option, and legacy Jobs panel split (#106)

= 2.33.0 =
* Changed: Jobs screen migrated to the new design system (page header, stat cards, underline tabs, status/priority badges) behind an opt-in beta toggle
* Added: Smoke test asserting the v3 panel wrapper is present only when the beta flag is enabled (#105)

= 2.32.0 =
* Added: Design token CSS (colors, type, spacing, radii, shadows) and component CSS foundation (buttons, panels, tables, notices) behind an opt-in beta toggle in Settings
* Added: Vanilla JS helpers for Toast, Modal, and Table interactions (no jQuery)
* Added: `contai_ui_v3_enabled()` flag resolver (user meta > site option) and `contai_enqueue_ui_v3()` helper (#104)

= 2.31.4 =
* Fixed: Content generation rejected with 422 — plugin now sends the API-expected image_provider aliases (default/alternative) at the boundary instead of internal identifiers
* Fixed: Site Wizard showed "Request failed" with no HTTP status when upstream returned a non-JSON error — fallback now includes the status code so timeouts and gateway errors are distinguishable (#100)

= 2.30.1 =
* Fixed: Post Generation jobs stuck in Processing status indefinitely — now catches all PHP error types and properly escalates to Failed after max retries (#86)

= 2.28.4 =
* Fixed: Cookie banner displayed buttons but no informative text when cookie text option was never explicitly saved (#85)

= 2.27.1 =
* Fixed: WP 6.9 sanitize_callback crash on onboarding REST route (floatval argument count)
* Fixed: Agent sync cron crash when API returns WP_Error
* Fixed: Onboarding now uses app-only auth (no user token required before account exists)
* Fixed: Payment link shown as clickable link instead of blocked popup
* Fixed: Session recovery preserves payment URL across page reloads
* Changed: Simplified amount selector to preset $5/$10/$25 buttons
* Changed: Added cancel button to polling state

= 2.21.8 =
* Fixed: Post Maintenance actions not working — refactored to process form in constructor (#72)
* Fixed: Wrong timezone on randomized dates, stale post cache, SSRF risk in thumbnail extraction
* Added: 14 regression tests for post maintenance panel

= 2.21.6 =
* Fixed: Site Wizard stuck at 58% on waitForPosts — failed jobs now count as finished (#69)
* Added: 4 regression tests for batch status with failed jobs

= 2.21.4 =
* Fixed: TOC theme selection not applied on frontend — added page cache purging on settings save (#71)
* Fixed: Misleading "Failed to save" error when saving unchanged settings
* Fixed: CSS cache busting broken due to incorrect path calculation in getAssetVersion
* Added: 19 unit tests for TOC settings panel, integration, and configuration

= 2.21.2 =
* Fixed: Plugin updates not applying until uninstall and reinstall (#68)
* Fixed: Stale browser cache after updates — assets now use dynamic version
* Added: Automatic upgrade routine that runs migrations and re-registers crons on update

= 2.20.0 =
* Added: Sponsored post orders management — view, accept, reject, reopen orders from the admin panel
* Added: Submit delivery URLs for orders awaiting content
* Added: Manual sync button to fetch latest marketplace orders
* Added: Paginated order list with status badges and action buttons
* Removed: One-click setup plan document (implemented)

= 2.18.0 =
* Added: SEO alt text on all images uploaded by the content pipeline (#49)
* Added: Meta description output via wp_head for generated posts (#49)
* Added: SEO title tag override using AI-generated metatitle (#49)
* Added: Auto-generated post excerpts for meta description support

= 2.17.3 =
* Fix: Featured image dedup no longer falls back to first image when all candidates are used — skips featured image to avoid duplication (#47)
* Fix: Featured image source URL claimed before upload to prevent race conditions in concurrent jobs
* Added: Regression test for upload failure cleanup

= 2.17.1 =
* Fix: Site Wizard re-execution now shows failed job error details instead of silently returning to form (#55)
* Fix: Website record ensured before API-dependent steps (tagline, theme tracking) (#55)
* Fix: Profile cache cleared on re-execution for fresh widget generation (#55)
* Added: 8 regression tests for re-execution visibility

= 2.16.0 =
* Added: Featured image deduplication — post generation avoids reusing the same featured image across posts
* Added: Optimized dedup query scoped to candidate URLs for performance at scale

= 2.15.5 =
* Fix: Site Wizard "Launch Site Generation" silently refreshing without action (#54)
* Fix: Nonce expiration now shows friendly "session expired" message instead of blank page
* Changed: Error messages now use WordPress transients for reliable delivery
* Added explicit form action URL to prevent POST target ambiguity

= 2.15.1 =
* Fixed Site Wizard not generating complete navigation (menu, breadcrumbs, comments)
* Integrated MainMenuManager to auto-create primary menu with Home + categories
* Added breadcrumb configuration for 8 supported themes
* Enabled comments on new posts by default

= 2.14.0 =
* Added breadcrumb defaults for 8 supported themes during site generation
* Added navigation setup step in Site Wizard (auto-creates menu from categories)
* Added default comment status set to open during site generation
* Fix: Batch completion hang when total=0 (Site Wizard waitForPosts)

= 2.13.0 =
* Added AdSense Account management tab in Ads Manager with OAuth connect/disconnect flow
* Added 11 REST endpoints for AdSense integration (earnings, sites, alerts, policy issues)
* Added earnings overview display and publisher ID auto-sync
* Fix: Delete confirmation dialog now works (was dead data-confirm attribute)
* Fix: Period parameter validation on earnings endpoint
* Fix: Graceful handling of non-JSON server error responses in JS

= 2.12.2 =
* Changed: Renamed "Link Building" to "Publisuites" in Tools sidebar menu, page title, apps panel, and logs adapter

= 2.12.0 =
* Added Google Analytics panel with full OAuth2 connection flow and 3-step visual wizard
* Added GA4 tag injection with GDPR Consent Mode v2 (analytics denied by default)
* Added custom dimensions and server-side events via Measurement Protocol
* Added BackfillAnalyticsMeta migration for existing posts
* Fix: Server event error handling and event idempotency

= 2.11.4 =
* Added one-click link building setup (unified 3-step flow into single click)
* Fix: Removed provider name exposure from client-facing UI strings

= 2.11.2 =
* Fix: Job queue stuck in PENDING when WP-Cron event is lost — added self-healing cron re-registration
* Added immediate job processing trigger via spawn_cron()

= 2.10.6 =
* Added 38 unit tests for admin form handlers (billing, link building, keyword extraction, and content queue)

= 2.10.5 =
* Fix: Orphan agent cron event not cleared on plugin uninstall
* Fix: Job processor deactivation not clearing all scheduled instances

= 2.10.3 =
* Fix: Site Wizard categories not loading after previous attempt due to double-encrypted API key

= 2.10.2 =
* Fix: Site Wizard ignoring language selection — language now correctly mapped from form field

= 2.10.1 =
* Fix: Stale auth error banner persisting after connection recovery
* Added error auto-clearing on successful connection validation

= 2.9.1 =
* Fix: AdSense setup failures no longer crash the entire site generation job

= 2.9.0 =
* Changed Search Console to one-click setup (unified 3-step manual flow into single click)

= 2.8.0 =
* Added topic-based keyword extraction (replaces domain URL input)
* Changed Site Generator to use topic-based extraction for keyword discovery
* Fix: AdSense publisher ID now saved immediately on form submission

= 2.6.0 =
* Added category-based theme auto-selection from API recommended themes
* Added theme defaults per theme (OceanWP, GeneratePress, ColorMag, Newsmatic)
* Added auth token retry on null and license activation retry
* Changed default theme to Astra
* Fix: Crypto fallback for legacy unencrypted keys

= 2.5.0 =
* Version bump

= 2.4.0 =
* Added AI Agent platform integration with full WordPress admin UI
* Added Agents admin page, API service, REST controller, settings and sync services
* Added agent actions cron for polling and processing pending actions
* Fix: Empty arrays now encode as objects in JSON request bodies for API compatibility

= 2.3.5 =
* Fix: BillingHistoryPanel now shows the correct merchant currency instead of hardcoding USD when usd_amount is present

= 2.3.4 =
* Added client-side logging system (ContaiClientLogReporter, Logs admin panel)
* Added API trace ID propagation for error traceability

= 2.3.3 =
* Fix: Search Console Disconnect Website now properly deletes the website from the 1Platform API before clearing local state
* Fix: Corrupted string literals showing "ContaiKeyword" instead of "Keyword" in user-facing messages
* Fix: 288 broken unit tests from class name mismatches after Contai prefix rename

= 2.3.1 =
* Migrated all admin menu slugs and screen IDs from `wpcontentai-` to `contai-` for consistent prefixing
* Prefixed all post meta keys with `contai_` to prevent naming collisions (`_seo_metatitle`, `_lp_*`)
* Added External Services disclosure for image and profile downloads via the 1Platform API
* Removed unnecessary `include_once` of `wp-admin/includes/misc.php`; changed remaining core includes to `require_once`
* Updated stale API URLs in code comments to `api.1platform.pro`
* Added `esc_attr()` escaping on dynamic HTML class attributes
* Converted unprepared SQL queries to use `$wpdb->prepare()` in APILogRepository and uninstall cleanup
* Removed duplicated transient cleanup queries in uninstall.php

= 2.3.0 =
* Rebranded to 1Platform Content AI
* All function, option, and hook prefixes migrated to `contai_` for WordPress.org compliance
* Removed admin hard-gating: all menu pages are now accessible without an API key
* Pages display a connection prompt (CTA) when not connected instead of redirecting
* Table of Contents and Internal Links now work as free local features without API key
* Added central security helper (contai_verify_request)
* Comprehensive External Services disclosure in readme
* Security hardening across all form handlers

= 2.2.0 =
* Menu restructure and security hardening
* Dead code cleanup

= 2.1.0 =
* Added AI Site Generator (Site Wizard)
* Added Job Monitor for real-time task tracking
* Enhanced job processing system

= 2.0.0 =
* Major architecture improvements

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 2.34.0 =
Full admin UI redesign. 12 screens migrated to a new unified design system. Review your admin experience after updating.

= 2.12.0 =
Google Analytics integration with GDPR Consent Mode v2. Connect your GA4 property directly from the plugin.

= 2.11.4 =
One-click link building setup and provider name cleanup.

= 2.9.0 =
Search Console now connects with a single click instead of 3 manual steps.

= 2.8.0 =
Keyword extraction now works by topic instead of competitor URL. Site Generator updated accordingly.

= 2.6.0 =
Theme is now auto-selected based on category. Default theme changed to Astra.

= 2.4.0 =
New AI Agent platform integration. Manage and trigger AI agents directly from wp-admin.

= 2.3.1 =
Prefix consistency and security hardening. All admin slugs, meta keys, and SQL queries updated for WordPress.org compliance.

= 2.3.0 =
Major compliance update. Rebranded to 1Platform Content AI. All admin pages now accessible without API key. TOC and Internal Links work as free local tools.

= 2.2.0 =
Menu restructure and security improvements. Update recommended for all users.

= 2.0.0 =
Major update with rebrand. Please review your settings after updating.

= 1.0.0 =
Initial release.
