13 define( 'IFRAME_REQUEST' , true ); |
13 define( 'IFRAME_REQUEST' , true ); |
14 |
14 |
15 /** Load WordPress Administration Bootstrap */ |
15 /** Load WordPress Administration Bootstrap */ |
16 require_once( dirname( __FILE__ ) . '/admin.php' ); |
16 require_once( dirname( __FILE__ ) . '/admin.php' ); |
17 |
17 |
18 if (!current_user_can('upload_files')) |
18 if ( ! current_user_can( 'upload_files' ) ) { |
19 wp_die(__('You do not have permission to upload files.')); |
19 wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 ); |
|
20 } |
20 |
21 |
21 wp_enqueue_script('plupload-handlers'); |
22 wp_enqueue_script('plupload-handlers'); |
22 wp_enqueue_script('image-edit'); |
23 wp_enqueue_script('image-edit'); |
23 wp_enqueue_script('set-post-thumbnail' ); |
24 wp_enqueue_script('set-post-thumbnail' ); |
24 wp_enqueue_style('imgareaselect'); |
25 wp_enqueue_style('imgareaselect'); |
29 // IDs should be integers |
30 // IDs should be integers |
30 $ID = isset($ID) ? (int) $ID : 0; |
31 $ID = isset($ID) ? (int) $ID : 0; |
31 $post_id = isset($post_id)? (int) $post_id : 0; |
32 $post_id = isset($post_id)? (int) $post_id : 0; |
32 |
33 |
33 // Require an ID for the edit screen. |
34 // Require an ID for the edit screen. |
34 if ( isset($action) && $action == 'edit' && !$ID ) { |
35 if ( isset( $action ) && $action == 'edit' && !$ID ) { |
35 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
36 wp_die( |
|
37 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
|
38 '<p>' . __( 'Invalid item ID.' ) . '</p>', |
|
39 403 |
|
40 ); |
36 } |
41 } |
37 |
42 |
38 if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) { |
43 if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) { |
39 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
44 wp_die( |
|
45 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
|
46 '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
|
47 403 |
|
48 ); |
40 } |
49 } |
41 |
50 |
42 // Upload type: image, video, file, ..? |
51 // Upload type: image, video, file, ..? |
43 if ( isset($_GET['type']) ) { |
52 if ( isset($_GET['type']) ) { |
44 $type = strval($_GET['type']); |
53 $type = strval($_GET['type']); |
45 } else { |
54 } else { |
46 /** |
55 /** |
47 * Filter the default media upload type in the legacy (pre-3.5.0) media popup. |
56 * Filters the default media upload type in the legacy (pre-3.5.0) media popup. |
48 * |
57 * |
49 * @since 2.5.0 |
58 * @since 2.5.0 |
50 * |
59 * |
51 * @param string $type The default media upload type. Possible values include |
60 * @param string $type The default media upload type. Possible values include |
52 * 'image', 'audio', 'video', 'file', etc. Default 'file'. |
61 * 'image', 'audio', 'video', 'file', etc. Default 'file'. |
57 // Tab: gallery, library, or type-specific. |
66 // Tab: gallery, library, or type-specific. |
58 if ( isset($_GET['tab']) ) { |
67 if ( isset($_GET['tab']) ) { |
59 $tab = strval($_GET['tab']); |
68 $tab = strval($_GET['tab']); |
60 } else { |
69 } else { |
61 /** |
70 /** |
62 * Filter the default tab in the legacy (pre-3.5.0) media popup. |
71 * Filters the default tab in the legacy (pre-3.5.0) media popup. |
63 * |
72 * |
64 * @since 2.5.0 |
73 * @since 2.5.0 |
65 * |
74 * |
66 * @param string $type The default media popup tab. Default 'type' (From Computer). |
75 * @param string $type The default media popup tab. Default 'type' (From Computer). |
67 */ |
76 */ |
84 * 'type_url' (From URL), or, if the tab does not exist (i.e., has not |
93 * 'type_url' (From URL), or, if the tab does not exist (i.e., has not |
85 * been registered via the {@see 'media_upload_tabs'} filter. |
94 * been registered via the {@see 'media_upload_tabs'} filter. |
86 * |
95 * |
87 * @since 2.5.0 |
96 * @since 2.5.0 |
88 */ |
97 */ |
89 do_action( "media_upload_$type" ); |
98 do_action( "media_upload_{$type}" ); |
90 } else { |
99 } else { |
91 /** |
100 /** |
92 * Fires inside limited and specific upload-tab views in the legacy |
101 * Fires inside limited and specific upload-tab views in the legacy |
93 * (pre-3.5.0) media popup. |
102 * (pre-3.5.0) media popup. |
94 * |
103 * |