Make WordPress Core


Ignore:
Timestamp:
12/15/2009 10:55:55 AM (15 years ago)
Author:
azaozz
Message:

Add 'trash' in comment moderation emails, props nacin, fixes #11426

File:
1 edited

Legend:

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

    r12401 r12402  
    1717if ( isset( $_POST['deletecomment'] ) )
    1818    $action = 'deletecomment';
     19
     20if ( 'cdc' == $action )
     21    $action = 'delete';
     22elseif ( 'mac' == $action )
     23    $action = 'approve';
     24
     25if ( isset( $_GET['dt'] ) ) {
     26    if ( 'spam' == $_GET['dt'] )
     27        $action = 'spam';
     28    elseif ( 'trash' == $_GET['dt'] )
     29        $action = 'trash';
     30}
    1931
    2032/**
     
    5466    break;
    5567
    56 case 'cdc' :
    57 case 'mac' :
     68case 'delete'  :
     69case 'approve' :
     70case 'trash'   :
     71case 'spam'    :
    5872
    5973    require_once('admin-header.php');
    6074
    6175    $comment_id = absint( $_GET['c'] );
    62     $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment';
    63     $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
     76    $formaction    = $action . 'comment';
     77    $nonce_action  = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
    6478    $nonce_action .= $comment_id;
    6579
     
    6882
    6983    if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
    70         comment_footer_die( 'cdc' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
     84        comment_footer_die( 'approve' != $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    7185?>
    7286<div class='wrap'>
     
    7488<div class="narrow">
    7589<?php
    76 if ( 'spam' == $_GET['dt'] ) {
    77     $caution_msg = __('You are about to mark the following comment as spam:');
    78     $button = __('Spam Comment');
    79 } elseif ( 'cdc' == $action ) {
    80     $caution_msg = __('You are about to delete the following comment:');
    81     $button = __('Delete Comment');
    82 } else {
    83     $caution_msg = __('You are about to approve the following comment:');
    84     $button = __('Approve Comment');
     90switch ( $action ) {
     91    case 'spam' :
     92        $caution_msg = __('You are about to mark the following comment as spam:');
     93        $button      = __('Spam Comment');
     94        break;
     95    case 'trash' :
     96        $caution_msg = __('You are about to move the following comment to the Trash:');
     97        $button      = __('Trash Comment');
     98        break;
     99    case 'delete' :
     100        $caution_msg = __('You are about to delete the following comment:');
     101        $button      = __('Permanently Delete Comment');
     102        break;
     103    default :
     104        $caution_msg = __('You are about to approve the following comment:');
     105        $button      = __('Approve Comment');
     106        break;
    85107}
    86108?>
     
    88110<p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
    89111
     112<table class="form-table comment-ays">
     113<tr class="alt">
     114<th scope="row"><?php _e('Author'); ?></th>
     115<td><?php echo $comment->comment_author; ?></td>
     116</tr>
     117<?php if ( $comment->comment_author_email ) { ?>
     118<tr>
     119<th scope="row"><?php _e('E-mail'); ?></th>
     120<td><?php echo $comment->comment_author_email; ?></td>
     121</tr>
     122<?php } ?>
     123<?php if ( $comment->comment_author_url ) { ?>
     124<tr>
     125<th scope="row"><?php _e('URL'); ?></th>
     126<td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td>
     127</tr>
     128<?php } ?>
     129<tr>
     130<th scope="row" valign="top"><?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th>
     131<td><?php echo $comment->comment_content; ?></td>
     132</tr>
     133</table>
     134
    90135<p><?php _e('Are you sure you want to do that?'); ?></p>
    91136
     
    94139<table width="100%">
    95140<tr>
    96 <td><input type='button' class="button" value='<?php esc_attr_e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>'" /></td>
     141<td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td>
    97142<td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td>
    98143</tr>
     
    101146<?php wp_nonce_field( $nonce_action ); ?>
    102147<input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' />
    103 <?php if ( 'spam' == $_GET['dt'] ) { ?>
    104 <input type='hidden' name='dt' value='spam' />
    105 <?php } ?>
    106148<input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' />
    107149<input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' />
    108150<input type='hidden' name='noredir' value='1' />
    109151</form>
    110 
    111 <table class="form-table" cellpadding="5">
    112 <tr class="alt">
    113 <th scope="row"><?php _e('Author'); ?></th>
    114 <td><?php echo $comment->comment_author; ?></td>
    115 </tr>
    116 <?php if ( $comment->comment_author_email ) { ?>
    117 <tr>
    118 <th scope="row"><?php _e('E-mail'); ?></th>
    119 <td><?php echo $comment->comment_author_email; ?></td>
    120 </tr>
    121 <?php } ?>
    122 <?php if ( $comment->comment_author_url ) { ?>
    123 <tr>
    124 <th scope="row"><?php _e('URL'); ?></th>
    125 <td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td>
    126 </tr>
    127 <?php } ?>
    128 <tr>
    129 <th scope="row" valign="top"><?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th>
    130 <td><?php echo $comment->comment_content; ?></td>
    131 </tr>
    132 </table>
    133152
    134153</div>
     
    143162case 'unspamcomment' :
    144163    $comment_id = absint( $_REQUEST['c'] );
     164    check_admin_referer( 'delete-comment_' . $comment_id );
     165
    145166    $noredir = isset($_REQUEST['noredir']);
    146167
     
    149170    if ( !current_user_can('edit_post', $comment->comment_post_ID ) )
    150171        comment_footer_die( __('You are not allowed to edit comments on this post.') );
    151 
    152     check_admin_referer( 'delete-comment_' . $comment_id );
    153172
    154173    if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') )
     
    163182    switch ( $action ) {
    164183        case 'deletecomment' :
    165             wp_delete_comment($comment_id);
     184            wp_delete_comment( $comment_id );
    166185            $redir = add_query_arg( array('deleted' => '1'), $redir );
    167186            break;
     
    189208    break;
    190209
     210case 'approvecomment'   :
    191211case 'unapprovecomment' :
    192212    $comment_id = absint( $_GET['c'] );
    193213    check_admin_referer( 'approve-comment_' . $comment_id );
    194214
    195     if ( isset( $_GET['noredir'] ) )
    196         $noredir = true;
    197     else
    198         $noredir = false;
     215    $noredir = isset( $_GET['noredir'] );
    199216
    200217    if ( !$comment = get_comment( $comment_id ) )
    201218        comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
    202219
    203     if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
    204         comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
    205 
    206     wp_set_comment_status( $comment->comment_ID, 'hold' );
     220    if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     221        if ( 'approvecomment' == $action )
     222            comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
     223        else
     224            comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
     225    }
    207226
    208227    if ( '' != wp_get_referer() && false == $noredir )
    209         wp_redirect( wp_get_referer() );
     228        $redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() );
    210229    else
    211         wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
    212 
    213     exit();
    214     break;
    215 
    216 case 'approvecomment' :
    217     $comment_id = absint( $_GET['c'] );
    218     check_admin_referer( 'approve-comment_' . $comment_id );
    219 
    220     if ( isset( $_GET['noredir'] ) )
    221         $noredir = true;
    222     else
    223         $noredir = false;
    224 
    225     if ( !$comment = get_comment( $comment_id ) )
    226         comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
    227 
    228     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    229         comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    230 
    231     wp_set_comment_status( $comment->comment_ID, 'approve' );
    232 
    233     if ( '' != wp_get_referer() && false == $noredir )
    234         wp_redirect( wp_get_referer() );
    235     else
    236         wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
     230        $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
     231
     232    if ( 'approvecomment' == $action ) {
     233        wp_set_comment_status( $comment_id, 'approve' );
     234        $redir = add_query_arg( array( 'approved' => 1 ), $redir );
     235    } else {
     236        wp_set_comment_status( $comment_id, 'hold' );
     237        $redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
     238    }
     239
     240    wp_redirect( $redir );
    237241
    238242    exit();
Note: See TracChangeset for help on using the changeset viewer.