mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Manage media uploaded file.
mp-wp_genesis 4 *
mp-wp_genesis 5 * There are many filters in here for media. Plugins can extend functionality
mp-wp_genesis 6 * by hooking into the filters.
mp-wp_genesis 7 *
mp-wp_genesis 8 * @package WordPress
mp-wp_genesis 9 * @subpackage Administration
mp-wp_genesis 10 */
mp-wp_genesis 11
mp-wp_genesis 12 /** Load WordPress Administration Bootstrap */
mp-wp_genesis 13 require_once('admin.php');
mp-wp_genesis 14
mp-wp_genesis 15 if (!current_user_can('upload_files'))
mp-wp_genesis 16 wp_die(__('You do not have permission to upload files.'));
mp-wp_genesis 17
mp-wp_genesis 18 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
mp-wp_genesis 19
mp-wp_genesis 20 // IDs should be integers
mp-wp_genesis 21 $ID = isset($ID) ? (int) $ID : 0;
mp-wp_genesis 22 $post_id = isset($post_id)? (int) $post_id : 0;
mp-wp_genesis 23
mp-wp_genesis 24 // Require an ID for the edit screen
mp-wp_genesis 25 if ( isset($action) && $action == 'edit' && !$ID )
mp-wp_genesis 26 wp_die(__("You are not allowed to be here"));
mp-wp_genesis 27
mp-wp_genesis 28 if ( isset($_GET['inline']) ) {
mp-wp_genesis 29
mp-wp_genesis 30 if ( isset($_GET['upload-page-form']) ) {
mp-wp_genesis 31 $errors = media_upload_form_handler();
mp-wp_genesis 32
mp-wp_genesis 33 $location = 'upload.php';
mp-wp_genesis 34 if ( $errors )
mp-wp_genesis 35 $location .= '?message=3';
mp-wp_genesis 36
mp-wp_genesis 37 wp_redirect( admin_url($location) );
mp-wp_genesis 38 }
mp-wp_genesis 39
mp-wp_genesis 40 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
mp-wp_genesis 41 // Upload File button was clicked
mp-wp_genesis 42 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
mp-wp_genesis 43 unset($_FILES);
mp-wp_genesis 44 if ( is_wp_error($id) ) {
mp-wp_genesis 45 $errors['upload_error'] = $id;
mp-wp_genesis 46 $id = false;
mp-wp_genesis 47 }
mp-wp_genesis 48 }
mp-wp_genesis 49
mp-wp_genesis 50 $title = __('Upload New Media');
mp-wp_genesis 51 $parent_file = 'upload.php';
mp-wp_genesis 52 require_once('admin-header.php'); ?>
mp-wp_genesis 53 <div class="wrap">
mp-wp_genesis 54 <?php screen_icon(); ?>
mp-wp_genesis 55 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 56
mp-wp_genesis 57 <form enctype="multipart/form-data" method="post" action="media-upload.php?inline=&upload-page-form=" class="media-upload-form type-form validate" id="file-form">
mp-wp_genesis 58
mp-wp_genesis 59 <?php media_upload_form(); ?>
mp-wp_genesis 60
mp-wp_genesis 61 <input type="hidden" name="post_id" id="post_id" value="0" />
mp-wp_genesis 62 <?php wp_nonce_field('media-form'); ?>
mp-wp_genesis 63 </form>
mp-wp_genesis 64 </div>
mp-wp_genesis 65
mp-wp_genesis 66 <?php
mp-wp_genesis 67 include('admin-footer.php');
mp-wp_genesis 68
mp-wp_genesis 69 } else {
mp-wp_genesis 70
mp-wp_genesis 71 // upload type: image, video, file, ..?
mp-wp_genesis 72 if ( isset($_GET['type']) )
mp-wp_genesis 73 $type = strval($_GET['type']);
mp-wp_genesis 74 else
mp-wp_genesis 75 $type = apply_filters('media_upload_default_type', 'file');
mp-wp_genesis 76
mp-wp_genesis 77 // tab: gallery, library, or type-specific
mp-wp_genesis 78 if ( isset($_GET['tab']) )
mp-wp_genesis 79 $tab = strval($_GET['tab']);
mp-wp_genesis 80 else
mp-wp_genesis 81 $tab = apply_filters('media_upload_default_tab', 'type');
mp-wp_genesis 82
mp-wp_genesis 83 $body_id = 'media-upload';
mp-wp_genesis 84
mp-wp_genesis 85 // let the action code decide how to handle the request
mp-wp_genesis 86 if ( $tab == 'type' || $tab == 'type_url' )
mp-wp_genesis 87 do_action("media_upload_$type");
mp-wp_genesis 88 else
mp-wp_genesis 89 do_action("media_upload_$tab");
mp-wp_genesis 90 }
mp-wp_genesis 91 ?>