=== RankHouse ===
Contributors: ekhata, rankhouseai
Tags: seo, ai, content, blog, publishing
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Publish SEO content from RankHouse to your WordPress site: blog posts, page copy and meta titles and descriptions, from one API key.

== Description ==

RankHouse is an autonomous SEO agent. It reads your site, plans a month of keywords from real Search Console data, writes a blog post every day, and checks whether ChatGPT, Google AI Overview, Perplexity, Gemini and Claude name you in the answer.

This plugin is the WordPress half of that loop. Install it, paste the API key from your RankHouse account, and the content the agent writes lands on your site: blog posts arrive as drafts, meta titles and descriptions update the pages you already have, and nothing goes live until you press Publish in RankHouse.

**What it publishes**

* Blog posts (hero image, categories, tags, author, reading time and SEO fields), as drafts or published
* Page SEO: meta title, meta description and keywords for pages, posts, categories and products that already rank but sit off page one
* Reads your categories and authors (read only), so the editor in RankHouse can file a post under the right ones
* Copy and SEO fields for existing WooCommerce products and product categories when WooCommerce is active (optional)
* Updates to content RankHouse created, and moving such posts to the Trash

**How it works**

1. Create a RankHouse account at https://rankhouse.ai and enter your domain.
2. Install this plugin, open Settings → RankHouse and paste the API key shown under Account → Integrations → WordPress.
3. Press Connect. The plugin registers your site with RankHouse once.
4. Press Publish in the RankHouse editor. The post appears in WordPress.

**What it does not do**

* It does not change existing content unless you publish a meta or page update from RankHouse.
* It never creates, edits or deletes WordPress users, and never touches roles or passwords. Posts are attributed to an author your site already has (or the default author you choose).
* It never creates or deletes categories, product categories or products. Blog posts may be filed under an existing category; a category name that does not exist on your site is ignored.
* It never permanently deletes anything. The only removal it can perform is moving a post that RankHouse itself published to the Trash, where you can restore it.
* It never changes prices, stock or SKUs.
* It does not send visitor data anywhere. Only the content you publish, and the categories, authors and page list it returns to RankHouse, travel between your site and RankHouse.
* It runs no scheduled tasks and creates no database tables.

**Security model**

* Every endpoint requires the API key (64 random hex characters, generated by RankHouse), compared in constant time. Ten wrong keys from one address lock that address out for 15 minutes.
* The key is stored as a non-autoloaded option, is only ever pasted by an administrator (manage_options + nonce), and can be revoked from either side at any time.
* All input is sanitized: titles with sanitize_text_field, HTML through wp_kses_post, ids with absint, URLs with esc_url_raw; images are fetched with WordPress's own safe download and media functions.
* The REST routes are hidden from the API index, and nothing runs on a schedule.

= Requirements =

