#28721 closed enhancement (fixed)
Scheduled changes for the customizer
Reported by: | danielbachhuber | Owned by: | sayedwp |
---|---|---|---|
Milestone: | 4.9 | Priority: | high |
Severity: | normal | Version: | |
Component: | Customize | Keywords: | needs-patch |
Focuses: | Cc: |
Description (last modified by )
Change History (31)
#2
@
6 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
@
5 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":{"value":"The 2016 Blog"},"blogdescription":{"value":"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:
↓ 6
@
5 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
@
5 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
@
5 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.
This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.
4 years ago
#9
@
4 years 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
@
4 years 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
@
4 years 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
@
3 years 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:
- Change the
blogname
in the customizer to “Scheduled Title” and note that that achangeset_uuid
query param is added to the URL. - 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 } )
Update: As of WordPress 4.9 the save
call should be changed to the following so that the UI reflects the new state:
wp.customize.state( 'selectedChangesetStatus' ).set( 'future' ); wp.customize.state( 'selectedChangesetDate' ).set( changesetDate ); wp.customize.previewer.save(); // Reads from state for default values.
- 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
This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.
3 years ago
This ticket was mentioned in Slack in #core-customize by melchoyce. View the logs.
3 years ago
This ticket was mentioned in Slack in #core-customize by joshuawold. View the logs.
3 years ago
#19
@
3 years 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
This ticket was mentioned in Slack in #core by westonruter. View the logs.
3 years ago
#22
@
2 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.
I have an issue for this issue logged in the Settings Revisions plugin project: https://github.com/x-team/wp-settings-revisions/issues/2