From 93d781343a0f7d73907fdb6f4b26758627df29ac Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 25 Sep 2015 05:22:53 +0000 Subject: [PATCH] Introduce 'duplicate_comment_id' filter. `wp_allow_comment()` disallows a comment if it matches a comment on the same post with the same content, author email, and parent. This new filter allows developers to circumvent or modify this logic, making the duplicate check more or less lenient, as they see fit. Fixes #9775. git-svn-id: https://develop.svn.wordpress.org/trunk@34536 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-functions.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment-functions.php b/src/wp-includes/comment-functions.php index 810eef4ba3..56e91b1f54 100644 --- a/src/wp-includes/comment-functions.php +++ b/src/wp-includes/comment-functions.php @@ -590,7 +590,22 @@ function wp_allow_comment( $commentdata ) { ") AND comment_content = %s LIMIT 1", wp_unslash( $commentdata['comment_content'] ) ); - if ( $wpdb->get_var( $dupe ) ) { + + $dupe_id = $wpdb->get_var( $dupe ); + + /** + * Filters the ID, if any, of the duplicate comment found when creating a new comment. + * + * Return an empty value from this filter to allow what WP considers a duplicate comment. + * + * @since 4.4.0 + * + * @param int $dupe_id ID of the comment identified as a duplicate. + * @param array $commentdata Data for the comment being created. + */ + $dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata ); + + if ( $dupe_id ) { /** * Fires immediately after a duplicate comment is detected. *