wp.deleteCategory xmlrpc method from josephscott. fixes #4599

git-svn-id: http://svn.automattic.com/wordpress/trunk@6417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-12-19 20:33:27 +00:00
parent fc8d8837a0
commit 00d334c288

View File

@ -84,6 +84,7 @@ class wp_xmlrpc_server extends IXR_Server {
'wp.getAuthors' => 'this:wp_getAuthors', 'wp.getAuthors' => 'this:wp_getAuthors',
'wp.getCategories' => 'this:mw_getCategories', // Alias 'wp.getCategories' => 'this:mw_getCategories', // Alias
'wp.newCategory' => 'this:wp_newCategory', 'wp.newCategory' => 'this:wp_newCategory',
'wp.deleteCategory' => 'this:wp_deleteCategory',
'wp.suggestCategories' => 'this:wp_suggestCategories', 'wp.suggestCategories' => 'this:wp_suggestCategories',
'wp.uploadFile' => 'this:mw_newMediaObject', // Alias 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias
@ -492,7 +493,7 @@ class wp_xmlrpc_server extends IXR_Server {
// Set the user context and make sure they are // Set the user context and make sure they are
// allowed to add a category. // allowed to add a category.
set_current_user(0, $username); set_current_user(0, $username);
if(!current_user_can("manage_categories", $page_id)) { if(!current_user_can("manage_categories")) {
return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
} }
@ -527,6 +528,31 @@ class wp_xmlrpc_server extends IXR_Server {
return($cat_id); return($cat_id);
} }
/**
* WordPress XML-RPC API
* wp_deleteCategory
*/
function wp_deleteCategory($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$category_id = (int) $args[3];
if( !$this->login_pass_ok( $username, $password ) ) {
return $this->error;
}
set_current_user(0, $username);
if( !current_user_can("manage_categories") ) {
return new IXR_Error( 401, __( "Sorry, you do not the right to delete a category." ) );
}
return wp_delete_category( $category_id );
}
/** /**
* WordPress XML-RPC API * WordPress XML-RPC API
* wp_suggestCategories * wp_suggestCategories