Make WordPress Core

Ticket #44237: 44237-duplicate.diff

File 44237-duplicate.diff, 1.3 KB (added by Katyatina, 6 years ago)

Duplicate comment message filter

  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index 4c78eb9..7f7b12b 100644
    function wp_allow_comment( $commentdata, $avoid_die = false ) { 
    698698                 * @param array $commentdata Comment data.
    699699                 */
    700700                do_action( 'comment_duplicate_trigger', $commentdata );
     701
     702                $duplicate_message = __( 'Duplicate comment detected; it looks as though you’ve already said that!' );
     703
     704                /**
     705                 * Filters duplicate comment message.
     706                 *
     707                 * @since 5.0
     708                 *
     709                 * @param string $duplicate_text Duplicate text message.
     710                 */
     711                $duplicate_message = apply_filters( 'comment_duplicate_message', $duplicate_message );
     712
    701713                if ( true === $avoid_die ) {
    702                         return new WP_Error( 'comment_duplicate', __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 );
     714                        return new WP_Error( 'comment_duplicate', $duplicate_message, 409 );
    703715                } else {
    704716                        if ( wp_doing_ajax() ) {
    705                                 die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ) );
     717                                die( $duplicate_message );
    706718                        }
    707719
    708                         wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 );
     720                        wp_die( $duplicate_message, 409 );
    709721                }
    710722        }
    711723