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';
14 $title = __('Edit Comment');
16 require_once ('admin-header.php');
18 $comment = (int) $_GET['c'];
20 if ( ! $comment = get_comment($comment) )
21 wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)'));
23 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
24 wp_die( __('You are not allowed to edit comments on this post.') );
26 $comment = get_comment_to_edit($comment);
28 include('edit-form-comment.php');
35 require_once('./admin-header.php');
37 $comment = (int) $_GET['c'];
38 $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment';
39 $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
40 $nonce_action .= $comment;
42 if ( ! $comment = get_comment_to_edit($comment) )
43 wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php'));
45 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
46 wp_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.') );
51 <?php if ( 'spam' == $_GET['dt'] ) { ?>
52 <p><?php echo '<strong>'.__('Caution:').'</strong> '.__('You are about to mark the following comment as spam:'); ?></p>
53 <?php } elseif ( 'cdc' == $action ) { ?>
54 <p><?php echo '<strong>'.__('Caution:').'</strong> '.__('You are about to delete the following comment:'); ?></p>
56 <p><?php echo '<strong>'.__('Caution:').'</strong> '.__('You are about to approve the following comment:'); ?></p>
59 <p><?php _e('Are you sure you want to do that?'); ?></p>
61 <form action='<?php echo get_option('siteurl'); ?>/wp-admin/comment.php' method='get'>
65 <td><input type='button' value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td>
66 <td align="right"><input type='submit' value='<?php _e('Yes'); ?>' /></td>
70 <?php wp_nonce_field($nonce_action); ?>
71 <input type='hidden' name='action' value='<?php echo $formaction; ?>' />
72 <?php if ( 'spam' == $_GET['dt'] ) { ?>
73 <input type='hidden' name='dt' value='spam' />
75 <input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
76 <input type='hidden' name='c' value='<?php echo $comment->comment_ID; ?>' />
77 <input type='hidden' name='noredir' value='1' />
80 <table class="editform" cellpadding="5">
82 <th scope="row"><?php _e('Author:'); ?></th>
83 <td><?php echo $comment->comment_author; ?></td>
85 <?php if ( $comment->comment_author_email ) { ?>
87 <th scope="row"><?php _e('E-mail:'); ?></th>
88 <td><?php echo $comment->comment_author_email; ?></td>
91 <?php if ( $comment->comment_author_url ) { ?>
93 <th scope="row"><?php _e('URL:'); ?></th>
94 <td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td>
98 <th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th>
99 <td><?php echo $comment->comment_content; ?></td>
108 case 'deletecomment':
109 $comment = (int) $_REQUEST['c'];
110 check_admin_referer('delete-comment_' . $comment);
112 if ( isset($_REQUEST['noredir']) ) {
118 if ( ! $comment = get_comment($comment) )
119 wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php'));
121 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
122 wp_die( __('You are not allowed to edit comments on this post.') );
124 if ( 'spam' == $_REQUEST['dt'] )
125 wp_set_comment_status($comment->comment_ID, 'spam');
127 wp_delete_comment($comment->comment_ID);
129 if ((wp_get_referer() != '') && (false == $noredir)) {
130 wp_redirect(wp_get_referer());
132 wp_redirect(get_option('siteurl') .'/wp-admin/edit-comments.php');
137 case 'unapprovecomment':
138 $comment = (int) $_GET['c'];
139 check_admin_referer('unapprove-comment_' . $comment);
141 if (isset($_GET['noredir'])) {
147 if ( ! $comment = get_comment($comment) )
148 wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php'));
150 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
151 wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
153 wp_set_comment_status($comment->comment_ID, "hold");
155 if ((wp_get_referer() != "") && (false == $noredir)) {
156 wp_redirect(wp_get_referer());
158 wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p=' . (int) $comment->comment_post_ID.'&c=1#comments');
163 case 'approvecomment':
164 $comment = (int) $_GET['c'];
165 check_admin_referer('approve-comment_' . $comment);
167 if (isset($_GET['noredir'])) {
173 if ( ! $comment = get_comment($comment) )
174 wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php'));
176 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
177 wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
179 wp_set_comment_status($comment->comment_ID, "approve");
180 if (get_option("comments_notify") == true) {
181 wp_notify_postauthor($comment->comment_ID);
185 if ((wp_get_referer() != "") && (false == $noredir)) {
186 wp_redirect(wp_get_referer());
188 wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p=' . (int) $comment->comment_post_ID.'&c=1#comments');
193 case 'editedcomment':
195 $comment_ID = (int) $_POST['comment_ID'];
196 $comment_post_ID = (int) $_POST['comment_post_id'];
198 check_admin_referer('update-comment_' . $comment_ID);
202 $location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
203 $location = apply_filters('comment_edit_redirect', $location, $comment_ID);
204 wp_redirect($location);
211 include('admin-footer.php');