Ticket #16981: 16981.importer.diff
File 16981.importer.diff, 1.8 KB (added by , 14 years ago) |
---|
-
trunk/wordpress-importer.php
5 5 Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. 6 6 Author: wordpressdotorg 7 7 Author URI: http://wordpress.org/ 8 Version: 0.4-alpha 28 Version: 0.4-alpha3 9 9 Text Domain: wordpress-importer 10 10 License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 11 11 */ … … 572 572 573 573 if ( 'attachment' == $postdata['post_type'] ) { 574 574 $remote_url = ! empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid']; 575 576 // try to use _wp_attached file for upload folder placement to ensure the same location as the export site 577 // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload() 578 $postdata['upload_date'] = $post['post_date']; 579 if ( isset( $post['postmeta'] ) ) { 580 foreach( $post['postmeta'] as $meta ) { 581 if ( $meta['key'] == '_wp_attached_file' ) { 582 if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) ) 583 $postdata['upload_date'] = $matches[0]; 584 break; 585 } 586 } 587 } 588 575 589 $comment_post_ID = $post_id = $this->process_attachment( $postdata, $remote_url ); 576 590 } else { 577 591 $comment_post_ID = $post_id = wp_insert_post( $postdata, true ); … … 833 847 $file_name = basename( $url ); 834 848 835 849 // get placeholder file in the upload dir with a unique, sanitized filename 836 $upload = wp_upload_bits( $file_name, 0, '', $post[' post_date'] );850 $upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] ); 837 851 if ( $upload['error'] ) 838 852 return new WP_Error( 'upload_dir_error', $upload['error'] ); 839 853