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 if ( ! isset( $_GET['inline'] ) )
13 define( 'IFRAME_REQUEST' , true );
15 /** Load WordPress Administration Bootstrap */
16 require_once('./admin.php');
18 if (!current_user_can('upload_files'))
19 wp_die(__('You do not have permission to upload files.'));
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' );
27 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
29 // IDs should be integers
30 $ID = isset($ID) ? (int) $ID : 0;
31 $post_id = isset($post_id)? (int) $post_id : 0;
33 // Require an ID for the edit screen
34 if ( isset($action) && $action == 'edit' && !$ID )
35 wp_die( __( 'Cheatin’ uh?' ) );
37 if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
38 wp_die( __( 'Cheatin’ uh?' ) );
40 // upload type: image, video, file, ..?
41 if ( isset($_GET['type']) )
42 $type = strval($_GET['type']);
44 $type = apply_filters('media_upload_default_type', 'file');
46 // tab: gallery, library, or type-specific
47 if ( isset($_GET['tab']) )
48 $tab = strval($_GET['tab']);
50 $tab = apply_filters('media_upload_default_tab', 'type');
52 $body_id = 'media-upload';
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");
58 do_action("media_upload_$tab");