Add wp post revision restore, diff, and prune commands#563
Merged
swissspidy merged 19 commits intomainfrom Feb 15, 2026
Merged
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…sed property Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…ror handling Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
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 <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
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 <841956+swissspidy@users.noreply.github.com>
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
Closed
thelovekesh
approved these changes
Jan 28, 2026
Member
thelovekesh
left a comment
There was a problem hiding this comment.
Changes looks good to me.
This comment was marked as resolved.
This comment was marked as resolved.
swissspidy
reviewed
Feb 15, 2026
…e instanceof Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
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 revisionsLatest Changes
Addressed code review feedback from @swissspidy:
get_post_or_revision()helper method to reduce code duplicationswitch/get_class()withinstanceofchecks for more robust type checkingCommands
wp post revision restore <revision_id>Restores a post to the specified revision using WordPress's native
wp_restore_post_revision().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 revisionnamespaceReady for merge.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.