WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#39275 closed enhancement (fixed)

Improve wp.customize.previewer.save() for changesets.

Reported by: sayedwp Owned by: sayedwp
Milestone: 4.9 Priority: high
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch
Focuses: javascript Cc:

Description (last modified by westonruter)

If you do not pass any status in wp.customize.previewer.save() the changeset status becomes published because the default changesetStatus is publish in core, which compels you to pass a status if you want to save the changeset with any other statuses like draft/pending/future however that eventually creates a revision. So if you do not want to create revisions there is no option except hacking the customize_save ajax request probably with $.ajaxPrefilter.

So I think if we do not pass any status in wp.customize.previewer.save() it should just save the changeset to the previous status set.
Also it would be nice if it had a param like skip_revision which skips creating new revision.

Attachments (2)

39275.patch (1.9 KB) - added by utkarshpatel 3 years ago.
Without using additional param. If status is not passed it will not store revision.
39275_version2.patch (3.2 KB) - added by utkarshpatel 3 years ago.
Adds additional param skip_revision for wp.customize.previewer.save. By default it will store revision.

Download all attachments as: .zip

Change History (17)

@utkarshpatel
3 years ago

Without using additional param. If status is not passed it will not store revision.

@utkarshpatel
3 years ago

Adds additional param skip_revision for wp.customize.previewer.save. By default it will store revision.

#1 @westonruter
3 years ago

  • Description modified (diff)
  • Summary changed from Improve wp.customize.previwer.save() for changesets. to Improve wp.customize.previewer.save() for changesets.

#2 @westonruter
3 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.8

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


3 years ago

#4 @jbpaul17
3 years ago

  • Milestone changed from 4.8 to 4.8.1

Per yesterday's bug scrub, we're going to punt this to 4.8.1.

#5 @westonruter
3 years ago

  • Milestone changed from 4.8.1 to 4.9

This ticket was mentioned in Slack in #core-customize by jeffpaul. View the logs.


3 years ago

#7 @westonruter
3 years ago

  • Owner set to westonruter
  • Status changed from new to accepted

#8 @westonruter
3 years ago

  • Owner changed from westonruter to sayedwp
  • Status changed from accepted to assigned

@sayedwp What are the scenarios where wp.customize.previewer.save() would need to be called directly? Are the use cases not now actually better served by calling wp.customize.requestChangesetUpdate() if no revision is desired to be made?

See also: https://github.com/xwp/wordpress-develop/pull/258/commits/dfe16326127c9007d903d60322d285d509003c4b

In regards to 39275_version2.patch, a couple bits of feedback:

  • filter_var() isn't used in core, so we'd to use an alternative.
  • This logic seems backwards: $allow_revision = (bool) $args['skip_revision'];. If we're skipping should this not mean a revision is disallowed?

But if this change isn't actually required, then no need to update the patch.

#9 @westonruter
3 years ago

  • Priority changed from normal to high

Bumping priority to high for visibility and alignment with 4.9 goals, and given proximity to beta 1 deadline.

#10 @sayedwp
3 years ago

@westonruter One scenario is when only the changeset post title or date needs to be updated without creating revisions even if there are no other changes. I think wp.customize.requestChangesetUpdate() would short circuit if there are no dirty settings. We had this problem when we were auto saving the changeset title / date in snapshot plugin.

#11 @westonruter
3 years ago

Updating the title would be supported by this proposed change here: https://github.com/xwp/wordpress-develop/pull/256/commits/242eafa

It allows a title or date to be supplied.

#12 @sayedwp
3 years ago

Great! this should work.

#13 @westonruter
3 years ago

It's not ideal that there are two separate APIs here that essentially do the same thing, but they do have different enough use cases that make them useful in their own right. We'll need to revisit these entirely to create a new common underlying API call that reaches out to the upcoming Customizer endpoints when we get to it.

This ticket was mentioned in Slack in #core-customize by jeffpaul. View the logs.


3 years ago

#15 @westonruter
3 years ago

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

In 41626:

Customize: Introduce drafting and scheduling for Customizer changesets.

  • Incorporates code from the Customize Snapshots and Customize Posts feature plugins.
  • Adds a new Publish Settings section for managing the changeset status, scheduled date, and frontend preview link.
  • Updates Publish button to reflect the status selected in the Publish Settings (including Save Draft and Schedule).
  • Deactivates the Themes section when a non-publish status selected, and deactivates the Publish Settings section when previewing a theme switch.
  • Introduces an outer section type (wp.customize.OuterSection in JS) for the Publish Settings section to use and for available widgets and available nav menu panels to use in the future. These sections can be expanded while other sections are expanded.
  • Introduces WP_Customize_Date_Time_Control in PHP and wp.customize.DateTimeControl in JS for managing a date/time value.
  • Keeps track of scheduled time and proactively publish from the client when the time arrives, as opposed to waiting for WP Cron.
  • Auto-publishes a scheduled changeset when attempting to access one that missed its schedule.
  • Starts a new changeset if attempting to save a changeset that was previously publish.
  • Adds force arg to requestChangesetUpdate() to force an update request even when there are no pending changes.
  • Adds utils methods for getCurrentTimestamp and getRemainingTime.
  • Adds new state values for selectedChangesetStatus, changesetDate, selectedChangesetDate.
  • Fixes logic for when to short-circuit check to close Customizer when there are unsaved changes.
  • Adds getter methods for autosaved and branching parameters, with the latter applying the customize_changeset_branching filter.
  • Call to establish_loaded_changeset on the fly when changeset_uuid() is called if no changeset UUID was specififed.
  • De-duplicates logic for dismissing auto-draft changesets.
  • Includes unit tests.

Builds on [41597].
Props sayedwp, westonruter, melchoyce, JoshuaWold, folletto, stubgo, karmatosed, dlh, paaljoachim, afercia, johnregan3, utkarshpatel, valendesigns.
See #30937.
Fixes #39896, #28721, #39275.

Note: See TracTickets for help on using tickets.