Changeset 13246
- Timestamp:
- 02/20/2010 11:18:25 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/comment.php
r12789 r13246 36 36 */ 37 37 function comment_footer_die( $msg ) { 38 global $hook_suffix; 38 39 echo "<div class='wrap'><p>$msg</p></div>"; 39 40 include('admin-footer.php'); … … 71 72 case 'spam' : 72 73 74 $comment_id = absint( $_GET['c'] ); 75 76 if ( !$comment = get_comment_to_edit( $comment_id ) ) { 77 wp_redirect( admin_url('edit-comments.php?error=1') ); 78 die(); 79 } 80 81 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) { 82 wp_redirect( admin_url('edit-comments.php?error=2') ); 83 die(); 84 } 85 73 86 require_once('admin-header.php'); 74 87 75 $comment_id = absint( $_GET['c'] );76 88 $formaction = $action . 'comment'; 77 89 $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; 78 90 $nonce_action .= $comment_id; 79 91 80 if ( !$comment = get_comment_to_edit( $comment_id ) )81 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );82 83 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )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.') );85 92 ?> 86 93 <div class='wrap'> 87 94 88 95 <div class="narrow"> 96 97 <?php screen_icon(); ?> 98 <h2><?php esc_html_e( 'Moderate Comment' ); ?></h2> 99 89 100 <?php 90 101 switch ( $action ) { … … 156 167 break; 157 168 158 case 'deletecomment' : 159 case 'trashcomment' : 160 case 'untrashcomment' : 161 case 'spamcomment' : 162 case 'unspamcomment' : 169 case 'deletecomment' : 170 case 'trashcomment' : 171 case 'untrashcomment' : 172 case 'spamcomment' : 173 case 'unspamcomment' : 174 case 'approvecomment' : 175 case 'unapprovecomment' : 163 176 $comment_id = absint( $_REQUEST['c'] ); 164 check_admin_referer( 'delete-comment_' . $comment_id ); 177 178 if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 179 check_admin_referer( 'approve-comment_' . $comment_id ); 180 else 181 check_admin_referer( 'delete-comment_' . $comment_id ); 165 182 166 183 $noredir = isset($_REQUEST['noredir']); … … 171 188 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 172 189 173 if ( '' != wp_get_referer() && false ==$noredir && false === strpos(wp_get_referer(), 'comment.php') )190 if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) 174 191 $redir = wp_get_referer(); 175 elseif ( '' != wp_get_original_referer() && false ==$noredir )192 elseif ( '' != wp_get_original_referer() && ! $noredir ) 176 193 $redir = wp_get_original_referer(); 194 elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 195 $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); 177 196 else 178 197 $redir = admin_url('edit-comments.php'); 179 198 180 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids' ), $redir );199 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); 181 200 182 201 switch ( $action ) { … … 201 220 $redir = add_query_arg( array('unspammed' => '1'), $redir ); 202 221 break; 203 } 222 case 'approvecomment' : 223 wp_set_comment_status( $comment_id, 'approve' ); 224 $redir = add_query_arg( array( 'approved' => 1 ), $redir ); 225 break; 226 case 'unapprovecomment' : 227 wp_set_comment_status( $comment_id, 'hold' ); 228 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); 229 break; 230 } 204 231 205 232 wp_redirect( $redir ); 206 207 233 die; 208 break;209 210 case 'approvecomment' :211 case 'unapprovecomment' :212 $comment_id = absint( $_GET['c'] );213 check_admin_referer( 'approve-comment_' . $comment_id );214 215 $noredir = isset( $_GET['noredir'] );216 217 if ( !$comment = get_comment( $comment_id ) )218 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );219 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 else224 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );225 }226 227 if ( '' != wp_get_referer() && false == $noredir )228 $redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() );229 else230 $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 );241 242 exit();243 234 break; 244 235 -
trunk/wp-admin/edit-comments.php
r13100 r13246 127 127 128 128 <?php 129 if ( isset( $_GET['error'] ) ) { 130 $error = (int) $_GET['error']; 131 $error_msg = ''; 132 switch ( $error ) { 133 case 1 : 134 $error_msg = __( 'Oops, no comment with this ID.' ); 135 break; 136 case 2 : 137 $error_msg = __( 'You are not allowed to edit comments on this post.' ); 138 break; 139 } 140 if ( $error_msg ) 141 echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; 142 } 143 129 144 if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) ) { 130 $approved = isset($_GET['approved']) ? (int) $_GET['approved']: 0;131 $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted']: 0;132 $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed']: 0;133 $untrashed = isset( $_GET['untrashed']) ? (int) $_GET['untrashed'] : 0;134 $spammed = isset($_GET['spammed']) ? (int) $_GET['spammed']: 0;135 $unspammed = isset( $_GET['unspammed']) ? (int) $_GET['unspammed'] : 0;145 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; 146 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; 147 $trashed = isset( $_GET['trashed'] ) ? (int) $_GET['trashed'] : 0; 148 $untrashed = isset( $_GET['untrashed'] ) ? (int) $_GET['untrashed'] : 0; 149 $spammed = isset( $_GET['spammed'] ) ? (int) $_GET['spammed'] : 0; 150 $unspammed = isset( $_GET['unspammed'] ) ? (int) $_GET['unspammed'] : 0; 136 151 137 152 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 ) { 138 echo '<div id="moderated" class="updated"><p>'; 139 140 if ( $approved > 0 ) { 141 printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); 142 echo '<br />'; 153 if ( $approved > 0 ) 154 $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); 155 156 if ( $spammed > 0 ) { 157 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 158 $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />'; 143 159 } 144 if ( $spammed > 0 ) { 145 printf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ); 160 161 if ( $unspammed > 0 ) 162 $messages = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); 163 164 if ( $trashed > 0 ) { 146 165 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 147 echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';166 $messages[] = sprintf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />'; 148 167 } 149 if ( $unspammed > 0 ) { 150 printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); 151 echo '<br />'; 152 } 153 if ( $trashed > 0 ) { 154 printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed ); 155 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 156 echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />'; 157 } 158 if ( $untrashed > 0 ) { 159 printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed ); 160 echo '<br />'; 161 } 162 if ( $deleted > 0 ) { 163 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); 164 echo '<br />'; 165 } 166 167 echo '</p></div>'; 168 169 if ( $untrashed > 0 ) 170 $messages[] = sprintf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed ); 171 172 if ( $deleted > 0 ) 173 $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); 174 175 echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>'; 168 176 } 169 177 }
Note: See TracChangeset
for help on using the changeset viewer.