Changeset 12402 for trunk/wp-admin/comment.php
- Timestamp:
- 12/15/2009 10:55:55 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/comment.php
r12401 r12402 17 17 if ( isset( $_POST['deletecomment'] ) ) 18 18 $action = 'deletecomment'; 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 } 19 31 20 32 /** … … 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 … … 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'> … … 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 ?> … … 88 110 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> 89 111 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 90 135 <p><?php _e('Are you sure you want to do that?'); ?></p> 91 136 … … 94 139 <table width="100%"> 95 140 <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> 97 142 <td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td> 98 143 </tr> … … 101 146 <?php wp_nonce_field( $nonce_action ); ?> 102 147 <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 148 <input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' /> 107 149 <input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> 108 150 <input type='hidden' name='noredir' value='1' /> 109 151 </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>133 152 134 153 </div> … … 143 162 case 'unspamcomment' : 144 163 $comment_id = absint( $_REQUEST['c'] ); 164 check_admin_referer( 'delete-comment_' . $comment_id ); 165 145 166 $noredir = isset($_REQUEST['noredir']); 146 167 … … 149 170 if ( !current_user_can('edit_post', $comment->comment_post_ID ) ) 150 171 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 151 152 check_admin_referer( 'delete-comment_' . $comment_id );153 172 154 173 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') ) … … 163 182 switch ( $action ) { 164 183 case 'deletecomment' : 165 wp_delete_comment( $comment_id);184 wp_delete_comment( $comment_id ); 166 185 $redir = add_query_arg( array('deleted' => '1'), $redir ); 167 186 break; … … 189 208 break; 190 209 210 case 'approvecomment' : 191 211 case 'unapprovecomment' : 192 212 $comment_id = absint( $_GET['c'] ); 193 213 check_admin_referer( 'approve-comment_' . $comment_id ); 194 214 195 if ( isset( $_GET['noredir'] ) ) 196 $noredir = true; 197 else 198 $noredir = false; 215 $noredir = isset( $_GET['noredir'] ); 199 216 200 217 if ( !$comment = get_comment( $comment_id ) ) 201 218 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); 202 219 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 } 207 226 208 227 if ( '' != wp_get_referer() && false == $noredir ) 209 wp_redirect(wp_get_referer() );228 $redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() ); 210 229 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 ); 237 241 238 242 exit();
Note: See TracChangeset
for help on using the changeset viewer.