46 |
46 |
47 if ( empty($errors) ) |
47 if ( empty($errors) ) |
48 $errors = null; |
48 $errors = null; |
49 |
49 |
50 if ( empty( $_GET['attachment_id'] ) ) { |
50 if ( empty( $_GET['attachment_id'] ) ) { |
51 wp_redirect('upload.php'); |
51 wp_redirect( admin_url('upload.php') ); |
52 exit(); |
52 exit(); |
53 } |
53 } |
54 $att_id = (int) $_GET['attachment_id']; |
54 $att_id = (int) $_GET['attachment_id']; |
55 |
55 |
56 if ( !current_user_can('edit_post', $att_id) ) |
56 if ( !current_user_can('edit_post', $att_id) ) |
57 wp_die ( __('You are not allowed to edit this attachment.') ); |
57 wp_die ( __('You are not allowed to edit this attachment.') ); |
58 |
58 |
59 $att = get_post($att_id); |
59 $att = get_post($att_id); |
60 |
60 |
61 if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?') ); |
61 if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?') ); |
|
62 if ( 'attachment' !== $att->post_type ) wp_die( __('You attempted to edit an item that isn’t an attachment. Please go back and try again.') ); |
62 if ( $att->post_status == 'trash' ) wp_die( __('You can’t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.') ); |
63 if ( $att->post_status == 'trash' ) wp_die( __('You can’t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.') ); |
63 |
64 |
64 add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); |
65 add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); |
65 |
66 |
66 wp_enqueue_script( 'wp-ajax-response' ); |
67 wp_enqueue_script( 'wp-ajax-response' ); |
67 wp_enqueue_script('image-edit'); |
68 wp_enqueue_script('image-edit'); |
68 wp_enqueue_style('imgareaselect'); |
69 wp_enqueue_style('imgareaselect'); |
69 |
70 |
70 require( 'admin-header.php' ); |
71 get_current_screen()->add_help_tab( array( |
|
72 'id' => 'overview', |
|
73 'title' => __('Overview'), |
|
74 'content' => |
|
75 '<p>' . __('This screen allows you to edit five fields for metadata in a file within the media library.') . '</p>' . |
|
76 '<p>' . __('For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.') . '</p>' . |
|
77 '<p>' . __('Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.') . '</p>' . |
|
78 '<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>' |
|
79 ) ); |
|
80 |
|
81 get_current_screen()->set_help_sidebar( |
|
82 '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
83 '<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen#Edit_Media" target="_blank">Documentation on Edit Media</a>') . '</p>' . |
|
84 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
85 ); |
|
86 |
|
87 require( './admin-header.php' ); |
71 |
88 |
72 $parent_file = 'upload.php'; |
89 $parent_file = 'upload.php'; |
73 $message = ''; |
90 $message = ''; |
74 $class = ''; |
91 $class = ''; |
75 if ( isset($_GET['message']) ) { |
92 if ( isset($_GET['message']) ) { |
76 switch ( $_GET['message'] ) : |
93 switch ( $_GET['message'] ) : |
77 case 'updated' : |
94 case 'updated' : |
78 $message = __('Media attachment updated.'); |
95 $message = __('Media attachment updated.'); |
79 $class = 'updated fade'; |
96 $class = 'updated'; |
80 break; |
97 break; |
81 endswitch; |
98 endswitch; |
82 } |
99 } |
83 if ( $message ) |
100 if ( $message ) |
84 echo "<div id='message' class='$class'><p>$message</p></div>\n"; |
101 echo "<div id='message' class='$class'><p>$message</p></div>\n"; |
85 |
102 |
86 ?> |
103 ?> |
87 |
104 |
88 <div class="wrap"> |
105 <div class="wrap"> |
89 <?php screen_icon(); ?> |
106 <?php screen_icon(); ?> |
90 <h2><?php _e( 'Edit Media' ); ?></h2> |
107 <h2> |
|
108 <?php |
|
109 echo esc_html( $title ); |
|
110 if ( current_user_can( 'upload_files' ) ) { ?> |
|
111 <a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a> |
|
112 <?php } ?> |
|
113 </h2> |
91 |
114 |
92 <form method="post" action="<?php echo esc_url( remove_query_arg( 'message' ) ); ?>" class="media-upload-form" id="media-single-form"> |
115 <form method="post" action="" class="media-upload-form" id="media-single-form"> |
|
116 <p class="submit" style="padding-bottom: 0;"> |
|
117 <?php submit_button( __( 'Update Media' ), 'primary', 'save', false ); ?> |
|
118 </p> |
|
119 |
93 <div class="media-single"> |
120 <div class="media-single"> |
94 <div id='media-item-<?php echo $att_id; ?>' class='media-item'> |
121 <div id='media-item-<?php echo $att_id; ?>' class='media-item'> |
95 <?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => $errors ) ); ?> |
122 <?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => !empty($errors[$att_id]) ? $errors[$att_id] : null ) ); ?> |
96 </div> |
123 </div> |
97 </div> |
124 </div> |
98 |
125 |
99 <p class="submit"> |
126 <?php submit_button( __( 'Update Media' ), 'primary', 'save' ); ?> |
100 <input type="submit" class="button-primary" name="save" value="<?php esc_attr_e('Update Media'); ?>" /> |
|
101 <input type="hidden" name="post_id" id="post_id" value="<?php echo isset($post_id) ? esc_attr($post_id) : ''; ?>" /> |
127 <input type="hidden" name="post_id" id="post_id" value="<?php echo isset($post_id) ? esc_attr($post_id) : ''; ?>" /> |
102 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($att_id); ?>" /> |
128 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($att_id); ?>" /> |
103 <input type="hidden" name="action" value="editattachment" /> |
129 <input type="hidden" name="action" value="editattachment" /> |
104 <?php wp_original_referer_field(true, 'previous'); ?> |
130 <?php wp_original_referer_field(true, 'previous'); ?> |
105 <?php wp_nonce_field('media-form'); ?> |
131 <?php wp_nonce_field('media-form'); ?> |
106 </p> |
132 |
107 </form> |
133 </form> |
108 |
134 |
109 </div> |
135 </div> |
110 |
136 |
111 <?php |
137 <?php |
112 |
138 |
113 require( 'admin-footer.php' ); |
139 require( './admin-footer.php' ); |
114 |
140 |
115 exit; |
141 exit; |
116 |
142 |
117 default: |
143 default: |
118 wp_redirect( 'upload.php' ); |
144 wp_redirect( admin_url('upload.php') ); |
119 exit; |
145 exit; |
120 |
146 |
121 endswitch; |
147 endswitch; |
122 |
|
123 |
|
124 ?> |
|