Ticket #11426: 11426.5.diff
File 11426.5.diff, 10.7 KB (added by , 15 years ago) |
---|
-
wp-admin/comment.php
17 17 if ( isset( $_POST['deletecomment'] ) ) 18 18 $action = 'deletecomment'; 19 19 20 if ( 'cdc' == $action ) 21 $action = 'delete'; 22 elseif ( 'mac' == $action ) 23 $action = 'approve'; 24 25 if ( isset( $_GET['dt'] ) ) { 26 if ( 'spam' == $_GET['dt'] ) 27 $action = 'spam'; 28 elseif ( 'trash' == $_GET['dt'] ) 29 $action = 'trash'; 30 } 31 20 32 /** 21 33 * Display error message at bottom of comments. 22 34 * … … 53 65 54 66 break; 55 67 56 case 'cdc' : 57 case 'mac' : 68 case 'delete' : 69 case 'approve' : 70 case 'trash' : 71 case 'spam' : 58 72 59 73 require_once('admin-header.php'); 60 74 61 75 $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_'; 64 78 $nonce_action .= $comment_id; 65 79 66 80 if ( !$comment = get_comment_to_edit( $comment_id ) ) 67 81 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); 68 82 69 83 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.') ); 71 85 ?> 72 86 <div class='wrap'> 73 87 74 88 <div class="narrow"> 75 89 <?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'); 90 switch ( $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; 85 107 } 86 108 ?> 87 109 … … 93 115 94 116 <table width="100%"> 95 117 <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> 97 119 <td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td> 98 120 </tr> 99 121 </table> 100 122 101 123 <?php wp_nonce_field( $nonce_action ); ?> 102 124 <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 } ?>106 125 <input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' /> 107 126 <input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> 108 127 <input type='hidden' name='noredir' value='1' /> … … 136 155 <?php 137 156 break; 138 157 139 case 'deletecomment' : 158 case 'deletecomment' : 159 case 'trashcomment' : 160 case 'untrashcomment' : 161 case 'spamcomment' : 162 case 'unspamcomment' : 140 163 $comment_id = absint( $_REQUEST['c'] ); 141 164 check_admin_referer( 'delete-comment_' . $comment_id ); 142 165 143 if ( isset( $_REQUEST['noredir'] ) )144 $noredir = true;145 else146 $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 else157 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 else164 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'] );174 166 $noredir = isset($_REQUEST['noredir']); 175 167 176 168 if ( !$comment = get_comment($comment_id) ) … … 178 170 if ( !current_user_can('edit_post', $comment->comment_post_ID ) ) 179 171 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 180 172 181 check_admin_referer( 'delete-comment_' . $comment_id );182 183 173 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') ) 184 174 $redir = wp_get_referer(); 185 175 elseif ( '' != wp_get_original_referer() && false == $noredir ) … … 190 180 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir ); 191 181 192 182 switch ( $action ) { 183 case 'deletecomment' : 184 wp_delete_comment( $comment_id ); 185 $redir = add_query_arg( array('deleted' => '1'), $redir ); 186 break; 193 187 case 'trashcomment' : 194 188 wp_trash_comment($comment_id); 195 189 $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); … … 213 207 die; 214 208 break; 215 209 210 case 'approvecomment' : 216 211 case 'unapprovecomment' : 217 212 $comment_id = absint( $_GET['c'] ); 218 213 check_admin_referer( 'approve-comment_' . $comment_id ); 219 214 220 if ( isset( $_GET['noredir'] ) ) 221 $noredir = true; 222 else 223 $noredir = false; 215 $noredir = isset( $_GET['noredir'] ); 224 216 225 217 if ( !$comment = get_comment( $comment_id ) ) 226 218 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); 227 219 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.') ); 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 } 230 226 231 wp_set_comment_status( $comment->comment_ID, 'hold' );232 233 227 if ( '' != wp_get_referer() && false == $noredir ) 234 wp_redirect(wp_get_referer() );228 $redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() ); 235 229 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 ) ); 237 231 238 exit(); 239 break; 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 } 240 239 241 case 'approvecomment' : 242 $comment_id = absint( $_GET['c'] ); 243 check_admin_referer( 'approve-comment_' . $comment_id ); 240 wp_redirect( $redir ); 244 241 245 if ( isset( $_GET['noredir'] ) )246 $noredir = true;247 else248 $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 else261 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );262 263 242 exit(); 264 243 break; 265 244 -
wp-includes/pluggable.php
1017 1017 $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); 1018 1018 } 1019 1019 $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"; 1022 1025 1023 1026 $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); 1024 1027 … … 1101 1104 break; 1102 1105 } 1103 1106 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"; 1107 1113 1108 1114 $notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:', 1109 1115 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";