Make WordPress Core


Ignore:
Timestamp:
07/30/2009 01:39:34 PM (15 years ago)
Author:
azaozz
Message:

Trash status updates for posts, pages, comments and attachments, props caesarsgrunt, see #4529

File:
1 edited

Legend:

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

    r11731 r11749  
    182182switch ( $action = $_POST['action'] ) :
    183183case 'delete-comment' : // On success, die with time() instead of 1
    184     check_ajax_referer( "delete-comment_$id" );
    185184    if ( !$comment = get_comment( $id ) )
    186185        die( (string) time() );
     
    188187        die('-1');
    189188
    190     if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
     189    if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
     190        check_ajax_referer( "trash-comment_$id" );
     191        if ( 'trash' == wp_get_comment_status( $comment->comment_ID ) )
     192            die( (string) time() );
     193        $r = wp_trash_comment( $comment->comment_ID );
     194    } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
     195        check_ajax_referer( "untrash-comment_$id" );
     196        $r = wp_untrash_comment( $comment->comment_ID );
     197    } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
     198        check_ajax_referer( "delete-comment_$id" );
    191199        if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) )
    192200            die( (string) time() );
    193201        $r = wp_set_comment_status( $comment->comment_ID, 'spam' );
    194202    } else {
    195         $r = wp_set_comment_status( $comment->comment_ID, 'delete' );
     203        check_ajax_referer( "delete-comment_$id" );
     204        $r = wp_delete_comment( $comment->comment_ID );
    196205    }
    197206    if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
Note: See TracChangeset for help on using the changeset viewer.