Link Guardian: automatic link protection & history
Link Guardian shields your site graph when URLs become unstable β it protects internal links when posts are drafted, trashed, or deleted, restores them when safe to republish (with Auto-Restore on Publish enabled), and keeps an auditable Protection History timeline. Pair it with Link Reports and scans so you separate βlifecycleβ removals from classic broken destinations.
Before you start
Link Guardian listens for editorial lifecycle events inside WordPress. When enabled, Remove Links on Draft, Remove Links on Trash, or permanent deletion paths can rewrite inbound anchors so sister posts stop pointing at content that temporarily (or permanently) left the published web. That is complementary to crawler-based Broken Links lists in Link Reports, which flag HTTP-level failures after a scan.
- Requires admin access. Toggling Guardian, saving Protection Settings, and restoring rows from history are privileged operations.
- Understand the KPI meanings. Total Protected, Pending Restore, Restored, and Failed summarise what the database tracked β Failed is Guardian processing issues, not the same metric as outbound β404β URLs in reports.
- Broken links? After Guardian stabilizes internal navigation, sweep structural 404s with Link Management scans plus Redirects / 404 / URL Medic utilities.
Enable Guardian
Flip the master control in the Link Guardian header when you are ready for automatic rewriting. Turning it off hides the KPI row and nested panels instantly in the UI so operators can troubleshoot without stray AJAX writes.
Link Guardian
Protects internal links when posts are drafted, trashed, or deleted
Master toggle beside the shield header plus the four KPI counters that mirror Total Protected, Pending Restore, Restored, and Failed.
Protection Settings
Within the Protection Settings panel you decide which WordPress statuses trigger surrogate removals:
- Remove Links on Draft β strip inbound links when an editor demotes a post to draft so live articles no longer point at inaccessible permalinks.
- Remove Links on Trash β extend the same behavior to trashed posts (still recoverable from the trash screen).
- Auto-Restore on Publish β reinsert anchors automatically after the destination returns to Published status.
π Protection Settings
Toggles autosave independently via AJAX β each row maps to a stored option key in slg_options.
Each descriptive row matches wp-admin strings: Remove Links on Draft, Remove Links on Trash, and Auto-Restore on Publish (mock toggles use srg-mock-tog).
Protection History timeline
Protection History renders a timeline keyed to lifecycle actions. Filter chips (All, Pending, Restored, Permanent, Failed) narrow the backlog; each row shows whether the inbound link was removed because of draft, trash, or delete workflows, timestamps in human-readable form, and optional anchor excerpts.
Protection History
Link removed from Spring pricing guide (target: Legacy promo LP)
Link removed from Case study roundup (target: Retired SKU page)
Draft and Trash icon wells mirror wp-admin Dashicon treatments; statuses echo the badges rendered beside each timeline row.
Broken links scan
Guardian focuses on editorial risk (draft/trash/delete). Classic broken-link detection still depends on the crawl index:
- Run scheduled or on-demand scans from Link Management so fresh HTTP statuses flow into Link Reports β Broken Links.
- Use Redirects, 404 Monitor, and URL Medic to chain permanent fixes once you confirm the destination should never return.
- Compare Guardianβs Failed KPI against report tables β if Guardian cannot rewrite content (permissions, malformed HTML, etc.), the history rowβs Reason field explains the failure while Link Reports still lists raw 404 pairs.
Link Reports aggregates scanner output β reconcile those URLs with redirects while Guardian quietly maintains safe internal citations during lifecycle churn.
Troubleshooting
KPI counters stay frozen after bulk edits
Reload the Utilities tab β stats query the persistence layer on render. Also confirm no optimisation plugin is stripping admin-ajax responses for slg_toggle_link_guardian.
History shows Failed with a Reason line
Open the offending post in the Classic/Block editor, ensure the anchor still exists somewhere Guardian can traverse, then retry from the Pending queue. Conflicting page builders occasionally wrap anchors in markup Guardian cannot hydrate.
Auto-Restore on Publish did nothing
Verify the setting stayed enabled (blue toggle). If the target was permanently deleted instead of drafted, Guardian may mark the record Permanent β manual content fixes or new links are required.
Broken Links table still lists URLs Guardian βshouldβ remove
Guardian works on internal editorial states; a URL can still 404 if the server misroutes it. Fix the HTTP layer via URL Medic & redirects, then rescan.