Changeset 883488
- Timestamp:
- 03/28/2014 11:05:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
akismet/trunk/class.akismet.php
r882552 r883488 123 123 if ( 'true' == $response[1] ) { 124 124 // akismet_spam_count will be incremented later by comment_is_spam() 125 add_filter('pre_comment_approved', array( 'Akismet', 'comment_is_spam' ) );126 127 $discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && get_option( 'akismet_strictness' ) === '1');125 add_filter('pre_comment_approved', array( 'Akismet', 'comment_is_spam' ) ); 126 127 $discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && ); 128 128 129 129 do_action( 'akismet_spam_caught', $discard ); … … 148 148 if ( 'true' != $response[1] && 'false' != $response[1] ) { 149 149 if ( !current_user_can('moderate_comments') ) { 150 add_filter('pre_comment_approved', array( 'Akismet', 'comment_needs_moderation' ) );150 add_filter('pre_comment_approved', array( 'Akismet', 'comment_needs_moderation' ) ); 151 151 } 152 152 if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_single_event') ) { … … 187 187 // as was checked by auto_check_comment 188 188 if ( is_object( $comment ) && !empty( self::$last_comment ) && is_array( self::$last_comment ) ) { 189 if ( isset( self::$last_comment['comment_post_ID'] ) 190 && intval( self::$last_comment['comment_post_ID'] ) == intval( $comment->comment_post_ID ) 191 && self::$last_comment['comment_author'] == $comment->comment_author 192 && self::$last_comment['comment_author_email'] == $comment->comment_author_email ) { 189 if ( self::matches_last_comment( $comment ) ) { 193 190 194 191 load_plugin_textdomain( 'akismet' ); … … 443 440 return defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE; 444 441 } 442 443 444 445 446 447 448 449 450 445 451 446 452 public static function get_ip_address() { 447 453 return isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null; 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 448 474 } 449 475 … … 482 508 483 509 // filter handler used to return a spam result to pre_comment_approved 484 public static function comment_is_spam( $approved ) { 485 static $just_once = false; 486 if ( $just_once ) 510 public static function comment_is_spam( $approved, $comment ) { 511 // Only do this if it's the correct comment 512 if ( !self::matches_last_comment( $comment ) ) { 513 self::log( "comment_is_spam mismatched comment, returning unaltered $approved" ); 487 514 return $approved; 515 488 516 489 517 // bump the counter here instead of when the filter is added to reduce the possibility of overcounting … … 491 519 update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr ); 492 520 493 // this is a one-shot deal494 $just_once = true;495 521 return 'spam'; 496 522 } 497 523 498 public static function comment_needs_moderation( $approved ) {499 static $just_once = false;500 if ( $just_once )524 public static function comment_needs_moderation( $approved ) { 525 526 501 527 return $approved; 502 503 // once only 504 $just_once = true; 505 return '0'; 528 } 529 return '0'; 506 530 } 507 531
Note: See TracChangeset
for help on using the changeset viewer.