Skip to content

Commit

Permalink
v 2.51.0
Browse files Browse the repository at this point in the history
- WPU Base Email v 0.1.0
- Ignore DS_Store files
  • Loading branch information
Darklg committed Jul 24, 2023
1 parent cd84b27 commit 1e08934
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 2 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tests/coverage
/coverage
.DS_Store
17 changes: 17 additions & 0 deletions inc/WPUBaseEmail/README.md
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');
``
42 changes: 42 additions & 0 deletions inc/WPUBaseEmail/WPUBaseEmail.php
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);
}

}
1 change: 1 addition & 0 deletions inc/WPUBaseEmail/templates/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
1 change: 1 addition & 0 deletions inc/WPUBaseEmail/templates/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
23 changes: 23 additions & 0 deletions inc/WPUBaseEmail/templates/template.mjml
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>
39 changes: 39 additions & 0 deletions inc/WPUBaseEmail/templates/template.php
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;"> &nbsp;
</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;"> &nbsp;
</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>
8 changes: 6 additions & 2 deletions wpubaseplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Plugin URI: https://github.com/WordPressUtilities/wpubaseplugin
Update URI: https://github.com/WordPressUtilities/wpubaseplugin
Description: A framework for a WordPress plugin
Version: 2.50.6
Version: 2.51.0
Author: Darklg
Author URI: https://darklg.me/
Text Domain: wpubaseplugin
Expand All @@ -18,7 +18,7 @@

class WPUBasePlugin {

public $version = '2.50.6';
public $version = '2.51.0';

private $utilities_classes = array(
'messages' => array(
Expand Down Expand Up @@ -48,6 +48,10 @@ class WPUBasePlugin {
'update' => array(
'namespace' => 'wpubaseupdate_0_4_3',
'name' => 'WPUBaseUpdate'
),
'email' => array(
'namespace' => 'wpubaseemail_0_1_0',
'name' => 'WPUBaseEmail'
)
);

Expand Down

0 comments on commit 1e08934

Please sign in to comment.