=== LinkTiller: AI Internal Linking ===
Contributors: saistudiosio
Tags: internal linking, seo, ai, orphan posts, link building
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Find orphaned content, review guarded suggestions from your own AI endpoint, insert one link at a time, and undo safely.

== Description ==

LinkTiller scans published posts and pages, builds an internal-link graph, and brings content with no incoming internal links to the top. Scanning is read-only. When an administrator asks for suggestions, LinkTiller sends a limited source excerpt and a list of real candidate posts to the configured AI endpoint.

The model proposes; LinkTiller verifies; you decide. A post changes only after you approve a specific suggestion.

Suggestions are constrained before you see them:

* Anchor phrases must be copied verbatim from the source content.
* Targets must be real posts from the scanned site.
* Existing links and duplicate targets are rejected.
* Every insertion requires a separate administrator click.
* DOM-safe insertion skips text already inside a link.
* Undo restores the exact content saved before the first LinkTiller insertion.

= Bring your own endpoint =

LinkTiller has no preset remote endpoint. Configure OpenAI or another OpenAI-compatible provider using your own API key and model name, or use a local endpoint such as LM Studio or Ollama.

LinkTiller does not proxy AI requests through Sai Studios and does not include an API key. Provider charges, retention, and privacy terms depend on the endpoint you choose.

= Focused by design =

LinkTiller does not bulk-edit posts, rewrite links on the public site, crawl for broken links, or promise search-ranking changes. It focuses on one reviewable workflow: scan, request suggestions, insert one approved link, and undo when needed.

== External services ==

LinkTiller contacts an AI service only after an administrator configures an endpoint and clicks "Review link suggestions."

For each suggestion request, the plugin sends:

* The source post title.
* Up to 4,000 characters of plain-text source content.
* Up to 40 candidate post URLs, titles, short excerpts, and orphan status.
* The model name configured in LinkTiller settings.

If an API key is configured, it is sent in the Authorization header to that endpoint. The key is stored in the site's WordPress options table. It is never sent to Sai Studios.

If you configure OpenAI (`https://api.openai.com/v1`), use of that endpoint is governed by OpenAI's policies:

* Service agreement: https://openai.com/policies/services-agreement/
* Privacy and data information: https://openai.com/policies/

If you replace the Base URL, the selected provider's terms and privacy policy apply. A local LM Studio or Ollama endpoint can keep the request on the machine hosting that endpoint, depending on your network configuration.

== Installation ==

1. Upload the `linktiller` folder through Plugins → Add Plugin → Upload Plugin, or copy it to `/wp-content/plugins/`.
2. Activate LinkTiller.
3. Open LinkTiller → Settings and configure an API key, Base URL, model, post types, and suggestion limit.
4. Open LinkTiller and click "Scan published content."
5. Request suggestions for a post, review each one, and insert only the links you want.

== Frequently Asked Questions ==

= Does LinkTiller edit posts automatically? =

No. Scanning is read-only. Each suggested link is inserted only after an administrator clicks Insert.

= Can I undo an insertion? =

Yes. LinkTiller keeps one backup per edited post. Undo restores that exact content and removes the backup.

= How many links can it suggest? =

You can configure between 1 and 10 suggestions per post. All values are included in this plugin without a paid key.

= What does the AI request cost? =

LinkTiller itself is free. Your selected provider may charge for API use. Local models can avoid provider fees but still use your own hardware and electricity.

= Does my content pass through Sai Studios? =

No. Requests go directly from your WordPress site to the Base URL configured in LinkTiller settings.

== Changelog ==

= 0.2.1 =
* Makes the complete 1-10 suggestion range available without a license gate.
* Documents exactly when external AI services are contacted and what data is sent.
* Rejects suggested anchors outside the documented 2-6 word range.
* Handles failed post updates without leaving a stale backup.
* Updates release metadata for WordPress 7.1 submission testing.

= 0.2.0 =
* Adds URL resolver fallback for sites with stale rewrite rules.
* Retries transient upstream failures with backoff.

= 0.1.0 =
* First release: scan and graph, orphan detection, BYOK suggestions, DOM-safe insertion, and undo.
