Ticket #5148: xmlrpc.php.diff
File xmlrpc.php.diff, 3.0 KB (added by , 17 years ago) |
---|
-
xmlrpc.php
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 add_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); … … 1098 1142 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 1099 1143 } 1100 1144 1145 if ( isset($content_struct['custom_fields']) ) { 1146 $this->add_custom_fields($post_ID, $content_struct['custom_fields']); 1147 } 1148 1101 1149 $this->attach_uploads( $post_ID, $post_content ); 1102 1150 1103 1151 logIO('O', "Posted ! ID: $post_ID"); … … 1318 1366 if (!$result) { 1319 1367 return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); 1320 1368 } 1369 1370 if ( isset($content_struct['custom_fields']) ) { 1371 $this->add_custom_fields($post_ID, $content_struct['custom_fields']); 1372 } 1373 1321 1374 $this->attach_uploads( $ID, $post_content ); 1322 1375 1323 1376 logIO('O',"(MW) Edited ! ID: $post_ID"); … … 1394 1447 'wp_password' => $postdata['post_password'], 1395 1448 'wp_author_id' => $author->ID, 1396 1449 'wp_author_display_name' => $author->display_name, 1397 'date_created_gmt' => new IXR_Date($post_date_gmt) 1450 'date_created_gmt' => new IXR_Date($post_date_gmt), 1451 'custom_fields' => $this->get_custom_fields($post_ID) 1398 1452 ); 1399 1453 1400 1454 return $resp; … … 1476 1530 'wp_password' => $entry['post_password'], 1477 1531 'wp_author_id' => $author->ID, 1478 1532 'wp_author_display_name' => $author->display_name, 1479 'date_created_gmt' => new IXR_Date($post_date_gmt) 1533 'date_created_gmt' => new IXR_Date($post_date_gmt), 1534 'custom_fields' => $this->get_custom_fields($entry['ID']) 1480 1535 ); 1481 1536 1482 1537 }