diff --git a/wp-includes/comment.php b/wp-includes/comment.php index c78914ee3..d617ea41c 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -187,9 +187,10 @@ function wp_allow_comment($commentdata) { if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) { $time_lastcomment = mysql2date('U', $lasttime); $time_newcomment = mysql2date('U', $comment_date_gmt); - if ( ($time_newcomment - $time_lastcomment) < 15 ) { + $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); + if ( $flood_die ) { do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); - wp_die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); + wp_die( __('You are posting comments too quickly. Slow down.') ); } } @@ -355,6 +356,14 @@ function wp_filter_comment($commentdata) { return $commentdata; } +function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { + if ( $block ) // a plugin has already blocked... we'll let that decision stand + return $block; + if ( ($time_newcomment - $time_lastcomment) < 15 ) + return true; + return false; +} + function wp_new_comment( $commentdata ) { $commentdata = apply_filters('preprocess_comment', $commentdata); diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 75f24eda0..ad60242ed 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -38,6 +38,8 @@ add_filter('comment_author', 'wp_specialchars'); add_filter('comment_email', 'antispambot'); +add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); + add_filter('comment_url', 'clean_url'); add_filter('comment_text', 'convert_chars');