| [ XREF Home ] [ Index ] |
PHP Cross Reference of WordPress TrunkProvided by Yoast |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Comment Management Screen 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** Load WordPress Bootstrap */ 10 require_once ('./admin.php'); 11 12 $parent_file = 'edit-comments.php'; 13 $submenu_file = 'edit-comments.php'; 14 15 wp_reset_vars( array('action') ); 16 17 if ( isset( $_POST['deletecomment'] ) ) 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 } 31 32 /** 33 * Display error message at bottom of comments. 34 * 35 * @param string $msg Error Message. Assumed to contain HTML and be sanitized. 36 */ 37 function comment_footer_die( $msg ) { 38 echo "<div class='wrap'><p>$msg</p></div>"; 39 include ('./admin-footer.php'); 40 die; 41 } 42 43 switch( $action ) { 44 45 case 'editcomment' : 46 $title = __('Edit Comment'); 47 48 add_contextual_help( $current_screen, '<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' . 49 '<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>' . 50 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 51 '<p>' . __( '<a href="http://codex.wordpress.org/Administration_Screens#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' . 52 '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' 53 ); 54 55 wp_enqueue_script('comment'); 56 require_once ('./admin-header.php'); 57 58 $comment_id = absint( $_GET['c'] ); 59 60 if ( !$comment = get_comment( $comment_id ) ) 61 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') ); 62 63 if ( !current_user_can( 'edit_comment', $comment_id ) ) 64 comment_footer_die( __('You are not allowed to edit this comment.') ); 65 66 if ( 'trash' == $comment->comment_approved ) 67 comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); 68 69 $comment = get_comment_to_edit( $comment_id ); 70 71 include ('./edit-form-comment.php'); 72 73 break; 74 75 case 'delete' : 76 case 'approve' : 77 case 'trash' : 78 case 'spam' : 79 80 $title = __('Moderate Comment'); 81 82 $comment_id = absint( $_GET['c'] ); 83 84 if ( !$comment = get_comment_to_edit( $comment_id ) ) { 85 wp_redirect( admin_url('edit-comments.php?error=1') ); 86 die(); 87 } 88 89 if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { 90 wp_redirect( admin_url('edit-comments.php?error=2') ); 91 die(); 92 } 93 94 // No need to re-approve/re-trash/re-spam a comment. 95 if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) { 96 wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) ); 97 die(); 98 } 99 100 require_once ('./admin-header.php'); 101 102 $formaction = $action . 'comment'; 103 $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; 104 $nonce_action .= $comment_id; 105 106 ?> 107 <div class='wrap'> 108 109 <div class="narrow"> 110 111 <?php screen_icon(); ?> 112 <h2><?php echo esc_html( $title ); ?></h2> 113 114 <?php 115 switch ( $action ) { 116 case 'spam' : 117 $caution_msg = __('You are about to mark the following comment as spam:'); 118 $button = __('Spam Comment'); 119 break; 120 case 'trash' : 121 $caution_msg = __('You are about to move the following comment to the Trash:'); 122 $button = __('Trash Comment'); 123 break; 124 case 'delete' : 125 $caution_msg = __('You are about to delete the following comment:'); 126 $button = __('Permanently Delete Comment'); 127 break; 128 default : 129 $caution_msg = __('You are about to approve the following comment:'); 130 $button = __('Approve Comment'); 131 break; 132 } 133 134 if ( $comment->comment_approved != '0' ) { // if not unapproved 135 $message = ''; 136 switch ( $comment->comment_approved ) { 137 case '1' : 138 $message = __('This comment is currently approved.'); 139 break; 140 case 'spam' : 141 $message = __('This comment is currently marked as spam.'); 142 break; 143 case 'trash' : 144 $message = __('This comment is currently in the Trash.'); 145 break; 146 } 147 if ( $message ) 148 echo '<div class="updated"><p>' . $message . '</p></div>'; 149 } 150 ?> 151 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> 152 153 <table class="form-table comment-ays"> 154 <tr class="alt"> 155 <th scope="row"><?php _e('Author'); ?></th> 156 <td><?php echo $comment->comment_author; ?></td> 157 </tr> 158 <?php if ( $comment->comment_author_email ) { ?> 159 <tr> 160 <th scope="row"><?php _e('E-mail'); ?></th> 161 <td><?php echo $comment->comment_author_email; ?></td> 162 </tr> 163 <?php } ?> 164 <?php if ( $comment->comment_author_url ) { ?> 165 <tr> 166 <th scope="row"><?php _e('URL'); ?></th> 167 <td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td> 168 </tr> 169 <?php } ?> 170 <tr> 171 <th scope="row" valign="top"><?php /* translators: field name in comment form */ _ex('Comment', 'noun'); ?></th> 172 <td><?php echo $comment->comment_content; ?></td> 173 </tr> 174 </table> 175 176 <p><?php _e('Are you sure you want to do this?'); ?></p> 177 178 <form action='comment.php' method='get'> 179 180 <table width="100%"> 181 <tr> 182 <td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td> 183 <td class="textright"><?php submit_button( $button, 'button' ); ?></td> 184 </tr> 185 </table> 186 187 <?php wp_nonce_field( $nonce_action ); ?> 188 <input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' /> 189 <input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> 190 <input type='hidden' name='noredir' value='1' /> 191 </form> 192 193 </div> 194 </div> 195 <?php 196 break; 197 198 case 'deletecomment' : 199 case 'trashcomment' : 200 case 'untrashcomment' : 201 case 'spamcomment' : 202 case 'unspamcomment' : 203 case 'approvecomment' : 204 case 'unapprovecomment' : 205 $comment_id = absint( $_REQUEST['c'] ); 206 207 if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 208 check_admin_referer( 'approve-comment_' . $comment_id ); 209 else 210 check_admin_referer( 'delete-comment_' . $comment_id ); 211 212 $noredir = isset($_REQUEST['noredir']); 213 214 if ( !$comment = get_comment($comment_id) ) 215 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') ); 216 if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) 217 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 218 219 if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) 220 $redir = wp_get_referer(); 221 elseif ( '' != wp_get_original_referer() && ! $noredir ) 222 $redir = wp_get_original_referer(); 223 elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 224 $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); 225 else 226 $redir = admin_url('edit-comments.php'); 227 228 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); 229 230 switch ( $action ) { 231 case 'deletecomment' : 232 wp_delete_comment( $comment_id ); 233 $redir = add_query_arg( array('deleted' => '1'), $redir ); 234 break; 235 case 'trashcomment' : 236 wp_trash_comment($comment_id); 237 $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); 238 break; 239 case 'untrashcomment' : 240 wp_untrash_comment($comment_id); 241 $redir = add_query_arg( array('untrashed' => '1'), $redir ); 242 break; 243 case 'spamcomment' : 244 wp_spam_comment($comment_id); 245 $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); 246 break; 247 case 'unspamcomment' : 248 wp_unspam_comment($comment_id); 249 $redir = add_query_arg( array('unspammed' => '1'), $redir ); 250 break; 251 case 'approvecomment' : 252 wp_set_comment_status( $comment_id, 'approve' ); 253 $redir = add_query_arg( array( 'approved' => 1 ), $redir ); 254 break; 255 case 'unapprovecomment' : 256 wp_set_comment_status( $comment_id, 'hold' ); 257 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); 258 break; 259 } 260 261 wp_redirect( $redir ); 262 die; 263 break; 264 265 case 'editedcomment' : 266 267 $comment_id = absint( $_POST['comment_ID'] ); 268 $comment_post_id = absint( $_POST['comment_post_ID'] ); 269 270 check_admin_referer( 'update-comment_' . $comment_id ); 271 272 edit_comment(); 273 274 $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; 275 $location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); 276 wp_redirect( $location ); 277 278 exit(); 279 break; 280 281 default: 282 wp_die( __('Unknown action.') ); 283 break; 284 285 } // end switch 286 287 include ('./admin-footer.php'); 288 289 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jun 1 08:30:02 2011 |
Cross-referenced by PHPXref 0.7 Provided by Yoast and awesome WordPress Hosting |