WordPress.org

WordPress build repository browser

Changeset 42490


Ignore:
Timestamp:
02/07/18 20:09:30 (2 weeks ago)
Author:
boonebgorges
Message:

Comments: Introduce 'allow_empty_comment' filter.

This filter allows plugin authors to allow empty comments on a selective
basis during comment submission.

Props jpurdy647.
Fixes #16979.
Built from https://develop.svn.wordpress.org/trunk@42661

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r42172 r42490  
    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', 
     
    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 ) ) { 
  • trunk/wp-includes/version.php

    r42489 r42490  
    55 * @global string $wp_version 
    66 */ 
    7 $wp_version = '5.0-alpha-42660'; 
     7$wp_version = '5.0-alpha-42661'; 
    88 
    99/** 
Note: See TracChangeset for help on using the changeset viewer.