=== ThinkGraph AI Connector ===
Contributors: thinkgraphai
Tags: seo, content strategy, internal links, ai, analytics
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.6.0
License: GPLv2 or later

Connect your site to ThinkGraph AI with a secret key instead of database credentials.

== Description ==

ThinkGraph AI maps your posts into a content knowledge graph and finds content gaps, orphan pages, internal-linking opportunities and answer-engine (AEO) readiness issues.

This plugin lets ThinkGraph read your site through a private, read-only API:

* Published posts (title, slug, dates, author, content), categories and tags
* SEO focus keyword and meta description presence (Yoast, Rank Math, AIOSEO, SEOPress)
* Featured image presence and comment counts

By itself the connection key never changes your content. It never exposes user emails, logins, passwords, comment text or site settings. Writing is limited to the optional draft key below.

== Installation ==

1. Upload the plugin and activate it.
2. Go to Settings > ThinkGraph AI and click "Generate keys". Copy the connection key and, if you want to send drafts, the draft key (both are shown once).
3. In ThinkGraph AI choose "Connect with plugin" and paste your site URL, the connection key and, optionally, the draft key.

== Security ==

* Only a SHA-256 hash of the key is stored; the key itself cannot be read back.
* Every data request must send the key in the X-ThinkGraph-Key header. Revoke or regenerate the key at any time.
* Uninstalling the plugin deletes the key.


== Optional draft key ==

"Generate keys" also creates a separate draft key. With it ThinkGraph AI can create new DRAFT posts on your site: title, content, featured image, excerpt, tags, and the focus keyword and meta description for Yoast SEO, Rank Math or SEOPress. It cannot publish or delete posts. It never creates categories, and it is limited to 20 drafts an hour. Revoke the draft key at any time. All in One SEO keeps its fields in its own table, so for that plugin the values are only shown in ThinkGraph for you to copy.

Updating an existing post in place after a refresh is OFF by default. Turn on "Allow ThinkGraph to update existing posts" under Settings > ThinkGraph AI to use it. When on, ThinkGraph replaces the title, content, excerpt, SEO fields and featured image of the one post you chose to update; status, URL, publish date and author are kept, and WordPress saves the old text as a revision you can restore. Anyone holding the draft key could then do the same, so leave it off unless you use that option.

If you let ThinkGraph add structured data, it prints a BlogPosting JSON-LD block in the page head of that post. If your SEO plugin already outputs Article schema, return false from the `tgai_output_jsonld` filter to switch it off.

== Changelog ==

= 1.6.0 =
* Security: updating an existing post in place is now off by default. A site administrator turns it on under Settings > ThinkGraph AI. Without it, the draft key can only create new drafts, so a leaked draft key cannot change published posts.
* ThinkGraph now sends keys only over HTTPS.

= 1.5.1 =
* Two keys only: the read-only connection key and the optional draft key. The optional database-login creator from 1.5.0 was removed (it fails on most shared hosts). If you connect by database instead, follow the host steps at thinkgraphai.com/help/connect-database.

= 1.4.0 =
* The posts endpoint accepts seo_plugin (yoast, rankmath, seopress, aioseo) so ThinkGraph reads the focus keyword from the one SEO plugin you use. All in One SEO keyphrases are read from its own table.
* Refreshed articles can update the existing post in place (opt-in per send) instead of creating a second draft. Status, URL, publish date and author are kept; the previous text stays in WordPress revisions.

= 1.3.0 =
* Lite mode for the posts endpoint: ThinkGraph can ask for word, heading, image and link counts instead of every article's full text, so very large sites load in seconds instead of timing out.

= 1.2.1 =
* The posts endpoint accepts an optional author_id, so ThinkGraph can read one author's latest posts without scanning the whole site.

= 1.2.0 =
* One Generate keys button creates both the read-only connection key and the optional draft key. Revoke the draft key on its own, or revoke all keys.

= 1.1.2 =
* Removed the per-minute read limit added in 1.1.1: it could refuse ThinkGraph's own reads and leave the dashboard showing old data.
* The draft module is loaded only if its file is present, so an incomplete upload cannot crash the site.

= 1.1.0 =
* Optional draft key and POST /draft endpoint (creates drafts only).
* Optional JSON-LD output for drafts created by ThinkGraph.

= 1.0.0 =
* First release: key management and read-only endpoints (ping, verify, site, posts).
