-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- WPU Base Email v 0.1.0 - Ignore DS_Store files
- Loading branch information
Showing
9 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
tests/coverage | ||
/coverage | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
WPU Base Email | ||
--- | ||
|
||
Nicely formatted emails in your plugin. | ||
|
||
## Insert in the INIT hook | ||
|
||
```php | ||
include dirname(__FILE__) . '/inc/WPUBaseEmail/WPUBaseEmail.php'; | ||
$this->baseemail = new \wpu_polls\WPUBaseEmail(); | ||
``` | ||
|
||
## Send an email where you need it | ||
|
||
```php | ||
$this->baseemail->send_email('test subject', 'test content'); | ||
`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
namespace wpubaseemail_0_1_0; | ||
|
||
/* | ||
Class Name: WPU Base Email | ||
Description: A class to handle native Email in WordPress admin | ||
Version: 0.1.0 | ||
Class URI: https://github.com/WordPressUtilities/wpubaseplugin | ||
Author: Darklg | ||
Author URI: https://darklg.me/ | ||
License: MIT License | ||
License URI: https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
class WPUBaseEmail { | ||
|
||
public function __construct() { | ||
} | ||
|
||
function send_email($subject, $email_text, $to = false, $headers = array(), $attachments = array()) { | ||
|
||
/* To */ | ||
if (!$to) { | ||
$to = get_option('admin_email'); | ||
} | ||
|
||
/* Content */ | ||
ob_start(); | ||
include dirname(__FILE__) . '/templates/template.php'; | ||
$out_html = ob_get_clean(); | ||
|
||
/* Headers */ | ||
if (!is_array($headers)) { | ||
$headers = array(); | ||
} | ||
$headers[] = 'Content-Type: text/html; charset=UTF-8'; | ||
|
||
/* Send mail */ | ||
wp_mail($to, $subject, $out_html, $headers, $attachments); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php /* Silence */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<mjml> | ||
<mj-head> | ||
<mj-style inline="inline"> | ||
.link-nostyle { color: inherit; } | ||
</mj-style> | ||
<mj-attributes> | ||
<mj-text color="#000000" font-size="16px" font-family="arial, helvetica, sans-serif" /> | ||
<mj-button background-color="red" color="white" /> | ||
<mj-divider border-width="1px" border-color="#F0F0F0" /> | ||
</mj-attributes> | ||
</mj-head> | ||
<mj-body background-color="#F0F0F0"> | ||
<mj-section background-color="#FFFFFF"> | ||
<mj-column> | ||
<mj-image width="100px" src="/assets/img/logo-small.png"></mj-image> | ||
<mj-divider /> | ||
<mj-text>Hello World</mj-text> | ||
<mj-divider /> | ||
<mj-text align="center" font-size="12px"><a class="link-nostyle" href="#">Hello World</a></mj-text> | ||
</mj-column> | ||
</mj-section> | ||
</mj-body> | ||
</mjml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
if (!isset($email_logo)) { | ||
$email_logo = get_header_image(); | ||
} | ||
if (!isset($footer_link)) { | ||
$footer_link = get_site_url(); | ||
} | ||
if (!isset($footer_text)) { | ||
$footer_text = get_bloginfo('name'); | ||
} | ||
if (!isset($email_text)) { | ||
$email_text = 'Hello World'; | ||
} | ||
|
||
?><!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title></title><!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style type="text/css">#outlook a { padding:0; } | ||
body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; } | ||
table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; } | ||
img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; } | ||
p { display:block;margin:13px 0; }</style><!--[if mso]> | ||
<noscript> | ||
<xml> | ||
<o:OfficeDocumentSettings> | ||
<o:AllowPNG/> | ||
<o:PixelsPerInch>96</o:PixelsPerInch> | ||
</o:OfficeDocumentSettings> | ||
</xml> | ||
</noscript> | ||
<![endif]--><!--[if lte mso 11]> | ||
<style type="text/css"> | ||
.mj-outlook-group-fix { width:100% !important; } | ||
</style> | ||
<![endif]--><style type="text/css">@media only screen and (min-width:480px) { | ||
.mj-column-per-100 { width:100% !important; max-width: 100%; } | ||
}</style><style media="screen and (min-width:480px)">.moz-text-html .mj-column-per-100 { width:100% !important; max-width: 100%; }</style><style type="text/css">@media only screen and (max-width:480px) { | ||
table.mj-full-width-mobile { width: 100% !important; } | ||
td.mj-full-width-mobile { width: auto !important; } | ||
}</style></head><body style="word-spacing:normal;background-color:#F0F0F0;"><div style="background-color:#F0F0F0;"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tbody><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:100px;"><img height="auto" src="<?php echo $email_logo; ?>" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;font-size:13px;" width="100"></td></tr></tbody></table></td></tr><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><p style="border-top:solid 1px #F0F0F0;font-size:1px;margin:0px auto;width:100%;"></p><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 1px #F0F0F0;font-size:1px;margin:0px auto;width:550px;" role="presentation" width="550px" ><tr><td style="height:0;line-height:0;"> | ||
</td></tr></table><![endif]--></td></tr><tr><td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:arial, helvetica, sans-serif;font-size:16px;line-height:1;text-align:left;color:#000000;"><?php echo $email_text; ?></div></td></tr><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><p style="border-top:solid 1px #F0F0F0;font-size:1px;margin:0px auto;width:100%;"></p><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 1px #F0F0F0;font-size:1px;margin:0px auto;width:550px;" role="presentation" width="550px" ><tr><td style="height:0;line-height:0;"> | ||
</td></tr></table><![endif]--></td></tr><tr><td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:arial, helvetica, sans-serif;font-size:12px;line-height:1;text-align:center;color:#000000;"><a class="link-nostyle" href="<?php echo $footer_link; ?>" style="color: inherit;"><?php echo $footer_text; ?></a></div></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters