Changeset 4569 for trunk/xmlrpc.php
- Timestamp:
- 12/01/2006 04:34:59 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xmlrpc.php
r4537 r4569 396 396 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.'); 397 397 } 398 $this->attach_uploads( $post_ID, $post_content ); 398 399 399 400 logIO('O', "Posted ! ID: $post_ID"); … … 445 446 return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.'); 446 447 } 448 $this->attach_uploads( $ID, $post_content ); 447 449 448 450 return true; … … 565 567 } 566 568 569 $this->attach_uploads( $post_ID, $post_content ); 570 567 571 logIO('O', "Posted ! ID: $post_ID"); 568 572 … … 570 574 } 571 575 576 function attach_uploads( $post_ID, $post_content ) { 577 global $wpdb; 578 579 // find any unattached files 580 $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '-1' AND post_type = 'attachment'" ); 581 if( is_array( $attachments ) ) { 582 foreach( $attachments as $file ) { 583 if( strpos( $post_content, $file->guid ) !== false ) { 584 $wpdb->query( "UPDATE {$wpdb->posts} SET post_parent = '$post_ID' WHERE ID = '{$file->ID}'" ); 585 } 586 } 587 } 588 } 572 589 573 590 /* metaweblog.editPost ...edits a post */ … … 644 661 return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.'); 645 662 } 663 $this->attach_uploads( $ID, $post_content ); 646 664 647 665 logIO('O',"(MW) Edited ! ID: $post_ID"); … … 842 860 return new IXR_Error(500, 'Could not write file '.$name); 843 861 } 862 // Construct the attachment array 863 // attach to post_id -1 864 $post_id = -1; 865 $attachment = array( 866 'post_title' => $name, 867 'post_content' => '', 868 'post_type' => 'attachment', 869 'post_parent' => $post_id, 870 'post_mime_type' => $type, 871 'guid' => $upload[ 'url' ] 872 ); 873 // Save the data 874 $id = wp_insert_attachment($attachment, $upload[ 'file' ], $post_id); 875 add_post_meta($id, '_wp_attachment_metadata', array()); 876 844 877 return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) ); 845 878 }
Note: See TracChangeset
for help on using the changeset viewer.