| 1 |
<?php |
| 2 |
/** |
| 3 |
* Email template loader. |
| 4 |
* |
| 5 |
* @package SureDonation |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace SureDonation\Inc\Emails; |
| 9 |
|
| 10 |
use SureDonation\Inc\Traits\Get_Instance; |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Email_Template class. |
| 19 |
* |
| 20 |
* @since 0.0.1 |
| 21 |
*/ |
| 22 |
class Email_Template { |
| 23 |
use Get_Instance; |
| 24 |
|
| 25 |
/** |
| 26 |
* Class constructor. |
| 27 |
* |
| 28 |
* @since 0.0.1 |
| 29 |
* @return void |
| 30 |
*/ |
| 31 |
public function __construct() { |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get email header. |
| 36 |
* |
| 37 |
* @since 0.0.1 |
| 38 |
* @return string |
| 39 |
*/ |
| 40 |
public function get_header() { |
| 41 |
ob_start(); |
| 42 |
?> |
| 43 |
<!DOCTYPE html> |
| 44 |
<html> |
| 45 |
<head> |
| 46 |
<meta charset="UTF-8"> |
| 47 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 48 |
<title><?php echo esc_html__( 'Donation Notification', 'suredonation' ); ?></title> |
| 49 |
</head> |
| 50 |
<body style="margin: 0; padding: 0;"> |
| 51 |
<div id="sd_wrapper" dir="ltr" style="margin: 0; background-color: #F8F8FC; padding: 40px 0 0 0; width: 100%;"> |
| 52 |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 53 |
<tbody> |
| 54 |
<tr> |
| 55 |
<td align="center" valign="top"> |
| 56 |
<table border="0" cellpadding="0" cellspacing="0" width="600" id="sd_template_container" style="background-color: #ffffff; border: 1px solid #dce0e6; margin-bottom: 25px;"> |
| 57 |
<tbody> |
| 58 |
<tr> |
| 59 |
<td align="center" valign="top"> |
| 60 |
<table border="0" cellpadding="0" cellspacing="0" width="600" id="sd_template_body"> |
| 61 |
<tbody> |
| 62 |
<tr> |
| 63 |
<td valign="top" id="sd_body_content" style="background-color: #ffffff;"> |
| 64 |
<table border="0" cellpadding="20" cellspacing="0" width="100%"> |
| 65 |
<tbody> |
| 66 |
<tr> |
| 67 |
<td valign="top" style="padding: 32px;"> |
| 68 |
<div id="sd_body_content_inner" style="color: #384860; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; line-height: 20px; text-align: left;"> |
| 69 |
<?php |
| 70 |
$output = ob_get_clean(); |
| 71 |
return false !== $output ? $output : ''; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Get email footer. |
| 76 |
* |
| 77 |
* @since 0.0.1 |
| 78 |
* @return string |
| 79 |
*/ |
| 80 |
public function get_footer() { |
| 81 |
ob_start(); |
| 82 |
?> |
| 83 |
</div> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
</tbody> |
| 87 |
</table> |
| 88 |
</td> |
| 89 |
</tr> |
| 90 |
</tbody> |
| 91 |
</table> |
| 92 |
</td> |
| 93 |
</tr> |
| 94 |
</tbody> |
| 95 |
</table> |
| 96 |
</td> |
| 97 |
</tr> |
| 98 |
</tbody> |
| 99 |
</table> |
| 100 |
</div> |
| 101 |
</body> |
| 102 |
</html> |
| 103 |
<?php |
| 104 |
$output = ob_get_clean(); |
| 105 |
return false !== $output ? $output : ''; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Render email template with body content. |
| 110 |
* |
| 111 |
* @param string $email_body Email body content. |
| 112 |
* @since 0.0.1 |
| 113 |
* @return string Complete email HTML. |
| 114 |
*/ |
| 115 |
public function render( $email_body ) { |
| 116 |
// Convert newlines to <br> tags for plain text. |
| 117 |
$email_body = nl2br( $email_body ); |
| 118 |
|
| 119 |
return $this->get_header() . $email_body . $this->get_footer(); |
| 120 |
} |
| 121 |
} |
| 122 |
|