3 * Manage media uploaded file.
5 * There are many filters in here for media. Plugins can extend functionality
6 * by hooking into the filters.
9 * @subpackage Administration
12 /** Load WordPress Administration Bootstrap */
13 require_once('./admin.php');
15 if (!current_user_can('upload_files'))
16 wp_die(__('You do not have permission to upload files.'));
18 wp_enqueue_script('plupload-handlers');
21 if ( isset( $_REQUEST['post_id'] ) ) {
22 $post_id = absint( $_REQUEST['post_id'] );
23 if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) )
28 $location = 'upload.php';
29 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
30 check_admin_referer('media-form');
31 // Upload File button was clicked
32 $id = media_handle_upload( 'async-upload', $post_id );
33 if ( is_wp_error( $id ) )
34 $location .= '?message=3';
36 wp_redirect( admin_url( $location ) );
40 $title = __('Upload New Media');
41 $parent_file = 'upload.php';
43 get_current_screen()->add_help_tab( array(
45 'title' => __('Overview'),
47 '<p>' . __('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:') . '</p>' .
49 '<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
50 '<li>' . __('Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.') . '</li>' .
51 '<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
54 get_current_screen()->set_help_sidebar(
55 '<p><strong>' . __('For more information:') . '</strong></p>' .
56 '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
57 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
60 require_once( ABSPATH . 'wp-admin/admin-header.php' );
62 $form_class = 'media-upload-form type-form validate';
64 if ( get_user_setting('uploader') || isset( $_GET['browser-uploader'] ) )
65 $form_class .= ' html-uploader';
68 <?php screen_icon(); ?>
69 <h2><?php echo esc_html( $title ); ?></h2>
71 <form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-new.php'); ?>" class="<?php echo $form_class; ?>" id="file-form">
73 <?php media_upload_form(); ?>
75 <script type="text/javascript">
76 var post_id = <?php echo $post_id; ?>, shortform = 3;
78 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
79 <?php wp_nonce_field('media-form'); ?>
80 <div id="media-items" class="hide-if-no-js"></div>
85 include( ABSPATH . 'wp-admin/admin-footer.php' );