Make WordPress Core

Changeset 34536


Ignore:
Timestamp:
09/25/2015 05:22:53 AM (9 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-functions.php

    r34535 r34536  
    591591        wp_unslash( $commentdata['comment_content'] )
    592592    );
    593     if ( $wpdb->get_var( $dupe ) ) {
     593
     594    $dupe_id = $wpdb->get_var( $dupe );
     595
     596    /**
     597     * Filters the ID, if any, of the duplicate comment found when creating a new comment.
     598     *
     599     * Return an empty value from this filter to allow what WP considers a duplicate comment.
     600     *
     601     * @since 4.4.0
     602     *
     603     * @param int   $dupe_id     ID of the comment identified as a duplicate.
     604     * @param array $commentdata Data for the comment being created.
     605     */
     606    $dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata );
     607
     608    if ( $dupe_id ) {
    594609        /**
    595610         * Fires immediately after a duplicate comment is detected.
Note: See TracChangeset for help on using the changeset viewer.