Skip to content

Page export: write a synced page back to its page folder (the reverse of wp bs pages sync) #216

Backlog

Description

@WebUppAdmin

We would like to ask for a page export in Blockstudio: a way to write a page from the database back to a page folder, so that syncing that folder again gives the same page.

The use case. Blockstudio lets an agent build a page as files, which is what agents do best. After that first sync the page is also edited by a person in the editor. We want WordPress to be the one home of the page from then on, with no file copy kept. When an agent next needs to change the page, it would export it to a folder, edit the files, and sync that one page back. Today the first half does not exist: wp bs pages has sync only, and Content Sync leaves the body of a page-sync page out.

What we do today. Our plugin has its own exporter. It writes index.php in the block tag form and page.json, then reads the file back through Blockstudio's parser and compares the result with the stored page. It works, but it lives outside Blockstudio. It has to follow the tag grammar from a distance (anchors, attributes read from markup, entities, value types), and to check itself it has to reach parser code that is not public. Every Blockstudio release can break it.

What would serve us. Either of these:

  1. An export command and a PHP entry beside it, for example wp bs pages export <name> --path=<folder> and Pages::export( $post_id, $folder ). It writes page.json and the content file for one page into a folder we name, which may be outside the theme. The promise we need is the round trip: syncing the exported folder, unchanged, writes the same post_content byte for byte. Where the tag form cannot hold a block exactly, plain block markup for that block or for the whole file would be fine, and so would a clear error naming the block.

  2. A smaller step that would already help: a public way to ask "what would a sync write for this page folder" without writing it (the parsed and serialised content), and a documented one-page sync for a folder we name that takes the post to update and never prunes other pages. Page_Sync::reconcile() with existing does the second part today and we use it. With both public we could keep our own exporter and stop relying on private code.

We are glad to test a build against our pages, or to send a pull request if that is easier for you.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions