| 开发者 | takahironishii |
|---|---|
| 更新时间 | 2026年9月22日 18:52 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
wp revision-autopilot count
wp revision-autopilot delete --scope=post --limit=100
wp revision-autopilot optimize
--dry-run reports what matches without touching it. --all repeats a bounded batch until nothing is left.
Abilities, when something else entirely is deciding
The same operations are published as abilities — named operations with input and output schemas, permission callbacks and behavioural annotations — using the Abilities API introduced in WordPress 6.9. Anything that can discover abilities can find these, understand what they take and return, check whether it is allowed to run them, and read back a structured result.
All three surfaces sit on one set of objects, so they cannot drift apart in what they actually do.
What it exposes
Four abilities, all under the revision-autopilot/ namespace:
count-revisions — how many revisions exist, their estimated content size, and the same broken down by parent post type. Read-only.list-revisions — one page of individual revisions with their parent post and timestamps. Read-only.delete-revisions — deletes one bounded batch for a scope and reports how many remain. Destructive.optimize-tables — runs OPTIMIZE TABLE on the posts and postmeta tables. Destructive.wp revision-autopilot count
wp revision-autopilot delete --scope=post --limit=100
wp revision-autopilot optimize
How it stays safe
Deleting revisions cannot be undone, and the same operations are reachable from three directions. Each one has to be safe on its own terms.
edit_posts; deleting or optimizing needs manage_options. Both are filterable.wp_is_post_revision() before removal, and deletion goes through wp_delete_post_revision() so related metadata is cleaned up with it. Published content is never touched.WP_Error saying which capability is missing, not a bare false.wp_posts, so the figures will look the same on the first screen you open.
Two details for anyone who had integrated with the old plugin:
tnrc_security_event action still fires, alongside this plugin's own revision_autopilot_event. Existing audit logging keeps working./wp-content/plugins/revision-autopilot/, or install it through the plugins screen.wp revision-autopilot count works immediately, and the abilities register themselves on WordPress 6.9 and up.No. Everything is on the screen under Tools. WP-CLI and the abilities exist for sites where cleanup should happen without a person watching — scheduled scripts, agent-driven maintenance, fleets of sites managed from one place — but nothing requires them.
No. Revisions are deleted permanently. Take a backup first, and use --dry-run or count-revisions to see what would go before it goes.
Because an unbounded delete on a large site is a request that runs until something kills it, leaving you with no idea how far it got. Each call removes a bounded batch and tells you how many remain, so the caller stays in control. wp revision-autopilot delete --all loops for you.
Deleting rows does not shrink the table file; only OPTIMIZE does. Run optimize-tables after deleting.
Read-only abilities are called with GET, destructive ones with POST, against /wp-json/wp-abilities/v1/abilities/<name>/run.
The abilities that take no arguments — count-revisions and optimize-tables — still need an input parameter present, even though it is empty:
curl -u user:app-password "https://example.com/wp-json/wp-abilities/v1/abilities/revision-autopilot/count-revisions/run?input="
Leaving input off entirely returns ability_invalid_input. The ones that do take arguments are called the usual way, for example ?input[per_page]=20.
The abilities need WordPress 6.9 or newer. On anything from WordPress 5.9 up, the screen and the WP-CLI commands work exactly the same — the abilities simply do not register, and nothing errors.
tnrc_security_event alongside revision_autopilot_event, so audit logging written against Takahiro Revision Cleanup keeps working after migrating.