Skip to content

Editor: Show the revision fields plugins register - #82159

Draft
ellatrix wants to merge 2 commits into
trunkfrom
revision-fields-in-visual-revisions
Draft

ellatrix wants to merge 2 commits into
trunkfrom
revision-fields-in-visual-revisions

Conversation

@ellatrix

@ellatrix ellatrix commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

What?

See #78130. The revisions sidebar now shows the fields plugins register with _wp_post_revision_fields, under the names they gave them, so a plugin that has no editor JS still has its data shown when comparing revisions.

Why?

The sidebar panel diffed revision.meta from the REST response, which is only the post meta registered with show_in_rest, and it labelled every row with the raw meta key. Plugins have always described their revisioned data to the classic screen through _wp_post_revision_fields, which returns a key and a human readable name, and _wp_post_revision_field_{$field}, which returns the value for a given revision. None of that reached the editor, so a plugin without REST or JS had nothing to show, and a plugin with REST meta got its key printed at the reader.

How?

  1. The revisions REST response carries the fields. Gutenberg_REST_Revisions_Controller adds a revision_fields object of key => { label, value }, built from _wp_post_revision_fields() minus the fields already in the response, with each value passed through the plugin's own field filter, the same call the classic screen makes. It is in the edit context only, and drops fields with no value.
  2. The panel uses the label. RevisionDiffPanel takes an optional labels map, and the fields panel prefers a registered field over the same key in meta, keeping the REST meta rows for keys nothing registered.
  3. The panel is now called "Fields" rather than "Meta", because a registered field is not necessarily meta.

Two things worth knowing. Plugins that add these filters inside an is_admin() guard will not surface, because a REST request is not an admin request; the "Open classic revisions screen" link stays the way to see those. And the field is only computed for requests that ask for it, which for the editor is the revisions the sidebar diffs.

Best read alongside #82158, which makes restoring reach the same data. Neither depends on the other.

Testing Instructions

  1. Activate the gutenberg-test-plugin-revision-fields test plugin, or add your own _wp_post_revision_fields entry for a meta key registered with revisions_enabled.
  2. Create a post, set the meta, and save. Change the content and the meta, then save again.
  3. Open Revisions in the sidebar and expand the Fields panel.
  4. The field is listed under the name the plugin gave it, with the value diffed against the previous revision, matching what revision.php shows.

Testing Instructions for Keyboard

Tab to Revisions in the sidebar and press Enter, then tab to the Fields panel and press Enter to expand it.

Screenshots or screencast

Classic revisions screen Visual revisions with this PR
The classic revisions screen showing an Event date section registered by a plugin The revisions sidebar showing the same Event date field in the Fields panel

Use of AI Tools

Authored with Claude Code assistance.

The revisions sidebar diffed only the post meta the REST API exposes, and
labelled each row with the raw meta key. Plugins have long registered
fields for the classic revisions screen through _wp_post_revision_fields,
with a name to show, and none of that reached the editor.

Revisions now carry those fields in the REST response, and the sidebar
panel lists them under the name the plugin gave them, falling back to the
meta it already showed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

1 similar comment
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] E2E Tests /packages/e2e-tests labels Aug 28, 2026
@ellatrix
ellatrix marked this pull request as draft August 28, 2026 04:15
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Size Change: +133 B (0%)

Total Size: 7.92 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 580 kB +133 B (+0.02%)

compressed-size-action

This branch has not been deployed

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

Labels

[Package] E2E Tests /packages/e2e-tests [Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant