Skip to content

Commit

Permalink
Merge pull request #21 from JWardee/v1.2.0
Browse files Browse the repository at this point in the history
+Added support for foreign letters #16
  • Loading branch information
JWardee authored Aug 20, 2018
2 parents f737ac5 + 82a4cc7 commit d54ada0
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
9 changes: 1 addition & 8 deletions build/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,4 @@ jQuery(function($) {
$(this).closest('.field-block').remove();
return false;
});

$('[data-html-preview]').each(function() {
var html = window.atob($(this).data('html-preview'));
console.log(html);
$(this)[0].src = 'data:text/html, ' + encodeURIComponent(html);
$(this).removeAttr('data-html-preview');
});
});
});
12 changes: 11 additions & 1 deletion build/scss/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@
margin: 10px 0;
}

.is-html-email {
display: block;
margin: 30px 0;
font-weight: bold;

input {
margin-right: 30px;
}
}

.-icon {
position: relative;
top: 50%;
Expand Down Expand Up @@ -278,4 +288,4 @@

.html-preview {
width: 100%;
}
}
12 changes: 12 additions & 0 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function route()
if (isset($_GET['page'])) {
if ($_GET['page'] == GeneralHelper::$adminPageSlug) {
if (current_user_can(Settings::get('default_view_role'))) {

/** Export message(s) */
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'export' ||
isset($_REQUEST['action2']) && $_REQUEST['action2'] == 'export') {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-logs')) {
Expand All @@ -68,6 +70,7 @@ public function route()
Mail::export($_REQUEST['id']);
}

/** Resend message(s) */
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'resend' &&
isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-logs')) {
Expand All @@ -78,6 +81,7 @@ public function route()
GeneralHelper::redirectToThisHomeScreen();
}

/** Delete message(s) */
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete' &&
isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'bulk-logs')) {
Expand All @@ -88,6 +92,7 @@ public function route()
GeneralHelper::redirectToThisHomeScreen();
}

/** Send mail */
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'new_mail') {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'new_mail')) {
wp_die(GeneralHelper::$failedNonceMessage);
Expand All @@ -97,6 +102,13 @@ public function route()
$_POST['subject'], $_POST['message']);
GeneralHelper::redirectToThisHomeScreen();
}

if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'single_mail' &&
isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
$log = Logs::get(['post__in' => [$_REQUEST['id']]]);
echo $log[0]['message'];
exit;
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/GeneralHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static public function setSettings()
* Flattens an array to dot notation.
*
* @param array $array An array
* @param string $separator The characater to flatten with
* @param string $separator The character to flatten with
* @param string $parent The parent passed to the child (private)
*
* @return array Flattened array to one level
Expand Down
2 changes: 1 addition & 1 deletion src/Loggers/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function getMailArgs($args)
'time' => time(),
'email_to' => GeneralHelper::arrayToString($args['to']),
'subject' => $args['subject'],
'message' => $args['message'],
'message' => strip_tags($args['message']),
'backtrace_segment' => json_encode($this->getBacktrace()),
'status' => 1,
'attachments' => json_encode($this->getAttachmentLocations($args['attachments'])),
Expand Down
7 changes: 0 additions & 7 deletions src/Models/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,4 @@ static public function truncate()

$wpdb->query("TRUNCATE TABLE " . $wpdb->prefix . GeneralHelper::$tableName);
}

static private function hasHtmlHeader($additionalHeaders)
{
foreach ($additionalHeaders as $additionalHeader) {

}
}
}
8 changes: 6 additions & 2 deletions src/Views/LogModal.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php if (isset($log)) : ?>
<?php
use WpMailCatcher\GeneralHelper;

if (isset($log)) :
?>
<div id="<?php echo $log['id']; ?>" class="modal">
<div class="modal-content <?php echo $log['is_html'] ? 'is-html' : 'is-not-html'; ?>">
<div class="modal-body">
Expand All @@ -9,7 +13,7 @@
</h2>
<div class="content-container">
<div class="content -active">
<iframe class="html-preview" data-html-preview="<?php echo base64_encode($log['message']); ?>"></iframe>
<iframe class="html-preview" src="?page=<?php echo GeneralHelper::$adminPageSlug; ?>&action=single_mail&id=<?php echo $log['id']; ?>"></iframe>
</div>
<div class="content">
<?php if (empty($log['attachments']) && empty($log['additional_headers'])) : ?>
Expand Down
4 changes: 3 additions & 1 deletion src/Views/NewMessageModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
<option value="to"><?php _e('To', 'WpMailCatcher'); ?></option>
<option value="cc"><?php _e('Cc', 'WpMailCatcher'); ?></option>
<option value="bcc"><?php _e('Bcc', 'WpMailCatcher'); ?></option>
<option value="custom"><?php _e('Custom', 'WpMailCatcher'); ?></option>
<option value="custom"><?php _e('Custom', 'WpMailCatcher'); ?></option>
</select>

<input name="header_values[]" type="text" class="field -input" />
</div>
</div>

<label class="is-html-email"><input type="checkbox" value="Content-Type: text/html" name="header_keys[]" /> Is HTML email? </label>
</div>
<div>
<h2><?php _e('Subject', 'WpMailCatcher'); ?></h2>
Expand Down

0 comments on commit d54ada0

Please sign in to comment.