wp_check_comment_data_max_lengths

Compares the lengths of comment data against the maximum character limits.

Description

(WP_Error|true) wp_check_comment_data_max_lengths( (array) $comment_data ); 

Returns (WP_Error|true)

WP_Error when a comment field exceeds the limit, otherwise true.

Parameters (1)

0. $comment_data (array)
Array of arguments for inserting a comment.

Usage

  1. if ( !function_exists( 'wp_check_comment_data_max_lengths' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // Array of arguments for inserting a comment. 
  5. $comment_data = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_check_comment_data_max_lengths($comment_data); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function wp_check_comment_data_max_lengths( $comment_data ) { 
  2.  
  3. if ( isset( $comment_data['comment_author'] ) && mb_strlen( $comment_data['comment_author'], '8bit' ) > $max_lengths['comment_author'] ) { 
  4. return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 ); 
  5.  
  6. if ( isset( $comment_data['comment_author_email'] ) && strlen( $comment_data['comment_author_email'] ) > $max_lengths['comment_author_email'] ) { 
  7. return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 ); 
  8.  
  9. if ( isset( $comment_data['comment_author_url'] ) && strlen( $comment_data['comment_author_url'] ) > $max_lengths['comment_author_url'] ) { 
  10. return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 ); 
  11.  
  12. if ( isset( $comment_data['comment_content'] ) && mb_strlen( $comment_data['comment_content'], '8bit' ) > $max_lengths['comment_content'] ) { 
  13. return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 ); 
  14.  
  15. return true;