Changeset 30980
- Timestamp:
- 12/20/2014 09:09:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/import.php
r29206 r30980 77 77 */ 78 78 function wp_import_handle_upload() { 79 if ( !isset($_FILES['import']) ) { 80 $file['error'] = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); 81 return $file; 79 if ( ! isset( $_FILES['import'] ) ) { 80 return array( 81 'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ) 82 ); 82 83 } 83 84 84 85 $overrides = array( 'test_form' => false, 'test_type' => false ); 85 86 $_FILES['import']['name'] .= '.txt'; 86 $file = wp_handle_upload( $_FILES['import'], $overrides ); 87 88 if ( isset( $file['error'] ) ) 89 return $file; 90 91 $url = $file['url']; 92 $type = $file['type']; 93 $file = $file['file']; 94 $filename = basename( $file ); 87 $upload = wp_handle_upload( $_FILES['import'], $overrides ); 88 89 if ( isset( $upload['error'] ) ) { 90 return $upload; 91 } 95 92 96 93 // Construct the object array 97 $object = array( 'post_title' => $filename, 98 'post_content' => $url, 99 'post_mime_type' => $type, 100 'guid' => $url, 94 $object = array( 95 'post_title' => basename( $upload['file'] ), 96 'post_content' => $upload['url'], 97 'post_mime_type' => $upload['type'], 98 'guid' => $upload['url'], 101 99 'context' => 'import', 102 100 'post_status' => 'private' … … 104 102 105 103 // Save the data 106 $id = wp_insert_attachment( $object, $ file);104 $id = wp_insert_attachment( $object, $upload['file'] ); 107 105 108 106 /* … … 112 110 wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); 113 111 114 return array( 'file' => $ file, 'id' => $id );112 return array( 'file' => $upload['file'], 'id' => $id ); 115 113 } 116 114
Note: See TracChangeset
for help on using the changeset viewer.