From 3be2e0334e480b7d850693c533cb7fc83a407de5 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 1 Feb 2007 00:34:33 +0000 Subject: [PATCH] XMLRPC API updates. git-svn-id: https://develop.svn.wordpress.org/trunk@4851 602fd350-edb4-49c9-b593-d223f7449a82 --- xmlrpc.php | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/xmlrpc.php b/xmlrpc.php index 8452f99ada..a93eda2e99 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -223,7 +223,7 @@ class wp_xmlrpc_server extends IXR_Server { "mt_allow_pings" => $allow_pings, "wp_slug" => $page->post_name, "wp_password" => $page->post_password, - "wp_author" => $author->user_nicename, + "wp_author" => $author->display_name, "wp_page_parent_id" => $page->post_parent, "wp_page_parent_title" => $parent_title, "wp_page_order" => $page->menu_order, @@ -444,7 +444,6 @@ class wp_xmlrpc_server extends IXR_Server { if(!$this->login_pass_ok($username, $password)) { return($this->error); } - // Get basic info on all users. $all_users = $wpdb->get_results(" SELECT u.ID id, @@ -953,6 +952,11 @@ class wp_xmlrpc_server extends IXR_Server { $post_author = $user->ID; + // If an author id was provided then use it instead. + if(!empty($content_struct["wp_author_id"])) { + $post_author = $content_struct["wp_author_id"]; + } + $post_title = $content_struct['title']; $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); $post_status = $publish ? 'publish' : 'draft'; @@ -1081,8 +1085,20 @@ class wp_xmlrpc_server extends IXR_Server { } // Only set the post_author if one is set. - if(!empty($content_struct["wp_author"])) { - $post_author = $content_struct["wp_author"]; + if(!empty($content_struct["wp_author_id"])) { + $post_author = $content_struct["wp_author_id"]; + } + + // Only set ping_status if it was provided. + if(isset($content_struct["mt_allow_pings"])) { + switch($content_struct["mt_allow_pings"]) { + case "0": + $ping_status = "closed"; + break; + case "1": + $ping_status = "open"; + break; + } } $post_title = $content_struct['title']; @@ -1111,10 +1127,6 @@ class wp_xmlrpc_server extends IXR_Server { get_option('default_comment_status') : $content_struct['mt_allow_comments']; - $ping_status = (empty($content_struct['mt_allow_pings'])) ? - get_option('default_ping_status') - : $content_struct['mt_allow_pings']; - // Do some timestamp voodoo $dateCreatedd = $content_struct['dateCreated']; if (!empty($dateCreatedd)) { @@ -1194,7 +1206,7 @@ class wp_xmlrpc_server extends IXR_Server { 'mt_allow_pings' => $allow_pings, 'wp_slug' => $postdata['post_name'], 'wp_password' => $postdata['post_password'], - 'wp_author' => $author->user_nicename, + 'wp_author' => $author->display_name, 'wp_author_username' => $author->user_login ); @@ -1239,7 +1251,7 @@ class wp_xmlrpc_server extends IXR_Server { $link = post_permalink($entry['ID']); // Get the post author info. - $author = get_userdata($entry['ID']); + $author = get_userdata($entry['post_author']); $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; @@ -1261,7 +1273,7 @@ class wp_xmlrpc_server extends IXR_Server { 'mt_allow_pings' => $allow_pings, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], - 'wp_author' => $author->user_nicename, + 'wp_author' => $author->display_name, 'wp_author_username' => $author->user_login );