
Safe Retire
v1.0.0weetech · 2026年11月24日 上架
Checks known references before posts and pages move to Trash. Permanent deletion is not protected.
- 正在使用
- 10 以下
- 评分
- 暂无
- 累计下载
- 34
- 最近更新
- 2026年11月24日
贡献者
截图
Safe Retire checks for known references at the moment a post or page is moved
to Trash. References found, query failures, candidate-limit exhaustion and
inspection time-budget exhaustion block that move.
Admin bulk Trash continues past blocked items and reports moved, blocked,
locked and failed items separately. Blocked items are listed in one notice with
the content that references each, plus an expandable description of inspection
coverage. REST Trash failures return
HTTP 409 with a Safe Retire error code, message and coverage information.
IMPORTANT: Only the original move to Trash is protected. Permanent deletion,
Empty Trash, automatic trash cleanup and forced API/CLI deletion are NOT
protected. A previously blocked item can still be permanently deleted.
If WordPress Trash is disabled (EMPTY_TRASH_DAYS is zero), deletion is not
protected at all.
Coverage:
- Absolute, site-root-relative and query-string URLs in stored post content,
including content in block navigation, templates and template parts. - Core navigation-link and navigation-submenu post-type object IDs.
- Classic menu post-type object IDs and exact current/earlier absolute or
site-root-relative custom menu URLs.
Not checked:
- Custom fields, Elementor, JetEngine and other page-builder data.
- Widgets and Customizer settings.
- Theme/plugin code, comments and term descriptions.
- External backlinks, redirects, dynamically generated links and arbitrary
URL encodings. - Relative URLs without a leading slash (for example ../contact).
- Custom menu URL variants with added query strings or fragments.
Source content in Trash is included because it can be restored. Moving a
source post to Trash does not remove its protection of linked targets, even
within the same bulk action. Remove the link and save the source to clear it,
or permanently delete the source only if its loss is intentional.
Revisions, auto-drafts, inherited content, attachments
and menu-item post content are excluded. Other stored post types can be sources;
only posts and pages are protected targets. Self-references are excluded.
Old slug metadata is used to reconstruct earlier URLs where possible; it is
not a complete history of permalink, parent or site URL changes.
“No references found” means no references found in the covered data, not
“safe to delete”. Unchecked sources do not themselves block Trash.
Inspection incomplete means the covered inspection failed; it never means
no references found. Counts on incomplete inspections can be partial.
Each item is checked immediately before its Trash operation, not from an
earlier preview or cached report. Bulk operations currently run one inspection
per item. The 1,000-candidate limit fails closed; the five-second budget is
checked after queries and is not a database statement timeout. Large sites
need staging performance testing before deployment. Concurrent edits between
inspection and mutation are not transactionally locked.
The plugin stores a rolling local log of 200 decisions in the safe_retire_log
option (timestamp, user ID, post ID, action, result, caller, reference count,
inspection status and any override reason). It does not send data externally.
Admin feedback is stored per user for up to two minutes, with up to 20
reference details per blocked item. The decision log is removed when the
plugin is uninstalled; deactivation alone does not remove it.
Developer API:
- Safe_Retire::scan( $post_id ) returns an inspection report without mutation.
- Safe_Retire::allow_once( $post_id, $reason ) permits one Trash attempt in the
current request, requires delete_post permission and a nonempty sanitized
reason, and records the reason when used. No override UI is provided. - wp safe-retire check prints a JSON inspection report.

