[wp-trac] [WordPress Trac] #37974: Add multi-panel feature to pages through add_theme_support

WordPress Trac noreply at wordpress.org
Tue Oct 18 10:39:08 UTC 2016


#37974: Add multi-panel feature to pages through add_theme_support
-----------------------------------------+------------------
 Reporter:  karmatosed                   |       Owner:
     Type:  task (blessed)               |      Status:  new
 Priority:  normal                       |   Milestone:  4.7
Component:  Themes                       |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  has-ux-feedback needs-patch  |     Focuses:  ui
-----------------------------------------+------------------

Comment (by pento):

 [attachment:37974.17.diff] is an experiment in using WP-API instead of
 `wp_ajax_find_posts()`. Any followup patches on this ticket should be
 based on [attachment:37974.16.diff], as 17 depends on WP-API being merged
 into Core.

 For testing 17, you ''must'' have the [https://wordpress.org/plugins/rest-
 api/ WP-API plugin] installed and activated.

 If you're interested in how I found it to work with, here are the primary
 changes:

 '''`WP_Customize_Post_Collection_Control::print_templates()`'''

 `data.title` is now `data.title.rendered`. A minor surprise, but was easy
 to fix after noticing that the titles were all coming up as `[object
 Object]`. :-)

 '''`WP_Customize_Post_Collection_Control::get_posts()`'''

 I had two problems here. First, the use of `rest_do_request()` is barely
 documented, I had to go digging around in other code for examples of how
 to use it.

 Second, there is no endpoint for getting a set of posts with arbitrary
 post_types. This means that we have to iterate over all of the defined
 post types, then manually sort the final results ourselves. The `usort()`
 call is a super ugly hack (and won't work in PHP 5.2), but it gets us
 there.

 '''`api.PostCollection.PostCollectionControl.search()`'''

 The `wp.api` library is super simple to work with, though the
 documentation could use some work. That was the easy part.

 Again, I ran into the lack of endpoint for arbitrary post_types, which
 meant a mess of promises to try and sync all of the data. This also has
 performance issues if there are multiple post types, as each one is a
 separate (though simultaneous) request. Merging the results took a bit of
 experimenting to work out the right data to give to `$.when`.

 Everything else stayed the same.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37974#comment:163>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list