Make WordPress Core


Ignore:
Timestamp:
04/19/2006 08:02:16 AM (20 years ago)
Author:
matt
Message:

A better comment delete button

File:
1 edited

Legend:

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

    r3671 r3721  
    1818    }
    1919}
     20
     21if ( isset( $_POST['deletecomment'] ) )
     22    $action = 'deletecomment';
    2023
    2124switch($action) {
     
    8083    echo "<input type='submit' value='" . __('Yes') . "' />";
    8184    echo "&nbsp;&nbsp;";
    82     echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';\" />\n";
     85    echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit-comments.php';\" />\n";
    8386    echo "</form>\n";
    8487    echo "</div>\n";
     
    8790
    8891case 'deletecomment':
     92
     93    check_admin_referer();
     94
     95    $comment = (int) $_REQUEST['comment'];
     96    $p = (int) $_REQUEST['p'];
     97    if ( isset($_REQUEST['noredir']) ) {
     98        $noredir = true;
     99    } else {
     100        $noredir = false;
     101    }
     102
     103    $postdata = get_post($p) or
     104        die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
     105
     106    if ( ! $comment = get_comment($comment) )
     107             die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
     108
     109    if ( !current_user_can('edit_post', $comment->comment_post_ID) )
     110        die( __('You are not allowed to edit comments on this post.') );
     111
     112    if ( 'spam' == $_REQUEST['delete_type'] )
     113        wp_set_comment_status($comment->comment_ID, 'spam');
     114    else
     115        wp_delete_comment($comment->comment_ID);
     116
     117    if (($_SERVER['HTTP_REFERER'] != '') && (false == $noredir)) {
     118        header('Location: ' . $_SERVER['HTTP_REFERER']);
     119    } else {
     120        header('Location: '. get_settings('siteurl') .'/wp-admin/edit-comments.php');
     121    }
     122    exit();
     123    break;
     124
     125case 'unapprovecomment':
    89126
    90127    check_admin_referer();
     
    98135    }
    99136
    100     $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    101 
    102     if ( ! $comment = get_comment($comment) )
    103              die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
    104 
    105     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    106         die( __('You are not allowed to edit comments on this post.') );
    107 
    108     if ( 'spam' == $_GET['delete_type'] )
    109         wp_set_comment_status($comment->comment_ID, 'spam');
    110     else
    111         wp_delete_comment($comment->comment_ID);
     137    if ( ! $comment = get_comment($comment) )
     138        die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
     139
     140    if ( !current_user_can('edit_post', $comment->comment_post_ID) )
     141        die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
     142
     143    wp_set_comment_status($comment->comment_ID, "hold");
    112144
    113145    if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
     
    119151    break;
    120152
    121 case 'unapprovecomment':
     153case 'approvecomment':
    122154
    123155    check_admin_referer();
     
    135167
    136168    if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    137         die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
    138 
    139     wp_set_comment_status($comment->comment_ID, "hold");
    140 
    141     if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
    142         header('Location: ' . $_SERVER['HTTP_REFERER']);
    143     } else {
    144         header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
    145     }
    146     exit();
    147     break;
    148 
    149 case 'approvecomment':
    150 
    151     check_admin_referer();
    152 
    153     $comment = (int) $_GET['comment'];
    154     $p = (int) $_GET['p'];
    155     if (isset($_GET['noredir'])) {
    156         $noredir = true;
    157     } else {
    158         $noredir = false;
    159     }
    160 
    161     if ( ! $comment = get_comment($comment) )
    162         die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    163 
    164     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    165169        die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    166170
     
    196200    break;
    197201} // end switch
     202
    198203include('admin-footer.php');
     204
    199205?>
Note: See TracChangeset for help on using the changeset viewer.