WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Comment Management Panel 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 wp_enqueue_script('comment'); 49 require_once ('admin-header.php'); 50 51 $comment_id = absint( $_GET['c'] ); 52 53 if ( !$comment = get_comment( $comment_id ) ) 54 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') ); 55 56 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 57 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 58 59 if ( 'trash' == $comment->comment_approved ) 60 comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); 61 62 $comment = get_comment_to_edit( $comment_id ); 63 64 include ('edit-form-comment.php'); 65 66 break; 67 68 case 'delete' : 69 case 'approve' : 70 case 'trash' : 71 case 'spam' : 72 73 $comment_id = absint( $_GET['c'] ); 74 75 if ( !$comment = get_comment_to_edit( $comment_id ) ) { 76 wp_redirect( admin_url('edit-comments.php?error=1') ); 77 die(); 78 } 79 80 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) { 81 wp_redirect( admin_url('edit-comments.php?error=2') ); 82 die(); 83 } 84 85 // No need to re-approve/re-trash/re-spam a comment. 86 if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) { 87 wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) ); 88 die(); 89 } 90 91 require_once ('admin-header.php'); 92 93 $formaction = $action . 'comment'; 94 $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; 95 $nonce_action .= $comment_id; 96 97 ?> 98 <div class='wrap'> 99 100 <div class="narrow"> 101 102 <?php screen_icon(); ?> 103 <h2><?php esc_html_e( 'Moderate Comment' ); ?></h2> 104 105 <?php 106 switch ( $action ) { 107 case 'spam' : 108 $caution_msg = __('You are about to mark the following comment as spam:'); 109 $button = __('Spam Comment'); 110 break; 111 case 'trash' : 112 $caution_msg = __('You are about to move the following comment to the Trash:'); 113 $button = __('Trash Comment'); 114 break; 115 case 'delete' : 116 $caution_msg = __('You are about to delete the following comment:'); 117 $button = __('Permanently Delete Comment'); 118 break; 119 default : 120 $caution_msg = __('You are about to approve the following comment:'); 121 $button = __('Approve Comment'); 122 break; 123 } 124 125 if ( $comment->comment_approved != '0' ) { // if not unapproved 126 $message = ''; 127 switch ( $comment->comment_approved ) { 128 case '1' : 129 $message = __('This comment is currently approved.'); 130 break; 131 case 'spam' : 132 $message = __('This comment is currently marked as spam.'); 133 break; 134 case 'trash' : 135 $message = __('This comment is currently in the Trash.'); 136 break; 137 } 138 if ( $message ) 139 echo '<div class="updated"><p>' . $message . '</p></div>'; 140 } 141 ?> 142 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> 143 144 <table class="form-table comment-ays"> 145 <tr class="alt"> 146 <th scope="row"><?php _e('Author'); ?></th> 147 <td><?php echo $comment->comment_author; ?></td> 148 </tr> 149 <?php if ( $comment->comment_author_email ) { ?> 150 <tr> 151 <th scope="row"><?php _e('E-mail'); ?></th> 152 <td><?php echo $comment->comment_author_email; ?></td> 153 </tr> 154 <?php } ?> 155 <?php if ( $comment->comment_author_url ) { ?> 156 <tr> 157 <th scope="row"><?php _e('URL'); ?></th> 158 <td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td> 159 </tr> 160 <?php } ?> 161 <tr> 162 <th scope="row" valign="top"><?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th> 163 <td><?php echo $comment->comment_content; ?></td> 164 </tr> 165 </table> 166 167 <p><?php _e('Are you sure you want to do this?'); ?></p> 168 169 <form action='comment.php' method='get'> 170 171 <table width="100%"> 172 <tr> 173 <td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td> 174 <td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td> 175 </tr> 176 </table> 177 178 <?php wp_nonce_field( $nonce_action ); ?> 179 <input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' /> 180 <input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' /> 181 <input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> 182 <input type='hidden' name='noredir' value='1' /> 183 </form> 184 185 </div> 186 </div> 187 <?php 188 break; 189 190 case 'deletecomment' : 191 case 'trashcomment' : 192 case 'untrashcomment' : 193 case 'spamcomment' : 194 case 'unspamcomment' : 195 case 'approvecomment' : 196 case 'unapprovecomment' : 197 $comment_id = absint( $_REQUEST['c'] ); 198 199 if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 200 check_admin_referer( 'approve-comment_' . $comment_id ); 201 else 202 check_admin_referer( 'delete-comment_' . $comment_id ); 203 204 $noredir = isset($_REQUEST['noredir']); 205 206 if ( !$comment = get_comment($comment_id) ) 207 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') ); 208 if ( !current_user_can('edit_post', $comment->comment_post_ID ) ) 209 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 210 211 if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) 212 $redir = wp_get_referer(); 213 elseif ( '' != wp_get_original_referer() && ! $noredir ) 214 $redir = wp_get_original_referer(); 215 elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 216 $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); 217 else 218 $redir = admin_url('edit-comments.php'); 219 220 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); 221 222 switch ( $action ) { 223 case 'deletecomment' : 224 wp_delete_comment( $comment_id ); 225 $redir = add_query_arg( array('deleted' => '1'), $redir ); 226 break; 227 case 'trashcomment' : 228 wp_trash_comment($comment_id); 229 $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); 230 break; 231 case 'untrashcomment' : 232 wp_untrash_comment($comment_id); 233 $redir = add_query_arg( array('untrashed' => '1'), $redir ); 234 break; 235 case 'spamcomment' : 236 wp_spam_comment($comment_id); 237 $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); 238 break; 239 case 'unspamcomment' : 240 wp_unspam_comment($comment_id); 241 $redir = add_query_arg( array('unspammed' => '1'), $redir ); 242 break; 243 case 'approvecomment' : 244 wp_set_comment_status( $comment_id, 'approve' ); 245 $redir = add_query_arg( array( 'approved' => 1 ), $redir ); 246 break; 247 case 'unapprovecomment' : 248 wp_set_comment_status( $comment_id, 'hold' ); 249 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); 250 break; 251 } 252 253 wp_redirect( $redir ); 254 die; 255 break; 256 257 case 'editedcomment' : 258 259 $comment_id = absint( $_POST['comment_ID'] ); 260 $comment_post_id = absint( $_POST['comment_post_ID'] ); 261 262 check_admin_referer( 'update-comment_' . $comment_id ); 263 264 edit_comment(); 265 266 $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; 267 $location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); 268 wp_redirect( $location ); 269 270 exit(); 271 break; 272 273 default: 274 wp_die( __('Unknown action.') ); 275 break; 276 277 } // end switch 278 279 include ('admin-footer.php'); 280 281 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |