]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/media-upload.php
WordPress 3.7.2-scripts
[autoinstalls/wordpress.git] / wp-admin / media-upload.php
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 if ( ! isset( $_GET['inline'] ) )
13         define( 'IFRAME_REQUEST' , true );
14
15 /** Load WordPress Administration Bootstrap */
16 require_once( dirname( __FILE__ ) . '/admin.php' );
17
18 if (!current_user_can('upload_files'))
19         wp_die(__('You do not have permission to upload files.'));
20
21 wp_enqueue_script('plupload-handlers');
22 wp_enqueue_script('image-edit');
23 wp_enqueue_script('set-post-thumbnail' );
24 wp_enqueue_style('imgareaselect');
25 wp_enqueue_script( 'media-gallery' );
26
27 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
28
29 // IDs should be integers
30 $ID = isset($ID) ? (int) $ID : 0;
31 $post_id = isset($post_id)? (int) $post_id : 0;
32
33 // Require an ID for the edit screen
34 if ( isset($action) && $action == 'edit' && !$ID )
35         wp_die( __( 'Cheatin&#8217; uh?' ) );
36
37         if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
38                 wp_die( __( 'Cheatin&#8217; uh?' ) );
39
40         // upload type: image, video, file, ..?
41         if ( isset($_GET['type']) )
42                 $type = strval($_GET['type']);
43         else
44                 $type = apply_filters('media_upload_default_type', 'file');
45
46         // tab: gallery, library, or type-specific
47         if ( isset($_GET['tab']) )
48                 $tab = strval($_GET['tab']);
49         else
50                 $tab = apply_filters('media_upload_default_tab', 'type');
51
52         $body_id = 'media-upload';
53
54         // let the action code decide how to handle the request
55         if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) )
56                 do_action("media_upload_$type");
57         else
58                 do_action("media_upload_$tab");