WP Manifestindependent plugin directory
manifest / builders / convert-revisions-to-json

Convert Revisions to JSON

WordPress plugin: browse a post's Divi 5 revisions in a meta box and export any revision as an importable Divi layout JSON file.

by Ed · github.com/eduard-un/convert-revisions-to-json

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/eduard-un/convert-revisions-to-json/archive/refs/heads/main.zip

Readme

Convert Revisions to JSON

Browse a post's revisions in a Divi-aware meta box and export any one of them as a Divi layout JSON file that can be imported on another site.

WordPress keeps revisions of Divi layouts, but Divi offers no way to get a layout back out of one. The only recovery path is a destructive revision restore on the live post, which also cannot move the layout anywhere else. This plugin adds that missing path.

Requirements

  • Divi 5 (tested against 5.9.0)
  • WordPress 5.8+, PHP 7.4+

Installation

Clone or download into your plugins directory, then activate:

cd wp-content/plugins
git clone https://github.com/eduard-un/convert-revisions-to-json.git
wp plugin activate convert-revisions-to-json

Or download the repository as a ZIP and install it through Plugins → Add New → Upload Plugin.

Divi 5 block content only. Revisions holding Divi 4 shortcode layouts are listed but marked non-exportable, so you can see they exist and why they cannot be used.

What it does

The meta box appears on any post whose builder is or was active — the box still shows if the builder has since been switched off, as long as a revision holds a layout.

  • A slider, prev/next stepping and author/date chrome, mirroring the native revisions screen.
  • Structure view: a Section → Row → Module tree built from the blocks. Turn on Compare with previous revision to mark nodes added, removed or changed. The count of differences is shown next to the checkbox, and Only changes collapses the tree to just the changed nodes and the path down to them — a typical revision changes one module out of several hundred, which is otherwise a long scroll to find.
  • Raw view: core's split diff over the block markup, for when the shape is identical and only styling changed.
  • Export as Divi JSON: streams a portability file for the selected revision.

Before download, the box warns if the revision references design presets that no longer exist on this site, naming the affected modules. Divi imports such a layout silently and falls back to default styling; this tells you first.

How the export works

The file is produced by Divi's own exporter (PortabilityPost), handed the revision's content instead of the live post's. That means the output is what Divi itself would write — base64 images, presets, global colors and variables, canvases, page settings — and stays correct as Divi changes, rather than being a reimplementation that drifts.

The exported post_content is not byte-identical to the stored revision: Divi runs it through wp_kses_post(), which normalizes inline CSS. Its native export does the same. The layout is unaffected.

Tests

wp eval-file wp-content/plugins/convert-revisions-to-json/tests/test-logic.php

54 assertions over the block parser, tree diffing, preset scanning, stale-preset detection and filename building. Exits non-zero on failure.

Manual QA checklist

The parts that touch Divi and the browser are not covered by the automated tests.

  1. Open a Divi 5 page in the editor. The Divi Revisions → JSON box appears below the editor, showing the newest revision.
  2. Drag the slider. The handle moves, the blue fill tracks it, and the tree, author, date and position counter update.
  3. Tick Compare with previous revision. A change count appears beside the checkbox. Changed nodes gain an amber marker; added and removed nodes gain green and red. Tick Only changes to collapse the tree to just those nodes.
  4. Switch to Raw. Core's split diff table appears.
  5. Click Export as Divi JSON. A divi-layout-<slug>-rev<id>-<date>.json file downloads.
  6. On a second Divi 5 site, use Divi's own import (Divi Library → Import, or the builder's portability modal) to load the file. Confirm the layout matches the revision, including images and preset-driven styling.
  7. Open a non-Divi post. The box does not appear.
  8. As a user without edit_post on that post, confirm the box does not render and the export URL returns a permission error.

Step 6 is the one thing the automated tests cannot reach — it needs a second site.

Design notes

docs/DESIGN.md records the architecture and, more usefully, the things that only surfaced by running the exporter against real content: Divi's lazily-autoloaded portability helpers, its image-pagination call that terminates a single-request export, and the two different shapes groupPreset.presetId takes in saved markup.

License

GPL-2.0-or-later. See LICENSE.

Read the full README on GitHub →