Make WordPress Core

Ticket #11426: 11426.3.diff

File 11426.3.diff, 10.0 KB (added by nacin, 15 years ago)

Third pass.

  • wp-includes/pluggable.php

     
    10171017                $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
    10181018        }
    10191019        $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
    1020         $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n";
    1021         $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n";
     1020        if ( EMPTY_TRASH_DAYS )
     1021                $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
     1022        else
     1023                $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
     1024        $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
    10221025
    10231026        $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
    10241027
     
    11011104                        break;
    11021105        }
    11031106
    1104         $notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=mac&c=$comment_id") ) . "\r\n";
    1105         $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n";
    1106         $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n";
     1107        $notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
     1108        if ( EMPTY_TRASH_DAYS )
     1109                $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
     1110        else
     1111                $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
     1112        $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
    11071113
    11081114        $notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
    11091115                'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
  • wp-admin/comment.php

     
    1717if ( isset( $_POST['deletecomment'] ) )
    1818        $action = 'deletecomment';
    1919
     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}
     31
    2032/**
    2133 * Display error message at bottom of comments.
    2234 *
     
    5365
    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
    6680        if ( !$comment = get_comment_to_edit( $comment_id ) )
    6781                comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
    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'>
    7387
    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?>
    87109
     
    93115
    94116<table width="100%">
    95117<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>
     118<td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td>
    97119<td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td>
    98120</tr>
    99121</table>
    100122
    101123<?php wp_nonce_field( $nonce_action ); ?>
    102124<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 } ?>
    106125<input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' />
    107126<input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' />
    108127<input type='hidden' name='noredir' value='1' />
     
    136155<?php
    137156        break;
    138157
    139 case 'deletecomment' :
     158case 'deletecomment'  :
     159case 'trashcomment'   :
     160case 'untrashcomment' :
     161case 'spamcomment'    :
     162case 'unspamcomment'  :
    140163        $comment_id = absint( $_REQUEST['c'] );
    141164        check_admin_referer( 'delete-comment_' . $comment_id );
    142165
    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 
    169 case 'trashcomment' :
    170 case 'untrashcomment' :
    171 case 'spamcomment' :
    172 case 'unspamcomment' :
    173         $comment_id = absint( $_REQUEST['c'] );
    174166        $noredir = isset($_REQUEST['noredir']);
    175167
    176168        if ( !$comment = get_comment($comment_id) )
     
    190182        $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir );
    191183
    192184        switch ( $action ) {
     185                case 'deletecomment' :
     186                        wp_delete_comment( $comment_id );
     187                        $redir = add_query_arg( array('deleted' => '1'), $redir );
     188                        break;
    193189                case 'trashcomment' :
    194190                        wp_trash_comment($comment_id);
    195191                        $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
     
    213209        die;
    214210        break;
    215211
     212case 'approvecomment'   :
    216213case 'unapprovecomment' :
    217214        $comment_id = absint( $_GET['c'] );
    218215        check_admin_referer( 'approve-comment_' . $comment_id );
    219216
    220         if ( isset( $_GET['noredir'] ) )
    221                 $noredir = true;
    222         else
    223                 $noredir = false;
     217        $noredir = isset( $_GET['noredir'] );
    224218
    225219        if ( !$comment = get_comment( $comment_id ) )
    226220                comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
    227221
    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 disapprove this comment.') );
     222        if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
     223                if ( 'approvecomment' == $action )
     224                        comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
     225                else
     226                        comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
     227        }
    230228
    231         wp_set_comment_status( $comment->comment_ID, 'hold' );
     229        if ( 'approvecomment' == $action ) {
     230                wp_set_comment_status( $comment_id, 'approve' );
     231                $redir = add_query_arg( array( 'approved' => 1 ), $redir );
     232        } else {
     233                wp_set_comment_status( $comment_id, 'hold' );
     234                $redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
     235        }
    232236
    233237        if ( '' != wp_get_referer() && false == $noredir )
    234238                wp_redirect( wp_get_referer() );
     
    238242        exit();
    239243        break;
    240244
    241 case 'approvecomment' :
    242         $comment_id = absint( $_GET['c'] );
    243         check_admin_referer( 'approve-comment_' . $comment_id );
    244 
    245         if ( isset( $_GET['noredir'] ) )
    246                 $noredir = true;
    247         else
    248                 $noredir = false;
    249 
    250         if ( !$comment = get_comment( $comment_id ) )
    251                 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
    252 
    253         if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    254                 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    255 
    256         wp_set_comment_status( $comment->comment_ID, 'approve' );
    257 
    258         if ( '' != wp_get_referer() && false == $noredir )
    259                 wp_redirect( wp_get_referer() );
    260         else
    261                 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
    262 
    263         exit();
    264         break;
    265 
    266245case 'editedcomment' :
    267246
    268247        $comment_id = absint( $_POST['comment_ID'] );