raw
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 wp_enqueue_script('swfupload');
mp-wp_genesis 19 wp_enqueue_script('swfupload-swfobject');
mp-wp_genesis 20 wp_enqueue_script('swfupload-queue');
mp-wp_genesis 21 wp_enqueue_script('swfupload-handlers');
mp-wp_genesis 22
mp-wp_genesis 23 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
mp-wp_genesis 24
mp-wp_genesis 25 // IDs should be integers
mp-wp_genesis 26 $ID = isset($ID) ? (int) $ID : 0;
mp-wp_genesis 27 $post_id = isset($post_id)? (int) $post_id : 0;
mp-wp_genesis 28
mp-wp_genesis 29 // Require an ID for the edit screen
mp-wp_genesis 30 if ( isset($action) && $action == 'edit' && !$ID )
mp-wp_genesis 31 wp_die(__("You are not allowed to be here"));
mp-wp_genesis 32
mp-wp_genesis 33 if ( isset($_GET['inline']) ) {
mp-wp_genesis 34
mp-wp_genesis 35 if ( isset($_GET['upload-page-form']) ) {
mp-wp_genesis 36 $errors = media_upload_form_handler();
mp-wp_genesis 37
mp-wp_genesis 38 $location = 'upload.php';
mp-wp_genesis 39 if ( $errors )
mp-wp_genesis 40 $location .= '?message=3';
mp-wp_genesis 41
mp-wp_genesis 42 wp_redirect( admin_url($location) );
mp-wp_genesis 43 }
mp-wp_genesis 44
mp-wp_genesis 45 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
mp-wp_genesis 46 // Upload File button was clicked
mp-wp_genesis 47 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
mp-wp_genesis 48 unset($_FILES);
mp-wp_genesis 49 if ( is_wp_error($id) ) {
mp-wp_genesis 50 $errors['upload_error'] = $id;
mp-wp_genesis 51 $id = false;
mp-wp_genesis 52 }
mp-wp_genesis 53 }
mp-wp_genesis 54
mp-wp_genesis 55 $title = __('Upload New Media');
mp-wp_genesis 56 $parent_file = 'upload.php';
mp-wp_genesis 57 require_once('admin-header.php'); ?>
mp-wp_genesis 58 <div class="wrap">
mp-wp_genesis 59 <?php screen_icon(); ?>
mp-wp_genesis 60 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 61
mp-wp_genesis 62 <form enctype="multipart/form-data" method="post" action="media-upload.php?inline=&amp;upload-page-form=" class="media-upload-form type-form validate" id="file-form">
mp-wp_genesis 63
mp-wp_genesis 64 <?php media_upload_form(); ?>
mp-wp_genesis 65
mp-wp_genesis 66 <script type="text/javascript">
mp-wp_genesis 67 jQuery(function($){
mp-wp_genesis 68 var preloaded = $(".media-item.preloaded");
mp-wp_genesis 69 if ( preloaded.length > 0 ) {
mp-wp_genesis 70 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
mp-wp_genesis 71 }
mp-wp_genesis 72 updateMediaForm();
mp-wp_genesis 73 post_id = 0;
mp-wp_genesis 74 shortform = 1;
mp-wp_genesis 75 });
mp-wp_genesis 76 </script>
mp-wp_genesis 77 <input type="hidden" name="post_id" id="post_id" value="0" />
mp-wp_genesis 78 <?php wp_nonce_field('media-form'); ?>
mp-wp_genesis 79 <div id="media-items"> </div>
mp-wp_genesis 80 <p>
mp-wp_genesis 81 <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
mp-wp_genesis 82 </p>
mp-wp_genesis 83 </form>
mp-wp_genesis 84 </div>
mp-wp_genesis 85
mp-wp_genesis 86 <?php
mp-wp_genesis 87 include('admin-footer.php');
mp-wp_genesis 88
mp-wp_genesis 89 } else {
mp-wp_genesis 90
mp-wp_genesis 91 // upload type: image, video, file, ..?
mp-wp_genesis 92 if ( isset($_GET['type']) )
mp-wp_genesis 93 $type = strval($_GET['type']);
mp-wp_genesis 94 else
mp-wp_genesis 95 $type = apply_filters('media_upload_default_type', 'file');
mp-wp_genesis 96
mp-wp_genesis 97 // tab: gallery, library, or type-specific
mp-wp_genesis 98 if ( isset($_GET['tab']) )
mp-wp_genesis 99 $tab = strval($_GET['tab']);
mp-wp_genesis 100 else
mp-wp_genesis 101 $tab = apply_filters('media_upload_default_tab', 'type');
mp-wp_genesis 102
mp-wp_genesis 103 $body_id = 'media-upload';
mp-wp_genesis 104
mp-wp_genesis 105 // let the action code decide how to handle the request
mp-wp_genesis 106 if ( $tab == 'type' || $tab == 'type_url' )
mp-wp_genesis 107 do_action("media_upload_$type");
mp-wp_genesis 108 else
mp-wp_genesis 109 do_action("media_upload_$tab");
mp-wp_genesis 110 }
mp-wp_genesis 111 ?>