mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Comment Management Panel
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** Load WordPress Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 $parent_file = 'edit-comments.php';
mp-wp_genesis 13 $submenu_file = 'edit-comments.php';
mp-wp_genesis 14
mp-wp_genesis 15 wp_reset_vars( array('action') );
mp-wp_genesis 16
mp-wp_genesis 17 if ( isset( $_POST['deletecomment'] ) )
mp-wp_genesis 18 $action = 'deletecomment';
mp-wp_genesis 19
mp-wp_genesis 20 /**
mp-wp_genesis 21 * Display error message at bottom of comments.
mp-wp_genesis 22 *
mp-wp_genesis 23 * @param string $msg Error Message. Assumed to contain HTML and be sanitized.
mp-wp_genesis 24 */
mp-wp_genesis 25 function comment_footer_die( $msg ) { //
mp-wp_genesis 26 echo "<div class='wrap'><p>$msg</p></div>";
mp-wp_genesis 27 include('admin-footer.php');
mp-wp_genesis 28 die;
mp-wp_genesis 29 }
mp-wp_genesis 30
mp-wp_genesis 31 switch( $action ) {
mp-wp_genesis 32
mp-wp_genesis 33 case 'editcomment' :
mp-wp_genesis 34 $title = __('Edit Comment');
mp-wp_genesis 35
mp-wp_genesis 36 wp_enqueue_script('comment');
mp-wp_genesis 37 require_once('admin-header.php');
mp-wp_genesis 38
mp-wp_genesis 39 $comment_id = absint( $_GET['c'] );
mp-wp_genesis 40
mp-wp_genesis 41 if ( !$comment = get_comment( $comment_id ) )
mp-wp_genesis 42 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') );
mp-wp_genesis 43
mp-wp_genesis 44 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
mp-wp_genesis 45 comment_footer_die( __('You are not allowed to edit comments on this post.') );
mp-wp_genesis 46
mp-wp_genesis 47 $comment = get_comment_to_edit( $comment_id );
mp-wp_genesis 48
mp-wp_genesis 49 include('edit-form-comment.php');
mp-wp_genesis 50
mp-wp_genesis 51 break;
mp-wp_genesis 52
mp-wp_genesis 53 case 'cdc' :
mp-wp_genesis 54 case 'mac' :
mp-wp_genesis 55
mp-wp_genesis 56 require_once('admin-header.php');
mp-wp_genesis 57
mp-wp_genesis 58 $comment_id = absint( $_GET['c'] );
mp-wp_genesis 59 $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment';
mp-wp_genesis 60 $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
mp-wp_genesis 61 $nonce_action .= $comment_id;
mp-wp_genesis 62
mp-wp_genesis 63 if ( !$comment = get_comment_to_edit( $comment_id ) )
mp-wp_genesis 64 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
mp-wp_genesis 65
mp-wp_genesis 66 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
mp-wp_genesis 67 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.') );
mp-wp_genesis 68 ?>
mp-wp_genesis 69 <div class='wrap'>
mp-wp_genesis 70
mp-wp_genesis 71 <div class="narrow">
mp-wp_genesis 72 <?php
mp-wp_genesis 73 if ( 'spam' == $_GET['dt'] ) {
mp-wp_genesis 74 $caution_msg = __('You are about to mark the following comment as spam:');
mp-wp_genesis 75 $button = __('Spam Comment');
mp-wp_genesis 76 } elseif ( 'cdc' == $action ) {
mp-wp_genesis 77 $caution_msg = __('You are about to delete the following comment:');
mp-wp_genesis 78 $button = __('Delete Comment');
mp-wp_genesis 79 } else {
mp-wp_genesis 80 $caution_msg = __('You are about to approve the following comment:');
mp-wp_genesis 81 $button = __('Approve Comment');
mp-wp_genesis 82 }
mp-wp_genesis 83 ?>
mp-wp_genesis 84
mp-wp_genesis 85 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
mp-wp_genesis 86
mp-wp_genesis 87 <p><?php _e('Are you sure you want to do that?'); ?></p>
mp-wp_genesis 88
mp-wp_genesis 89 <form action='comment.php' method='get'>
mp-wp_genesis 90
mp-wp_genesis 91 <table width="100%">
mp-wp_genesis 92 <tr>
mp-wp_genesis 93 <td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>" /></td>
mp-wp_genesis 94 <td class="textright"><input type='submit' class="button" value='<?php echo $button; ?>' /></td>
mp-wp_genesis 95 </tr>
mp-wp_genesis 96 </table>
mp-wp_genesis 97
mp-wp_genesis 98 <?php wp_nonce_field( $nonce_action ); ?>
mp-wp_genesis 99 <input type='hidden' name='action' value='<?php echo $formaction; ?>' />
mp-wp_genesis 100 <?php if ( 'spam' == $_GET['dt'] ) { ?>
mp-wp_genesis 101 <input type='hidden' name='dt' value='spam' />
mp-wp_genesis 102 <?php } ?>
mp-wp_genesis 103 <input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
mp-wp_genesis 104 <input type='hidden' name='c' value='<?php echo $comment->comment_ID; ?>' />
mp-wp_genesis 105 <input type='hidden' name='noredir' value='1' />
mp-wp_genesis 106 </form>
mp-wp_genesis 107
mp-wp_genesis 108 <table class="form-table" cellpadding="5">
mp-wp_genesis 109 <tr class="alt">
mp-wp_genesis 110 <th scope="row"><?php _e('Author'); ?></th>
mp-wp_genesis 111 <td><?php echo $comment->comment_author; ?></td>
mp-wp_genesis 112 </tr>
mp-wp_genesis 113 <?php if ( $comment->comment_author_email ) { ?>
mp-wp_genesis 114 <tr>
mp-wp_genesis 115 <th scope="row"><?php _e('E-mail'); ?></th>
mp-wp_genesis 116 <td><?php echo $comment->comment_author_email; ?></td>
mp-wp_genesis 117 </tr>
mp-wp_genesis 118 <?php } ?>
mp-wp_genesis 119 <?php if ( $comment->comment_author_url ) { ?>
mp-wp_genesis 120 <tr>
mp-wp_genesis 121 <th scope="row"><?php _e('URL'); ?></th>
mp-wp_genesis 122 <td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td>
mp-wp_genesis 123 </tr>
mp-wp_genesis 124 <?php } ?>
mp-wp_genesis 125 <tr>
mp-wp_genesis 126 <th scope="row" valign="top"><?php echo _c('Comment|noun'); ?></th>
mp-wp_genesis 127 <td><?php echo $comment->comment_content; ?></td>
mp-wp_genesis 128 </tr>
mp-wp_genesis 129 </table>
mp-wp_genesis 130
mp-wp_genesis 131 </div>
mp-wp_genesis 132 </div>
mp-wp_genesis 133 <?php
mp-wp_genesis 134 break;
mp-wp_genesis 135
mp-wp_genesis 136 case 'deletecomment' :
mp-wp_genesis 137 $comment_id = absint( $_REQUEST['c'] );
mp-wp_genesis 138 check_admin_referer( 'delete-comment_' . $comment_id );
mp-wp_genesis 139
mp-wp_genesis 140 if ( isset( $_REQUEST['noredir'] ) )
mp-wp_genesis 141 $noredir = true;
mp-wp_genesis 142 else
mp-wp_genesis 143 $noredir = false;
mp-wp_genesis 144
mp-wp_genesis 145 if ( !$comment = get_comment( $comment_id ) )
mp-wp_genesis 146 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
mp-wp_genesis 147
mp-wp_genesis 148 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
mp-wp_genesis 149 comment_footer_die( __('You are not allowed to edit comments on this post.') );
mp-wp_genesis 150
mp-wp_genesis 151 if ( 'spam' == $_REQUEST['dt'] )
mp-wp_genesis 152 wp_set_comment_status( $comment->comment_ID, 'spam' );
mp-wp_genesis 153 else
mp-wp_genesis 154 wp_delete_comment( $comment->comment_ID );
mp-wp_genesis 155
mp-wp_genesis 156 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) )
mp-wp_genesis 157 wp_redirect( wp_get_referer() );
mp-wp_genesis 158 else if ( '' != wp_get_original_referer() && false == $noredir )
mp-wp_genesis 159 wp_redirect( wp_get_original_referer() );
mp-wp_genesis 160 else
mp-wp_genesis 161 wp_redirect( admin_url('edit-comments.php') );
mp-wp_genesis 162
mp-wp_genesis 163 die;
mp-wp_genesis 164 break;
mp-wp_genesis 165
mp-wp_genesis 166 case 'unapprovecomment' :
mp-wp_genesis 167 $comment_id = absint( $_GET['c'] );
mp-wp_genesis 168 check_admin_referer( 'unapprove-comment_' . $comment_id );
mp-wp_genesis 169
mp-wp_genesis 170 if ( isset( $_GET['noredir'] ) )
mp-wp_genesis 171 $noredir = true;
mp-wp_genesis 172 else
mp-wp_genesis 173 $noredir = false;
mp-wp_genesis 174
mp-wp_genesis 175 if ( !$comment = get_comment( $comment_id ) )
mp-wp_genesis 176 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
mp-wp_genesis 177
mp-wp_genesis 178 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
mp-wp_genesis 179 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
mp-wp_genesis 180
mp-wp_genesis 181 wp_set_comment_status( $comment->comment_ID, 'hold' );
mp-wp_genesis 182
mp-wp_genesis 183 if ( '' != wp_get_referer() && false == $noredir )
mp-wp_genesis 184 wp_redirect( wp_get_referer() );
mp-wp_genesis 185 else
mp-wp_genesis 186 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
mp-wp_genesis 187
mp-wp_genesis 188 exit();
mp-wp_genesis 189 break;
mp-wp_genesis 190
mp-wp_genesis 191 case 'approvecomment' :
mp-wp_genesis 192 $comment_id = absint( $_GET['c'] );
mp-wp_genesis 193 check_admin_referer( 'approve-comment_' . $comment_id );
mp-wp_genesis 194
mp-wp_genesis 195 if ( isset( $_GET['noredir'] ) )
mp-wp_genesis 196 $noredir = true;
mp-wp_genesis 197 else
mp-wp_genesis 198 $noredir = false;
mp-wp_genesis 199
mp-wp_genesis 200 if ( !$comment = get_comment( $comment_id ) )
mp-wp_genesis 201 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
mp-wp_genesis 202
mp-wp_genesis 203 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
mp-wp_genesis 204 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
mp-wp_genesis 205
mp-wp_genesis 206 wp_set_comment_status( $comment->comment_ID, 'approve' );
mp-wp_genesis 207
mp-wp_genesis 208 if ( '' != wp_get_referer() && false == $noredir )
mp-wp_genesis 209 wp_redirect( wp_get_referer() );
mp-wp_genesis 210 else
mp-wp_genesis 211 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
mp-wp_genesis 212
mp-wp_genesis 213 exit();
mp-wp_genesis 214 break;
mp-wp_genesis 215
mp-wp_genesis 216 case 'editedcomment' :
mp-wp_genesis 217
mp-wp_genesis 218 $comment_id = absint( $_POST['comment_ID'] );
mp-wp_genesis 219 $comment_post_id = absint( $_POST['comment_post_id'] );
mp-wp_genesis 220
mp-wp_genesis 221 check_admin_referer( 'update-comment_' . $comment_id );
mp-wp_genesis 222
mp-wp_genesis 223 edit_comment();
mp-wp_genesis 224
mp-wp_genesis 225 $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
mp-wp_genesis 226 $location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
mp-wp_genesis 227 wp_redirect( $location );
mp-wp_genesis 228
mp-wp_genesis 229 exit();
mp-wp_genesis 230 break;
mp-wp_genesis 231
mp-wp_genesis 232 default:
mp-wp_genesis 233 wp_die( __('Unknown action.') );
mp-wp_genesis 234 break;
mp-wp_genesis 235
mp-wp_genesis 236 } // end switch
mp-wp_genesis 237
mp-wp_genesis 238 include('admin-footer.php');
mp-wp_genesis 239
mp-wp_genesis 240 ?>