Ticket #5148: xmlrpc.php.2.diff
| File xmlrpc.php.2.diff, 2.9 kB (added by josephscott, 8 months ago) |
|---|
-
xmlrpc.php
old new 172 172 } 173 173 } 174 174 175 function get_custom_fields($post_id) { 176 $post_id = (int) $post_id; 177 178 $custom_fields = array(); 179 180 foreach ( (array) has_meta($post_id) as $meta ) { 181 // Don't expose protected fields. 182 if ( strpos($meta['meta_key'], '_wp_') === 0 ) { 183 continue; 184 } 185 186 $custom_fields[] = array( 187 "id" => $meta['meta_id'], 188 "key" => $meta['meta_key'], 189 "value" => $meta['meta_value'] 190 ); 191 } 192 193 return $custom_fields; 194 } 195 196 function set_custom_fields($post_id, $fields) { 197 $post_id = (int) $post_id; 198 199 foreach ( (array) $fields as $meta ) { 200 if ( isset($meta['id']) ) { 201 $meta['id'] = (int) $meta['id']; 202 203 if ( isset($meta['key']) ) { 204 update_meta($meta['id'], $meta['key'], $meta['value']); 205 } 206 else { 207 delete_meta($meta['id']); 208 } 209 } 210 else { 211 $_POST['metakeyinput'] = $meta['key']; 212 $_POST['metavalue'] = $meta['value']; 213 add_meta($post_id); 214 } 215 } 216 } 217 175 218 /** 176 219 * WordPress XML-RPC API 177 220 * wp_getPage … … 243 286 "wp_page_order" => $page->menu_order, 244 287 "wp_author_id" => $author->ID, 245 288 "wp_author_display_name" => $author->display_name, 246 "date_created_gmt" => new IXR_Date($page_date_gmt) 289 "date_created_gmt" => new IXR_Date($page_date_gmt), 290 "custom_fields" => $this->get_custom_fields($page_id) 247 291 ); 248 292 249 293 return($page_struct); … … 1112 1156 if (!$post_ID) { 1113 1157 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 1114 1158 } 1159 1160 if ( isset($content_struct['custom_fields']) ) { 1161 $this->set_custom_fields($post_ID, $content_struct['custom_fields']); 1162 } 1115 1163 1116 1164 $this->attach_uploads( $post_ID, $post_content ); 1117 1165 … … 1332 1380 if (!$result) { 1333 1381 return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); 1334 1382 } 1383 1384 if ( isset($content_struct['custom_fields']) ) { 1385 $this->set_custom_fields($post_ID, $content_struct['custom_fields']); 1386 } 1387 1335 1388 $this->attach_uploads( $ID, $post_content ); 1336 1389 1337 1390 logIO('O',"(MW) Edited ! ID: $post_ID"); … … 1404 1457 'wp_author_id' => $author->ID, 1405 1458 'wp_author_display_name' => $author->display_name, 1406 1459 'date_created_gmt' => new IXR_Date($post_date_gmt), 1407 'post_status' => $postdata['post_status'] 1460 'post_status' => $postdata['post_status'], 1461 'custom_fields' => $this->get_custom_fields($post_ID) 1408 1462 ); 1409 1463 1410 1464 return $resp; … … 1487 1541 'wp_author_id' => $author->ID, 1488 1542 'wp_author_display_name' => $author->display_name, 1489 1543 'date_created_gmt' => new IXR_Date($post_date_gmt), 1490 'post_status' => $entry['post_status'] 1544 'post_status' => $entry['post_status'], 1545 'custom_fields' => $this->get_custom_fields($entry['ID']) 1491 1546 ); 1492 1547 1493 1548 }
