=== Internal Post Linker - Link Internal Posts, Pages, Products without leaving the page ===
Contributors: 7thskysoftware
Tags: internal links, Post Linker, editor, SEO, Backlink
Donate link: https://https://7thskysoftware.com/
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Link selected editor text to existing internal posts, pages, and public custom post types without leaving the WordPress editor.

== Description ==

Internal Post Linker helps editors create internal links while writing. Select text in the editor, open the internal link search, choose an existing site result, and the plugin applies the selected result's permalink to the selected text.

The plugin supports the WordPress block editor and the Classic Editor/TinyMCE visual editor. Search results include useful context before insertion, including title, post type, publication date, excerpt, privacy status, current-post label, and a preview link.

= Key Features =

* Link selected text to posts, pages, and public custom post types.
* Works in the block editor and Classic Editor/TinyMCE visual editor.
* Searches linkable content by title and slug.
* Shows result title, post type, date, excerpt, private status, and current-post label.
* Adds WordPress editor link metadata so newly inserted block editor links display correctly.
* Uses nonce-protected admin-ajax requests for editor search.
* Includes a REST search endpoint for editor integrations.
* Supports older block editor builds that expose toolbar APIs through `wp.editor`.
* Excludes attachments from link targets.
* Works without a build step.

## Using It In The Block Editor

1. Open a post, page, or supported custom post type in the WordPress block editor.
2. Click inside a text block, such as a Paragraph, Heading, List, or other rich text block.
3. Highlight the text you want to link.
4. Click the **Internal Post Link** toolbar button.
5. In the modal, search for the page, post, or article you want to link.
6. Review the search results.
7. Click the result you want.
8. The selected text is linked immediately.
9. Save, update, or publish the post as usual.

## Using It In Classic Editor

1. Open a post or page in Classic Editor.
2. Make sure you are using the **Visual** editor tab.
3. Highlight the text you want to link.
4. Click the **Internal Link** button in the editor toolbar.
5. Search for the internal content you want to link.
6. Click a result.
7. The selected text is linked immediately.
8. Save, update, or publish the post as usual.

## Search Results

Each result can show:

- Title.
- Content type, such as Post, Page, or a custom post type label.
- Published date.
- Excerpt.
- Private status, when applicable.
- Current post label, when the matching result is the post currently being edited.
- A preview link where available.

The plugin searches titles and slugs. For best results, search using words from the target content title.

Examples:

- `Smart Support`
- `Gravity Forms`
- `Agent Assignment`
- `REST API`

## Linking To The Current Post

The current post may appear in search results if it matches the search term. It is labeled **Current post** so editors can identify it before linking.

In most editorial workflows, linking a post to itself is not useful. If you see the **Current post** label, choose a different result unless you intentionally want a self-link.

## Updating An Existing Link

In the block editor:

1. Click or select the already linked text.
2. Open **Internal Post Link**.
3. Search for the replacement content.
4. Click the new result.

The existing link is replaced with the selected internal link.

In Classic Editor:

1. Select the linked text.
2. Click **Internal Link**.
3. Search and choose the replacement result.

## Removing A Link

The plugin focuses on finding and applying internal links. To remove a link, use the editor's standard unlink control:

- In the block editor, click the linked text and use the unlink option in the link popover or toolbar.
- In Classic Editor, select the linked text and click the standard unlink toolbar button.

## Search Security

Search requests are protected with WordPress permissions and nonces. The plugin only returns search results for logged-in users who can edit posts.

The plugin does not expose internal search to public site visitors.

## Supported Content Types

The plugin searches public post types that have an editor UI, including:

- Posts.
- Pages.
- Public custom post types.
- Knowledge base articles, documentation articles, or other public editor-backed content types when registered by your site.

Attachments are excluded from search results.

== Installation ==

1. Upload the `7sky-internal-post-linker` folder to `/wp-content/plugins/`.
2. Activate **7Sky Internal Post Linker** from **Plugins -> Installed Plugins**.
3. Open a post or page in the editor.
4. Select text and click **Internal Post Link**.
5. Search for internal content and click a result to apply the link.

== Frequently Asked Questions ==

= Does it work with pages and custom post types? =

Yes. It searches public post types that have an editor UI, excluding attachments.

= Does it work in the Classic Editor? =

Yes. In Classic Editor visual mode, use the **Internal Link** TinyMCE toolbar button.

= Does it work in the block editor? =

Yes. Select text in a rich text block, then use the **Internal Post Link** toolbar control.

= Does it link private posts? =

Private posts are included only for users who can read private posts.

= What content does the search use? =

The search matches post titles and slugs, then returns up to eight recently modified matching results.

= Can users without editing permissions search posts? =

No. Search requests require a logged-in user who can edit posts.

== Screenshots ==
1. Linking Page, Post, Product from the editor directly.
2. Inserting a link using Internal Post linker

== Changelog ==


= 1.0.0 =
* Initial production release.
* Added block editor and Classic Editor internal post linking.
* Added secure internal content search and contextual result previews.
* Added compatibility fixes for older editor APIs and WordPress link metadata.
* Added Plugin Check-friendly search and translation handling.

== Upgrade Notice ==
Initial release.
