-
Notifications
You must be signed in to change notification settings - Fork 11
Allow settings to be deleted from a snapshot #17
Comments
Likewise, when calling |
That isn't really needed in wp-admin. I envisioned creating a backbone collection of the setting IDs and using buttons to remove and undo. The buttons would modified the collection and dynamically update a hidden input. That way when "Save Draft" is clicked the new content is updated without those IDs. |
@valendesigns OK, so you're thinking to not do this the WP admin edit post screen, but rather inside the Customizer itself? I think this ties into that idea we had about providing a UI to list out what the current pending changes are in the Customizer. When loading the Customizer with a snapshot, we'd need to grab all of the setting values prior to calling The trick then would be if the user updates the snapshot, we'd also need to send a list of all of the settings that have been reverted so that when the snapshot is saved, those settings can be removed from it. This was what I was referring to with |
No, I think you misunderstood me, we're talking about two different pieces of the puzzle. I'm saying that we don't need to bootstrap the Customizer in What you mentioned above still is valid if we want to revert settings in the Customizer, but that is low priority IMO. |
Create link 'Remove setting,' which toggles to 'Restore setting' on click. It also sets a hidden text field for each setting to be removed. On saving, these appear in $_REQUEST[ 'customize_snapshot_remove_settings' ]. Filter post content on 'content_save_pre,' when this is saved. If $_REQUEST has settings to be removed, filter them out. Also, add simple styling of this 'Remove setting' link. It appears red when set to 'remove,' and blue when set to 'restore.'
Create link 'Remove setting,' which toggles to 'Restore setting' on click. It also sets a hidden text field for each setting to be removed. On saving, these appear in [ 'customize_snapshot_remove_settings' ]. Filter post content on 'content_save_pre,' when this is saved. If has settings to be removed, filter them out. Also, add simple styling of this 'Remove setting' link. It appears red when setto 'remove,' and blue when set to 'restore.'
Pull Request Opened Hi @westonruter,
|
Before evaluating ->post_type, pass it to isset(). Short-circuit the conditional if it's not set.
Instead of attaching methods to 'on' event handler, Attach them to module-scope components object. Haven't yet implemented a way to export them, as Weston suggested.
Using Weston's snippet, output link title in PHP, with localization. And attach localized text 'Restore settting' to the link's data-text-restore attribute. On clicking the link, call method changeLinkText. This toggles the title to the other value stored in the data attribute. And stores the old title in the data attribute, for the next time it's clicked.
At Weston's suggestion, pass second argument to json_decode. This will then return an array, instead of an object. So access the array value with $data[ $setting_id ]. Instead of previous object access with $data->{ $setting_id }.
…tent. Also, wp_unslash() the $content. Otherwise, the json_decode function will return null.
Before iterating through the settings to unset, Ensure that the settings are in an array, as expected.
Issue #17 : Enable deleting settings in snapshot wp-admin/post page.
Given a UI for listing out the available snapshots in the WP Admin (#12), if opening a snapshot in its edit post screen (see also #16), there could be a listing of the settings in that snapshot along with checkboxes that when checked, a button could be clicked to remove them from the snapshot.
The text was updated successfully, but these errors were encountered: