pmpro_send_html

Adds template files and changes content type to html if using PHPMailer directly.

Description

pmpro_send_html( $phpmailer ); 

Parameters (1)

0. $phpmailer
The phpmailer.

Usage

  1. if ( !function_exists( 'pmpro_send_html' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/email.php'; 
  3.  
  4. // The phpmailer. 
  5. $phpmailer = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_send_html($phpmailer); 
  9.  

Defined (1)

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

/includes/email.php  
  1. function pmpro_send_html( $phpmailer ) { 
  2.  
  3. //to check if we should wpautop later 
  4. $original_body = $phpmailer->Body; 
  5.  
  6. // Set the original plain text message 
  7. $phpmailer->AltBody = wp_specialchars_decode($phpmailer->Body, ENT_QUOTES); 
  8. // Clean < and > around text links in WP 3.1 
  9. $phpmailer->Body = preg_replace('#<(http://[^*]+)>#', '$1', $phpmailer->Body); 
  10. // Convert line breaks & make links clickable 
  11. $phpmailer->Body = make_clickable ($phpmailer->Body); 
  12.  
  13. // Get header for message if found 
  14. if(file_exists(get_stylesheet_directory() . "/email_header.html")) 
  15. $header = file_get_contents(get_stylesheet_directory() . "/email_header.html"); 
  16. elseif(file_exists(get_template_directory() . "/email_header.html")) 
  17. $header = file_get_contents(get_template_directory() . "/email_header.html"); 
  18. else 
  19. $header = ""; 
  20.  
  21. // Get footer for message if found 
  22. if(file_exists(get_stylesheet_directory() . "/email_footer.html")) 
  23. $footer = file_get_contents(get_stylesheet_directory() . "/email_footer.html"); 
  24. elseif(file_exists(get_template_directory() . "/email_footer.html")) 
  25. $footer = file_get_contents(get_template_directory() . "/email_footer.html"); 
  26. else 
  27. $footer = ""; 
  28.  
  29. // Add header/footer to the email 
  30. if(!empty($header)) 
  31. $phpmailer->Body = $header . "\n" . $phpmailer->Body; 
  32. if(!empty($footer)) 
  33. $phpmailer->Body = $phpmailer->Body . "\n" . $footer; 
  34.  
  35. // Replace variables in email 
  36. global $current_user; 
  37. $data = array( 
  38. "name" => $current_user->display_name,  
  39. "sitename" => get_option("blogname"),  
  40. "login_link" => pmpro_url("account"),  
  41. "display_name" => $current_user->display_name,  
  42. "user_email" => $current_user->user_email,  
  43. "subject" => $phpmailer->Subject 
  44. ); 
  45. foreach($data as $key => $value) 
  46. $phpmailer->Body = str_replace("!!" . $key . "!!", $value, $phpmailer->Body); 
  47.  
  48. // If there is no HTML, run through wpautop 
  49. if($original_body == strip_tags($original_body) && 
  50. $header == strip_tags($header) && 
  51. $footer == strip_tags($footer) 
  52. $phpmailer->Body = wpautop($phpmailer->Body); 
  53.  
  54. do_action("pmpro_after_phpmailer_init", $phpmailer); 
  55. do_action("pmpro_after_pmpmailer_init", $phpmailer); //typo left in for backwards compatibility