2 require_once('admin.php');
4 $parent_file = 'edit-comments.php';
5 $submenu_file = 'edit-comments.php';
7 wp_reset_vars( array('action') );
9 if ( isset( $_POST['deletecomment'] ) )
10 $action = 'deletecomment';
12 function comment_footer_die( $msg ) { // $msg is assumed to contain HTML and be sanitized
13 echo "<div class='wrap'><p>$msg</p></div>";
14 include('admin-footer.php');
21 $title = __('Edit Comment');
23 wp_enqueue_script('comment');
25 require_once('admin-header.php');
27 $comment_id = absint( $_GET['c'] );
29 if ( !$comment = get_comment( $comment_id ) )
30 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') );
32 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
33 comment_footer_die( __('You are not allowed to edit comments on this post.') );
35 $comment = get_comment_to_edit( $comment_id );
37 include('edit-form-comment.php');
44 require_once('admin-header.php');
46 $comment_id = absint( $_GET['c'] );
47 $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment';
48 $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
49 $nonce_action .= $comment_id;
51 if ( !$comment = get_comment_to_edit( $comment_id ) )
52 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
54 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
55 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.') );
61 if ( 'spam' == $_GET['dt'] ) {
62 $caution_msg = __('You are about to mark the following comment as spam:');
63 $button = __('Spam Comment');
64 } elseif ( 'cdc' == $action ) {
65 $caution_msg = __('You are about to delete the following comment:');
66 $button = __('Delete Comment');
68 $caution_msg = __('You are about to approve the following comment:');
69 $button = __('Approve Comment');
73 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
75 <p><?php _e('Are you sure you want to do that?'); ?></p>
77 <form action='comment.php' method='get'>
81 <td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>" /></td>
82 <td class="textright"><input type='submit' class="button" value='<?php echo $button; ?>' /></td>
86 <?php wp_nonce_field( $nonce_action ); ?>
87 <input type='hidden' name='action' value='<?php echo $formaction; ?>' />
88 <?php if ( 'spam' == $_GET['dt'] ) { ?>
89 <input type='hidden' name='dt' value='spam' />
91 <input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
92 <input type='hidden' name='c' value='<?php echo $comment->comment_ID; ?>' />
93 <input type='hidden' name='noredir' value='1' />
96 <table class="form-table" cellpadding="5">
98 <th scope="row"><?php _e('Author'); ?></th>
99 <td><?php echo $comment->comment_author; ?></td>
101 <?php if ( $comment->comment_author_email ) { ?>
103 <th scope="row"><?php _e('E-mail'); ?></th>
104 <td><?php echo $comment->comment_author_email; ?></td>
107 <?php if ( $comment->comment_author_url ) { ?>
109 <th scope="row"><?php _e('URL'); ?></th>
110 <td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td>
114 <th scope="row" valign="top"><?php _e('Comment'); ?></th>
115 <td><?php echo $comment->comment_content; ?></td>
124 case 'deletecomment' :
125 $comment_id = absint( $_REQUEST['c'] );
126 check_admin_referer( 'delete-comment_' . $comment_id );
128 if ( isset( $_REQUEST['noredir'] ) )
133 if ( !$comment = get_comment( $comment_id ) )
134 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
136 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
137 comment_footer_die( __('You are not allowed to edit comments on this post.') );
139 if ( 'spam' == $_REQUEST['dt'] )
140 wp_set_comment_status( $comment->comment_ID, 'spam' );
142 wp_delete_comment( $comment->comment_ID );
144 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) )
145 wp_redirect( wp_get_referer() );
146 else if ( '' != wp_get_original_referer() && false == $noredir )
147 wp_redirect( wp_get_original_referer() );
149 wp_redirect( admin_url('edit-comments.php') );
154 case 'unapprovecomment' :
155 $comment_id = absint( $_GET['c'] );
156 check_admin_referer( 'unapprove-comment_' . $comment_id );
158 if ( isset( $_GET['noredir'] ) )
163 if ( !$comment = get_comment( $comment_id ) )
164 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
166 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
167 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
169 wp_set_comment_status( $comment->comment_ID, 'hold' );
171 if ( '' != wp_get_referer() && false == $noredir )
172 wp_redirect( wp_get_referer() );
174 wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
179 case 'approvecomment' :
180 $comment_id = absint( $_GET['c'] );
181 check_admin_referer( 'approve-comment_' . $comment_id );
183 if ( isset( $_GET['noredir'] ) )
188 if ( !$comment = get_comment( $comment_id ) )
189 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
191 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
192 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
194 wp_set_comment_status( $comment->comment_ID, 'approve' );
196 if ( '' != wp_get_referer() && false == $noredir )
197 wp_redirect( wp_get_referer() );
199 wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
204 case 'editedcomment' :
206 $comment_id = absint( $_POST['comment_ID'] );
207 $comment_post_id = absint( $_POST['comment_post_id'] );
209 check_admin_referer( 'update-comment_' . $comment_id );
213 $location = ( empty( $_POST['referredby'] ) ? "edit.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
214 $location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
215 wp_redirect( $location );
221 wp_die( __('Unknown action.') );
226 include('admin-footer.php');