Edit File by line
/home/zeestwma/redstone.../wp-admin...
File: comment.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Comment Management Screen
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/** Load WordPress Bootstrap */
[8] Fix | Delete
require_once __DIR__ . '/admin.php';
[9] Fix | Delete
[10] Fix | Delete
$parent_file = 'edit-comments.php';
[11] Fix | Delete
$submenu_file = 'edit-comments.php';
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* @global string $action
[15] Fix | Delete
*/
[16] Fix | Delete
global $action;
[17] Fix | Delete
[18] Fix | Delete
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
[19] Fix | Delete
[20] Fix | Delete
if ( isset( $_POST['deletecomment'] ) ) {
[21] Fix | Delete
$action = 'deletecomment';
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
if ( 'cdc' === $action ) {
[25] Fix | Delete
$action = 'delete';
[26] Fix | Delete
} elseif ( 'mac' === $action ) {
[27] Fix | Delete
$action = 'approve';
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
if ( isset( $_GET['dt'] ) ) {
[31] Fix | Delete
if ( 'spam' === $_GET['dt'] ) {
[32] Fix | Delete
$action = 'spam';
[33] Fix | Delete
} elseif ( 'trash' === $_GET['dt'] ) {
[34] Fix | Delete
$action = 'trash';
[35] Fix | Delete
}
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
if ( isset( $_REQUEST['c'] ) ) {
[39] Fix | Delete
$comment_id = absint( $_REQUEST['c'] );
[40] Fix | Delete
$comment = get_comment( $comment_id );
[41] Fix | Delete
[42] Fix | Delete
// Prevent actions on a comment associated with a trashed post.
[43] Fix | Delete
if ( $comment && 'trash' === get_post_status( $comment->comment_post_ID ) ) {
[44] Fix | Delete
wp_die(
[45] Fix | Delete
__( 'You cannot edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' )
[46] Fix | Delete
);
[47] Fix | Delete
}
[48] Fix | Delete
} else {
[49] Fix | Delete
$comment = null;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
switch ( $action ) {
[53] Fix | Delete
[54] Fix | Delete
case 'editcomment':
[55] Fix | Delete
// Used in the HTML title tag.
[56] Fix | Delete
$title = __( 'Edit Comment' );
[57] Fix | Delete
[58] Fix | Delete
get_current_screen()->add_help_tab(
[59] Fix | Delete
array(
[60] Fix | Delete
'id' => 'overview',
[61] Fix | Delete
'title' => __( 'Overview' ),
[62] Fix | Delete
'content' =>
[63] Fix | Delete
'<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>' .
[64] Fix | Delete
'<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>',
[65] Fix | Delete
)
[66] Fix | Delete
);
[67] Fix | Delete
[68] Fix | Delete
get_current_screen()->set_help_sidebar(
[69] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[70] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/documentation/article/comments-screen/">Documentation on Comments</a>' ) . '</p>' .
[71] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
[72] Fix | Delete
);
[73] Fix | Delete
[74] Fix | Delete
wp_enqueue_script( 'comment' );
[75] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[76] Fix | Delete
[77] Fix | Delete
if ( ! $comment ) {
[78] Fix | Delete
comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
[82] Fix | Delete
comment_footer_die( __( 'Sorry, you are not allowed to edit this comment.' ) );
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if ( 'trash' === $comment->comment_approved ) {
[86] Fix | Delete
comment_footer_die( __( 'This comment is in the Trash. Please move it out of the Trash if you want to edit it.' ) );
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$comment = get_comment_to_edit( $comment_id );
[90] Fix | Delete
[91] Fix | Delete
require ABSPATH . 'wp-admin/edit-form-comment.php';
[92] Fix | Delete
[93] Fix | Delete
break;
[94] Fix | Delete
[95] Fix | Delete
case 'delete':
[96] Fix | Delete
case 'approve':
[97] Fix | Delete
case 'trash':
[98] Fix | Delete
case 'spam':
[99] Fix | Delete
// Used in the HTML title tag.
[100] Fix | Delete
$title = __( 'Moderate Comment' );
[101] Fix | Delete
[102] Fix | Delete
if ( ! $comment ) {
[103] Fix | Delete
wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
[104] Fix | Delete
die();
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
[108] Fix | Delete
wp_redirect( admin_url( 'edit-comments.php?error=2' ) );
[109] Fix | Delete
die();
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
// No need to re-approve/re-trash/re-spam a comment.
[113] Fix | Delete
if ( str_replace( '1', 'approve', $comment->comment_approved ) === $action ) {
[114] Fix | Delete
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
[115] Fix | Delete
die();
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[119] Fix | Delete
[120] Fix | Delete
$formaction = $action . 'comment';
[121] Fix | Delete
$nonce_action = ( 'approve' === $action ) ? 'approve-comment_' : 'delete-comment_';
[122] Fix | Delete
$nonce_action .= $comment_id;
[123] Fix | Delete
[124] Fix | Delete
?>
[125] Fix | Delete
<div class="wrap">
[126] Fix | Delete
[127] Fix | Delete
<h1><?php echo esc_html( $title ); ?></h1>
[128] Fix | Delete
[129] Fix | Delete
<?php
[130] Fix | Delete
switch ( $action ) {
[131] Fix | Delete
case 'spam':
[132] Fix | Delete
$caution_msg = __( 'You are about to mark the following comment as spam:' );
[133] Fix | Delete
$button = _x( 'Mark as spam', 'comment' );
[134] Fix | Delete
break;
[135] Fix | Delete
case 'trash':
[136] Fix | Delete
$caution_msg = __( 'You are about to move the following comment to the Trash:' );
[137] Fix | Delete
$button = __( 'Move to Trash' );
[138] Fix | Delete
break;
[139] Fix | Delete
case 'delete':
[140] Fix | Delete
$caution_msg = __( 'You are about to delete the following comment:' );
[141] Fix | Delete
$button = __( 'Permanently delete comment' );
[142] Fix | Delete
break;
[143] Fix | Delete
default:
[144] Fix | Delete
$caution_msg = __( 'You are about to approve the following comment:' );
[145] Fix | Delete
$button = __( 'Approve comment' );
[146] Fix | Delete
break;
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
if ( '0' !== $comment->comment_approved ) { // If not unapproved.
[150] Fix | Delete
$message = '';
[151] Fix | Delete
switch ( $comment->comment_approved ) {
[152] Fix | Delete
case '1':
[153] Fix | Delete
$message = __( 'This comment is currently approved.' );
[154] Fix | Delete
break;
[155] Fix | Delete
case 'spam':
[156] Fix | Delete
$message = __( 'This comment is currently marked as spam.' );
[157] Fix | Delete
break;
[158] Fix | Delete
case 'trash':
[159] Fix | Delete
$message = __( 'This comment is currently in the Trash.' );
[160] Fix | Delete
break;
[161] Fix | Delete
}
[162] Fix | Delete
if ( $message ) {
[163] Fix | Delete
wp_admin_notice(
[164] Fix | Delete
$message,
[165] Fix | Delete
array(
[166] Fix | Delete
'type' => 'info',
[167] Fix | Delete
'id' => 'message',
[168] Fix | Delete
)
[169] Fix | Delete
);
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
wp_admin_notice(
[173] Fix | Delete
'<strong>' . __( 'Caution:' ) . '</strong> ' . $caution_msg,
[174] Fix | Delete
array(
[175] Fix | Delete
'type' => 'warning',
[176] Fix | Delete
'id' => 'message',
[177] Fix | Delete
)
[178] Fix | Delete
);
[179] Fix | Delete
?>
[180] Fix | Delete
[181] Fix | Delete
<table class="form-table comment-ays">
[182] Fix | Delete
<tr>
[183] Fix | Delete
<th scope="row"><?php _e( 'Author' ); ?></th>
[184] Fix | Delete
<td><?php comment_author( $comment ); ?></td>
[185] Fix | Delete
</tr>
[186] Fix | Delete
<?php if ( get_comment_author_email( $comment ) ) { ?>
[187] Fix | Delete
<tr>
[188] Fix | Delete
<th scope="row"><?php _e( 'Email' ); ?></th>
[189] Fix | Delete
<td><?php comment_author_email( $comment ); ?></td>
[190] Fix | Delete
</tr>
[191] Fix | Delete
<?php } ?>
[192] Fix | Delete
<?php if ( get_comment_author_url( $comment ) ) { ?>
[193] Fix | Delete
<tr>
[194] Fix | Delete
<th scope="row"><?php _e( 'URL' ); ?></th>
[195] Fix | Delete
<td><a href="<?php comment_author_url( $comment ); ?>"><?php comment_author_url( $comment ); ?></a></td>
[196] Fix | Delete
</tr>
[197] Fix | Delete
<?php } ?>
[198] Fix | Delete
<tr>
[199] Fix | Delete
<th scope="row"><?php /* translators: Column name or table row header. */ _e( 'In response to' ); ?></th>
[200] Fix | Delete
<td>
[201] Fix | Delete
<?php
[202] Fix | Delete
$post_id = $comment->comment_post_ID;
[203] Fix | Delete
if ( current_user_can( 'edit_post', $post_id ) ) {
[204] Fix | Delete
$post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
[205] Fix | Delete
$post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
[206] Fix | Delete
} else {
[207] Fix | Delete
$post_link = esc_html( get_the_title( $post_id ) );
[208] Fix | Delete
}
[209] Fix | Delete
echo $post_link;
[210] Fix | Delete
[211] Fix | Delete
if ( $comment->comment_parent ) {
[212] Fix | Delete
$parent = get_comment( $comment->comment_parent );
[213] Fix | Delete
$parent_link = esc_url( get_comment_link( $parent ) );
[214] Fix | Delete
$name = get_comment_author( $parent );
[215] Fix | Delete
printf(
[216] Fix | Delete
/* translators: %s: Comment link. */
[217] Fix | Delete
' | ' . __( 'In reply to %s.' ),
[218] Fix | Delete
'<a href="' . $parent_link . '">' . $name . '</a>'
[219] Fix | Delete
);
[220] Fix | Delete
}
[221] Fix | Delete
?>
[222] Fix | Delete
</td>
[223] Fix | Delete
</tr>
[224] Fix | Delete
<tr>
[225] Fix | Delete
<th scope="row"><?php _e( 'Submitted on' ); ?></th>
[226] Fix | Delete
<td>
[227] Fix | Delete
<?php
[228] Fix | Delete
$submitted = sprintf(
[229] Fix | Delete
/* translators: 1: Comment date, 2: Comment time. */
[230] Fix | Delete
__( '%1$s at %2$s' ),
[231] Fix | Delete
/* translators: Comment date format. See https://www.php.net/manual/datetime.format.php */
[232] Fix | Delete
get_comment_date( __( 'Y/m/d' ), $comment ),
[233] Fix | Delete
/* translators: Comment time format. See https://www.php.net/manual/datetime.format.php */
[234] Fix | Delete
get_comment_date( __( 'g:i a' ), $comment )
[235] Fix | Delete
);
[236] Fix | Delete
if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
[237] Fix | Delete
echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
[238] Fix | Delete
} else {
[239] Fix | Delete
echo $submitted;
[240] Fix | Delete
}
[241] Fix | Delete
?>
[242] Fix | Delete
</td>
[243] Fix | Delete
</tr>
[244] Fix | Delete
<tr>
[245] Fix | Delete
<th scope="row"><?php /* translators: Field name in comment form. */ _ex( 'Comment', 'noun' ); ?></th>
[246] Fix | Delete
<td class="comment-content">
[247] Fix | Delete
<?php comment_text( $comment ); ?>
[248] Fix | Delete
<p class="edit-comment">
[249] Fix | Delete
<a href="<?php echo esc_url( admin_url( "comment.php?action=editcomment&c={$comment->comment_ID}" ) ); ?>"><?php esc_html_e( 'Edit' ); ?></a>
[250] Fix | Delete
</p>
[251] Fix | Delete
</td>
[252] Fix | Delete
</tr>
[253] Fix | Delete
</table>
[254] Fix | Delete
[255] Fix | Delete
<form action="comment.php" method="get" class="comment-ays-submit">
[256] Fix | Delete
<p>
[257] Fix | Delete
<?php submit_button( $button, 'primary', 'submit', false ); ?>
[258] Fix | Delete
<a href="<?php echo esc_url( admin_url( 'edit-comments.php' ) ); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a>
[259] Fix | Delete
</p>
[260] Fix | Delete
[261] Fix | Delete
<?php wp_nonce_field( $nonce_action ); ?>
[262] Fix | Delete
<input type="hidden" name="action" value="<?php echo esc_attr( $formaction ); ?>" />
[263] Fix | Delete
<input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
[264] Fix | Delete
<input type="hidden" name="noredir" value="1" />
[265] Fix | Delete
</form>
[266] Fix | Delete
[267] Fix | Delete
</div>
[268] Fix | Delete
<?php
[269] Fix | Delete
break;
[270] Fix | Delete
[271] Fix | Delete
case 'deletecomment':
[272] Fix | Delete
case 'trashcomment':
[273] Fix | Delete
case 'untrashcomment':
[274] Fix | Delete
case 'spamcomment':
[275] Fix | Delete
case 'unspamcomment':
[276] Fix | Delete
case 'approvecomment':
[277] Fix | Delete
case 'unapprovecomment':
[278] Fix | Delete
$comment_id = absint( $_REQUEST['c'] );
[279] Fix | Delete
[280] Fix | Delete
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
[281] Fix | Delete
check_admin_referer( 'approve-comment_' . $comment_id );
[282] Fix | Delete
} else {
[283] Fix | Delete
check_admin_referer( 'delete-comment_' . $comment_id );
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
$noredir = isset( $_REQUEST['noredir'] );
[287] Fix | Delete
[288] Fix | Delete
$comment = get_comment( $comment_id );
[289] Fix | Delete
if ( ! $comment ) {
[290] Fix | Delete
comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'edit-comments.php' ) );
[291] Fix | Delete
}
[292] Fix | Delete
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
[293] Fix | Delete
comment_footer_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
if ( wp_get_referer() && ! $noredir && ! str_contains( wp_get_referer(), 'comment.php' ) ) {
[297] Fix | Delete
$redir = wp_get_referer();
[298] Fix | Delete
} elseif ( wp_get_original_referer() && ! $noredir ) {
[299] Fix | Delete
$redir = wp_get_original_referer();
[300] Fix | Delete
} elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
[301] Fix | Delete
$redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
[302] Fix | Delete
} else {
[303] Fix | Delete
$redir = admin_url( 'edit-comments.php' );
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
$redir = remove_query_arg( array( 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved' ), $redir );
[307] Fix | Delete
[308] Fix | Delete
switch ( $action ) {
[309] Fix | Delete
case 'deletecomment':
[310] Fix | Delete
wp_delete_comment( $comment );
[311] Fix | Delete
$redir = add_query_arg( array( 'deleted' => '1' ), $redir );
[312] Fix | Delete
break;
[313] Fix | Delete
case 'trashcomment':
[314] Fix | Delete
wp_trash_comment( $comment );
[315] Fix | Delete
$redir = add_query_arg(
[316] Fix | Delete
array(
[317] Fix | Delete
'trashed' => '1',
[318] Fix | Delete
'ids' => $comment_id,
[319] Fix | Delete
),
[320] Fix | Delete
$redir
[321] Fix | Delete
);
[322] Fix | Delete
break;
[323] Fix | Delete
case 'untrashcomment':
[324] Fix | Delete
wp_untrash_comment( $comment );
[325] Fix | Delete
$redir = add_query_arg( array( 'untrashed' => '1' ), $redir );
[326] Fix | Delete
break;
[327] Fix | Delete
case 'spamcomment':
[328] Fix | Delete
wp_spam_comment( $comment );
[329] Fix | Delete
$redir = add_query_arg(
[330] Fix | Delete
array(
[331] Fix | Delete
'spammed' => '1',
[332] Fix | Delete
'ids' => $comment_id,
[333] Fix | Delete
),
[334] Fix | Delete
$redir
[335] Fix | Delete
);
[336] Fix | Delete
break;
[337] Fix | Delete
case 'unspamcomment':
[338] Fix | Delete
wp_unspam_comment( $comment );
[339] Fix | Delete
$redir = add_query_arg( array( 'unspammed' => '1' ), $redir );
[340] Fix | Delete
break;
[341] Fix | Delete
case 'approvecomment':
[342] Fix | Delete
wp_set_comment_status( $comment, 'approve' );
[343] Fix | Delete
$redir = add_query_arg( array( 'approved' => 1 ), $redir );
[344] Fix | Delete
break;
[345] Fix | Delete
case 'unapprovecomment':
[346] Fix | Delete
wp_set_comment_status( $comment, 'hold' );
[347] Fix | Delete
$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
[348] Fix | Delete
break;
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
wp_redirect( $redir );
[352] Fix | Delete
die;
[353] Fix | Delete
[354] Fix | Delete
case 'editedcomment':
[355] Fix | Delete
$comment_id = absint( $_POST['comment_ID'] );
[356] Fix | Delete
$comment_post_id = absint( $_POST['comment_post_ID'] );
[357] Fix | Delete
[358] Fix | Delete
check_admin_referer( 'update-comment_' . $comment_id );
[359] Fix | Delete
[360] Fix | Delete
$updated = edit_comment();
[361] Fix | Delete
if ( is_wp_error( $updated ) ) {
[362] Fix | Delete
wp_die( $updated->get_error_message() );
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
[366] Fix | Delete
[367] Fix | Delete
/**
[368] Fix | Delete
* Filters the URI the user is redirected to after editing a comment in the admin.
[369] Fix | Delete
*
[370] Fix | Delete
* @since 2.1.0
[371] Fix | Delete
*
[372] Fix | Delete
* @param string $location The URI the user will be redirected to.
[373] Fix | Delete
* @param int $comment_id The ID of the comment being edited.
[374] Fix | Delete
*/
[375] Fix | Delete
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
[376] Fix | Delete
[377] Fix | Delete
wp_redirect( $location );
[378] Fix | Delete
exit;
[379] Fix | Delete
[380] Fix | Delete
default:
[381] Fix | Delete
wp_die( __( 'Unknown action.' ) );
[382] Fix | Delete
[383] Fix | Delete
} // End switch.
[384] Fix | Delete
[385] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[386] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function