7 * |
7 * |
8 * @package WordPress |
8 * @package WordPress |
9 * @subpackage Administration |
9 * @subpackage Administration |
10 */ |
10 */ |
11 |
11 |
12 if ( ! isset( $_GET['inline'] ) ) |
12 if ( ! isset( $_GET['inline'] ) ) { |
13 define( 'IFRAME_REQUEST' , true ); |
13 define( 'IFRAME_REQUEST', true ); |
|
14 } |
14 |
15 |
15 /** Load WordPress Administration Bootstrap */ |
16 /** Load WordPress Administration Bootstrap */ |
16 require_once( dirname( __FILE__ ) . '/admin.php' ); |
17 require_once( dirname( __FILE__ ) . '/admin.php' ); |
17 |
18 |
18 if ( ! current_user_can( 'upload_files' ) ) { |
19 if ( ! current_user_can( 'upload_files' ) ) { |
19 wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 ); |
20 wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 ); |
20 } |
21 } |
21 |
22 |
22 wp_enqueue_script('plupload-handlers'); |
23 wp_enqueue_script( 'plupload-handlers' ); |
23 wp_enqueue_script('image-edit'); |
24 wp_enqueue_script( 'image-edit' ); |
24 wp_enqueue_script('set-post-thumbnail' ); |
25 wp_enqueue_script( 'set-post-thumbnail' ); |
25 wp_enqueue_style('imgareaselect'); |
26 wp_enqueue_style( 'imgareaselect' ); |
26 wp_enqueue_script( 'media-gallery' ); |
27 wp_enqueue_script( 'media-gallery' ); |
27 |
28 |
28 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); |
29 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
29 |
30 |
30 // IDs should be integers |
31 // IDs should be integers |
31 $ID = isset($ID) ? (int) $ID : 0; |
32 $ID = isset( $ID ) ? (int) $ID : 0; |
32 $post_id = isset($post_id)? (int) $post_id : 0; |
33 $post_id = isset( $post_id ) ? (int) $post_id : 0; |
33 |
34 |
34 // Require an ID for the edit screen. |
35 // Require an ID for the edit screen. |
35 if ( isset( $action ) && $action == 'edit' && !$ID ) { |
36 if ( isset( $action ) && $action == 'edit' && ! $ID ) { |
36 wp_die( |
37 wp_die( |
37 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
38 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
38 '<p>' . __( 'Invalid item ID.' ) . '</p>', |
39 '<p>' . __( 'Invalid item ID.' ) . '</p>', |
39 403 |
40 403 |
40 ); |
41 ); |
41 } |
42 } |
42 |
43 |
43 if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) { |
44 if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post', $_REQUEST['post_id'] ) ) { |
44 wp_die( |
45 wp_die( |
45 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
46 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
46 '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
47 '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
47 403 |
48 403 |
48 ); |
49 ); |
49 } |
50 } |
50 |
51 |
51 // Upload type: image, video, file, ..? |
52 // Upload type: image, video, file, ..? |
52 if ( isset($_GET['type']) ) { |
53 if ( isset( $_GET['type'] ) ) { |
53 $type = strval($_GET['type']); |
54 $type = strval( $_GET['type'] ); |
54 } else { |
55 } else { |
55 /** |
56 /** |
56 * Filters the default media upload type in the legacy (pre-3.5.0) media popup. |
57 * Filters the default media upload type in the legacy (pre-3.5.0) media popup. |
57 * |
58 * |
58 * @since 2.5.0 |
59 * @since 2.5.0 |
78 } |
79 } |
79 |
80 |
80 $body_id = 'media-upload'; |
81 $body_id = 'media-upload'; |
81 |
82 |
82 // Let the action code decide how to handle the request. |
83 // Let the action code decide how to handle the request. |
83 if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) ) { |
84 if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab, media_upload_tabs() ) ) { |
84 /** |
85 /** |
85 * Fires inside specific upload-type views in the legacy (pre-3.5.0) |
86 * Fires inside specific upload-type views in the legacy (pre-3.5.0) |
86 * media popup based on the current tab. |
87 * media popup based on the current tab. |
87 * |
88 * |
88 * The dynamic portion of the hook name, `$type`, refers to the specific |
89 * The dynamic portion of the hook name, `$type`, refers to the specific |