=== Blog AI Connector ===
Contributors: philipmeagher
Tags: seo, rest api, meta description, indexnow, blogging
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Lets the Blog AI service set the SEO title, meta description, focus keyword and canonical URL of your posts, adds the structured data it sends, and tells IndexNow about new posts.

== Description ==

Blog AI Connector is a small helper plugin for sites that use [Blog AI](https://www.blogaihq.com), a hosted service that writes, publishes and refreshes blog posts from your Google Search Console data. The plugin is only useful if you have a Blog AI account and have connected this site to it.

WordPress doesn't expose the SEO fields that Yoast SEO and Rank Math store with each post to its REST API, so an outside service can't set them when it publishes a post. This plugin registers those fields with the REST API for posts and pages, so that Blog AI can:

* set the SEO title, meta description, focus keyword and canonical URL of a post when it publishes or updates it, and
* read the SEO titles and descriptions of your existing posts and pages for its content audit.

It works with Yoast SEO or Rank Math. It does nothing visible on your site.

It can also add structured data (schema.org JSON-LD) to posts Blog AI publishes: a BlogPosting description of the post and, when the post has a "Frequently asked questions" section, an FAQPage. Search engines and AI answer engines read it; visitors don't see it. Blog AI only sends it when your site's setting in Blog AI asks for it, and by default not when Yoast SEO or Rank Math is active, because they add their own Article schema.

It also tells IndexNow search engines (Microsoft Bing, Yandex, Seznam, Naver and Yep) when a post or page is published or updated, so they can pick up the change quickly. You can turn this off under Settings > Reading. Google does not take part in IndexNow.

= What the plugin does =

* Registers these post meta keys with the REST API, for posts and pages: `_yoast_wpseo_title`, `_yoast_wpseo_metadesc`, `_yoast_wpseo_focuskw`, `_yoast_wpseo_canonical`, `rank_math_title`, `rank_math_description`, `rank_math_focus_keyword` and `rank_math_canonical_url`.
* Only users who can edit a post or page can read or change these fields through the REST API. They are removed from REST responses for everyone else, including visitors who are not logged in.
* Cleans every value before it is saved: canonical URLs must be http or https addresses, and the other fields are saved as plain text.
* Registers one more post meta key for posts, `_blogai_schema`, with the same rules (only users who can edit the post can read or change it through the REST API). It holds the structured data Blog AI sent with the post, and is saved only when it is a valid schema.org JSON-LD object.
* On the page of a published post that has `_blogai_schema`, prints it in the page head as `<script type="application/ld+json">`, with the post's own address, published and modified dates, and featured image filled in by WordPress. Nothing is printed for other posts, pages, drafts or password-protected posts. Developers can change or remove it with the `blog_ai_connector_schema` filter.
* Adds one read-only REST route, `GET /wp-json/blogpilot/v1/status`, available only to users who can edit posts. It returns the plugin version and whether Yoast SEO or Rank Math is active, so Blog AI can tell the plugin is installed. (`blogpilot` is the product's earlier name; the route keeps it so existing connections keep working.)

* IndexNow (on by default; Settings > Reading > "Blog AI Connector: IndexNow" to turn it off): on activation the plugin creates a random IndexNow key and serves it as a small text file at your site's address (for example `https://example.com/<key>.txt`), which is how IndexNow checks that submissions come from your site. When a post or page is published, or a published one is updated, the plugin sends its public address to IndexNow a few seconds later (in a WP-Cron event, so saving is never slowed down). Password-protected posts, drafts and private posts are never sent. Nothing is sent while "Discourage search engines from indexing this site" is ticked, or on a site whose environment type is not "production" (staging and local copies).
* Settings > Reading shows the key file's address and the result of the last submission.

= What the plugin does not do =

* It makes no requests to Blog AI. Its only outgoing request is the IndexNow submission described above, made from your site to api.indexnow.org.
* It stores no personal data. It saves three settings (whether IndexNow is on, its key, and the last submission's time and result), which are removed when you delete the plugin. It sets no cookies and adds nothing visible to your pages: the only thing it adds is the structured data script described above, on posts Blog AI sent it with.
* It doesn't add a credit, link or "powered by" notice to your site.

== External services ==

This plugin is a connector for Blog AI, an external service run by Blog AI (Ireland). The plugin itself never contacts Blog AI or any other server. The connection runs the other way: Blog AI calls your site's WordPress REST API, signed in as a WordPress user you choose, using an Application Password you create in your WordPress profile and enter in Blog AI.

What Blog AI sends to and reads from your site, and when:

* When you connect the site or test the connection: Blog AI reads the REST API index and the status route above to check that the site is reachable and the plugin is active.
* When you import posts or run a content audit: Blog AI reads your published posts and pages (titles, content, addresses, categories, tags and the SEO fields listed above).
* When you publish, schedule or update a post from Blog AI: Blog AI sends the post (title, content, excerpt, categories, tags, featured image and its alt text), its SEO fields and, when your setting asks for it, its structured data to your site.

Blog AI stores what it imports, and your Application Password, on its own servers, so it can act on your behalf. Your account data is stored in the EU. You can stop all access at any time by revoking the Application Password in WordPress (Users → Profile → Application Passwords) or by removing the site in Blog AI.

* Service: https://www.blogaihq.com
* Terms of service: https://www.blogaihq.com/legal/terms
* Privacy policy: https://www.blogaihq.com/legal/privacy

This plugin also uses IndexNow, an open protocol run by the participating search engines (https://www.indexnow.org). When a post or page is published or updated on your site, and IndexNow is on, your site sends a request to https://api.indexnow.org/indexnow with your site's host name, the IndexNow key, the address of the key file and the public address(es) of the post. No other data is sent. IndexNow shares the addresses with the participating search engines (Microsoft Bing, Yandex, Seznam, Naver and Yep), which may then visit those pages. Turn it off under Settings > Reading.

* IndexNow documentation: https://www.indexnow.org/documentation
* IndexNow terms of service and privacy (indexnow.org is run by Microsoft, Yandex and Seznam): https://www.indexnow.org/terms

Posts written on Blog AI's free plan end with a short "Produced in partnership with Blog AI" line, with a nofollow link to Blog AI. That line is part of the post content Blog AI sends, not something this plugin adds; on a paid plan it is off unless you switch it on in Blog AI's settings. You can edit or remove it in the post like any other text.

== Installation ==

1. In WordPress, go to Plugins → Add New Plugin and search for "Blog AI Connector", or upload the plugin's zip file.
2. Click Install Now, then Activate.
3. In your WordPress profile (Users → Profile), create an Application Password for Blog AI, if you haven't already.
4. In Blog AI, add or open your site on the Sites page, enter the Application Password and run the connection test. It shows whether the connector was found.

Yoast SEO or Rank Math must be installed and active for the SEO fields to have any effect on your pages.

== Frequently Asked Questions ==

= Do I need a Blog AI account? =

Yes. The plugin only makes your SEO fields available to Blog AI through the REST API. Without a Blog AI account connected to this site it does nothing useful. Blog AI has a free plan; paid plans are listed at https://www.blogaihq.com/pricing.

= Does Blog AI work without this plugin? =

Mostly. Blog AI can publish posts to WordPress with only an Application Password. Without this plugin it can't set Yoast SEO fields, and it can't read the SEO fields of your pages for its audit. Rank Math fields can still be set through Rank Math's own REST route.

= Does the plugin slow my site down? =

No. It adds no scripts, styles or database tables, and does nothing on the pages your visitors see. IndexNow submissions run in the background a few seconds after you save, not while you save.

= Does IndexNow get my posts into Google? =

No. Google does not use IndexNow. Google finds new posts through your sitemap and links from your other pages; you can also ask it to index a post with the URL Inspection tool in Google Search Console. Blog AI shows each new post's Google status and links you to that tool.

= I already use another IndexNow plugin. =

Turn IndexNow off in one of them (here: Settings > Reading), so each change is sent once. Rank Math's Instant Indexing module and Microsoft's IndexNow plugin also submit to IndexNow.

= Why does Settings > Reading say IndexNow refused a submission? =

"Could not read the key file" means IndexNow could not open the key file address shown there. Open it in your browser: it should show the key. If it shows a "not found" page, a caching or security plugin, or your server's configuration, may be stopping WordPress from answering that address.

= Can other people read my focus keywords through the REST API? =

No. The plugin removes the SEO fields from REST API responses for anyone who can't edit the post or page.

= Which SEO plugins are supported? =

Yoast SEO and Rank Math.

= Will I get duplicate schema with Yoast SEO or Rank Math? =

Not by default. Both already add Article schema to your posts, so Blog AI doesn't send its own to sites that use them unless you turn structured data on for the site in Blog AI. To remove what the plugin prints, turn the setting off in Blog AI and update the post, or use the `blog_ai_connector_schema` filter.

= What happens when I deactivate or delete the plugin? =

The fields stop being available through the REST API, the key file is no longer served and nothing more is sent to IndexNow. The SEO titles, descriptions and canonicals already saved stay in your posts, because they belong to your SEO plugin. Deleting the plugin also removes its three IndexNow settings.

= Where can I get help? =

Email hello@blogaihq.com, or see the help centre at https://www.blogaihq.com/help.

== Screenshots ==

1. The connection test on the Blog AI Sites page, showing that the connector and the SEO plugin were found.
2. A post published by Blog AI, with the SEO title and meta description filled in in Yoast SEO.
3. The plugin in the WordPress Plugins list after activation.

== Changelog ==

= 1.4.0 =
* New: structured data. Posts Blog AI publishes can carry schema.org JSON-LD (BlogPosting, and FAQPage when the post has a FAQ), stored in the `_blogai_schema` post meta and printed in the post's page head with the post's own address, dates and featured image. Only when Blog AI sends it (by default not on sites with Yoast SEO or Rank Math). Filter: `blog_ai_connector_schema`.
* Blog AI now also sets the focus keyword (Yoast SEO / Rank Math) when it publishes a post.
* The status route reports structured data support.

= 1.3.0 =
* New: IndexNow. When a post or page is published or updated, the site tells IndexNow search engines (Microsoft Bing, Yandex, Seznam, Naver, Yep) about it. On by default; turn it off under Settings > Reading.
* An IndexNow key is created on activation and served at the site root.
* Nothing is sent from staging sites or while search engines are discouraged.
* The status route also reports whether IndexNow is on.

= 1.2.0 =
* First release on WordPress.org.
* Plugin folder and main file renamed to blog-ai-connector; text domain blog-ai-connector.
* Updates now come from WordPress.org (the self-hosted update header is removed).
* Readme: describes the Blog AI service, what data it reads and sends, and links to its terms and privacy policy.

= 1.1.0 =
* Renamed to Blog AI Connector.
* SEO fields of pages are exposed too (read-only site audit).
* SEO fields are hidden from REST responses for users who can't edit the post or page.
* Safe to load twice (plugin and must-use plugin).

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.4.0 =
Adds structured data (schema) for posts Blog AI publishes, printed in the page head. Nothing changes for posts Blog AI didn't send it with.

= 1.3.0 =
Adds IndexNow: new and updated posts are sent to Bing and other IndexNow search engines. On by default; Settings > Reading to turn it off.

= 1.2.0 =
First WordPress.org release. If you installed the connector from a zip downloaded from Blog AI before 1.2.0, deactivate and delete that copy (folder blogpilot-connector), then install Blog AI Connector from the WordPress.org directory so you get updates.
