Make WordPress Core

Ticket #16979: 0001-Add-filter-require_valid_content-to-bypass-WP-Error-.patch

File 0001-Add-filter-require_valid_content-to-bypass-WP-Error-.patch, 1.0 KB (added by jpurdy647, 8 years ago)

Patch to allow filter to bypass wP Error caused by an empty comment

  • wp-includes/comment.php

    From 6698543be34e794394837a5222f0873346af5c1d Mon Sep 17 00:00:00 2001
    From: Joshua Purdy <jpurdy647@gmail.com>
    Date: Tue, 30 May 2017 17:42:03 -0400
    Subject: [PATCH] Add filter `require_valid_content` to bypass WP Error when
     submitted comment is empty
    
    ---
     wp-includes/comment.php | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/wp-includes/comment.php b/wp-includes/comment.php
    index ba60070fd..e31c396b7 100644
    a b function wp_handle_comment_submission( $comment_data ) { 
    30693069        }
    30703070
    30713071        if ( '' == $comment_content ) {
    3072                 return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
     3072                $require_valid_comment = apply_filters('require_valid_comment', true, $commentdata );
     3073                if ($require_valid_comment){
     3074                        return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 );
     3075                }
    30733076        }
    30743077
    30753078        $commentdata = compact(