Opened 14 years ago
Closed 13 years ago
#16476 closed enhancement (duplicate)
Custom post types support in XML-RPC
Reported by: | tillkruess | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | XML-RPC | Keywords: | |
Focuses: | Cc: |
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)
#2
@
14 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.
#3
@
14 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.
Note: See
TracTickets for help on using
tickets.
+1 from me.
I agree it'd be great if XMLRPC wasn't limited to posts and pages.