Changeset 4265

Show
Ignore:
Timestamp:
10/02/06 18:19:44 (2 years ago)
Author:
ryan
Message:

Pluggable comment throttling from Mark Jaquith. fixes #3175

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/comment.php

    r4196 r4265  
    188188        $time_lastcomment = mysql2date('U', $lasttime); 
    189189        $time_newcomment  = mysql2date('U', $comment_date_gmt); 
    190         if ( ($time_newcomment - $time_lastcomment) < 15 ) { 
     190        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); 
     191        if ( $flood_die ) { 
    191192            do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); 
    192             wp_die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') ); 
     193            wp_die( __('You are posting comments too quickly.  Slow down.') ); 
    193194        } 
    194195    } 
     
    354355    $commentdata['filtered'] = true; 
    355356    return $commentdata; 
     357} 
     358 
     359function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { 
     360    if ( $block ) // a plugin has already blocked... we'll let that decision stand 
     361        return $block; 
     362    if ( ($time_newcomment - $time_lastcomment) < 15 ) 
     363        return true; 
     364    return false; 
    356365} 
    357366 
  • trunk/wp-includes/default-filters.php

    r4201 r4265  
    3838 
    3939add_filter('comment_email', 'antispambot'); 
     40 
     41add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); 
    4042 
    4143add_filter('comment_url', 'clean_url');