]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/media-upload.php
WordPress 3.9.1-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                 /**
45                  * Filter the default media upload type in the legacy (pre-3.5.0) media popup.
46                  *
47                  * @since 2.5.0
48                  *
49                  * @param string $type The default media upload type. Possible values include
50                  *                     'image', 'audio', 'video', 'file', etc. Default 'file'.
51                  */
52                 $type = apply_filters( 'media_upload_default_type', 'file' );
53         }
54
55         // tab: gallery, library, or type-specific
56         if ( isset($_GET['tab']) ) {
57                 $tab = strval($_GET['tab']);
58         } else {
59                 /**
60                  * Filter the default tab in the legacy (pre-3.5.0) media popup.
61                  *
62                  * @since 2.5.0
63                  *
64                  * @param string $type The default media popup tab. Default 'type' (From Computer).
65                  */
66                 $tab = apply_filters( 'media_upload_default_tab', 'type' );
67         }
68
69         $body_id = 'media-upload';
70
71         // let the action code decide how to handle the request
72         if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) ) {
73                 /**
74                  * Fires inside specific upload-type views in the legacy (pre-3.5.0)
75                  * media popup based on the current tab.
76                  *
77                  * The dynamic portion of the hook name, $type, refers to the specific
78                  * media upload type. Possible values include 'image', 'audio', 'video',
79                  * 'file', etc.
80                  *
81                  * The hook only fires if the current $tab is 'type' (From Computer),
82                  * 'type_url' (From URL), or, if the tab does not exist (i.e., has not
83                  * been registered via the 'media_upload_tabs' filter.
84                  *
85                  * @since 2.5.0
86                  */
87                 do_action( "media_upload_$type" );
88         } else {
89                 /**
90                  * Fires inside limited and specific upload-tab views in the legacy
91                  * (pre-3.5.0) media popup.
92                  *
93                  * The dynamic portion of the hook name, $tab, refers to the specific
94                  * media upload tab. Possible values include 'library' (Media Library),
95                  * or any custom tab registered via the 'media_upload_tabs' filter.
96                  *
97                  * @since 2.5.0
98                  */
99                 do_action( "media_upload_$tab" );
100         }