Description
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.
Screenshots


Installation
- Copy the safe-retire directory to wp-content/plugins/.
- Activate Safe Retire in the Plugins screen.
- Test on a staging copy before using it on a production site.
There are no settings. Attachments and custom post types are not protected.
FAQ
-
Does this guarantee a page is safe to remove?
-
No. Read the inspection coverage and exclusions above.
-
Can Empty Trash remove content that still has references?
-
Yes. Only moves to Trash are guarded. Permanent deletion is deliberately
unguarded, including Empty Trash and automatic cleanup. -
Does it protect posts removed by other plugins or scheduled tasks?
-
Yes, if they use WordPress’s standard “move to Trash” function and Trash is
enabled. Those moves are checked like any other. Tools that delete content
permanently, bypassing Trash, are not protected. Safe Retire has not been
tested with specific third-party plugins. -
Will it slow down my site?
-
The check runs only at the moment you move a post or page to Trash, not on
front-end page loads. Each item triggers a few database searches of stored
content, so very large sites should test bulk Trash on a staging copy first. -
Does it work on multisite?
-
Each site is checked on its own. References on other sites in a network are
not inspected. Uninstalling removes the decision log from every site. -
Why was an item blocked?
-
The notice lists each blocked item with the content that links to it, or the
reason the inspection could not complete. Expand “Inspection coverage” to seewhat was and was not checked. Remove the link and save the source, then try again.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“Safe Retire” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “Safe Retire” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.0.0
- Initial release.
