[wp-trac] [WordPress Trac] #40527: Decouple WP_Customize_Manager
WordPress Trac
noreply at wordpress.org
Mon Aug 28 12:10:16 UTC 2017
#40527: Decouple WP_Customize_Manager
--------------------------+------------------
Reporter: utkarshpatel | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.9
Component: Customize | Version: 4.8
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------
Comment (by dlh):
[attachment:40527.diff] is a first attempt at a `WP_Customize_Changeset`
class.
Some notes about the patch:
- The scope so far has been to abstract as much changeset code as possible
that operates independently of a `WP_Customize_Manager` instance. I chose
this scope in part based on the comment here: https://github.com/WP-API
/wp-api-customize-endpoints/pull/5#discussion_r118804446.
- There is, of course, room to add more functionality from
`WP_Customize_Manager` -- for instance, more of the logic from
`save_changeset_post()`. But because doing so also might increase the
coupling between the two classes, I thought it best to check in first.
- One exception to the above is the `publish()` method, which accepts a
`$wp_customize` instance.
- There are two named constructors for instantiating an instance based on
a UUID or a post ID. Core needs to be able to look up changeset data by
both UUID and post ID, and in neither case is there guaranteed to be a
corresponding post in the database. I found it easier to handle the logic
for what the changeset instance should look like under these different
circumstances in the separate constructors rather than a single
`__construct()`, but I'm open to other ideas.
- The patch doesn't try to swap a `WP_Customize_Changeset` into every
location in core where it could be used, so it might not handle all the
requirements it would need to yet. Attempting to integrate the class into
the in-progress REST API endpoints would also probably uncover additional
needs or other functionality that would be helpful.
- comment:3 is addressed in the patch, but not comment:2 yet.
- No unit tests yet.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40527#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list