MC4WP_Comment_Form_Integration

Class MC4WP_Comment_Form_Integration.

Defined (1)

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

/includes/integrations/class-comment-form.php  
  1. class MC4WP_Comment_Form_Integration extends MC4WP_Integration { 
  2.  
  3. protected $type = 'comment_form'; 
  4.  
  5. public function __construct() { 
  6.  
  7. parent::__construct(); 
  8.  
  9. // hooks for outputting the checkbox 
  10. add_action( 'thesis_hook_after_comment_box', array( $this, 'output_checkbox' ), 10 ); 
  11. add_action( 'comment_form', array( $this, 'output_checkbox' ) ); 
  12.  
  13. // hooks for checking if we should subscribe the commenter 
  14. add_action( 'comment_post', array( $this, 'subscribe_from_comment' ), 40, 2 ); 
  15.  
  16. /** 
  17. * Grabs data from WP Comment Form 
  18. * @param int $comment_id 
  19. * @param string $comment_approved 
  20. * @return bool|string 
  21. */ 
  22. public function subscribe_from_comment( $comment_id, $comment_approved = '' ) { 
  23.  
  24. if( $this->is_spam() ) { 
  25. return false; 
  26.  
  27. // was sign-up checkbox checked? 
  28. if ( $this->checkbox_was_checked() === false ) { 
  29. return false; 
  30.  
  31. // is this a spam comment? 
  32. if ( $comment_approved === 'spam' ) { 
  33. return false; 
  34.  
  35. $comment = get_comment( $comment_id ); 
  36.  
  37. $email = $comment->comment_author_email; 
  38. $merge_vars = array( 
  39. 'NAME' => $comment->comment_author,  
  40. 'OPTIN_IP' => $comment->comment_author_IP,  
  41. ); 
  42.  
  43. return $this->subscribe( $email, $merge_vars, 'comment', $comment_id );