Avoid PHP notices when deleting or restoring an item that no longer exists. props johnbillion, ocean90. fixes #24246.
git-svn-id: http://core.svn.wordpress.org/trunk@24201 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6f2d7d1d3b
commit
6898eba2f2
|
@ -133,10 +133,10 @@ case 'edit':
|
|||
exit();
|
||||
}
|
||||
|
||||
if ( empty($post->ID) )
|
||||
if ( ! $post )
|
||||
wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
|
||||
|
||||
if ( null == $post_type_object )
|
||||
if ( ! $post_type_object )
|
||||
wp_die( __( 'Unknown post type.' ) );
|
||||
|
||||
if ( ! current_user_can( $post_type_object->cap->edit_post, $post_id ) )
|
||||
|
@ -220,6 +220,12 @@ case 'editpost':
|
|||
case 'trash':
|
||||
check_admin_referer('trash-post_' . $post_id);
|
||||
|
||||
if ( ! $post )
|
||||
wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) );
|
||||
|
||||
if ( ! $post_type_object )
|
||||
wp_die( __( 'Unknown post type.' ) );
|
||||
|
||||
if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
|
||||
wp_die( __( 'You are not allowed to move this item to the Trash.' ) );
|
||||
|
||||
|
@ -238,6 +244,12 @@ case 'trash':
|
|||
case 'untrash':
|
||||
check_admin_referer('untrash-post_' . $post_id);
|
||||
|
||||
if ( ! $post )
|
||||
wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) );
|
||||
|
||||
if ( ! $post_type_object )
|
||||
wp_die( __( 'Unknown post type.' ) );
|
||||
|
||||
if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
|
||||
wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
|
||||
|
||||
|
@ -251,6 +263,12 @@ case 'untrash':
|
|||
case 'delete':
|
||||
check_admin_referer('delete-post_' . $post_id);
|
||||
|
||||
if ( ! $post )
|
||||
wp_die( __( 'This item has already been deleted.' ) );
|
||||
|
||||
if ( ! $post_type_object )
|
||||
wp_die( __( 'Unknown post type.' ) );
|
||||
|
||||
if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
|
||||
wp_die( __( 'You are not allowed to delete this item.' ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue