PluginProbe
ShiftController Employee Shift Scheduling / 4.9.92
ShiftController Employee Shift Scheduling v4.9.92
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / _wordpress / email.php

email.php in ShiftController Employee Shift Scheduling 4.9.92, at hc3/_wordpress/email.php

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_Email
3 {
4 protected $emailHtml = 1;
5 protected $emailFrom;
6 protected $emailFromName;
7
8 public function __construct(
9 HC3_Settings $settings
10 )
11 {
12 $this->emailHtml = $settings->get( 'email_html' );
13 $this->emailFrom = $settings->get( 'email_from' );
14 $this->emailFromName = $settings->get( 'email_fromname' );
15 }
16
17 public function send( $to, $subj, $msg )
18 {
19 if( $this->emailHtml ){
20 $msg = nl2br( $msg );
21 }
22 else {
23 $msg = strip_tags( $msg );
24 }
25
26 add_filter( 'wp_mail_content_type', array($this, 'set_html_mail_content_type') );
27 add_filter( 'wp_mail_charset', array($this, 'set_charset') );
28
29 $headers = array();
30 if( strlen($this->emailFrom) ){
31 $headers[] = 'From: ' . $this->emailFromName . ' <' . $this->emailFrom . '>';
32 }
33
34 @wp_mail( $to, $subj, $msg, $headers );
35
36 remove_filter( 'wp_mail_content_type', array($this, 'set_html_mail_content_type') );
37 remove_filter( 'wp_mail_charset', array($this, 'set_charset') );
38
39 return $this;
40 }
41
42 public function set_html_mail_content_type()
43 {
44 $return = $this->emailHtml ? 'text/html' : 'text/plain';
45 return $return;
46 }
47
48 public function set_charset( $charset )
49 {
50 $return = 'utf-8';
51 return $return;
52 }
53 }