fix: name the WordPress revision screen for library and layout revisions (audit L3)

lit/revision-restore takes only content types, so a write to a library entry
or a Theme Builder layout now answers with restore_url (wp-admin
revision.php for its revision_id), also per page in lit/divi-replace-text.
The guides and readme no longer present lit/revision-restore as the way back
for these types.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
2026-09-27 23:05:05 +02:00
co-authored by Claude Opus 5.5
parent 79f2fdbda6
commit dcae2d4b91
11 changed files with 48 additions and 12 deletions
@@ -383,7 +383,7 @@ final class DiviReplaceTextAbility implements Ability
'revision_id' => $saved['revision_id'] ?? null,
'log_id' => $saved['log_id'] ?? null,
'warnings' => is_array($saved['warnings'] ?? null) ? $saved['warnings'] : [],
];
] + (isset($saved['restore_url']) ? ['restore_url' => $saved['restore_url']] : []);
}
/**
@@ -41,6 +41,9 @@ abstract class DiviWriteAbility implements Ability
'affected_count' => ['type' => 'integer'],
'hidden_count' => ['type' => 'integer'],
'backup_id' => ['type' => 'integer'],
// Library entries and Theme Builder layouts: their revision in WordPress' revision screen (audit L3 –
// lit/revision-restore takes only content types).
'restore_url' => ['type' => 'string'],
// Theme Builder layouts: the enabled templates that show the layout – those the user may edit; the
// others only as a count (ruling Q22).
'templates' => ['type' => 'array', 'items' => ['type' => 'object']],
@@ -155,10 +155,28 @@ final class DiviWriter
foreach ($change->entries() as $entry) {
$tool->changed(DiviChange::idOf($entry, $index) ?? '?', $entry['type'], $entry['action'], $entry['label']);
}
$restore = self::restoreUrl($page, $saved['revision_id']);
if ($restore !== null) {
$tool->with('restore_url', $restore);
}
return $tool->toArray();
}
/**
* Audit L3: lit/revision-restore takes only the content types (ContentSchema) – not library entries or Theme
* Builder layouts. Their revision is restored in WordPress' revision screen; null for everything else.
*/
private static function restoreUrl(DiviPage $page, mixed $revisionId): ?string
{
$noRestoreTool = $page->isLibraryItem() || $page->isThemeBuilderLayout();
if (! $noRestoreTool || ! is_int($revisionId) || $revisionId <= 0) {
return null;
}
return admin_url('revision.php?revision=' . $revisionId);
}
/**
* save() for the Divi tools (E2): pages as before; a library entry keeps its shape, a global one
* needs confirm (dry run first), gets a backup when revisions are off and clears every page's