|
124 | 124 | } |
125 | 125 |
|
126 | 126 | if ( ! $post ) { |
127 | | - wp_die( __( 'You attempted to edit an item that does not exist. Perhaps it was deleted?' ) ); |
| 127 | + wp_die( __( 'You attempted to edit an item that does not exist. Perhaps it was deleted?' ), 404 ); |
128 | 128 | } |
129 | 129 |
|
130 | 130 | if ( ! $post_type_object ) { |
131 | | - wp_die( __( 'Invalid post type.' ) ); |
| 131 | + wp_die( __( 'Invalid post type.' ), 400 ); |
132 | 132 | } |
133 | 133 |
|
134 | 134 | if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ), true ) ) { |
135 | | - wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
| 135 | + wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ), 403 ); |
136 | 136 | } |
137 | 137 |
|
138 | 138 | if ( ! current_user_can( 'edit_post', $post_id ) ) { |
139 | | - wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); |
| 139 | + wp_die( __( 'Sorry, you are not allowed to edit this item.' ), 403 ); |
140 | 140 | } |
141 | 141 |
|
142 | 142 | if ( 'trash' === $post->post_status ) { |
143 | | - wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ) ); |
| 143 | + wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ), 409 ); |
144 | 144 | } |
145 | 145 |
|
146 | 146 | if ( ! empty( $_GET['get-post-lock'] ) ) { |
|
239 | 239 | check_admin_referer( 'trash-post_' . $post_id ); |
240 | 240 |
|
241 | 241 | if ( ! $post ) { |
242 | | - wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) ); |
| 242 | + wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ), 410 ); |
243 | 243 | } |
244 | 244 |
|
245 | 245 | if ( ! $post_type_object ) { |
246 | | - wp_die( __( 'Invalid post type.' ) ); |
| 246 | + wp_die( __( 'Invalid post type.' ), 400 ); |
247 | 247 | } |
248 | 248 |
|
249 | 249 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
250 | | - wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
| 250 | + wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ), 403 ); |
251 | 251 | } |
252 | 252 |
|
253 | 253 | $user_id = wp_check_post_lock( $post_id ); |
254 | 254 | if ( $user_id ) { |
255 | 255 | $user = get_userdata( $user_id ); |
256 | 256 | /* translators: %s: User's display name. */ |
257 | | - wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) ); |
| 257 | + wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ), 409 ); |
258 | 258 | } |
259 | 259 |
|
260 | 260 | if ( ! wp_trash_post( $post_id ) ) { |
261 | | - wp_die( __( 'Error in moving the item to Trash.' ) ); |
| 261 | + wp_die( __( 'Error in moving the item to Trash.' ), 500 ); |
262 | 262 | } |
263 | 263 |
|
264 | 264 | wp_redirect( |
|
276 | 276 | check_admin_referer( 'untrash-post_' . $post_id ); |
277 | 277 |
|
278 | 278 | if ( ! $post ) { |
279 | | - wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) ); |
| 279 | + wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ), 410 ); |
280 | 280 | } |
281 | 281 |
|
282 | 282 | if ( ! $post_type_object ) { |
283 | | - wp_die( __( 'Invalid post type.' ) ); |
| 283 | + wp_die( __( 'Invalid post type.' ), 400 ); |
284 | 284 | } |
285 | 285 |
|
286 | 286 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
287 | | - wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
| 287 | + wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ), 403 ); |
288 | 288 | } |
289 | 289 |
|
290 | 290 | if ( ! wp_untrash_post( $post_id ) ) { |
291 | | - wp_die( __( 'Error in restoring the item from Trash.' ) ); |
| 291 | + wp_die( __( 'Error in restoring the item from Trash.' ), 500 ); |
292 | 292 | } |
293 | 293 |
|
294 | 294 | $sendback = add_query_arg( |
|
305 | 305 | check_admin_referer( 'delete-post_' . $post_id ); |
306 | 306 |
|
307 | 307 | if ( ! $post ) { |
308 | | - wp_die( __( 'This item has already been deleted.' ) ); |
| 308 | + wp_die( __( 'This item has already been deleted.' ), 410 ); |
309 | 309 | } |
310 | 310 |
|
311 | 311 | if ( ! $post_type_object ) { |
312 | | - wp_die( __( 'Invalid post type.' ) ); |
| 312 | + wp_die( __( 'Invalid post type.' ), 400 ); |
313 | 313 | } |
314 | 314 |
|
315 | 315 | if ( ! current_user_can( 'delete_post', $post_id ) ) { |
316 | | - wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
| 316 | + wp_die( __( 'Sorry, you are not allowed to delete this item.' ), 403 ); |
317 | 317 | } |
318 | 318 |
|
319 | 319 | if ( 'attachment' === $post->post_type ) { |
320 | 320 | $force = ( ! MEDIA_TRASH ); |
321 | 321 | if ( ! wp_delete_attachment( $post_id, $force ) ) { |
322 | | - wp_die( __( 'Error in deleting the attachment.' ) ); |
| 322 | + wp_die( __( 'Error in deleting the attachment.' ), 500 ); |
323 | 323 | } |
324 | 324 | } else { |
325 | 325 | if ( ! wp_delete_post( $post_id, true ) ) { |
326 | | - wp_die( __( 'Error in deleting the item.' ) ); |
| 326 | + wp_die( __( 'Error in deleting the item.' ), 500 ); |
327 | 327 | } |
328 | 328 | } |
329 | 329 |
|
|
0 commit comments