Changeset 6418
- Timestamp:
- 12/19/07 21:07:38 (9 months ago)
- Files:
-
- trunk/xmlrpc.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/xmlrpc.php
r6417 r6418 172 172 } 173 173 } 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 } 174 217 175 218 /** … … 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 … … 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 ); … … 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 … … 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 … … 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
