equal
deleted
inserted
replaced
83 |
83 |
84 $sendback = wp_get_referer(); |
84 $sendback = wp_get_referer(); |
85 if ( ! $sendback || |
85 if ( ! $sendback || |
86 strpos( $sendback, 'post.php' ) !== false || |
86 strpos( $sendback, 'post.php' ) !== false || |
87 strpos( $sendback, 'post-new.php' ) !== false ) { |
87 strpos( $sendback, 'post-new.php' ) !== false ) { |
88 $sendback = admin_url( 'edit.php' ); |
88 if ( 'attachment' == $post_type ) { |
89 $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : ''; |
89 $sendback = admin_url( 'upload.php' ); |
|
90 } else { |
|
91 $sendback = admin_url( 'edit.php' ); |
|
92 $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : ''; |
|
93 } |
90 } else { |
94 } else { |
91 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback ); |
95 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback ); |
92 } |
96 } |
93 |
97 |
94 switch($action) { |
98 switch($action) { |
146 $post_type = $post->post_type; |
150 $post_type = $post->post_type; |
147 if ( 'post' == $post_type ) { |
151 if ( 'post' == $post_type ) { |
148 $parent_file = "edit.php"; |
152 $parent_file = "edit.php"; |
149 $submenu_file = "edit.php"; |
153 $submenu_file = "edit.php"; |
150 $post_new_file = "post-new.php"; |
154 $post_new_file = "post-new.php"; |
|
155 } elseif ( 'attachment' == $post_type ) { |
|
156 $parent_file = 'upload.php'; |
|
157 $submenu_file = 'upload.php'; |
|
158 $post_new_file = 'media-new.php'; |
151 } else { |
159 } else { |
152 if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) |
160 if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) |
153 $parent_file = $post_type_object->show_in_menu; |
161 $parent_file = $post_type_object->show_in_menu; |
154 else |
162 else |
155 $parent_file = "edit.php?post_type=$post_type"; |
163 $parent_file = "edit.php?post_type=$post_type"; |
159 |
167 |
160 if ( $last = wp_check_post_lock( $post->ID ) ) { |
168 if ( $last = wp_check_post_lock( $post->ID ) ) { |
161 add_action('admin_notices', '_admin_notice_post_locked' ); |
169 add_action('admin_notices', '_admin_notice_post_locked' ); |
162 } else { |
170 } else { |
163 $active_post_lock = wp_set_post_lock( $post->ID ); |
171 $active_post_lock = wp_set_post_lock( $post->ID ); |
164 wp_enqueue_script('autosave'); |
172 |
|
173 if ( 'attachment' !== $post_type ) |
|
174 wp_enqueue_script('autosave'); |
165 } |
175 } |
166 |
176 |
167 $title = $post_type_object->labels->edit_item; |
177 $title = $post_type_object->labels->edit_item; |
168 $post = get_post_to_edit($post_id); |
178 $post = get_post($post_id, OBJECT, 'edit'); |
169 |
179 |
170 if ( post_type_supports($post_type, 'comments') ) { |
180 if ( post_type_supports($post_type, 'comments') ) { |
171 wp_enqueue_script('admin-comments'); |
181 wp_enqueue_script('admin-comments'); |
172 enqueue_comment_hotkeys_js(); |
182 enqueue_comment_hotkeys_js(); |
173 } |
183 } |
175 include('./edit-form-advanced.php'); |
185 include('./edit-form-advanced.php'); |
176 |
186 |
177 break; |
187 break; |
178 |
188 |
179 case 'editattachment': |
189 case 'editattachment': |
180 check_admin_referer('update-attachment_' . $post_id); |
190 check_admin_referer('update-post_' . $post_id); |
181 |
191 |
182 // Don't let these be changed |
192 // Don't let these be changed |
183 unset($_POST['guid']); |
193 unset($_POST['guid']); |
184 $_POST['post_type'] = 'attachment'; |
194 $_POST['post_type'] = 'attachment'; |
185 |
195 |
188 $newmeta['thumb'] = $_POST['thumb']; |
198 $newmeta['thumb'] = $_POST['thumb']; |
189 |
199 |
190 wp_update_attachment_metadata( $post_id, $newmeta ); |
200 wp_update_attachment_metadata( $post_id, $newmeta ); |
191 |
201 |
192 case 'editpost': |
202 case 'editpost': |
193 check_admin_referer('update-' . $post_type . '_' . $post_id); |
203 check_admin_referer('update-post_' . $post_id); |
194 |
204 |
195 $post_id = edit_post(); |
205 $post_id = edit_post(); |
196 |
206 |
197 redirect_post($post_id); // Send user on their way while we keep working |
207 redirect_post($post_id); // Send user on their way while we keep working |
198 |
208 |
199 exit(); |
209 exit(); |
200 break; |
210 break; |
201 |
211 |
202 case 'trash': |
212 case 'trash': |
203 check_admin_referer('trash-' . $post_type . '_' . $post_id); |
213 check_admin_referer('trash-post_' . $post_id); |
204 |
214 |
205 $post = & get_post($post_id); |
215 $post = get_post($post_id); |
206 |
216 |
207 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
217 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
208 wp_die( __('You are not allowed to move this item to the Trash.') ); |
218 wp_die( __('You are not allowed to move this item to the Trash.') ); |
209 |
219 |
210 if ( ! wp_trash_post($post_id) ) |
220 if ( ! wp_trash_post($post_id) ) |
213 wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) ); |
223 wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) ); |
214 exit(); |
224 exit(); |
215 break; |
225 break; |
216 |
226 |
217 case 'untrash': |
227 case 'untrash': |
218 check_admin_referer('untrash-' . $post_type . '_' . $post_id); |
228 check_admin_referer('untrash-post_' . $post_id); |
219 |
229 |
220 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
230 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
221 wp_die( __('You are not allowed to move this item out of the Trash.') ); |
231 wp_die( __('You are not allowed to move this item out of the Trash.') ); |
222 |
232 |
223 if ( ! wp_untrash_post($post_id) ) |
233 if ( ! wp_untrash_post($post_id) ) |
226 wp_redirect( add_query_arg('untrashed', 1, $sendback) ); |
236 wp_redirect( add_query_arg('untrashed', 1, $sendback) ); |
227 exit(); |
237 exit(); |
228 break; |
238 break; |
229 |
239 |
230 case 'delete': |
240 case 'delete': |
231 check_admin_referer('delete-' . $post_type . '_' . $post_id); |
241 check_admin_referer('delete-post_' . $post_id); |
232 |
242 |
233 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
243 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
234 wp_die( __('You are not allowed to delete this item.') ); |
244 wp_die( __('You are not allowed to delete this item.') ); |
235 |
245 |
236 $force = !EMPTY_TRASH_DAYS; |
246 $force = !EMPTY_TRASH_DAYS; |