Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

Implements two new commands for managing WordPress post revisions: restore to revert posts to previous revisions and diff to compare revision content.

Commands

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 wp_text_diff(). Auto-detects parent post when <to> is omitted.

# Compare two revisions
wp post revision diff 123 456

# Compare revision with current post
wp post revision diff 123

# Compare specific fields
wp post revision diff 123 456 --field=post_title

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

  • src/Post_Revision_Command.php: New command class with field allowlist validation and type-safe implementation
  • entity-command.php: Registers post revision namespace
  • composer.json: Adds command entries for autocompletion
  • phpcs.xml.dist: Excludes new command from prefix rules
  • features/post-revision.feature: 7 test scenarios covering success and error cases

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.wordpress.org
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)
  • downloads.wordpress.org
    • Triggering command: /usr/bin/curl curl -sSfL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>wp post revisions</issue_title>
<issue_description>This command is to manage revisions for the specific post.
I think that a large number of people need it for now... 😓

Examples:

Lists all revisions for post_id=221

$ wp post revisions 221 --format=json

Restores revision from 233.

$ wp post revisions 221 --restore=233

Displays diff.

$ wp post revisions 221 --diff=233:255

Or

$ wp post revisions 221 --diff=233

</issue_description>

<agent_instructions>Let's start with two new commands:

  1. wp post revision restore <post_id> - Restore a revision with the given ID
  2. wp post revision diff <from> <to> - Compare/diff two revisions</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber Restoring and displaying diffs would be pretty interesting. @danielbachhuber Another implementation of revisions https://github.com/trepmal/wp-revisions-cli

💡 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.

@github-actions github-actions bot added command:post Related to 'post' command command:post-list Related to 'post list' command command:post-meta Related to 'post meta' command command:post-meta-get Related to 'post meta get' command command:post-meta-update Related to 'post meta update' command labels Jan 12, 2026
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
Copilot AI requested a review from swissspidy January 12, 2026 12:59
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 0% with 58 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Post_Revision_Command.php 0.00% 58 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:post Related to 'post' command command:post-list Related to 'post list' command command:post-meta Related to 'post meta' command command:post-meta-get Related to 'post meta get' command command:post-meta-update Related to 'post meta update' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wp post revisions

2 participants