Changeset 4961 for trunk/xmlrpc.php
- Timestamp:
- 03/03/2007 04:56:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xmlrpc.php
r4953 r4961 150 150 global $wpdb; 151 151 152 if( is_string($array)) {152 if(!is_array($array)) { 153 153 return($wpdb->escape($array)); 154 154 } … … 1101 1101 1102 1102 // Only set a post parent if one was given. 1103 if( !empty($content_struct["wp_page_parent_id"])) {1103 if(isset($content_struct["wp_page_parent_id"])) { 1104 1104 $post_parent = $content_struct["wp_page_parent_id"]; 1105 1105 } … … 1167 1167 if ( is_array($to_ping) ) 1168 1168 $to_ping = implode(' ', $to_ping); 1169 1170 if(isset($content_struct["mt_allow_comments"])) { 1171 $comment_status = $content_struct["mt_allow_comments"]; 1172 } 1169 1173 1170 $comment_status = (!isset($content_struct['mt_allow_comments'])) ?1171 get_option('default_comment_status')1172 : $content_struct['mt_allow_comments'];1173 1174 1174 // Do some timestamp voodoo 1175 1175 $dateCreatedd = $content_struct['dateCreated']; … … 1388 1388 if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) { 1389 1389 $overwrite = true; 1390 1391 // If the file isn't writable then error out now. 1392 if(!is_writable($data["name"])) { 1393 return(new IXR_Error(500, "File is not writable, over write failed.")); 1394 } 1395 1396 // We now know the file is good so don't use the sanitized name. 1397 $name = $data["name"]; 1398 1399 // Get postmeta info on the object. 1400 $old_meta = $wpdb->get_row(" 1401 SELECT * 1402 FROM {$wpdb->postmeta} 1403 WHERE meta_key = '_wp_attached_file' 1404 AND meta_value = '{$name}' 1405 "); 1406 1407 // Get post info on the object. 1408 $old_post = get_post($old_meta->post_id); 1390 1409 } 1391 1410 … … 1422 1441 ); 1423 1442 1424 // Only make a database entry if this is a new file. 1425 if(!$overwrite) { 1426 // Save the data 1427 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 1428 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 1429 } 1443 // If we are over writing then set the correct post_id and URL 1444 // instead of getting new ones. 1445 if($overwrite) { 1446 $post_id = $old_meta->post_id; 1447 $attachment["post_parent"] = $old_meta->post_id; 1448 $attachment["ID"] = $old_meta->post_id; 1449 1450 $upload["url"] = $old_post->guid; 1451 $attachment["guid"] = $old_post->guid; 1452 } 1453 1454 // Save the data 1455 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 1456 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 1430 1457 1431 1458 return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) );
Note: See TracChangeset
for help on using the changeset viewer.