Admin includes reorg. see #4334
git-svn-id: http://svn.automattic.com/wordpress/trunk@5542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
44
wp-admin/includes/import.php
Normal file
44
wp-admin/includes/import.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
function get_importers() {
|
||||
global $wp_importers;
|
||||
uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
|
||||
return $wp_importers;
|
||||
}
|
||||
|
||||
function register_importer( $id, $name, $description, $callback ) {
|
||||
global $wp_importers;
|
||||
|
||||
$wp_importers[$id] = array ( $name, $description, $callback );
|
||||
}
|
||||
|
||||
function wp_import_cleanup( $id ) {
|
||||
wp_delete_attachment( $id );
|
||||
}
|
||||
|
||||
function wp_import_handle_upload() {
|
||||
$overrides = array( 'test_form' => false, 'test_type' => false );
|
||||
$file = wp_handle_upload( $_FILES['import'], $overrides );
|
||||
|
||||
if ( isset( $file['error'] ) )
|
||||
return $file;
|
||||
|
||||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = addslashes( $file['file'] );
|
||||
$filename = basename( $file );
|
||||
|
||||
// Construct the object array
|
||||
$object = array( 'post_title' => $filename,
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => $type,
|
||||
'guid' => $url
|
||||
);
|
||||
|
||||
// Save the data
|
||||
$id = wp_insert_attachment( $object, $file );
|
||||
|
||||
return array( 'file' => $file, 'id' => $id );
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user