Make WordPress Core

Changeset 44970


Ignore:
Timestamp:
03/21/2019 09:09:47 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Comments: Introduce comment_flood_message and comment_duplicate_message filters for comment flood and duplicate comment error messages.

Props odminstudios, Katyatina, mukesh27.
Fixes #44237.

File:
1 edited

Legend:

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

    r44842 r44970  
    688688                 */
    689689                do_action( 'comment_duplicate_trigger', $commentdata );
     690
     691                /**
     692                 * Filters duplicate comment error message.
     693                 *
     694                 * @since 5.2.0
     695                 *
     696                 * @param string $comment_duplicate_message Duplicate comment error message.
     697                 */
     698                $comment_duplicate_message = apply_filters( 'comment_duplicate_message', __( 'Duplicate comment detected; it looks as though you’ve already said that!' ) );
     699
    690700                if ( true === $avoid_die ) {
    691                         return new WP_Error( 'comment_duplicate', __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 );
     701                        return new WP_Error( 'comment_duplicate', $comment_duplicate_message, 409 );
    692702                } else {
    693703                        if ( wp_doing_ajax() ) {
    694                                 die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ) );
     704                                die( $comment_duplicate_message );
    695705                        }
    696706
    697                         wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 );
     707                        wp_die( $comment_duplicate_message, 409 );
    698708                }
    699709        }
     
    745755
    746756        if ( $is_flood ) {
    747                 return new WP_Error( 'comment_flood', __( 'You are posting comments too quickly. Slow down.' ), 429 );
     757                /** This filter is documented in wp-includes/comment-template.php */
     758                $comment_flood_message = apply_filters( 'comment_flood_message', __( 'You are posting comments too quickly. Slow down.' ) );
     759               
     760                return new WP_Error( 'comment_flood', $comment_flood_message, 429 );
    748761        }
    749762
     
    889902                         */
    890903                        do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
     904
    891905                        if ( true === $avoid_die ) {
    892906                                return true;
    893907                        } else {
     908                                /**
     909                                 * Filters the comment flood error message.
     910                                 *
     911                                 * @since 5.2.0
     912                                 *
     913                                 * @param string $comment_flood_message Comment flood error message.
     914                                 */
     915                                $comment_flood_message = apply_filters( 'comment_flood_message', __( 'You are posting comments too quickly. Slow down.' ) );
     916
    894917                                if ( wp_doing_ajax() ) {
    895                                         die( __( 'You are posting comments too quickly. Slow down.' ) );
     918                                        die( $comment_flood_message );
    896919                                }
    897920
    898                                 wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 );
     921                                wp_die( $comment_flood_message, 429 );
    899922                        }
    900923                }
Note: See TracChangeset for help on using the changeset viewer.