Make WordPress Core

Ticket #16979: 16979.2.diff

File 16979.2.diff, 1.2 KB (added by boonebgorges, 7 years ago)
  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index c134aadcd0..e2c5ccbd3c 100644
    function wp_handle_comment_submission( $comment_data ) { 
    32223222                }
    32233223        }
    32243224
    3225         if ( '' == $comment_content ) {
    3226                 return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
    3227         }
    3228 
    32293225        $commentdata = compact(
    32303226                'comment_post_ID',
    32313227                'comment_author',
    function wp_handle_comment_submission( $comment_data ) { 
    32373233                'user_ID'
    32383234        );
    32393235
     3236        /**
     3237         * Filters whether an empty comment should be allowed.
     3238         *
     3239         * @since 5.0.0
     3240         *
     3241         * @param bool  $allow_empty_comment Default false.
     3242         * @param array $commentdata         Array of comment data to be sent to wp_insert_comment().
     3243         */
     3244        $allow_empty_comment = apply_filters( 'allow_empty_comment', false, $commentdata );
     3245        if ( '' === $comment_content && ! $allow_empty_comment ) {
     3246                return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
     3247        }
     3248
    32403249        $check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );
    32413250        if ( is_wp_error( $check_max_lengths ) ) {
    32423251                return $check_max_lengths;