=== LeKeyLinks ===
Contributors: laobuluo
Tags: seo, links, keywords, content, automation
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.0
Stable tag: 1.0.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically convert keywords in posts into links. Supports Chinese and English, priority, max replaces, and per-post link limits.

== Description ==

LeKeyLinks helps you add internal links automatically. After you define keywords and target URLs in the admin area, matching text in post content is replaced with links while existing links and code blocks are left alone.

**Features**

* Chinese and English keywords (English uses word boundaries)
* Keyword priority and per-keyword maximum replacements
* Per-post total link limit (default 5, configurable) to reduce processing cost
* Skips text inside existing `<a>` tags
* Skips `<pre>`, `<code>`, `<script>`, `<style>`, and similar regions
* Keyword list caching to reduce database queries
* Fast content pre-check before DOM parsing
* Optional replacement in excerpts (`the_excerpt`)
* Link styling: bold, color, and rel tokens (noopener, nofollow, sponsored, ugc)
* Per-post skip via classic editor, block editor, or `_lekl_skip` meta
* Feeds are not processed; content replacement defaults to singular views

**Management**

* Add, edit, delete, search, and paginate keywords
* Central settings screen for switches and styles

== Installation ==

1. Upload the `lekeylinks` folder to `/wp-content/plugins/`, or install the ZIP via Plugins → Add New → Upload Plugin.
2. Activate LeKeyLinks on the Plugins screen.
3. Open the Keyword Links menu, add keywords and destination URLs.
4. Open Keyword Links → Settings to configure the per-post link limit and styles.

== Frequently Asked Questions ==

= Why was a keyword not linked? =

Possible reasons: the keyword reached its max replacements; the post reached the per-post link limit; the match is inside an existing link or code block; the post is marked to skip replacement; the plugin is disabled; or you are not on a singular view and excerpt replacement is off.

= What is the difference between max replacements and the per-post link limit? =

Max replacements applies to one keyword. The per-post link limit caps the total number of auto-inserted links in one post (or one excerpt pass). Both apply, and keywords are processed from higher to lower priority.

= How do I skip replacement for one post? =

Enable the per-post skip panel in Settings, then check the option in the editor. You can also set post meta `_lekl_skip` to `1`.

= What are the server requirements? =

The PHP DOM extension (libxml) is required. PHP 7.4 or newer is recommended.

== Screenshots ==

1. Keyword list management screen
2. Add or edit a keyword
3. Plugin settings screen

== Changelog ==

= 1.0.6 =
* Plugin Check: Tested up to 7.1; use %i for table names; remove report markdown from plugin root

= 1.0.5 =
* Plugin Check: English readme, Requires WP 6.2+, translators comments, output escaping
* Plugin Check: prefixed globals, dbDelta/custom-table phpcs notes, remove load_plugin_textdomain
* Link URLs limited to http/https; admin capability checks retained

= 1.0.4 =
* Security: admin write actions require manage_options; link URLs limited to http/https
* Compliance: ABSPATH guards, Domain Path / Requires headers, uninstall.php, dbDelta
* Duplicate keyword check; max_replace clamped to 0–100

= 1.0.3 =
* Per-post link limit; skip pre/code regions; performance and PHP 8.2 compatibility

= 1.0.2 =
* Keyword list transient cache; per-post skip panels; excerpt replacement; rel extras

= 1.0.1 =
* Settings: master switch, bold links, link color

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 1.0.6 =
Recommended: Tested up to WordPress 7.1; safer SQL identifiers (%i). Requires WordPress 6.2+.

= 1.0.5 =
Recommended update for Plugin Check compliance (readme language, escaping, and coding standards).
