From 6b94d841236b5da2f7618a2c2331a637262d5868 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 6 Oct 2008 19:20:50 +0000 Subject: [PATCH] Return enclosure data in mw_getPosts(). Props Otto42. fixes #7772 git-svn-id: http://svn.automattic.com/wordpress/trunk@9089 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- xmlrpc.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xmlrpc.php b/xmlrpc.php index a8fc67949e..9417248a56 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -2525,6 +2525,19 @@ class wp_xmlrpc_server extends IXR_Server { if( $postdata['post_status'] === 'future' ) { $postdata['post_status'] = 'publish'; } + + $enclosure = array(); + foreach ( (array) get_post_custom($post_ID) as $key => $val) { + if ($key == 'enclosure') { + foreach ( (array) $val as $enc ) { + $encdata = split("\n", $enc); + $enclosure['url'] = trim(htmlspecialchars($encdata[0])); + $enclosure['length'] = trim($encdata[1]); + $enclosure['type'] = trim($encdata[2]); + break 2; + } + } + } $resp = array( 'dateCreated' => new IXR_Date($post_date), @@ -2550,7 +2563,9 @@ class wp_xmlrpc_server extends IXR_Server { 'post_status' => $postdata['post_status'], 'custom_fields' => $this->get_custom_fields($post_ID) ); - + + if (!empty($enclosure)) $resp['enclosure'] = $enclosure; + return $resp; } else { return new IXR_Error(404, __('Sorry, no such post.'));