Ajax Deleting an object that's already been deleted should silently succeed. Hat tip: mdawaffe. Fixes #7264.
git-svn-id: https://develop.svn.wordpress.org/trunk@8296 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
304340a9b0
commit
b210295d0b
@ -30,14 +30,17 @@ switch ( $action = $_POST['action'] ) :
|
|||||||
case 'delete-comment' :
|
case 'delete-comment' :
|
||||||
check_ajax_referer( "delete-comment_$id" );
|
check_ajax_referer( "delete-comment_$id" );
|
||||||
if ( !$comment = get_comment( $id ) )
|
if ( !$comment = get_comment( $id ) )
|
||||||
die('0');
|
die('1');
|
||||||
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
|
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( isset($_POST['spam']) && 1 == $_POST['spam'] )
|
if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
|
||||||
|
if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) )
|
||||||
|
die('1');
|
||||||
$r = wp_set_comment_status( $comment->comment_ID, 'spam' );
|
$r = wp_set_comment_status( $comment->comment_ID, 'spam' );
|
||||||
else
|
} else {
|
||||||
$r = wp_delete_comment( $comment->comment_ID );
|
$r = wp_delete_comment( $comment->comment_ID );
|
||||||
|
}
|
||||||
|
|
||||||
die( $r ? '1' : '0' );
|
die( $r ? '1' : '0' );
|
||||||
break;
|
break;
|
||||||
@ -46,24 +49,38 @@ case 'delete-cat' :
|
|||||||
if ( !current_user_can( 'manage_categories' ) )
|
if ( !current_user_can( 'manage_categories' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
|
$cat = get_category( $id );
|
||||||
|
if ( !$cat || is_wp_error( $cat ) )
|
||||||
|
die('1');
|
||||||
|
|
||||||
if ( wp_delete_category( $id ) )
|
if ( wp_delete_category( $id ) )
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else
|
||||||
|
die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-tag' :
|
case 'delete-tag' :
|
||||||
check_ajax_referer( "delete-tag_$id" );
|
check_ajax_referer( "delete-tag_$id" );
|
||||||
if ( !current_user_can( 'manage_categories' ) )
|
if ( !current_user_can( 'manage_categories' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
|
$tag = get_term( $id, 'post_tag' );
|
||||||
|
if ( !$tag || is_wp_error( $tag ) )
|
||||||
|
die('1');
|
||||||
|
|
||||||
if ( wp_delete_term($id, 'post_tag'))
|
if ( wp_delete_term($id, 'post_tag'))
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else
|
||||||
|
die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-link-cat' :
|
case 'delete-link-cat' :
|
||||||
check_ajax_referer( "delete-link-category_$id" );
|
check_ajax_referer( "delete-link-category_$id" );
|
||||||
if ( !current_user_can( 'manage_categories' ) )
|
if ( !current_user_can( 'manage_categories' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
|
$cat = get_term( $id, 'link_category' );
|
||||||
|
if ( !$cat || is_wp_error( $cat ) )
|
||||||
|
die('1');
|
||||||
|
|
||||||
$cat_name = get_term_field('name', $id, 'link_category');
|
$cat_name = get_term_field('name', $id, 'link_category');
|
||||||
|
|
||||||
// Don't delete the default cats.
|
// Don't delete the default cats.
|
||||||
@ -94,14 +111,20 @@ case 'delete-link' :
|
|||||||
if ( !current_user_can( 'manage_links' ) )
|
if ( !current_user_can( 'manage_links' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
|
$link = get_bookmark( $id );
|
||||||
|
if ( !$link || is_wp_error( $link ) )
|
||||||
|
die('1');
|
||||||
|
|
||||||
if ( wp_delete_link( $id ) )
|
if ( wp_delete_link( $id ) )
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else
|
||||||
|
die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-meta' :
|
case 'delete-meta' :
|
||||||
check_ajax_referer( "delete-meta_$id" );
|
check_ajax_referer( "delete-meta_$id" );
|
||||||
if ( !$meta = get_post_meta_by_id( $id ) )
|
if ( !$meta = get_post_meta_by_id( $id ) )
|
||||||
die('0');
|
die('1');
|
||||||
|
|
||||||
if ( !current_user_can( 'edit_post', $meta->post_id ) )
|
if ( !current_user_can( 'edit_post', $meta->post_id ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
if ( delete_meta( $meta->meta_id ) )
|
if ( delete_meta( $meta->meta_id ) )
|
||||||
@ -113,6 +136,9 @@ case 'delete-post' :
|
|||||||
if ( !current_user_can( 'delete_post', $id ) )
|
if ( !current_user_can( 'delete_post', $id ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
|
if ( !get_post( $id ) )
|
||||||
|
die('1');
|
||||||
|
|
||||||
if ( wp_delete_post( $id ) )
|
if ( wp_delete_post( $id ) )
|
||||||
die('1');
|
die('1');
|
||||||
else
|
else
|
||||||
@ -123,19 +149,28 @@ case 'delete-page' :
|
|||||||
if ( !current_user_can( 'delete_page', $id ) )
|
if ( !current_user_can( 'delete_page', $id ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
|
if ( !get_page( $id ) )
|
||||||
|
die('1');
|
||||||
|
|
||||||
if ( wp_delete_post( $id ) )
|
if ( wp_delete_post( $id ) )
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else
|
||||||
|
die('0');
|
||||||
break;
|
break;
|
||||||
case 'dim-comment' :
|
case 'dim-comment' :
|
||||||
if ( !$comment = get_comment( $id ) )
|
if ( !$comment = get_comment( $id ) )
|
||||||
die('0');
|
die('0');
|
||||||
|
|
||||||
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
|
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
if ( !current_user_can( 'moderate_comments' ) )
|
if ( !current_user_can( 'moderate_comments' ) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) {
|
$current = wp_get_comment_status( $comment->comment_ID );
|
||||||
|
if ( $_POST['new'] == $current )
|
||||||
|
die('1');
|
||||||
|
|
||||||
|
if ( 'unapproved' == $current ) {
|
||||||
check_ajax_referer( "approve-comment_$id" );
|
check_ajax_referer( "approve-comment_$id" );
|
||||||
if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) )
|
if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) )
|
||||||
die('1');
|
die('1');
|
||||||
|
@ -768,15 +768,15 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true
|
|||||||
$actions = array();
|
$actions = array();
|
||||||
|
|
||||||
if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
|
if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
|
||||||
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
|
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
|
||||||
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | ';
|
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | ';
|
||||||
|
|
||||||
// we're looking at list of only approved or only unapproved comments
|
// we're looking at list of only approved or only unapproved comments
|
||||||
if ( 'moderated' == $comment_status ) {
|
if ( 'moderated' == $comment_status ) {
|
||||||
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
|
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
|
||||||
unset($actions['unapprove']);
|
unset($actions['unapprove']);
|
||||||
} elseif ( 'approved' == $comment_status ) {
|
} elseif ( 'approved' == $comment_status ) {
|
||||||
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | ';
|
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | ';
|
||||||
unset($actions['approve']);
|
unset($actions['approve']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user