equal
deleted
inserted
replaced
12 if ( ! isset( $_GET['inline'] ) ) { |
12 if ( ! isset( $_GET['inline'] ) ) { |
13 define( 'IFRAME_REQUEST', true ); |
13 define( 'IFRAME_REQUEST', true ); |
14 } |
14 } |
15 |
15 |
16 /** Load WordPress Administration Bootstrap */ |
16 /** Load WordPress Administration Bootstrap */ |
17 require_once( dirname( __FILE__ ) . '/admin.php' ); |
17 require_once __DIR__ . '/admin.php'; |
18 |
18 |
19 if ( ! current_user_can( 'upload_files' ) ) { |
19 if ( ! current_user_can( 'upload_files' ) ) { |
20 wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 ); |
20 wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 ); |
21 } |
21 } |
22 |
22 |
24 wp_enqueue_script( 'image-edit' ); |
24 wp_enqueue_script( 'image-edit' ); |
25 wp_enqueue_script( 'set-post-thumbnail' ); |
25 wp_enqueue_script( 'set-post-thumbnail' ); |
26 wp_enqueue_style( 'imgareaselect' ); |
26 wp_enqueue_style( 'imgareaselect' ); |
27 wp_enqueue_script( 'media-gallery' ); |
27 wp_enqueue_script( 'media-gallery' ); |
28 |
28 |
29 @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' ) ); |
30 |
30 |
31 // IDs should be integers |
31 // IDs should be integers. |
32 $ID = isset( $ID ) ? (int) $ID : 0; |
32 $ID = isset( $ID ) ? (int) $ID : 0; // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
33 $post_id = isset( $post_id ) ? (int) $post_id : 0; |
33 $post_id = isset( $post_id ) ? (int) $post_id : 0; |
34 |
34 |
35 // Require an ID for the edit screen. |
35 // Require an ID for the edit screen. |
36 if ( isset( $action ) && $action == 'edit' && ! $ID ) { |
36 if ( isset( $action ) && 'edit' === $action && ! $ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
37 wp_die( |
37 wp_die( |
38 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
38 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
39 '<p>' . __( 'Invalid item ID.' ) . '</p>', |
39 '<p>' . __( 'Invalid item ID.' ) . '</p>', |
40 403 |
40 403 |
41 ); |
41 ); |
47 '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
47 '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
48 403 |
48 403 |
49 ); |
49 ); |
50 } |
50 } |
51 |
51 |
52 // Upload type: image, video, file, ..? |
52 // Upload type: image, video, file, ...? |
53 if ( isset( $_GET['type'] ) ) { |
53 if ( isset( $_GET['type'] ) ) { |
54 $type = strval( $_GET['type'] ); |
54 $type = strval( $_GET['type'] ); |
55 } else { |
55 } else { |
56 /** |
56 /** |
57 * 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. |
79 } |
79 } |
80 |
80 |
81 $body_id = 'media-upload'; |
81 $body_id = 'media-upload'; |
82 |
82 |
83 // Let the action code decide how to handle the request. |
83 // Let the action code decide how to handle the request. |
84 if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab, media_upload_tabs() ) ) { |
84 if ( 'type' === $tab || 'type_url' === $tab || ! array_key_exists( $tab, media_upload_tabs() ) ) { |
85 /** |
85 /** |
86 * 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) |
87 * media popup based on the current tab. |
87 * media popup based on the current tab. |
88 * |
88 * |
89 * 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 |