Add wp post revision restore, diff, and prune commands#563
Open
Add wp post revision restore, diff, and prune commands#563
Conversation
Co-authored-by: swissspidy <[email protected]>
…sed property Co-authored-by: swissspidy <[email protected]>
Co-authored-by: swissspidy <[email protected]>
…ror handling Co-authored-by: swissspidy <[email protected]>
Copilot
AI
changed the title
[WIP] Add commands for restoring and diffing post revisions
Add wp post revision restore and diff commands
Jan 12, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
10 tasks
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: swissspidy <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
Copilot
AI
changed the title
Add wp post revision restore and diff commands
Add wp post revision restore, diff, and prune commands
Jan 25, 2026
thelovekesh
approved these changes
Jan 28, 2026
Member
thelovekesh
left a comment
There was a problem hiding this comment.
Changes looks good to me.
Comment on lines
+325
to
+331
| WP_CLI::confirm( | ||
| sprintf( | ||
| 'Are you sure you want to prune revisions for %d posts?', | ||
| count( $post_ids ) | ||
| ), | ||
| $assoc_args | ||
| ); |
Member
There was a problem hiding this comment.
Does WP_CLI::confirm() accounts for shell pipes and non terminal scenarios?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation Plan for Post Revision Commands
wp post revision restore <post_id>- Restore a revision with the given IDwp post revision diff <from> <to>- Compare/diff two revisions with CLI-friendly colored outputwp post revision prune [<post-ids>...] [--latest=<limit>] [--earliest=<limit>]- Delete old revisionsCommands
wp post revision restore <revision_id>Restores a post to the specified revision using WordPress's native
wp_restore_post_revision().wp post revision restore 123 # Success: Restored revision 123.wp post revision diff <from> [<to>] [--field=<field>]Compares revision content using CLI-friendly colored diff output. Auto-detects parent post when
<to>is omitted.wp post revision prune [<post-ids>...] [--latest=<limit>] [--earliest=<limit>]Deletes old post revisions while keeping a specified number of latest or earliest revisions.
Features:
<post-ids>is provided, flags apply individually to those posts only<post-ids>is not provided, flags apply to all posts individually--yesto skip)--latestor--earliestflag (cannot use both)Diff Output
The diff command displays changes with color coding:
-prefix = Deleted lines+prefix = Added linesprefix = Unchanged linesExample output:
Supports 15 post fields:
post_title,post_content,post_excerpt,post_name,post_status,post_type,post_author,post_date,post_date_gmt,post_modified,post_modified_gmt,post_parent,menu_order,comment_status,ping_status.Implementation
post revisionnamespace💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.