sharing_email_check_for_spam_via_akismet

Return $data as it if email about to be send out is not spam.

Description

sharing_email_check_for_spam_via_akismet( $data ); 

Parameters (1)

0. $data
The data.

Usage

  1. if ( !function_exists( 'sharing_email_check_for_spam_via_akismet' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/sharedaddy/sharedaddy.php'; 
  3.  
  4. // The data. 
  5. $data = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = sharing_email_check_for_spam_via_akismet($data); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/sharedaddy/sharedaddy.php  
  1. function sharing_email_check_for_spam_via_akismet( $data ) { 
  2.  
  3. if ( ! function_exists( 'akismet_http_post' ) && ! method_exists( 'Akismet', 'http_post' ) ) 
  4. return $data; 
  5.  
  6. // Prepare the body_request for akismet 
  7. $body_request = array( 
  8. 'blog' => get_option( 'home' ),  
  9. 'permalink' => get_permalink( $data['post']->ID ),  
  10. 'comment_type' => 'share',  
  11. 'comment_author' => $data['name'],  
  12. 'comment_author_email' => $data['source'],  
  13. 'comment_content' => sharing_email_send_post_content( $data ),  
  14. 'user_agent' => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null ),  
  15. ); 
  16.  
  17. if ( method_exists( 'Akismet', 'http_post' ) ) { 
  18. $body_request['user_ip'] = Akismet::get_ip_address(); 
  19. $response = Akismet::http_post( build_query( $body_request ), 'comment-check' ); 
  20. } else { 
  21. global $akismet_api_host, $akismet_api_port; 
  22. $body_request['user_ip'] = ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null ); 
  23. $response = akismet_http_post( build_query( $body_request ), $akismet_api_host, '/1.1/comment-check', $akismet_api_port ); 
  24.  
  25. // The Response is spam lets not send the email. 
  26. if ( ! empty( $response ) && isset( $response[1] ) && 'true' == trim( $response[1] ) ) { // 'true' is spam 
  27. return false; // don't send the email 
  28. return $data;