Opened 2 years ago
Closed 19 months ago
#16476 closed enhancement (duplicate)
Custom post types support in XML-RPC
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | XML-RPC | Version: | 3.1 |
| Severity: | normal | Keywords: | |
| Cc: | trac@…, raam@… |
Description
The function mw_newPost (metaWeblog.newPost) does not support custom post types, only post and page are supported.
Publishing custom post types via rpc would be neat.
Attachments (1)
Change History (9)
comment:2
rofflox
— 2 years ago
I've already played around with this. In my opinion, the whole wp-xmlrpc-server class should be overhauled.
For example:
- Create a generic wp_getPost / wp_newPost / wp_deletePost / wp_editPost
- The output of the functions should be more or less the same as in the default functions. E.g. title => post_title, postid => ID etc.
- For backwards compatibility:
- Create all sub functions e.g. mw_getPost with link to the generic wp_getPost
- Add an optional second parameter "mode" to format the output based on the calling function. E.g. mode = mw_getPost will format the output of the result array in a different way.
- Take an associative array instead of a numeric one as argument, so we could seamless add additional features in the future. Thats already WP standard.
- For custom post types, we have to check for the registered capbilities. Unfortunaltey, they aren't mapped by default. This should also be added to the register_posttype function. e.g.
if (! current_user_can('edit_' . $args->post_type, $args->post_id)) {
return new IXR_Error(401, __('Sorry, you cannot edit the post type _' . $args->post_type . '_.'));
}
I've added a working example for wp_getPost, wp_getPosts and wp_getPage in the diff. Maybe someone could check if this is a good approach and give feedback.
comment:3
hakre
— 2 years ago
Can you provide a patch w/o deprecating for the moment? It's not that I won't like the idea but to keep things simple and I think deprecation needs some decision first.
comment:4
ptahdunbar
— 2 years ago
- Cc trac@… added
comment:5
josephscott
— 2 years ago
I like having custom post type support in XML-RPC, but I don't think this is the way forward on it. I think this is a good time to consider some new methods that will work on any post type (custom and built in).
comment:7
nprasath002
— 19 months ago
Related #18429
comment:8
SergeyBiryukov
— 19 months ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
+1 from me.
I agree it'd be great if XMLRPC wasn't limited to posts and pages.