Changes between Version 56 and Version 57 of Ticket #30937
- Timestamp:
- 10/02/2016 07:48:31 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30937
-
Property
Summary
changed from
Add Customizer transactions
toAdd Customizer changesets (state persistance)
- Property Keywords has-patch added; needs-patch removed
-
Property
Summary
changed from
-
Ticket #30937 – Description
v56 v57 4 4 5 5 Another downside is that whenever the preview needs to load a new URL it has to re-send all the modified settings so that the Customizer preview will have them available to add to the filters, since the Customized data is not persisted in WordPress in any way. There's also a performance hit to continually send all data with each request, which was partially improved with #28580. 6 I 7 So I propose that we introduce persisted Customizer settings, in other words '''Customizer ~~transactions~~ changesets'''. 6 8 7 So I propose that we introduce persisted Customizer settings, in other words '''Customizer transactions'''.9 When opening the Customizer for the first time, a changeset UUID can be generated. Whenever a setting changes, an Ajax request sends the updated setting to WordPress to be persisted in a `customize_changeset` post which has a post_name corresponding to that UUID (or a post is created dynamically if not existing already). Any changes made in the Customizer then get amended to the same `customize_changeset` post, which has a key/value JSON blob as its `post_content`. 8 10 9 When opening the Customizer for the first time, a transaction UUID can be generated. Whenever a setting changes, an Ajax request sends the updated setting to WordPress to be persisted in a `wp_transaction` post which has a post_name corresponding to that UUID (or a post is created dynamically if not existing already). Any changes made in the Customizer then get amended to the same `wp_transaction` post, which has a key/value JSON blob as its `post_content`. 11 Instead of POSTing all of the customized settings to the preview, we then only have to reference the changeset UUID when loading URLs into the Customizer preview. Indeed, the patch I've worked on does this in a way that resolves #30028 (Load Customizer preview iframe with natural URL) and #23225 by injecting the changeset UUID as a query parameter for the URL being previewed and then amended to any site URL generated in the preview, so that navigating around the site in the preview (even following standard links with `GET` requests) will ensure that the changeset will continue to be referenced and loaded. In this way, when a changeset is updated the Customizer preview only has to do `location.reload()` instead of the current approach of doing an Ajax POST request followed by `document.write()` in the iframe window. (Nevertheless, the existing “seamless refresh” logic can remaij in which a loading `PreviewIframe` instance can replace the previously loaded one after it has finished loaded.) 10 12 11 Instead of POSTing all of the customized settings to the preview, we then only have to reference the transaction UUID when loading URLs into the Customizer preview. Indeed, the patch I've worked on does this in a way that resolves #30028 (Load Customizer preview iframe with natural URL) and #23225 by injecting the transaction UUID as a query parameter for the URL being previewed and then amended to any site URL generated in the preview, so that navigating around the site in the preview (even following standard links with `GET` requests) will ensure that the transaction will continue to be referenced and loaded. In this way, when a transaction is updated the Customizer preview only has to do `location.reload()` instead of the current approach of doing an Ajax POST request followed by `document.write()` in the iframe window.13 As noted in #20714, my patch also injects the changeset UUID in form submissions (GET and POST), as well as in jQuery Ajax requests. This allows you to preview setting changes for full web applications in the Customizer. 12 14 13 As noted in #20714, my patch also injects the transaction UUID in form submissions (GET and POST), as well as in jQuery Ajax requests. This allows you to preview setting changes for full web applications in the Customizer. 14 15 Other side-benefits that Customizer transactions will bring us: 15 Other side-benefits that Customizer changesets will bring us: 16 16 17 17 * Settings can be drafted and then returned to later. 18 18 * Settings can be collaborated on by multiple users (though not concurrently, without some Heartbeat system in place) 19 * The capability to publish a ` wp_transaction` post can be limited by role, allowing 'Customizer contributors' to submit settings as pending review.20 * Settings can be scheduled for going live at a later date by saving the transactionpost simply with `post_status=future` (see #28721)21 * With each save in the Customizer resulting in a new transactionpost being created, then there is Customizer revision history (see #31088, #31089)22 * Accessing the Customizer preview for a transaction needs no special capabilities since the transaction is updated by an authorized user via single Ajax request. This means that Customizer previews (frontend URLs with the transactionUUID amended) can be shared for anonymous users to review.23 * Customizer Theme Switch (#31303) could preview another theme and refresh the Customizer without losing settings, and thus no AYS dialog would be needed. 19 * The capability to publish a `customize_changeset` post can be limited by role, allowing 'Customizer contributors' to submit settings as pending review. 20 * Settings can be scheduled for going live at a later date by saving the changeset post simply with `post_status=future` (see #28721) 21 * With each save in the Customizer resulting in a new changeset post being created, then there is Customizer revision history (see #31088, #31089) 22 * Accessing the Customizer preview for a changeset needs no special capabilities since the changeset is updated by an authorized user via single Ajax request. This means that Customizer previews (frontend URLs with the changeset UUID amended) can be shared for anonymous users to review. 23 * Customizer Theme Switch (#31303) could preview another theme and refresh the Customizer without losing settings, and thus no AYS dialog would be needed. (See #36485.) 24 24 25 Something else that motivated my investigation into Customizer transactions is thinking about how the Customizer will relate to the '''JSON REST API'''. How can the REST API be improved with the Customizer? If the REST API provides a `transactions` endpoint for doing CRUD operations on Customizer settings, and if the REST API also has global recognition for a `customize_transaction_uuid` query parameter in all requests, then it becomes possible for the Customizer to be used to preview changes in applications that merely interact with the JSON REST API, as long as they include the transactionUUID in the requests.25 Something else that motivated my investigation into Customizer changesets is thinking about how the Customizer will relate to the '''JSON REST API'''. How can the REST API be improved with the Customizer? If the REST API provides a `changesets` endpoint for doing CRUD operations on Customizer settings, and if the REST API also has global recognition for a `customize_changeset_uuid` query parameter in all requests, then it becomes possible for the Customizer to be used to preview changes in applications that merely interact with the JSON REST API, as long as they include the changeset UUID in the requests. 26 26 27 There's a lot of exciting possibilities introduced with Customizer transactions.27 There's a lot of exciting possibilities introduced with Customizer changesets. 28 28 29 Initial alpha Core patch for Customizer transactions can be seen at: https://github.com/xwp/wordpress-develop/pull/6129 Initial alpha Core patch for Customizer changesets can be seen at: https://github.com/xwp/wordpress-develop/pull/61 30 30 31 31 See Make Core blog post: https://make.wordpress.org/core/2015/01/26/customizer-transactions-proposal/