Ticket #6191: 6191.02.patch
File 6191.02.patch, 2.7 KB (added by , 10 years ago) |
---|
-
src/bp-activity/bp-activity-akismet.php
326 326 $activity_data['comment_type'] = $activity->type; 327 327 $activity_data['permalink'] = bp_activity_get_permalink( $activity->id, $activity ); 328 328 $activity_data['user_ID'] = $userdata->ID; 329 $activity_data['user_role'] = akismet_get_user_roles($userdata->ID );329 $activity_data['user_role'] = self::call_api( 'get_user_roles', $userdata->ID ); 330 330 331 331 /** 332 332 * Get the nonce if the new activity was submitted through the "what's up, Paul?" form. … … 505 505 $activity_data['user_agent'] = bp_core_current_user_ua(); 506 506 $activity_data['user_ip'] = bp_core_current_user_ip(); 507 507 508 if ( akismet_test_mode() )508 if ( self::call_api( 'test_mode' ) ) { 509 509 $activity_data['is_test'] = 'true'; 510 } 510 511 511 512 // Loop through _POST args and rekey strings 512 513 foreach ( $_POST as $key => $value ) … … 539 540 540 541 // Send to Akismet 541 542 add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) ); 542 $response = akismet_http_post($query_string, $akismet_api_host, $path, $akismet_api_port );543 $response = self::call_api( 'http_post', $query_string, $akismet_api_host, $path, $akismet_api_port ); 543 544 remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) ); 544 545 545 546 // Get the response … … 618 619 $event = array( 619 620 'event' => $event, 620 621 'message' => $message, 621 'time' => akismet_microtime(),622 'time' => self::call_api( 'microtime' ), 622 623 'user' => bp_loggedin_user_id(), 623 624 ); 624 625 … … 644 645 645 646 return $history; 646 647 } 648 649 /** 650 * Call various native Akismet functions. 651 * 652 * This was created to support older Akismet versions... unfortunately. 653 * 654 * @since BuddyPress (2.3.0) 655 * 656 * @param string $function_name The function or method name to call. 657 * @param mixed $args,... The arguments supported by $function_name. 658 * @return mixed 659 */ 660 public static function call_api( $function_name = '' ) { 661 $args = func_get_args(); 662 array_shift( $args ); 663 664 // Akismet >= 3.0 665 if ( class_exists( 'Akismet' ) ) { 666 if ( 'microtime' === $function_name ) { 667 $function_name = '_get_microtime'; 668 } elseif ( 'test_mode' === $function_name ) { 669 $function_name = 'is_test_mode'; 670 } elseif ( 'http_post' === $function_name ) { 671 $args = array( 672 $args[0], 673 str_replace( '/1.1/', '', $args[2] ) 674 ); 675 } 676 677 $callback = array( 'Akismet', $function_name ); 678 679 // Akismet < 3.0 680 } else { 681 $callback = "akismet_{$function_name}"; 682 } 683 684 return call_user_func_array( $callback, $args ); 685 } 647 686 } 648 687 649 688 /**