Changeset 36272 for trunk/src/wp-includes/comment.php
- Timestamp:
- 01/13/2016 01:24:46 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r36215 r36272 949 949 950 950 /** 951 * Calculate the maximum character length of a column from the comments table. 952 * 953 * @since 4.5.0 954 * 955 * @global wpdb $wpdb WordPress database abstraction object. 956 * 957 * @param string $column Name of a column in the comments table. 958 * @return int Maximum column character length. 959 */ 960 function wp_get_comment_column_max_length( $column ) { 961 global $wpdb; 962 963 $col_length = $wpdb->get_col_length( $wpdb->comments, $column ); 964 if ( ! is_array( $col_length ) && (int) $col_length > 0 ) { 965 $max_length = (int) $col_length; 966 } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && intval( $col_length['length'] ) > 0 ) { 967 $max_length = (int) $col_length['length']; 968 } else { 969 $max_length = 255; 970 } 971 972 if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) { 973 $max_length = $max_length - 10; 974 } 975 976 /** 977 * Filters the calculated length for a given column of the comments table. 978 * 979 * @since 4.5.0 980 * 981 * @param int $max_length Maximum column character length. 982 * @param string $column Column name. 983 */ 984 return apply_filters( 'wp_get_comment_column_max_length', $max_length, $column ); 985 } 986 987 /** 951 988 * Does comment contain blacklisted characters or words. 952 989 * … … 2779 2816 } 2780 2817 2818 if ( isset( $comment_author ) && wp_get_comment_column_max_length( 'comment_author' ) < mb_strlen( $comment_author, '8bit' ) ) { 2819 return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 ); 2820 } 2821 2822 if ( isset( $comment_author_email ) && wp_get_comment_column_max_length( 'comment_author_email' ) < strlen( $comment_author_email ) ) { 2823 return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 ); 2824 } 2825 2826 if ( isset( $comment_author_url ) && wp_get_comment_column_max_length( 'comment_author_url' ) < strlen( $comment_author_url ) ) { 2827 return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 ); 2828 } 2829 2781 2830 if ( '' == $comment_content ) { 2782 2831 return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 ); 2832 } elseif ( wp_get_comment_column_max_length( 'comment_content' ) < mb_strlen( $comment_content, '8bit' ) ) { 2833 return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 ); 2783 2834 } 2784 2835
Note: See TracChangeset
for help on using the changeset viewer.