WordPress.org

Make WordPress Core

Opened 6 days ago

Closed 3 days ago

#42206 closed defect (bug) (fixed)

Customize: Facilitate including changeset title with save requests

Reported by: dlh Owned by: westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

Allowing users to set the title of a Customize changeset is useful on sites that enable both changeset branching and a post list table for saved changesets. However, there's currently no "official" way to control the title of a changeset submitted with the 'customize_save' Ajax request.

Unofficially, one workaround is to replace the default "Save" button with a custom button that provides more control over what happens when the user saves their changes. But the default "Save" button's added powers in 4.9 makes replacing it less feasible.

As discussed in Slack, one way to provide more control over the title is to trigger an event before sending the 'customize_save' request, which is the approach I've tried in the attached patch.

Another idea from the Slack discussion was adding a changesetTitle state. I decided to try the event first because (a) managing the state adds a lot of overhead for a feature with no core UI now, (b) a future core UI for the title might benefit from some other approach than a changesetTitle state, and (c) an event might scale more easily to future changeset parameters that also don't have a core UI.

I named the event 'customize-save' for consistency with the Ajax action. 'save-data' was suggested in Slack, but I decided against it because the PHP filter by that name passes parameters that seem closer to the existing 'changeset-save' event. Of course, the name could be anything.

Attachments (4)

42206.diff (916 bytes) - added by dlh 6 days ago.
42206.2.diff (903 bytes) - added by dlh 5 days ago.
42206.3.diff (892 bytes) - added by westonruter 3 days ago.
42206.4.diff (908 bytes) - added by westonruter 3 days ago.
Rename yet again to save-request-params

Download all attachments as: .zip

Change History (8)

@dlh
6 days ago

#1 @westonruter
6 days ago

  • Milestone changed from Awaiting Review to 4.9
  • Owner set to westonruter
  • Status changed from new to accepted
  • Type changed from enhancement to defect (bug)

This will be needed by the Customize Snapshots plugin when adding support for 4.9. The plugin will need to add the title field, but as noted in this ticket, there would not be a clean way to ensure this title is included in the save requests.

I think save-data will be a better name ultimately because customize-save is redundant in that it's being triggered on the wp.customize object already. The reason the Ajax action is prefixed by customize is because it is in the global scope.

@dlh
5 days ago

#2 @dlh
5 days ago

42206.2.diff switches to 'save-data'.

@westonruter
3 days ago

#3 @westonruter
3 days ago

Thinking about this some more, and now I'm thinking save-params would be a better name because otherwise save-data could be confused with the customize_changeset_data param. See 42206.3.diff.

@westonruter
3 days ago

Rename yet again to save-request-params

#4 @westonruter
3 days ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 41869:

Customize: Add 'save-request-params' event on wp.customize for plugins to inject/modify params in save requests.

Allows feature plugins, for example, to supply a customize_changeset_title param instead of having to wrap wp.customize.previewer.query.

Props dlh.
Fixes #42206.

Note: See TracTickets for help on using tickets.