Opened 8 years ago
Closed 8 years ago
#39033 closed enhancement (fixed)
WP REST API: Add `supports` object to `/types` response
Reported by: | timmydcrawford | Owned by: | rachelbaker |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | has-patch has-unit-tests commit |
Focuses: | Cc: |
Description
While working on a Calypso [pull request](https://github.com/Automattic/wp-calypso/pull/9751) to utilize the post types endpoint on WordPress.com, I hit a bit of a stumbling block with the current implementation.
In the [WordPress.com API](https://github.com/Automattic/jetpack/blob/master/json-endpoints/class.wpcom-json-api-list-post-types-endpoint.php#L61), the output of [get_all_post_type_supports](https://developer.wordpress.org/reference/functions/get_all_post_type_supports/) is returned in a supports
object for each post type.
Adding this object to the response stream was easy enough to do as a plugin via register_rest_field
, but I figured it might be worth considering including in the core endpoint.
Attachments (2)
Change History (7)
#1
@
8 years ago
- Keywords needs-patch needs-unit-tests added
- Milestone changed from Awaiting Review to 4.8
- Summary changed from WP REST API: Consider adding `supports` object to `/types` response to WP REST API: Add `supports` object to `/types` response
#2
@
8 years ago
what do you think about only including if the context is edit?
Seems like a good idea. Shall I work on a patch?
@
8 years ago
Include supports
in the output of the post types REST API endpoint (for edit
context only). Includes tests.
#3
@
8 years ago
- Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
39033.diff adds supports
with all of the supported features to each of the post types, only for edit
context. The patch also includes tests.
#4
@
8 years ago
- Keywords commit added
@tyxla Your patch looked great, thank you for the unit tests as well. We have the item response properties in alphabetical order - minus a special exception for rest_base
which is the last property in the Post Type response object.
In 39033.1.diff I moved the supports
property above taxonomies
in the response object to keep the semi-alpha order. Marking this for commit.
Sounds reasonable to me. I don't know if this is something we would want to expose without authentication. @timmydcrawford what do you think about only including if the
context
isedit
?