WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 15 months ago

#41972 new enhancement

Add Import/Export functionality to the Customizer

Reported by: philclothier Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8.2
Component: Customize Keywords:
Focuses: ui Cc:
PR Number:

Description

As a theme author, a big part of our documentation and guidance is instructing people how to replicate different theme previews. Fr complex Customizer settings, it would be great to be able to provide a user with a file which could be uploaded to the site. Much like uploading an xml file to import the post/page content.

I'm aware of plugins such as https://wordpress.org/plugins/customizer-export-import. However I think it would be a great enhancement to add import/export functionality to core, removing the reliance on a plugin and the extra burden this adds for beginner level users.

This could also help alleviate issues raised in #27177.

The import/export options could be a further development of the UI mentioned in #39896.

Change History (2)

#1 @westonruter
2 years ago

cf. my comment on #39896:

It is trivial to implement an export feature because it's simply a matter of exporting the contents of the customize_changeset post. Well, and any posts that may be referenced in that changeset.

The hard thing is importing a changeset. Settings for widgets and nav menus all make reference to auto-incremented IDs in their settings, and so importing a changeset would run the real risk of conflicting with existing changes on a given site. Importing a changeset in a way that does not conflict with existing content is what the starter content feature was designed to solve: #38114.

In order to export and import a changeset, it would essentially need to be able to “understand“ the structure of the IDs (e.g. nav_menu_item[123] and the structure of the values, like when page_on_front is set to 4, that the 123 in the former and the 4 in the latter are both references to post IDs. It's the same problem you get when trying to migrate parts of a database from one site to another existing database. This is a problem that VersionPress has been focused on heavily as well as Mergebot. There may be a way to leverage schema work done by these projects as a way to inform a changeset import/export tool. But it would be out of scope for this ticket.

#2 @galbaras
15 months ago

@westonruter The complexity of importing may be just a result of using the post export for exporting changesets.

Since the customizer can turn a changeset into a rendered page for previewing on the source site, it must first resolve all the references. Exporting at that point (from the customizer, not the WP exporter) should provide enough information for the subsequent import.

There may be caveats, like requiring the same theme(s) and plugins to be present/active on the target site as on the source site, but assuming all the settings are fully included in the export, not referenced, importing should work OK.

I think this enhancement can be a major leap forward once the customizer is fully adopted by plugin developers as a way to save/edit plugin settings. Taking new developments and respective settings live, while not changing content, can then be a far easier matter than it is today.

Note: See TracTickets for help on using tickets.