Edit File by line
/home/zeestwma/richards...
File: wp-comments-post.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Handles Comment Post to WordPress and prevents duplicate comment posting.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if ( 'POST' !== $_SERVER['REQUEST_METHOD'] ) {
[7] Fix | Delete
$protocol = $_SERVER['SERVER_PROTOCOL'];
[8] Fix | Delete
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) {
[9] Fix | Delete
$protocol = 'HTTP/1.0';
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
header( 'Allow: POST' );
[13] Fix | Delete
header( "$protocol 405 Method Not Allowed" );
[14] Fix | Delete
header( 'Content-Type: text/plain' );
[15] Fix | Delete
exit;
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
/** Sets up the WordPress Environment. */
[19] Fix | Delete
require __DIR__ . '/wp-load.php';
[20] Fix | Delete
[21] Fix | Delete
nocache_headers();
[22] Fix | Delete
[23] Fix | Delete
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
[24] Fix | Delete
if ( is_wp_error( $comment ) ) {
[25] Fix | Delete
$data = (int) $comment->get_error_data();
[26] Fix | Delete
if ( ! empty( $data ) ) {
[27] Fix | Delete
wp_die(
[28] Fix | Delete
'<p>' . $comment->get_error_message() . '</p>',
[29] Fix | Delete
__( 'Comment Submission Failure' ),
[30] Fix | Delete
array(
[31] Fix | Delete
'response' => $data,
[32] Fix | Delete
'back_link' => true,
[33] Fix | Delete
)
[34] Fix | Delete
);
[35] Fix | Delete
} else {
[36] Fix | Delete
exit;
[37] Fix | Delete
}
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
$user = wp_get_current_user();
[41] Fix | Delete
$cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Fires after comment cookies are set.
[45] Fix | Delete
*
[46] Fix | Delete
* @since 3.4.0
[47] Fix | Delete
* @since 4.9.6 The `$cookies_consent` parameter was added.
[48] Fix | Delete
*
[49] Fix | Delete
* @param WP_Comment $comment Comment object.
[50] Fix | Delete
* @param WP_User $user Comment author's user object. The user may not exist.
[51] Fix | Delete
* @param bool $cookies_consent Comment author's consent to store cookies.
[52] Fix | Delete
*/
[53] Fix | Delete
do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );
[54] Fix | Delete
[55] Fix | Delete
$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
[56] Fix | Delete
[57] Fix | Delete
// If user didn't consent to cookies, add specific query arguments to display the awaiting moderation message.
[58] Fix | Delete
if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) {
[59] Fix | Delete
$location = add_query_arg(
[60] Fix | Delete
array(
[61] Fix | Delete
'unapproved' => $comment->comment_ID,
[62] Fix | Delete
'moderation-hash' => wp_hash( $comment->comment_date_gmt ),
[63] Fix | Delete
),
[64] Fix | Delete
$location
[65] Fix | Delete
);
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Filters the location URI to send the commenter after posting.
[70] Fix | Delete
*
[71] Fix | Delete
* @since 2.0.5
[72] Fix | Delete
*
[73] Fix | Delete
* @param string $location The 'redirect_to' URI sent via $_POST.
[74] Fix | Delete
* @param WP_Comment $comment Comment object.
[75] Fix | Delete
*/
[76] Fix | Delete
$location = apply_filters( 'comment_post_redirect', $location, $comment );
[77] Fix | Delete
[78] Fix | Delete
wp_safe_redirect( $location );
[79] Fix | Delete
exit;
[80] Fix | Delete
[81] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function