Half Baked Link Injection

外掛說明

Half Baked Link Injection lets you define simple rules that automatically replace whole-word phrases with links when WordPress renders post and page content.

It is designed for clean, predictable linking that stays out of your way. Rules are applied only to the_content, and existing links are never modified. This makes it useful for SEO hygiene, internal linking, and turning recurring terms into consistent references without editing each post manually.

How it works

Create one or more injection rules. Each rule includes:
* A phrase (whole-word matching is always used)
* A destination URL (internal relative links or external URLs)
* Optional settings like case sensitivity, where it applies, and how often it triggers

When a post or page is displayed, the plugin scans only the text portions of the content and injects links where appropriate. It will not touch phrases inside existing <a> tags, and it skips script and style blocks to avoid breaking markup.

Targeting and control

Rules can be scoped and prioritized so you stay in control when phrases overlap or your site grows.
* Post type targeting: apply a rule to Posts, Pages, or both
* Priority ordering: lower numbers win when multiple rules could match the same spot
* Tie-breaking: if priorities match, newer rules win

Occurrence options

Control how frequently each phrase is linked:
* First
* First + every Nth
* Every Nth
* All

This is useful when you want a light touch on long articles.

External links done properly

When a rule points to an external URL, the plugin:
* Adds target="_blank"
* Ensures rel includes noopener noreferrer
* Lets you append additional rel tokens like nofollow or sponsored

Relative URLs stay relative and do not get target="_blank".

Built for safety and performance

  • No recursion into the_content
  • Processes content safely by splitting HTML and touching only text tokens
  • Skips existing <a> tags
  • Skips <script> and <style> blocks

Privacy and data

This plugin does not send any data off-site. Rules are stored locally in your WordPress database in a single option.

Uninstall

Uninstalling the plugin removes stored rules from your database.

螢幕擷圖

  • The rules list screen, showing priority, phrase, destination, and scope.
  • Adding or editing a rule, including whole-word and occurrence options.
  • Internal link picker for selecting posts and pages.

安裝方式

  1. Upload the plugin files to the /wp-content/plugins/half-baked-link-injection directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the Plugins screen in WordPress.
  3. Go to Settings and open Half Baked Link Injection.
  4. Add one or more injection rules and save.

常見問題集

Does it change existing links?

No. If a phrase appears inside an existing <a> tag, it is ignored and not replaced.

Does it work on excerpts, titles, or widgets?

No. Rules are applied to post and page content only via the_content.

What does whole-word matching mean?

It uses whole-word boundaries, so it will not match partial words. For example, “cat” will not match “catch”.

How are conflicts handled when multiple rules could match?

Rules are evaluated by priority (lower wins). If priorities match, newer rules win. Existing links are never modified, and the plugin will not create nested links.

Can I add nofollow or sponsored to external links?

Yes. Add tokens in the rule’s Rel field. For external URLs, noopener noreferrer are always added.

Where are rules stored?

Rules are stored locally in your WordPress database in a single option.

使用者評論

這個外掛目前沒有任何使用者評論。

參與者及開發者

以下人員參與了開源軟體〈Half Baked Link Injection〉的開發相關工作。

參與者

將〈Half Baked Link Injection〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

3.0.10

  • Docs: Clarify data storage/privacy and uninstall behavior.

3.0.9

  • Fix: Remove discouraged load_plugin_textdomain() call (translations auto-load on WordPress.org).

3.0.8

  • Tweak: Align admin/AJAX capability checks (edit_posts).
  • Tweak: Load translations via load_plugin_textdomain().

3.0.7

  • Fix: Plugin Check nonce/sanitization warnings in rules save handler.

3.0.6

  • Fix: Add plugin owner to Contributors in readme.
  • Fix: Sanitize/validate posted rules earlier to satisfy review + Plugin Check.
  • Fix: Prefix plugin class name to satisfy Plugin Check.

3.0.5

  • Fix: Plugin Check input-sanitization warnings in admin handlers.

3.0.4

  • Fix: Overlay N value now saves correctly (occurrence mode value alignment).

3.0.3

  • Fix: Show N input in Add New Rule overlay for Nth modes; correct N value saving.

3.0.2

  • Fix: Show/hide N input in Add New Rule overlay (correct field IDs).

3.0.1

  • Admin: Add New Rule overlay now includes N value for Nth occurrence modes.

3.0.0

  • Version bump.

2.0.36

  • Change: Occurrence modes updated to: First, First + every Nth (1-10), Every Nth (1-10), All.

2.0.35

  • Fix: harden Add rule (overlay) save handler to avoid fatals (safe fallbacks for UUID, limits, and sanitizers).

2.0.34

  • Fix: resolve critical error on save (missing sanitize_post_types and MAX_RULES constant).

2.0.33

  • Fix: restore stable admin JS (Remove buttons work again) and make Add rule overlay submit via admin-post without breaking the page.

2.0.32

  • Fix: Add rule overlay save form is no longer nested (nested forms prevented submission in some browsers).

2.0.31

  • Admin: Add Injection overlay now saves via admin-post with a minimal payload (no AJAX, no full settings form submit) to avoid timeouts.

2.0.30

  • Fix: Add Injection overlay AJAX save now includes its own nonce (previous build never localized addRuleNonce).

2.0.29

  • Admin: Add Injection overlay now saves the new rule via AJAX to avoid full-page submits/timeouts.

2.0.26

  • Fix: Add Injection overlay now uses the same row-creation logic as the main screen, so new rules are populated correctly and save reliably.

2.0.25

  • Fix: enqueue wp-util on settings screen so the Add Injection overlay can render new rows.

2.0.24

  • Fix: wire up Add rule and Cancel buttons inside the Add Injection overlay.

2.0.23

  • Fix: Add rule overlay now reliably adds rows (ensure wp-util dependency and add a fallback Add button inside the modal).

2.0.22

  • Fix: ensure link picker modal appears above the Add Injection overlay.

2.0.21

  • Fix: link picker now works inside the Add Injection overlay; selected URLs populate the overlay URL field.

2.0.20

  • Fix: Add New Rule now opens the overlay dialog (previous build still appended a new row directly).

2.0.19

  • Admin: add new injections via an overlay dialog (instead of appending a new row at the bottom).

2.0.18

  • Admin: block saving duplicate phrases (case-insensitive). If duplicates are detected, nothing is saved.

2.0.17

  • Hotfix: revert admin UI enhancements that caused timeouts on some hosts. Core injection behavior unchanged.

2.0.14

  • Enhancement: prevent self-link injections; Admin: block saving duplicate phrases (case-insensitive) with an error.

2.0.7

  • Plugin Checker: fix escaping for dynamic name attributes; add translators comment; harden request method check; add PHPCS annotation for sanitized POST arrays.

2.0.6

  • Fix: correct admin asset gating without request vars; resolve activation WSOD in 2.0.5.

2.0.4

  • Compliance: update Tested up to header; minor i18n cleanup for admin UI text.

2.0.3

  • Performance: avoid expensive regex runs when phrase not present; add per-request replacement cap; faster internal token splitting.

2.0.2

  • Initial release.