* A RankHouse account (https://rankhouse.ai)
* WordPress 6.2 or newer, PHP 7.4 or newer
* Pretty permalinks (Settings → Permalinks, anything except "Plain")
* An https:// site address (plain http is accepted only for local development hosts)
* WooCommerce 8.0 or newer is optional — product publishing is available when it is active

== External services ==

This plugin connects your site to **RankHouse** (https://rankhouse.ai), the content and SEO service operated by RankHouse, 346-B, 9th Floor, Office Plan X, Arfa Karim Tower, Lahore 54000, Pakistan. It contacts the RankHouse API at **api.rankhouse.ai** only in these moments:

* When you press **Connect**, **Check status** or **Disconnect** on the Settings → RankHouse screen, and once when you **deactivate** the plugin (a best-effort "disconnect" so RankHouse stops publishing to a site that no longer listens). Deleting the plugin makes no network call.

Data **sent** to RankHouse in those calls: the API key you pasted (as the request credential), your site's public REST URL (for example https://example.com/wp-json/rankhouse/v1), the plugin version and site address (in the User-Agent header). RankHouse derives your site domain from the REST URL and stores it against your account.

Everything else is **inbound**: after you connect, RankHouse calls the plugin's REST endpoints on your site (https://your-site/wp-json/rankhouse/v1/…), authenticated with the API key you pasted, to create and update blog posts, update the copy and SEO fields of existing pages, categories and — when WooCommerce is active — products and product categories, to move posts RankHouse published to the Trash, and to read your list of pages, categories, authors and languages so they can be chosen in the RankHouse editor. It cannot create, edit or delete users, cannot create or delete categories or products, and cannot permanently delete anything. Nothing is pushed to RankHouse on a schedule, and nothing happens until you connect.

**Images**: when a post or product from RankHouse carries a hero or product image, the plugin downloads that image into your Media Library from the URL RankHouse supplies. Today those images are served from RankHouse's storage hosts **rankhouseimages.blob.core.windows.net** (Microsoft Azure Blob Storage) and **storage.googleapis.com** (Google Cloud Storage). No other third-party service is contacted.

Data is exchanged only after you explicitly connect the site, and stops when you disconnect or revoke the key in RankHouse. It is processed under RankHouse's terms and privacy policy:

* Terms of Service: https://rankhouse.ai/terms-of-service
* Privacy Policy: https://rankhouse.ai/privacy-policy
* Support: rankhouse.ai@gmail.com

== Installation ==

1. Upload the plugin folder to /wp-content/plugins/ or install it from the Plugins screen, then activate it.
2. Make sure Settings → Permalinks is set to anything other than "Plain" and your site address uses https://.
3. In RankHouse (https://rankhouse.ai), open Account → Integrations → WordPress and generate an API key.
4. In WordPress, open Settings → RankHouse, paste the key and press Connect. The status turns green when the handshake succeeds.
5. Optionally choose a default author for posts that name an author your site does not have.

== Frequently Asked Questions ==

= Will it publish without asking? =

No. Blog posts arrive as drafts; nothing goes live until you press Publish in RankHouse. Meta and page updates are applied only when you publish them from the RankHouse editor.

= Does it work with Yoast SEO, Rank Math or SEOPress? =

Yes. Meta title, meta description and focus keyword are written to the fields those plugins read when one of them is active. Without an SEO plugin the plugin outputs the title tag and meta description itself. All In One SEO is not supported yet.

= Do I need WooCommerce? =

No. Posts, pages and categories work on any WordPress site. Product and product-category copy updates switch on automatically when WooCommerce is active.

= Why does it need pretty permalinks? =

RankHouse calls your site's REST API with query strings (for example ?per_page=100), which the "Plain" permalink form cannot carry. Choose any other structure under Settings → Permalinks.

= Does it work with WPML or Polylang? =

Yes. The plugin reports your languages to RankHouse, assigns the language RankHouse sends with each post, and refuses to write a post whose language does not match the one it already has.

= What happens when I deactivate the plugin? =

The plugin tells RankHouse (best effort) that the site stopped listening, so RankHouse marks the integration as disconnected. Your API key stays stored on the site; re-activate and press Connect to resume.

= How do I disconnect? =

Settings → RankHouse → Disconnect. The plugin notifies RankHouse, deletes the API key from your site and stops accepting calls. You can also revoke the key in RankHouse → Account → Integrations at any time.

= Does uninstalling remove my content? =

No. Uninstalling never deletes posts, pages, products, terms or users. The plugin's own settings are removed; the small RankHouse tags it stored on posts, terms and users are removed only if you ticked "remove data on uninstall" beforehand.

== Screenshots ==

1. Settings → RankHouse — paste the API key and connect.
2. Connected state with status check, this-site facts and publishing settings.
3. The WordPress card in RankHouse → Account → Integrations where the key is generated.

== Changelog ==

= 1.0.1 =
* Narrowed what the API key can do: no user, category or product creation or deletion, no permanent deletes (Trash only, and only for posts RankHouse published), no price/stock/SKU writes. Wrong-key lockout added.

= 1.0.0 =
* First release: posts, pages, SEO fields, languages and optional WooCommerce product copy from RankHouse.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
