Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #59

merged 108 commits into from Jul 27, 2016


None yet
4 participants
Copy link

westonruter commented Jul 11, 2016

Over the past week, off-and-on, I've done a deep dive into the snapshots PHP code and I believe I've come up with an improved refactored codebase that cleans out some cruft and improves maintainability.

  • Refactor codebase, including new Post_Type class
  • Use customize_refresh_nonces filter to export snapshot nonce
  • Eliminate generate_snapshot_uuid request by returning new UUID in saving response
  • Ensure that setting validations are handled in snapshot requests
  • Fixes #26 by removing the can_preview method: only users who have the setting's capability can write to the snapshot, so everyone should be able to freely preview what has been stored there.
  • Fixes #31 by adding support for setting validation.
  • Fixes #28 by ensuring that snapshots UI isn't loaded if a theme switch is happening.
  • Important change: Since scope was removed, now we don't need a dirty flag in the post data. We're only storing the changed values. Because of this, we can now simplify the snapshot data to just be the values. We can skip storing a sanitized flag as well, however this needs more discovery.
  • Allow snapshot posts to be published from the admin, and thus also scheduled for publication. Customizer settings get saved when a snapshot post transitions to the publish status. If any of the settings are unrecognized or invalid, none of the settings are saved and the status gets kicked back to pending with error messages explaining the problem(s). Published snapshots are considered "locked" and the UI for updating them is hidden, aside from trash. Fixes #62.
  • Add link in Customizer to access edit post screen.
  • Ensure that get_permalink() returns the frontend URL for the site with the customize_snapshot_uuid param added.
  • Add initial read-only REST API endpoints for snapshots. See #63.


  • Update unit tests to work with newly-refactored codebase.
  • Make sure that widget instance data is properly encoded so that it can be re-hydrated.
  • Make sure that saving a snapshot with invalid settings will cause the invalidation messages to appear in the settings as opposed to a modal error screen.

PR originally opened to master in #53

westonruter added some commits Jun 15, 2016

Ensure Post_Type::get_post_content() is always used to get post_conte…
…nt; ensure data migration accounts for dirty
Merge pull request #54 from xwp/bugfix/trac-37247
Check for unauthorized, unrecognized, and invalid settings prior to sanitizing

@westonruter westonruter referenced this pull request Jul 11, 2016


Refactor #53

1 of 2 tasks complete

westonruter and others added some commits Jul 26, 2016

[WIP] Add prepare_snapshot_post_content_for_publish
* Remove bulk actions filter
* Replace publish filter with transition filter.
* Remove hiding of publish metabox if not current theme. Allow publishing if not current theme.
* Remove hiding of author metabox.
* Remove extraneous info now that publish metabox is restored.
* Move Post_Type logic to Customize_Snapshot_Manager
Merge pull request #63 from xwp/feature/issue-29-rest-api
Add initial read-only REST API endpoints for snapshots
Merge pull request #62 from xwp/feature/publish-snapshot
Allow snapshot posts to publish and be scheduled

This comment has been minimized.

Copy link

coveralls commented Jul 27, 2016

Coverage Status

Coverage decreased (-4.7%) to 87.413% when pulling db598cb on feature/refactor into 04c80c0 on develop.


This comment has been minimized.

Copy link

coveralls commented Jul 27, 2016

Coverage Status

Coverage decreased (-4.7%) to 87.413% when pulling 9c56143 on feature/refactor into 04c80c0 on develop.

@westonruter westonruter merged commit 68e8f34 into develop Jul 27, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@westonruter westonruter deleted the feature/refactor branch Jul 27, 2016

@westonruter westonruter modified the milestone: 0.5.0 Aug 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.