Make WordPress Core

Opened 3 years ago

Last modified 44 hours ago

#28721 assigned enhancement

Scheduled changes for the customizer

Reported by: danielbachhuber Owned by: sayedwp
Milestone: 4.9 Priority: normal
Severity: normal Version:
Component: Customize Keywords: needs-patch
Focuses: Cc:

Description (last modified by westonruter)

As a user who uses the Customizer to change the layout of my homepage (or some other non-"set it and forget it option"), I'd like to be able to make changes in the Customizer, and schedule them to go live.

Depends on #39896, #31089.

Change History (21)

#1 @westonruter
3 years ago

I have an issue for this issue logged in the Settings Revisions plugin project: https://github.com/x-team/wp-settings-revisions/issues/2

#2 @celloexpressions
3 years ago

I think we would need to implement some sort of a revisions framework for the Customizer first. This would be doable for standard options and theme_mods, but could get really messy with custom setting types, and more complex implementations like Widgets and Menus.

#3 @westonruter
3 years ago

I have a working patch that adds support for scheduling Customizer settings. See #30937. The underlying mechanism for this is the proposed “Customizer transaction”. This not only facilitates scheduled settings, but it also gives us Customizer revisions.

With that patch, you can use WP-CLI to schedule a change to the blogname via:

wp post create \
    --post_type=wp_transaction \
    --post_name=$(cat /proc/sys/kernel/random/uuid) \
    --post_date_gmt="2016-01-01 00:00:00" \
    --post_status="future" \
    --post_content='{"blogname":"The 2016 Blog","blogdescription":"So much better than 2015!"}'

Obviously a nicer wp transaction command abstraction would be needed, but this is a proof of concept.

#4 follow-up: @designsimply
3 years ago

Just out of curiosity, what are the use cases for needing to schedule settings changes, and how common is it to want to do that?

#5 @danielbachhuber
3 years ago

what are the use cases for needing to schedule settings changes

One use case is to have a featured stories module with one to three stories. Editorial would like to be able to make changes for this module to be applied at some time in the future.

#6 in reply to: ↑ 4 @westonruter
3 years ago

Replying to designsimply:

what are the use cases for needing to schedule settings changes

Maybe you want a widget to appear in a sidebar at a specific time, or you want to change header image on Saturday at midnight, or even you want to activate a different theme at the start of the new year.

#7 @westonruter
17 months ago

  • Milestone changed from Future Release to 4.6

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

17 months ago

#9 @celloexpressions
17 months ago

Per the Slack conversation above, since this would involve building some UI to be usable for most people, I'd suggest waiting until after transactions land to explore it further, potentially in a future release and probably in a plugin first. Bringing in the underlying functionality with transactions, then using this ticket to make that accessible for the average user.

#10 @westonruter
17 months ago

I suggest the UI and feature be developed first in the Customize Snapshots plugin: https://github.com/xwp/wp-customize-snapshots/issues/15

#11 @celloexpressions
17 months ago

  • Milestone changed from 4.6 to Future Release

Let's revisit whether this is 4.6 material after the base transactions code is in core. Development in the plugin will probably be better to save for a future release.

#12 @westonruter
12 months ago

The infrastructure for this has been implemented in the patch for #30937.

To test, first do grunt patch:https://github.com/xwp/wordpress-develop/pull/161.

There is no UI as part of the patch, so to test scheduling a change to the site title in 5 minutes:

  1. Change the blogname in the customizer to “Scheduled Title” and note that that a changeset_uuid query param is added to the URL.
  2. Open the console and (assuming your browser timezone is the same as the blog's timezone_string):
    inOneMinute = (new Date( new Date().valueOf() + 5 * 60 * 1000 )); 
    changesetDate = inOneMinute.getFullYear() + '-' + ( '00' + ( inOneMinute.getMonth() + 1 ) ).substr( -2 ) + '-' + ( '00' + inOneMinute.getDate() ).substr( -2 ) + ' ' + ( '00' + inOneMinute.getHours() ).substr( -2 ) + ':' + ( '00' + inOneMinute.getMinutes() ).substr( -2 ) + ':' + ( '00' + inOneMinute.getSeconds() ).substr( -2 );
    wp.customize.previewer.save( { 
        status: 'future', 
        date: changesetDate
     } )
  3. Assuming that WP Cron is running properly your environment, you should see the new site title “Scheduled Title” at the designated time.

Alternatively, here is how you can schedule a change using WP-CLI without going into the customizer at all:

wp post create \
    --post_type=customize_changeset \
    --post_name=$( uuidgen ) \
    --post_status=future \
    --post_date="$( wp eval "echo get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() + 5 * 60 ) );" )" \
    --post_content='{"blogname":{ "value":"Scheduled Title"}}'

If WP Cron isn't firing, you can always wp cron event run publish_future_post

#13 @westonruter
11 months ago

In 38810:

Customize: Implement customized state persistence with changesets.

Includes infrastructure developed in the Customize Snapshots feature plugin.

See https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/

Props westonruter, valendesigns, utkarshpatel, stubgo, lgedeon, ocean90, ryankienstra, mihai2u, dlh, aaroncampbell, jonathanbardo, jorbin.
See #28721.
See #31089.
Fixes #30937.
Fixes #31517.
Fixes #30028.
Fixes #23225.
Fixes #34142.
Fixes #36485.

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

7 months ago

#15 @westonruter
7 months ago

  • Description modified (diff)

#16 @westonruter
3 months ago

  • Milestone changed from Future Release to 4.9

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

5 weeks ago

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

5 weeks ago

#19 @JoshuaWold
5 weeks ago

Just posted some options based on a conversation last week (on the save and publish button discussion) on https://core.trac.wordpress.org/ticket/39896#comment:18

Last edited 5 weeks ago by JoshuaWold (previous) (diff)

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

3 weeks ago

#21 @jbpaul17
44 hours ago

  • Owner set to sayedwp
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.