Changeset 39101 for trunk/src/wp-includes/comment.php
- Timestamp:
- 11/03/2016 01:11:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r38925 r39101 1123 1123 1124 1124 /** 1125 * Compares the lengths of comment data against the maximum character limits. 1126 * 1127 * @since 4.7.0 1128 * 1129 * @param array $comment_data Array of arguments for inserting a comment. 1130 * @return WP_Error|true WP_Error when a comment field exceeds the limit, 1131 * otherwise true. 1132 */ 1133 function wp_check_comment_data_max_lengths( $comment_data ) { 1134 $max_lengths = wp_get_comment_fields_max_lengths(); 1135 1136 if ( isset( $comment_data['comment_author'] ) && mb_strlen( $comment_data['comment_author'], '8bit' ) > $max_lengths['comment_author'] ) { 1137 return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 ); 1138 } 1139 1140 if ( isset( $comment_data['comment_author_email'] ) && strlen( $comment_data['comment_author_email'] ) > $max_lengths['comment_author_email'] ) { 1141 return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 ); 1142 } 1143 1144 if ( isset( $comment_data['comment_author_url'] ) && strlen( $comment_data['comment_author_url'] ) > $max_lengths['comment_author_url'] ) { 1145 return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 ); 1146 } 1147 1148 if ( isset( $comment_data['comment_content'] ) && mb_strlen( $comment_data['comment_content'], '8bit' ) > $max_lengths['comment_content'] ) { 1149 return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 ); 1150 } 1151 1152 return true; 1153 } 1154 1155 /** 1125 1156 * Does comment contain blacklisted characters or words. 1126 1157 * … … 3033 3064 3034 3065 $comment_type = ''; 3035 $max_lengths = wp_get_comment_fields_max_lengths();3036 3066 3037 3067 if ( get_option( 'require_name_email' ) && ! $user->exists() ) { … … 3043 3073 } 3044 3074 3045 if ( isset( $comment_author ) && $max_lengths['comment_author'] < mb_strlen( $comment_author, '8bit' ) ) {3046 return new WP_Error( 'comment_author_column_length', __( '<strong>ERROR</strong>: your name is too long.' ), 200 );3047 }3048 3049 if ( isset( $comment_author_email ) && $max_lengths['comment_author_email'] < strlen( $comment_author_email ) ) {3050 return new WP_Error( 'comment_author_email_column_length', __( '<strong>ERROR</strong>: your email address is too long.' ), 200 );3051 }3052 3053 if ( isset( $comment_author_url ) && $max_lengths['comment_author_url'] < strlen( $comment_author_url ) ) {3054 return new WP_Error( 'comment_author_url_column_length', __( '<strong>ERROR</strong>: your url is too long.' ), 200 );3055 }3056 3057 3075 if ( '' == $comment_content ) { 3058 3076 return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 ); 3059 } elseif ( $max_lengths['comment_content'] < mb_strlen( $comment_content, '8bit' ) ) {3060 return new WP_Error( 'comment_content_column_length', __( '<strong>ERROR</strong>: your comment is too long.' ), 200 );3061 3077 } 3062 3078 … … 3072 3088 ); 3073 3089 3090 $check_max_lengths = wp_check_comment_data_max_lengths( $commentdata ); 3091 if ( is_wp_error( $check_max_lengths ) ) { 3092 return $check_max_lengths; 3093 } 3094 3074 3095 $comment_id = wp_new_comment( wp_slash( $commentdata ), true ); 3075 3096 if ( is_wp_error( $comment_id ) ) {
Note: See TracChangeset
for help on using the changeset viewer.