786 | | if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { |
787 | | // The author and the admins get respect. |
788 | | $approved = 1; |
789 | | } else { |
790 | | // Everyone else's comments will be checked. |
791 | | if ( check_comment( |
792 | | $commentdata['comment_author'], |
793 | | $commentdata['comment_author_email'], |
794 | | $commentdata['comment_author_url'], |
795 | | $commentdata['comment_content'], |
796 | | $commentdata['comment_author_IP'], |
797 | | $commentdata['comment_agent'], |
798 | | $commentdata['comment_type'] |
799 | | ) ) { |
800 | | $approved = 1; |
801 | | } else { |
802 | | $approved = 0; |
803 | | } |
804 | | |
805 | | if ( wp_check_comment_disallowed_list( |
806 | | $commentdata['comment_author'], |
807 | | $commentdata['comment_author_email'], |
808 | | $commentdata['comment_author_url'], |
809 | | $commentdata['comment_content'], |
810 | | $commentdata['comment_author_IP'], |
811 | | $commentdata['comment_agent'] |
812 | | ) ) { |
813 | | $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam'; |
814 | | } |
815 | | } |
816 | | |
| 1257 | * Checks whether comment data passes internal checks or has disallowed content. |
| 1258 | * |
| 1259 | * @since 6.7.0 |
| 1260 | * |
| 1261 | * @global wpdb $wpdb WordPress database abstraction object. |
| 1262 | * |
| 1263 | * @param array $comment_data Array of arguments for inserting a comment. |
| 1264 | * @return int|string The approval status (0|1|'spam'|'trash'). |
| 1265 | */ |
| 1266 | function wp_check_comment_data( $comment_data ) { |
| 1267 | global $wpdb; |
| 1268 | |
| 1269 | if ( ! empty( $comment_data['user_id'] ) ) { |
| 1270 | $user = get_userdata( $comment_data['user_id'] ); |
| 1271 | $post_author = $wpdb->get_var( |
| 1272 | $wpdb->prepare( |
| 1273 | "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", |
| 1274 | $comment_data['comment_post_ID'] |
| 1275 | ) |
| 1276 | ); |
| 1277 | } |
| 1278 | |
| 1279 | if ( isset( $user ) && ( $comment_data['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { |
| 1280 | // The author and the admins get respect. |
| 1281 | $approved = 1; |
| 1282 | } else { |
| 1283 | // Everyone else's comments will be checked. |
| 1284 | if ( check_comment( |
| 1285 | $comment_data['comment_author'], |
| 1286 | $comment_data['comment_author_email'], |
| 1287 | $comment_data['comment_author_url'], |
| 1288 | $comment_data['comment_content'], |
| 1289 | $comment_data['comment_author_IP'], |
| 1290 | $comment_data['comment_agent'], |
| 1291 | $comment_data['comment_type'] |
| 1292 | ) ) { |
| 1293 | $approved = 1; |
| 1294 | } else { |
| 1295 | $approved = 0; |
| 1296 | } |
| 1297 | |
| 1298 | if ( wp_check_comment_disallowed_list( |
| 1299 | $comment_data['comment_author'], |
| 1300 | $comment_data['comment_author_email'], |
| 1301 | $comment_data['comment_author_url'], |
| 1302 | $comment_data['comment_content'], |
| 1303 | $comment_data['comment_author_IP'], |
| 1304 | $comment_data['comment_agent'] |
| 1305 | ) ) { |
| 1306 | $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam'; |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | return $approved; |
| 1311 | } |
| 1312 | |
| 1313 | /** |