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