3
* Comment Management Screen
6
* @subpackage Administration
9
/** Load WordPress Bootstrap */
10
require_once( dirname( __FILE__ ) . '/admin.php' );
12
$parent_file = 'edit-comments.php';
13
$submenu_file = 'edit-comments.php';
15
wp_reset_vars( array('action') );
17
if ( isset( $_POST['deletecomment'] ) )
18
$action = 'deletecomment';
20
if ( 'cdc' == $action )
22
elseif ( 'mac' == $action )
25
if ( isset( $_GET['dt'] ) ) {
26
if ( 'spam' == $_GET['dt'] )
28
elseif ( 'trash' == $_GET['dt'] )
33
* Display error message at bottom of comments.
35
* @param string $msg Error Message. Assumed to contain HTML and be sanitized.
37
function comment_footer_die( $msg ) {
38
echo "<div class='wrap'><p>$msg</p></div>";
39
include( ABSPATH . 'wp-admin/admin-footer.php' );
46
$title = __('Edit Comment');
48
get_current_screen()->add_help_tab( array(
50
'title' => __('Overview'),
52
'<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' .
53
'<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>'
56
get_current_screen()->set_help_sidebar(
57
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
58
'<p>' . __( '<a href="http://codex.wordpress.org/Administration_Screens#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' .
59
'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
62
wp_enqueue_script('comment');
63
require_once( ABSPATH . 'wp-admin/admin-header.php' );
65
$comment_id = absint( $_GET['c'] );
67
if ( !$comment = get_comment( $comment_id ) )
68
comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'javascript:history.go(-1)') );
70
if ( !current_user_can( 'edit_comment', $comment_id ) )
71
comment_footer_die( __('You are not allowed to edit this comment.') );
73
if ( 'trash' == $comment->comment_approved )
74
comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') );
76
$comment = get_comment_to_edit( $comment_id );
78
include( ABSPATH . 'wp-admin/edit-form-comment.php' );
87
$title = __('Moderate Comment');
89
$comment_id = absint( $_GET['c'] );
91
if ( !$comment = get_comment_to_edit( $comment_id ) ) {
92
wp_redirect( admin_url('edit-comments.php?error=1') );
96
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) {
97
wp_redirect( admin_url('edit-comments.php?error=2') );
101
// No need to re-approve/re-trash/re-spam a comment.
102
if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
103
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
107
require_once( ABSPATH . 'wp-admin/admin-header.php' );
109
$formaction = $action . 'comment';
110
$nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
111
$nonce_action .= $comment_id;
118
<h2><?php echo esc_html( $title ); ?></h2>
123
$caution_msg = __('You are about to mark the following comment as spam:');
124
$button = __('Spam Comment');
127
$caution_msg = __('You are about to move the following comment to the Trash:');
128
$button = __('Trash Comment');
131
$caution_msg = __('You are about to delete the following comment:');
132
$button = __('Permanently Delete Comment');
135
$caution_msg = __('You are about to approve the following comment:');
136
$button = __('Approve Comment');
140
if ( $comment->comment_approved != '0' ) { // if not unapproved
142
switch ( $comment->comment_approved ) {
144
$message = __('This comment is currently approved.');
147
$message = __('This comment is currently marked as spam.');
150
$message = __('This comment is currently in the Trash.');
154
echo '<div class="updated"><p>' . $message . '</p></div>';
157
<p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
159
<table class="form-table comment-ays">
161
<th scope="row"><?php _e('Author'); ?></th>
162
<td><?php echo $comment->comment_author; ?></td>
164
<?php if ( $comment->comment_author_email ) { ?>
166
<th scope="row"><?php _e('E-mail'); ?></th>
167
<td><?php echo $comment->comment_author_email; ?></td>
170
<?php if ( $comment->comment_author_url ) { ?>
172
<th scope="row"><?php _e('URL'); ?></th>
173
<td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td>
177
<th scope="row"><?php /* translators: field name in comment form */ _ex('Comment', 'noun'); ?></th>
178
<td><?php echo $comment->comment_content; ?></td>
182
<p><?php _e('Are you sure you want to do this?'); ?></p>
184
<form action="comment.php" method="get">
188
<td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td>
189
<td class="textright"><?php submit_button( $button, 'button' ); ?></td>
193
<?php wp_nonce_field( $nonce_action ); ?>
194
<input type="hidden" name="action" value="<?php echo esc_attr($formaction); ?>" />
195
<input type="hidden" name="c" value="<?php echo esc_attr($comment->comment_ID); ?>" />
196
<input type="hidden" name="noredir" value="1" />
204
case 'deletecomment' :
205
case 'trashcomment' :
206
case 'untrashcomment' :
208
case 'unspamcomment' :
209
case 'approvecomment' :
210
case 'unapprovecomment' :
211
$comment_id = absint( $_REQUEST['c'] );
213
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
214
check_admin_referer( 'approve-comment_' . $comment_id );
216
check_admin_referer( 'delete-comment_' . $comment_id );
218
$noredir = isset($_REQUEST['noredir']);
220
if ( !$comment = get_comment($comment_id) )
221
comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'edit-comments.php') );
222
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
223
comment_footer_die( __('You are not allowed to edit comments on this post.') );
225
if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') )
226
$redir = wp_get_referer();
227
elseif ( '' != wp_get_original_referer() && ! $noredir )
228
$redir = wp_get_original_referer();
229
elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
230
$redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
232
$redir = admin_url('edit-comments.php');
234
$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir );
237
case 'deletecomment' :
238
wp_delete_comment( $comment_id );
239
$redir = add_query_arg( array('deleted' => '1'), $redir );
241
case 'trashcomment' :
242
wp_trash_comment($comment_id);
243
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
245
case 'untrashcomment' :
246
wp_untrash_comment($comment_id);
247
$redir = add_query_arg( array('untrashed' => '1'), $redir );
250
wp_spam_comment($comment_id);
251
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
253
case 'unspamcomment' :
254
wp_unspam_comment($comment_id);
255
$redir = add_query_arg( array('unspammed' => '1'), $redir );
257
case 'approvecomment' :
258
wp_set_comment_status( $comment_id, 'approve' );
259
$redir = add_query_arg( array( 'approved' => 1 ), $redir );
261
case 'unapprovecomment' :
262
wp_set_comment_status( $comment_id, 'hold' );
263
$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
267
wp_redirect( $redir );
270
case 'editedcomment' :
272
$comment_id = absint( $_POST['comment_ID'] );
273
$comment_post_id = absint( $_POST['comment_post_ID'] );
275
check_admin_referer( 'update-comment_' . $comment_id );
279
$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
282
* Filter the URI the user is redirected to after editing a comment in the admin.
286
* @param string $location The URI the user will be redirected to.
287
* @param int $comment_id The ID of the comment being edited.
289
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
290
wp_redirect( $location );
295
wp_die( __('Unknown action.') );
299
include( ABSPATH . 'wp-admin/admin-footer.php' );