source: trunk/www.guidonia.net/wp/wp-admin/media-upload.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 2.9 KB
Line 
1<?php
2/**
3 * Manage media uploaded file.
4 *
5 * There are many filters in here for media. Plugins can extend functionality
6 * by hooking into the filters.
7 *
8 * @package WordPress
9 * @subpackage Administration
10 */
11
12/** Load WordPress Administration Bootstrap */
13require_once('admin.php');
14
15if (!current_user_can('upload_files'))
16 wp_die(__('You do not have permission to upload files.'));
17
18wp_enqueue_script('swfupload-all');
19wp_enqueue_script('swfupload-handlers');
20
21@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
22
23// IDs should be integers
24$ID = isset($ID) ? (int) $ID : 0;
25$post_id = isset($post_id)? (int) $post_id : 0;
26
27// Require an ID for the edit screen
28if ( isset($action) && $action == 'edit' && !$ID )
29 wp_die(__("You are not allowed to be here"));
30
31if ( isset($_GET['inline']) ) {
32 $errors = array();
33
34 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
35 // Upload File button was clicked
36 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
37 unset($_FILES);
38 if ( is_wp_error($id) ) {
39 $errors['upload_error'] = $id;
40 $id = false;
41 }
42 }
43
44 if ( isset($_GET['upload-page-form']) ) {
45 $errors = array_merge($errors, (array) media_upload_form_handler());
46
47 $location = 'upload.php';
48 if ( $errors )
49 $location .= '?message=3';
50
51 wp_redirect( admin_url($location) );
52 }
53
54 $title = __('Upload New Media');
55 $parent_file = 'upload.php';
56 require_once('admin-header.php'); ?>
57 <div class="wrap">
58 <?php screen_icon(); ?>
59 <h2><?php echo esc_html( $title ); ?></h2>
60
61 <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">
62
63 <?php media_upload_form(); ?>
64
65 <script type="text/javascript">
66 jQuery(function($){
67 var preloaded = $(".media-item.preloaded");
68 if ( preloaded.length > 0 ) {
69 preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
70 }
71 updateMediaForm();
72 post_id = 0;
73 shortform = 1;
74 });
75 </script>
76 <input type="hidden" name="post_id" id="post_id" value="0" />
77 <?php wp_nonce_field('media-form'); ?>
78 <div id="media-items"> </div>
79 <p>
80 <input type="submit" class="button savebutton" name="save" value="<?php esc_attr_e( 'Save all changes' ); ?>" />
81 </p>
82 </form>
83 </div>
84
85<?php
86 include('admin-footer.php');
87
88} else {
89
90 // upload type: image, video, file, ..?
91 if ( isset($_GET['type']) )
92 $type = strval($_GET['type']);
93 else
94 $type = apply_filters('media_upload_default_type', 'file');
95
96 // tab: gallery, library, or type-specific
97 if ( isset($_GET['tab']) )
98 $tab = strval($_GET['tab']);
99 else
100 $tab = apply_filters('media_upload_default_tab', 'type');
101
102 $body_id = 'media-upload';
103
104 // let the action code decide how to handle the request
105 if ( $tab == 'type' || $tab == 'type_url' )
106 do_action("media_upload_$type");
107 else
108 do_action("media_upload_$tab");
109}
110?>
Note: See TracBrowser for help on using the repository browser.