Make WordPress Core

Ticket #11432: 11432.2.diff

File 11432.2.diff, 2.7 KB (added by caesarsgrunt, 16 years ago)

Better patch (also combines deletecomment into the same function as all the other delete actions)

  • wp-admin/includes/dashboard.php

     
    545545
    546546                $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
    547547                $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
    548                 $spam_url = esc_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
     548                $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
    549549                $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
    550550                $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
    551551
  • wp-admin/comment.php

     
    137137        break;
    138138
    139139case 'deletecomment' :
    140         $comment_id = absint( $_REQUEST['c'] );
    141         check_admin_referer( 'delete-comment_' . $comment_id );
    142 
    143         if ( isset( $_REQUEST['noredir'] ) )
    144                 $noredir = true;
    145         else
    146                 $noredir = false;
    147 
    148         if ( !$comment = get_comment( $comment_id ) )
    149                 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
    150 
    151         if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
    152                 comment_footer_die( __('You are not allowed to edit comments on this post.') );
    153 
    154         if ( 'spam' == $_REQUEST['dt'] )
    155                 wp_set_comment_status( $comment->comment_ID, 'spam' );
    156         else
    157                 wp_delete_comment( $comment->comment_ID );
    158 
    159         if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) )
    160                 wp_redirect( wp_get_referer() );
    161         else if ( '' != wp_get_original_referer() && false == $noredir )
    162                 wp_redirect( wp_get_original_referer() );
    163         else
    164                 wp_redirect( admin_url('edit-comments.php') );
    165 
    166         die;
    167         break;
    168 
    169140case 'trashcomment' :
    170141case 'untrashcomment' :
    171142case 'spamcomment' :
     
    190161        $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir );
    191162
    192163        switch ( $action ) {
     164                case 'deletecomment' :
     165                        wp_delete_comment($comment_id);
     166                        $redir = add_query_arg( array('deleted' => '1'), $redir );
     167                        break;
    193168                case 'trashcomment' :
    194169                        wp_trash_comment($comment_id);
    195170                        $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );