{"action":"created","issue":{"url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/issues/37","labels_url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/issues/37/comments","events_url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/issues/37/events","html_url":"https://github.com/xwp/wp-customize-widgets-plus/pull/37","id":112287871,"number":37,"title":"Customizer Settings Snapshot","user":{"login":"valendesigns","id":62798,"avatar_url":"https://avatars.githubusercontent.com/u/62798?v=3","gravatar_id":"","url":"https://api.github.com/users/valendesigns","html_url":"https://github.com/valendesigns","followers_url":"https://api.github.com/users/valendesigns/followers","following_url":"https://api.github.com/users/valendesigns/following{/other_user}","gists_url":"https://api.github.com/users/valendesigns/gists{/gist_id}","starred_url":"https://api.github.com/users/valendesigns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valendesigns/subscriptions","organizations_url":"https://api.github.com/users/valendesigns/orgs","repos_url":"https://api.github.com/users/valendesigns/repos","events_url":"https://api.github.com/users/valendesigns/events{/privacy}","received_events_url":"https://api.github.com/users/valendesigns/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"valendesigns","id":62798,"avatar_url":"https://avatars.githubusercontent.com/u/62798?v=3","gravatar_id":"","url":"https://api.github.com/users/valendesigns","html_url":"https://github.com/valendesigns","followers_url":"https://api.github.com/users/valendesigns/followers","following_url":"https://api.github.com/users/valendesigns/following{/other_user}","gists_url":"https://api.github.com/users/valendesigns/gists{/gist_id}","starred_url":"https://api.github.com/users/valendesigns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valendesigns/subscriptions","organizations_url":"https://api.github.com/users/valendesigns/orgs","repos_url":"https://api.github.com/users/valendesigns/repos","events_url":"https://api.github.com/users/valendesigns/events{/privacy}","received_events_url":"https://api.github.com/users/valendesigns/received_events","type":"User","site_admin":false},"milestone":null,"comments":11,"created_at":"2015-10-20T05:04:03Z","updated_at":"2015-11-03T09:38:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/pulls/37","html_url":"https://github.com/xwp/wp-customize-widgets-plus/pull/37","diff_url":"https://github.com/xwp/wp-customize-widgets-plus/pull/37.diff","patch_url":"https://github.com/xwp/wp-customize-widgets-plus/pull/37.patch"},"body":"Basically, this is Customizer Transactions lite which would allow a user to share a customizer snapshot with anyone.\r\n\r\n#### User Stories\r\n- [x] Share the exact current state of the Customizer settings, including dirty and non-dirty settings, a “full snapshot”.\r\n- [x] Share the modified (dirty) settings, for a “diff snapshot”.\r\n- [x] Allow unauthenticated user to access a snapshot to view on the frontend, or authenticated users to load the snapshot in the Customizer (maybe there should be an admin bar link for this instead of automatically redirecting).\r\n\r\n#### Todo's\r\n- [x] Build a custom post type that saves a JSON blob of all the Customizer settings into post_content to be played back at a future date.\r\n- [x] Potentially, we could have an option to save only the dirty settings. This means any changes made after the snapshot was created would persist and the dirty settings would be played on top of the current settings.\r\n- [x] Use `customize_snapshot_uuid` as the query parameter, which is passed a UUID mapped to a specific post title.\r\n- [x] Create a new UUID every time Share is clicked, if the user is not viewing a saved snapshot.\r\n- [x] Add a button to the Customizer that indicates the user can share the current URL with non authenticated users to preview.\r\n- [x] Clicking \"Save\" when previewing a snapshot should save & publish the snapshot and save the Customizer, while clicking \"Save\" when _not_ previewing a snapshot should only save the Customizer.\r\n- [x] Unit test `Customize_Snapshot_Manager`.\r\n- [x] Unit test `Customize_Snapshot`.\r\n- [x] Add Underscore templates for the dialogs.\r\n- [ ] Preview a snapshot when a UUID is present in the query string.\r\n  - [x] Rewrite the Customize deep link.\r\n  - [x] Don't allow snapshots when previewing an inactive theme or for a different theme than the snapshot was intended for.\r\n  - [x] Update values for authenticated users in the Customizer.\r\n  - [x] Update values for all users by Bootstrapping a headless Customizer on the front-end.\r\n  - [ ] Disable the navigation click events when visiting the preview URL.\r\n  - [ ] Make it work with the [contextual-settings](https://github.com/xwp/wp-customize-contextual-settings) plugin.\r\n\r\n#### Known Issues\r\n- [x] __Blocker__: When `WP_Customize_Manager::add_dynamic_settings` is called from `Customize_Snapshot_Manager::save`, via the save or update snapshot methods, errors are thrown if you've added widgets or menus. Based on the errors the issue stems from `WP_Customize_Manager::get_setting` being passed an illegal offset or `null`.\r\n- [x] __Bug__: Site icon doesn't preview.\r\n- [x] __Bug__: Nav Menu doesn't preview.\r\n\r\n#### Caveats\r\nCurrently the saved data is JS sanitized. There is a risk with that, that if the site changes their auth key constant, that the JS values for widgets would then fail to convert from JS values back to PHP values, because the HMAC check would then fail. However, I have not found a way to save them as sanitized PHP and then convert them back to JS at run time without the preview breaking."},"comment":{"url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/issues/comments/153298782","html_url":"https://github.com/xwp/wp-customize-widgets-plus/pull/37#issuecomment-153298782","issue_url":"https://api.github.com/repos/xwp/wp-customize-widgets-plus/issues/37","id":153298782,"user":{"login":"valendesigns","id":62798,"avatar_url":"https://avatars.githubusercontent.com/u/62798?v=3","gravatar_id":"","url":"https://api.github.com/users/valendesigns","html_url":"https://github.com/valendesigns","followers_url":"https://api.github.com/users/valendesigns/followers","following_url":"https://api.github.com/users/valendesigns/following{/other_user}","gists_url":"https://api.github.com/users/valendesigns/gists{/gist_id}","starred_url":"https://api.github.com/users/valendesigns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valendesigns/subscriptions","organizations_url":"https://api.github.com/users/valendesigns/orgs","repos_url":"https://api.github.com/users/valendesigns/repos","events_url":"https://api.github.com/users/valendesigns/events{/privacy}","received_events_url":"https://api.github.com/users/valendesigns/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T09:38:13Z","updated_at":"2015-11-03T09:38:13Z","body":"@westonruter It appears that this feature is mostly working as we want it to for all users. Except, and this is an bug one, with contextual settings (insert sad face here). We should connect tomorrow and discuss how to get the two working together.\r\n\r\nAt first glance I noticed that the Customizer thinks the settings are global, so when you save the snapshot data it doesn't differentiate the global and local scope. So even though previewing a snapshot with contextual settings will work, when you load it in the Customizer it sets the global scope for all the widgets to the values in the snapshot and `Localise to the current page` is unchecked. I know we keep slightly different hours, so feel free to checkout the PR tomorrow if you have a chance and haven't heard from me yet."}}