root/tags/1.3/wp-admin/includes/import.php

Revision 1069, 1.0 kB (checked in by donncha, 1 year ago)

Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439

Line 
1 <?php
2
3 function get_importers() {
4     global $wp_importers;
5     uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
6     return $wp_importers;
7 }
8
9 function register_importer( $id, $name, $description, $callback ) {
10     global $wp_importers;
11     if ( is_wp_error( $callback ) )
12         return $callback;
13     $wp_importers[$id] = array ( $name, $description, $callback );
14 }
15
16 function wp_import_cleanup( $id ) {
17     wp_delete_attachment( $id );
18 }
19
20 function wp_import_handle_upload() {
21     $overrides = array( 'test_form' => false, 'test_type' => false );
22     $file = wp_handle_upload( $_FILES['import'], $overrides );
23
24     if ( isset( $file['error'] ) )
25         return $file;
26
27     $url = $file['url'];
28     $type = $file['type'];
29     $file = addslashes( $file['file'] );
30     $filename = basename( $file );
31
32     // Construct the object array
33     $object = array( 'post_title' => $filename,
34         'post_content' => $url,
35         'post_mime_type' => $type,
36         'guid' => $url
37     );
38
39     // Save the data
40     $id = wp_insert_attachment( $object, $file );
41
42     return array( 'file' => $file, 'id' => $id );
43 }
44
45 ?>
46
Note: See TracBrowser for help on using the browser.