Skip to content

Try: site history for Simplified publish, with Restore - #271

Open
getdave wants to merge 4 commits into
getdave/global-save-prototypes-rebuildfrom
getdave/site-history
Open

getdave wants to merge 4 commits into
getdave/global-save-prototypes-rebuildfrom
getdave/site-history

Conversation

@getdave

@getdave getdave commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

What does this do?

This adds site history to "Simplified publish", stacked on #270. A clock in the top bar opens a panel listing everything Publish site has published, and any earlier version can be brought back.

Only what Publish site publishes is listed: templates, template parts, site styles, menus and site settings. Pages and posts keep core's own revisions.

How does it work?

  • A small log on top of core revisions. Core already keeps a revision of each template, part, styles record and menu it saves, but nothing says which were saved together, and site settings have no revisions at all. includes/site-history.php adds one entry per Publish site with the time, the person and each change. A change points at the revision it made, or holds the saved values for a site setting. The log is a non-autoloaded option capped at 50 entries, read and written through /site-history.
  • From what to what. Just before the save, while the editor still holds both the old and new records, site-history-diff.js works out what changed and stores it with the entry. Style values show by their preset name with colour swatches, settings show their old and new values, and blocks show as edited, added or removed. Each entry therefore still reads correctly after the theme or palette changes.
  • Three levels of detail. An entry lists its changes. Opening it gives each change a one-line summary, and a change with several details opens a screen listing each one from → to.
  • Restore is an edit, not a save. Restore asks first in a dialog, then loads that version back in as unsaved changes, which wait for Publish site like any other. Nothing is previewed. The newest entry is marked "Latest" rather than offering Restore, because restoring it would change nothing.

The clock stays disabled until something has been published.

What's not here yet?

Unpublished changes still live only in the editor's memory, so a refresh loses them. Keeping a draft between visits, and scheduling, come next.

How do I test it?

  1. Change the site colours in Colors, then Publish site.
  2. Open the clock. The entry reads "Published 1 change". Open it, then open "Site look" to see each colour from → to.
  3. Change the site name and publish again. The first entry now has Restore.
  4. Restore it. The dialog explains that the preview changes but the site doesn't until it's published. After confirming, Publish site appears with the old colours waiting.

Tests

  • PHPUnit covers the log in tests/phpunit/site-history-test.php: entries, revisions, leaving out pages, the cap, permissions, and keeping details safe.
  • Unit tests cover the diffing in src/top-bar/test/site-history-diff.js.
  • There's no e2e spec yet. I'd add one once the direction is settled.

🤖 Generated with Claude Code

@getdave
getdave added this pull request to stack #272 November 19, 2026 21:57
@github-actions

Copy link
Copy Markdown

Try this branch in WordPress Playground, with a WooCommerce shop, for an AI agent to drive, or on a blank site with WordPress's default theme. All run the latest build of getdave/site-history and update with every push, a few minutes after the Plugin zip build finishes.

To start in a workspace other than Default, open it in Writing, Builder or Selling.

@scruffian scruffian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we haven't got this totally right, but this is a step in the right direction.

@getdave
getdave marked this pull request as ready for review November 20, 2026 12:05
Phase 2 of the "Simplified publish" prototype. A clock in the top bar
opens a panel listing what each Publish site published.

- A small PHP log (`includes/site-history.php`) records each Publish
  site as one entry: the time, the person, and per change the core
  revision it made, or for site settings the values saved. Only
  templates, template parts, site styles, menus and site settings go in.
  Pages and posts keep core's revisions.
- Each change carries what it changed, from what to what, worked out
  just before the save (`site-history-diff.js`): style values by preset
  name with swatches, settings, and blocks added, removed or edited.
- Three levels: an entry, its changes with a one-line summary, and a
  screen of every detail.
- Restore asks first in a dialog, then loads the version back in as
  unsaved edits that wait for Publish site. Nothing is previewed.
- The clock is disabled until something has been published.
- PHPUnit tests for the log; unit tests for the diffing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@getdave
getdave force-pushed the getdave/site-history branch from b7bb2f0 to eade78b Compare November 20, 2026 12:33
A revision holds a record as a save left it, so an entry's own revisions
are what the site already shows, and Restore put back what was live. Going
back to an entry now undoes every later publish instead: each record they
changed goes back to how it was before the oldest of them.

- Log `previous_revision` with each record, and `previous` values with
  each site setting.
- Note the revision each person's save made, so a save by someone else
  before the entry is logged isn't claimed.
- Keep a record's original as a revision before its first update, so the
  first change can be undone.
- Only keep site settings REST knows.
- Say when there was nothing to put back, rather than "Version put back".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rCnBtFg3artGYxgKtvdpE
- A template or part a later publish first changed had no earlier version,
  so restoring to before it failed. It now goes back to the theme's file,
  as core's reset does but as an unsaved edit.
- An autosave is no longer noted as the revision a save made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rCnBtFg3artGYxgKtvdpE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants