Make WordPress Core


Ignore:
Timestamp:
10/08/2009 08:24:59 AM (17 years ago)
Author:
azaozz
Message:

Add Undo when moving comments to the trash, remove unneeded nonces, see #4529

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r12007 r12008  
    200200                die('-1');
    201201
     202        check_ajax_referer( "delete-comment_$id" );
     203        $status = wp_get_comment_status( $comment->comment_ID );
     204
    202205        if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
    203                 check_ajax_referer( "trash-comment_$id" );
    204                 if ( 'trash' == wp_get_comment_status( $comment->comment_ID ) )
     206                if ( 'trash' == $status )
    205207                        die( (string) time() );
    206208                $r = wp_trash_comment( $comment->comment_ID );
    207209        } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
    208                 check_ajax_referer( "untrash-comment_$id" );
     210                if ( 'trash' != $status )
     211                        die( (string) time() );
    209212                $r = wp_untrash_comment( $comment->comment_ID );
    210213        } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
    211                 check_ajax_referer( "delete-comment_$id" );
    212                 if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) )
     214                if ( 'spam' == $status )
    213215                        die( (string) time() );
    214216                $r = wp_set_comment_status( $comment->comment_ID, 'spam' );
     217        } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
     218                $r = wp_delete_comment( $comment->comment_ID );
    215219        } else {
    216                 check_ajax_referer( "delete-comment_$id" );
    217                 $r = wp_delete_comment( $comment->comment_ID );
    218         }
     220                die('-1');
     221        }
     222
    219223        if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
    220224                _wp_ajax_delete_comment_response( $comment->comment_ID );
     
    369373                die( (string) time() );
    370374
    371         $r = 0;
    372         if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
    373                 check_ajax_referer( "approve-comment_$id" );
     375        check_ajax_referer( "approve-comment_$id" );
     376        if ( in_array( $current, array( 'unapproved', 'spam' ) ) )
    374377                $result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
    375         } else {
    376                 check_ajax_referer( "unapprove-comment_$id" );
     378        else
    377379                $result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
    378         }
     380
    379381        if ( is_wp_error($result) ) {
    380382                $x = new WP_Ajax_Response( array(
Note: See TracChangeset for help on using the changeset viewer.