plugin updates
This commit is contained in:
@@ -479,7 +479,8 @@ function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
|
||||
* @return mixed An array of values if `$single` is false.
|
||||
* The value of meta data field if `$single` is true.
|
||||
* False for an invalid `$comment_id` (non-numeric, zero, or negative value).
|
||||
* An empty string if a valid but non-existing comment ID is passed.
|
||||
* An empty array if a valid but non-existing comment ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing comment ID is passed and `$single` is true.
|
||||
*/
|
||||
function get_comment_meta( $comment_id, $key = '', $single = false ) {
|
||||
return get_metadata( 'comment', $comment_id, $key, $single );
|
||||
@@ -772,59 +773,7 @@ function wp_allow_comment( $commentdata, $wp_error = false ) {
|
||||
return new WP_Error( 'comment_flood', $comment_flood_message, 429 );
|
||||
}
|
||||
|
||||
if ( ! empty( $commentdata['user_id'] ) ) {
|
||||
$user = get_userdata( $commentdata['user_id'] );
|
||||
$post_author = $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1",
|
||||
$commentdata['comment_post_ID']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
|
||||
// The author and the admins get respect.
|
||||
$approved = 1;
|
||||
} else {
|
||||
// Everyone else's comments will be checked.
|
||||
if ( check_comment(
|
||||
$commentdata['comment_author'],
|
||||
$commentdata['comment_author_email'],
|
||||
$commentdata['comment_author_url'],
|
||||
$commentdata['comment_content'],
|
||||
$commentdata['comment_author_IP'],
|
||||
$commentdata['comment_agent'],
|
||||
$commentdata['comment_type']
|
||||
) ) {
|
||||
$approved = 1;
|
||||
} else {
|
||||
$approved = 0;
|
||||
}
|
||||
|
||||
if ( wp_check_comment_disallowed_list(
|
||||
$commentdata['comment_author'],
|
||||
$commentdata['comment_author_email'],
|
||||
$commentdata['comment_author_url'],
|
||||
$commentdata['comment_content'],
|
||||
$commentdata['comment_author_IP'],
|
||||
$commentdata['comment_agent']
|
||||
) ) {
|
||||
$approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a comment's approval status before it is set.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 4.9.0 Returning a WP_Error value from the filter will short-circuit comment insertion
|
||||
* and allow skipping further processing.
|
||||
*
|
||||
* @param int|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam', 'trash',
|
||||
* or WP_Error.
|
||||
* @param array $commentdata Comment data.
|
||||
*/
|
||||
return apply_filters( 'pre_comment_approved', $approved, $commentdata );
|
||||
return wp_check_comment_data( $commentdata );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1291,6 +1240,75 @@ function wp_check_comment_data_max_lengths( $comment_data ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether comment data passes internal checks or has disallowed content.
|
||||
*
|
||||
* @since 6.7.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param array $comment_data Array of arguments for inserting a comment.
|
||||
* @return int|string|WP_Error The approval status on success (0|1|'spam'|'trash'),
|
||||
* WP_Error otherwise.
|
||||
*/
|
||||
function wp_check_comment_data( $comment_data ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! empty( $comment_data['user_id'] ) ) {
|
||||
$user = get_userdata( $comment_data['user_id'] );
|
||||
$post_author = $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1",
|
||||
$comment_data['comment_post_ID']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $user ) && ( $comment_data['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
|
||||
// The author and the admins get respect.
|
||||
$approved = 1;
|
||||
} else {
|
||||
// Everyone else's comments will be checked.
|
||||
if ( check_comment(
|
||||
$comment_data['comment_author'],
|
||||
$comment_data['comment_author_email'],
|
||||
$comment_data['comment_author_url'],
|
||||
$comment_data['comment_content'],
|
||||
$comment_data['comment_author_IP'],
|
||||
$comment_data['comment_agent'],
|
||||
$comment_data['comment_type']
|
||||
) ) {
|
||||
$approved = 1;
|
||||
} else {
|
||||
$approved = 0;
|
||||
}
|
||||
|
||||
if ( wp_check_comment_disallowed_list(
|
||||
$comment_data['comment_author'],
|
||||
$comment_data['comment_author_email'],
|
||||
$comment_data['comment_author_url'],
|
||||
$comment_data['comment_content'],
|
||||
$comment_data['comment_author_IP'],
|
||||
$comment_data['comment_agent']
|
||||
) ) {
|
||||
$approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a comment's approval status before it is set.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 4.9.0 Returning a WP_Error value from the filter will short-circuit comment insertion
|
||||
* and allow skipping further processing.
|
||||
*
|
||||
* @param int|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam', 'trash',
|
||||
* or WP_Error.
|
||||
* @param array $commentdata Comment data.
|
||||
*/
|
||||
return apply_filters( 'pre_comment_approved', $approved, $comment_data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a comment contains disallowed characters or words.
|
||||
*
|
||||
@@ -2276,9 +2294,18 @@ function wp_new_comment( $commentdata, $wp_error = false ) {
|
||||
$commentdata['comment_type'] = 'comment';
|
||||
}
|
||||
|
||||
$commentdata['comment_approved'] = wp_allow_comment( $commentdata, $wp_error );
|
||||
|
||||
if ( is_wp_error( $commentdata['comment_approved'] ) ) {
|
||||
return $commentdata['comment_approved'];
|
||||
}
|
||||
|
||||
$commentdata = wp_filter_comment( $commentdata );
|
||||
|
||||
$commentdata['comment_approved'] = wp_allow_comment( $commentdata, $wp_error );
|
||||
if ( ! in_array( $commentdata['comment_approved'], array( 'trash', 'spam' ), true ) ) {
|
||||
// Validate the comment again after filters are applied to comment data.
|
||||
$commentdata['comment_approved'] = wp_check_comment_data( $commentdata );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $commentdata['comment_approved'] ) ) {
|
||||
return $commentdata['comment_approved'];
|
||||
@@ -3115,6 +3142,7 @@ function pingback( $content, $post ) {
|
||||
|
||||
if ( $pingback_server_url ) {
|
||||
if ( function_exists( 'set_time_limit' ) ) {
|
||||
// Allows an additional 60 seconds for each pingback to complete.
|
||||
set_time_limit( 60 );
|
||||
}
|
||||
|
||||
@@ -3764,7 +3792,7 @@ function wp_comments_personal_data_exporter( $email_address, $page = 1 ) {
|
||||
case 'comment_link':
|
||||
$value = get_comment_link( $comment->comment_ID );
|
||||
$value = sprintf(
|
||||
'<a href="%s" target="_blank" rel="noopener">%s</a>',
|
||||
'<a href="%s" target="_blank">%s</a>',
|
||||
esc_url( $value ),
|
||||
esc_html( $value )
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user