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.
Built from https://develop.svn.wordpress.org/trunk@34536


git-svn-id: http://core.svn.wordpress.org/trunk@34500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-09-25 05:23:28 +00:00
parent e2c57a9451
commit cb586896c6
2 changed files with 17 additions and 2 deletions

View File

@ -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.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34535';
$wp_version = '4.4-alpha-34536';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.