Version Description
- [COMPOSER] Improve buttons on posts layout
- [COMPOSER] Improved header layout and logo
- [COMPOSER] Genrally improved block spacing
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 7.1.5 |
Comparing to | |
See all releases |
Code changes from version 7.1.4 to 7.1.5
- emails/blocks/cta/block.php +33 -18
- emails/blocks/footer/block.php +10 -12
- emails/blocks/giphy/block.php +11 -4
- emails/blocks/header/block.php +7 -53
- emails/blocks/header/layout-default.php +44 -0
- emails/blocks/header/options.php +3 -1
- emails/blocks/header/style.css +0 -8
- emails/blocks/heading/block.php +2 -18
- emails/blocks/hero/block-full.php +17 -21
- emails/blocks/hero/block-left.php +19 -28
- emails/blocks/hero/block-right.php +18 -27
- emails/blocks/hero/block.php +18 -29
- emails/blocks/hero/style.css +0 -5
- emails/blocks/html/block.php +2 -2
- emails/blocks/image/block.php +3 -14
- emails/blocks/posts/layout-big-image.php +32 -45
- emails/blocks/posts/layout-one-2.php +14 -12
- emails/blocks/posts/layout-one.php +10 -9
- emails/blocks/posts/layout-two.php +18 -7
- emails/blocks/preheader/options.php +1 -0
- emails/blocks/separator/block.php +1 -1
- emails/blocks/social/block.php +8 -3
- emails/emails.php +306 -346
- emails/tnp-composer/css/newsletter.css +11 -79
- includes/composer.php +128 -13
- includes/helper.php +15 -0
- includes/module.php +9 -1
- main/status.php +1 -1
- plugin.php +2 -2
- readme.txt +7 -1
emails/blocks/cta/block.php
CHANGED
@@ -9,11 +9,12 @@ $default_options = array(
|
|
9 |
'button_label' => 'Call to action',
|
10 |
'button_url' => home_url(),
|
11 |
'button_font_family' => '',
|
12 |
-
'button_font_size'
|
13 |
'button_font_weight' => '',
|
14 |
-
'button_font_color'
|
15 |
-
'button_background'
|
16 |
-
'
|
|
|
17 |
'button_width' => '200',
|
18 |
'button_align' => 'center',
|
19 |
'block_padding_top' => 20,
|
@@ -22,14 +23,22 @@ $default_options = array(
|
|
22 |
);
|
23 |
|
24 |
// Migration from old option names
|
25 |
-
if (!empty($options['font_color']))
|
26 |
-
|
27 |
-
if (!empty($options['
|
28 |
-
|
29 |
-
if (!empty($options['
|
30 |
-
|
31 |
-
if (!empty($options['
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
unset($options['font_color']);
|
35 |
unset($options['url']);
|
@@ -59,15 +68,21 @@ if (!empty($options['schema'])) {
|
|
59 |
// Cloned since we need to set the general options
|
60 |
$button_options = $options;
|
61 |
|
62 |
-
$button_options['button_font_family'] = empty(
|
63 |
-
$button_options['button_font_size']
|
64 |
-
$button_options['button_font_color']
|
65 |
-
$button_options['button_font_weight'] = empty(
|
66 |
-
$button_options['button_background']
|
67 |
?>
|
68 |
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
<div itemscope="" itemtype="http://schema.org/EmailMessage">
|
73 |
<div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
|
9 |
'button_label' => 'Call to action',
|
10 |
'button_url' => home_url(),
|
11 |
'button_font_family' => '',
|
12 |
+
'button_font_size' => '',
|
13 |
'button_font_weight' => '',
|
14 |
+
'button_font_color' => '',
|
15 |
+
'button_background' => '',
|
16 |
+
'align' => 'center',
|
17 |
+
'block_background' => '',
|
18 |
'button_width' => '200',
|
19 |
'button_align' => 'center',
|
20 |
'block_padding_top' => 20,
|
23 |
);
|
24 |
|
25 |
// Migration from old option names
|
26 |
+
if (!empty($options['font_color']))
|
27 |
+
$options['button_font_color'] = $options['font_color'];
|
28 |
+
if (!empty($options['url']))
|
29 |
+
$options['button_url'] = $options['url'];
|
30 |
+
if (!empty($options['font_family']))
|
31 |
+
$options['button_font_family'] = $options['font_family'];
|
32 |
+
if (!empty($options['font_size']))
|
33 |
+
$options['button_font_size'] = $options['font_size'];
|
34 |
+
if (!empty($options['font_weight']))
|
35 |
+
$options['button_font_weight'] = $options['font_weight'];
|
36 |
+
if (!empty($options['background']))
|
37 |
+
$options['button_background'] = $options['background'];
|
38 |
+
if (!empty($options['text']))
|
39 |
+
$options['button_label'] = $options['text'];
|
40 |
+
if (!empty($options['width']))
|
41 |
+
$options['button_width'] = $options['width'];
|
42 |
|
43 |
unset($options['font_color']);
|
44 |
unset($options['url']);
|
68 |
// Cloned since we need to set the general options
|
69 |
$button_options = $options;
|
70 |
|
71 |
+
$button_options['button_font_family'] = empty($options['button_font_family']) ? $global_button_font_family : $options['button_font_family'];
|
72 |
+
$button_options['button_font_size'] = empty($options['button_font_size']) ? $global_button_font_size : $options['button_font_size'];
|
73 |
+
$button_options['button_font_color'] = empty($options['button_font_color']) ? $global_button_font_color : $options['button_font_color'];
|
74 |
+
$button_options['button_font_weight'] = empty($options['button_font_weight']) ? $global_button_font_weight : $options['button_font_weight'];
|
75 |
+
$button_options['button_background'] = empty($options['button_background']) ? $global_button_background_color : $options['button_background'];
|
76 |
?>
|
77 |
|
78 |
|
79 |
+
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; border-collapse: collapse;">
|
80 |
+
<tr>
|
81 |
+
<td align="<?php echo esc_attr($options['align'])?>">
|
82 |
+
<?php echo TNP_Composer::button($button_options); ?>
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
</table>
|
86 |
|
87 |
<div itemscope="" itemtype="http://schema.org/EmailMessage">
|
88 |
<div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
|
emails/blocks/footer/block.php
CHANGED
@@ -21,25 +21,23 @@ $default_options = array(
|
|
21 |
);
|
22 |
$options = array_merge($default_options, $options);
|
23 |
|
24 |
-
$
|
25 |
-
$text_font_size = empty( $options['font_size'] ) ? $global_text_font_size : $options['font_size'];
|
26 |
-
$text_font_color = empty( $options['font_color'] ) ? $global_text_font_color : $options['font_color'];
|
27 |
-
$text_font_weight = empty( $options['font_weight'] ) ? $global_text_font_weight : $options['font_weight'];
|
28 |
|
29 |
?>
|
30 |
<style>
|
31 |
-
.
|
32 |
-
font-family: <?php echo $
|
33 |
-
font-size: <?php echo $
|
34 |
-
font-weight: <?php echo $
|
35 |
-
color: <?php echo $
|
36 |
text-decoration: none;
|
|
|
37 |
}
|
38 |
</style>
|
39 |
|
40 |
-
<a inline-class="
|
41 |
|
42 |
-
<span inline-class="
|
43 |
|
44 |
-
<a inline-class="
|
45 |
|
21 |
);
|
22 |
$options = array_merge($default_options, $options);
|
23 |
|
24 |
+
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
|
|
|
|
|
|
25 |
|
26 |
?>
|
27 |
<style>
|
28 |
+
.text {
|
29 |
+
font-family: <?php echo $text_style->font_family ?>;
|
30 |
+
font-size: <?php echo round($text_style->font_size*0.9) ?>px;
|
31 |
+
font-weight: <?php echo $text_style->font_weight ?>;
|
32 |
+
color: <?php echo $text_style->font_color ?>;
|
33 |
text-decoration: none;
|
34 |
+
line-height: normal;
|
35 |
}
|
36 |
</style>
|
37 |
|
38 |
+
<a inline-class="text" href="<?php if ($options['url'] == 'unsubscription') echo '{unsubscription_url}'; else echo '{profile_url}' ?>" target="_blank"><?php echo esc_html($options['profile']) ?></a>
|
39 |
|
40 |
+
<span inline-class="text"> | </span>
|
41 |
|
42 |
+
<a inline-class="text" href="{email_url}" target="_blank"><?php echo esc_html($options['view']) ?></a>
|
43 |
|
emails/blocks/giphy/block.php
CHANGED
@@ -21,11 +21,18 @@ $defaults = array(
|
|
21 |
$options = array_merge($defaults, $options);
|
22 |
|
23 |
?>
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
<tr>
|
27 |
-
<td
|
28 |
-
<img src="<?php echo $options['giphy_url'] ?>"
|
29 |
</td>
|
30 |
</tr>
|
31 |
</table>
|
21 |
$options = array_merge($defaults, $options);
|
22 |
|
23 |
?>
|
24 |
+
<style>
|
25 |
+
.image {
|
26 |
+
display: inline-block;
|
27 |
+
max-width: 100%!important;
|
28 |
+
height: auto!important;
|
29 |
+
font-size: 0;
|
30 |
+
}
|
31 |
+
</style>
|
32 |
+
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="responsive">
|
33 |
<tr>
|
34 |
+
<td align="center">
|
35 |
+
<img src="<?php echo $options['giphy_url'] ?>" inline-class="image">
|
36 |
</td>
|
37 |
</tr>
|
38 |
</table>
|
emails/blocks/header/block.php
CHANGED
@@ -7,9 +7,10 @@
|
|
7 |
|
8 |
$default_options = array(
|
9 |
'font_family' => '',
|
10 |
-
'font_size' =>
|
11 |
'font_color' => '',
|
12 |
'font_weight' => '',
|
|
|
13 |
'block_padding_top' => 15,
|
14 |
'block_padding_bottom' => 15,
|
15 |
'block_padding_left' => 15,
|
@@ -27,10 +28,11 @@ $text_font_weight = empty( $options['font_weight'] ) ? $global_text_font_weight
|
|
27 |
if (empty($info['header_logo']['id'])) {
|
28 |
$media = false;
|
29 |
} else {
|
30 |
-
$media =
|
31 |
if ($media) {
|
32 |
$media->alt = $info['header_title'];
|
33 |
$media->link = home_url();
|
|
|
34 |
}
|
35 |
}
|
36 |
|
@@ -41,57 +43,9 @@ if ($empty) {
|
|
41 |
} elseif ($options['layout'] === 'logo') {
|
42 |
include __DIR__ . '/layout-logo.php';
|
43 |
return;
|
|
|
|
|
|
|
44 |
}
|
45 |
?>
|
46 |
|
47 |
-
<style>
|
48 |
-
.header-text {
|
49 |
-
font-family: <?php echo $text_font_family ?>;
|
50 |
-
font-size: <?php echo $text_font_size ?>px;
|
51 |
-
font-weight: <?php echo $text_font_weight ?>;
|
52 |
-
color: <?php echo $text_font_color ?>;
|
53 |
-
text-decoration: none;
|
54 |
-
line-height: normal;
|
55 |
-
padding: 10px;
|
56 |
-
}
|
57 |
-
|
58 |
-
.header-title {
|
59 |
-
font-family: <?php echo $text_font_family ?>;
|
60 |
-
font-size: <?php echo $text_font_size * 1.2 ?>px;
|
61 |
-
font-weight: <?php echo $text_font_weight ?>;
|
62 |
-
color: <?php echo $text_font_color ?>;
|
63 |
-
text-decoration: none;
|
64 |
-
line-height: normal;
|
65 |
-
}
|
66 |
-
|
67 |
-
.header-logo {
|
68 |
-
font-family: <?php echo $text_font_family ?>;
|
69 |
-
font-weight: <?php echo $text_font_weight ?>;
|
70 |
-
color: <?php echo $text_font_color ?>;
|
71 |
-
line-height: normal;
|
72 |
-
}
|
73 |
-
|
74 |
-
.header-logo-img {
|
75 |
-
display: inline-block;
|
76 |
-
max-width: 100% !important;
|
77 |
-
}
|
78 |
-
</style>
|
79 |
-
|
80 |
-
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="header-table">
|
81 |
-
<tr>
|
82 |
-
<td align="left" width="50%" inline-class="header-logo" class="header-logo-global">
|
83 |
-
<?php if ($media) { ?>
|
84 |
-
<a href="<?php echo home_url() ?>" target="_blank">
|
85 |
-
<img alt="<?php echo esc_attr($media->alt) ?>" src="<?php echo $media->url ?>" width="<?php echo $media->width ?>" height="<?php echo $media->height ?>" inline-class="header-logo-img" border="0">
|
86 |
-
</a>
|
87 |
-
<?php } else { ?>
|
88 |
-
<a href="<?php echo home_url() ?>" target="_blank" inline-class="header-title">
|
89 |
-
<?php echo esc_attr($info['header_title']) ?>
|
90 |
-
</a>
|
91 |
-
<?php } ?>
|
92 |
-
</td>
|
93 |
-
<td width="50%" align="right" class="mobile-hide" inline-class="header-text">
|
94 |
-
<?php echo esc_html($info['header_sub']) ?>
|
95 |
-
</td>
|
96 |
-
</tr>
|
97 |
-
</table>
|
7 |
|
8 |
$default_options = array(
|
9 |
'font_family' => '',
|
10 |
+
'font_size' => '',
|
11 |
'font_color' => '',
|
12 |
'font_weight' => '',
|
13 |
+
'logo_height' => 100,
|
14 |
'block_padding_top' => 15,
|
15 |
'block_padding_bottom' => 15,
|
16 |
'block_padding_left' => 15,
|
28 |
if (empty($info['header_logo']['id'])) {
|
29 |
$media = false;
|
30 |
} else {
|
31 |
+
$media = tnp_get_media($info['header_logo']['id'], 'large');
|
32 |
if ($media) {
|
33 |
$media->alt = $info['header_title'];
|
34 |
$media->link = home_url();
|
35 |
+
$media->set_height($options['logo_height']);
|
36 |
}
|
37 |
}
|
38 |
|
43 |
} elseif ($options['layout'] === 'logo') {
|
44 |
include __DIR__ . '/layout-logo.php';
|
45 |
return;
|
46 |
+
} else {
|
47 |
+
include __DIR__ . '/layout-default.php';
|
48 |
+
return;
|
49 |
}
|
50 |
?>
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emails/blocks/header/layout-default.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<style>
|
2 |
+
.text {
|
3 |
+
font-family: <?php echo $text_font_family ?>;
|
4 |
+
font-size: <?php echo $text_font_size ?>px;
|
5 |
+
font-weight: <?php echo $text_font_weight ?>;
|
6 |
+
color: <?php echo $text_font_color ?>;
|
7 |
+
text-decoration: none;
|
8 |
+
line-height: normal;
|
9 |
+
padding: 10px;
|
10 |
+
}
|
11 |
+
|
12 |
+
.title {
|
13 |
+
font-family: <?php echo $text_font_family ?>;
|
14 |
+
font-size: <?php echo $text_font_size * 1.2 ?>px;
|
15 |
+
font-weight: <?php echo $text_font_weight ?>;
|
16 |
+
color: <?php echo $text_font_color ?>;
|
17 |
+
text-decoration: none;
|
18 |
+
line-height: normal;
|
19 |
+
}
|
20 |
+
|
21 |
+
.logo {
|
22 |
+
font-family: <?php echo $text_font_family ?>;
|
23 |
+
font-weight: <?php echo $text_font_weight ?>;
|
24 |
+
color: <?php echo $text_font_color ?>;
|
25 |
+
line-height: normal !important;
|
26 |
+
}
|
27 |
+
</style>
|
28 |
+
|
29 |
+
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; border-collapse: collapse;">
|
30 |
+
<tr>
|
31 |
+
<td align="center" width="50%" inline-class="logo">
|
32 |
+
<?php if ($media) { ?>
|
33 |
+
<?php echo TNP_Composer::image($media) ?>
|
34 |
+
<?php } else { ?>
|
35 |
+
<a href="<?php echo home_url() ?>" target="_blank" inline-class="title">
|
36 |
+
<?php echo esc_attr($info['header_title']) ?>
|
37 |
+
</a>
|
38 |
+
<?php } ?>
|
39 |
+
</td>
|
40 |
+
<td width="50%" align="center" inline-class="text">
|
41 |
+
<?php echo esc_html($info['header_sub']) ?>
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
</table>
|
emails/blocks/header/options.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
/* @var $options array contains all the options the current block we're ediging contains */
|
4 |
/* @var $controls NewsletterControls */
|
5 |
-
/* @var $
|
6 |
?>
|
7 |
|
8 |
<p>
|
@@ -19,4 +19,6 @@ $fields->select('layout', __('Layout', 'newsletter'), ['' => __('Default', 'news
|
|
19 |
'weight_default' => true
|
20 |
] ) ?>
|
21 |
|
|
|
|
|
22 |
<?php $fields->block_commons() ?>
|
2 |
|
3 |
/* @var $options array contains all the options the current block we're ediging contains */
|
4 |
/* @var $controls NewsletterControls */
|
5 |
+
/* @var $fields NewsletterFields */
|
6 |
?>
|
7 |
|
8 |
<p>
|
19 |
'weight_default' => true
|
20 |
] ) ?>
|
21 |
|
22 |
+
<?php $fields->number('logo_height', __('Height'))?>
|
23 |
+
|
24 |
<?php $fields->block_commons() ?>
|
emails/blocks/header/style.css
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
@media all and (max-width: 640) {
|
2 |
-
.header-table td {
|
3 |
-
width: 100%!important;
|
4 |
-
}
|
5 |
-
.header-logo-global {
|
6 |
-
text-align: center!important;
|
7 |
-
}
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emails/blocks/heading/block.php
CHANGED
@@ -25,22 +25,6 @@ $title_font_size = empty($options['font_size']) ? $global_title_font_size : $opt
|
|
25 |
$title_font_color = empty($options['font_color']) ? $global_title_font_color : $options['font_color'];
|
26 |
$title_font_weight = empty($options['font_weight']) ? $global_title_font_weight : $options['font_weight'];
|
27 |
|
28 |
-
//if (!empty($options['schema'])) {
|
29 |
-
// if ($options['schema'] === 'dark') {
|
30 |
-
// $options['block_background'] = '#000000';
|
31 |
-
// $options['font_color'] = '#ffffff';
|
32 |
-
// }
|
33 |
-
//
|
34 |
-
// if ($options['schema'] === 'bright') {
|
35 |
-
// $options['block_background'] = '#ffffff';
|
36 |
-
// $options['font_color'] = '#444444';
|
37 |
-
// }
|
38 |
-
//
|
39 |
-
// if ($options['schema'] === 'red') {
|
40 |
-
// $options['block_background'] = '#c00000';
|
41 |
-
// $options['font_color'] = '#ffffff';
|
42 |
-
// }
|
43 |
-
//}
|
44 |
?>
|
45 |
|
46 |
<style>
|
@@ -55,9 +39,9 @@ $title_font_weight = empty($options['font_weight']) ? $global_title_font_weight
|
|
55 |
}
|
56 |
</style>
|
57 |
|
58 |
-
<table border="0" cellspacing="0" cellpadding="0" width="100%"
|
59 |
<tr>
|
60 |
-
<td align="<?php echo esc_attr($options['align']) ?>" valign="middle"
|
61 |
<?php echo $options['text'] ?>
|
62 |
</td>
|
63 |
</tr>
|
25 |
$title_font_color = empty($options['font_color']) ? $global_title_font_color : $options['font_color'];
|
26 |
$title_font_weight = empty($options['font_weight']) ? $global_title_font_weight : $options['font_weight'];
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
?>
|
29 |
|
30 |
<style>
|
39 |
}
|
40 |
</style>
|
41 |
|
42 |
+
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
43 |
<tr>
|
44 |
+
<td align="<?php echo esc_attr($options['align']) ?>" valign="middle" inline-class="title">
|
45 |
<?php echo $options['text'] ?>
|
46 |
</td>
|
47 |
</tr>
|
emails/blocks/hero/block-full.php
CHANGED
@@ -1,43 +1,39 @@
|
|
1 |
<style>
|
2 |
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
3 |
.title {
|
4 |
-
font-family: <?php echo $
|
5 |
-
font-size: <?php echo $
|
6 |
-
font-weight: <?php echo $
|
7 |
-
color: <?php echo $
|
8 |
line-height: normal;
|
9 |
margin: 0;
|
10 |
}
|
11 |
|
12 |
.text {
|
13 |
-
font-family: <?php echo $
|
14 |
-
font-size: <?php echo $
|
15 |
-
font-weight: <?php echo $
|
16 |
-
color: <?php echo $
|
17 |
padding: 20px 0 0 0;
|
18 |
-
line-height:
|
19 |
margin: 0;
|
20 |
}
|
21 |
|
22 |
.image {
|
23 |
-
|
24 |
-
display: inline-block;
|
25 |
-
border: 0px;
|
26 |
-
margin: 0;
|
27 |
}
|
28 |
|
29 |
-
.
|
30 |
-
|
31 |
}
|
32 |
-
</style>
|
33 |
|
34 |
-
|
35 |
|
36 |
<table width="100%" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
37 |
<?php if ($media) { ?>
|
38 |
<tr>
|
39 |
-
<td
|
40 |
-
|
41 |
</td>
|
42 |
</tr>
|
43 |
<?php } ?>
|
@@ -47,6 +43,7 @@
|
|
47 |
<?php echo $options['title'] ?>
|
48 |
</td>
|
49 |
</tr>
|
|
|
50 |
<tr>
|
51 |
<td align="center" inline-class="text">
|
52 |
<?php echo $options['text'] ?>
|
@@ -54,8 +51,7 @@
|
|
54 |
</tr>
|
55 |
|
56 |
<tr>
|
57 |
-
<td align="center">
|
58 |
-
<br>
|
59 |
<?php echo TNP_Composer::button($button_options) ?>
|
60 |
</td>
|
61 |
</tr>
|
1 |
<style>
|
2 |
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
3 |
.title {
|
4 |
+
font-family: <?php echo $title_style->font_family ?>;
|
5 |
+
font-size: <?php echo $title_style->font_size ?>px;
|
6 |
+
font-weight: <?php echo $title_style->font_weight ?>;
|
7 |
+
color: <?php echo $title_style->font_color ?>;
|
8 |
line-height: normal;
|
9 |
margin: 0;
|
10 |
}
|
11 |
|
12 |
.text {
|
13 |
+
font-family: <?php echo $text_style->font_family ?>;
|
14 |
+
font-size: <?php echo $text_style->font_size ?>px;
|
15 |
+
font-weight: <?php echo $text_style->font_weight ?>;
|
16 |
+
color: <?php echo $text_style->font_color ?>;
|
17 |
padding: 20px 0 0 0;
|
18 |
+
line-height: 1.5em;
|
19 |
margin: 0;
|
20 |
}
|
21 |
|
22 |
.image {
|
23 |
+
padding-bottom: 20px;
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
+
.button {
|
27 |
+
padding-top: 15px;
|
28 |
}
|
|
|
29 |
|
30 |
+
</style>
|
31 |
|
32 |
<table width="100%" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
33 |
<?php if ($media) { ?>
|
34 |
<tr>
|
35 |
+
<td align="center" inline-class="image">
|
36 |
+
<?php echo TNP_Composer::image($media); ?>
|
37 |
</td>
|
38 |
</tr>
|
39 |
<?php } ?>
|
43 |
<?php echo $options['title'] ?>
|
44 |
</td>
|
45 |
</tr>
|
46 |
+
|
47 |
<tr>
|
48 |
<td align="center" inline-class="text">
|
49 |
<?php echo $options['text'] ?>
|
51 |
</tr>
|
52 |
|
53 |
<tr>
|
54 |
+
<td align="center" inline-class="button">
|
|
|
55 |
<?php echo TNP_Composer::button($button_options) ?>
|
56 |
</td>
|
57 |
</tr>
|
emails/blocks/hero/block-left.php
CHANGED
@@ -1,57 +1,48 @@
|
|
1 |
<style>
|
2 |
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
3 |
.title {
|
4 |
-
font-family: <?php echo $
|
5 |
-
font-size: <?php echo $
|
6 |
-
font-weight: <?php echo $
|
7 |
-
color: <?php echo $
|
8 |
margin: 0;
|
9 |
text-align: center;
|
10 |
line-height: normal;
|
|
|
11 |
}
|
12 |
.text {
|
13 |
-
font-family: <?php echo $
|
14 |
-
font-size: <?php echo $
|
15 |
-
font-weight: <?php echo $
|
16 |
-
color: <?php echo $
|
17 |
-
padding:
|
18 |
-
line-height:
|
19 |
margin: 0;
|
20 |
text-align: center;
|
21 |
}
|
22 |
|
23 |
-
.image {
|
24 |
-
max-width: 100%!important;
|
25 |
-
display: block;
|
26 |
-
}
|
27 |
-
.image-a {
|
28 |
-
display: block;
|
29 |
-
}
|
30 |
-
|
31 |
.button {
|
32 |
-
padding
|
33 |
}
|
34 |
</style>
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
<table width="49%" align="left" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
39 |
<tr>
|
40 |
<td align="center" valign="top">
|
41 |
-
|
42 |
</td>
|
43 |
</tr>
|
44 |
</table>
|
45 |
|
46 |
-
<table width="
|
47 |
<tr>
|
48 |
-
<td
|
49 |
-
|
50 |
</td>
|
51 |
</tr>
|
52 |
<tr>
|
53 |
-
<td
|
54 |
-
|
55 |
</td>
|
56 |
</tr>
|
57 |
|
1 |
<style>
|
2 |
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
3 |
.title {
|
4 |
+
font-family: <?php echo $title_style->font_family ?>;
|
5 |
+
font-size: <?php echo $title_style->font_size ?>px;
|
6 |
+
font-weight: <?php echo $title_style->font_weight ?>;
|
7 |
+
color: <?php echo $title_style->font_color ?>;
|
8 |
margin: 0;
|
9 |
text-align: center;
|
10 |
line-height: normal;
|
11 |
+
padding: 10px 0;
|
12 |
}
|
13 |
.text {
|
14 |
+
font-family: <?php echo $text_style->font_family ?>;
|
15 |
+
font-size: <?php echo $text_style->font_size ?>px;
|
16 |
+
font-weight: <?php echo $text_style->font_weight ?>;
|
17 |
+
color: <?php echo $text_style->font_color ?>;
|
18 |
+
padding: 10px 0;
|
19 |
+
line-height: 1.5em;
|
20 |
margin: 0;
|
21 |
text-align: center;
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
.button {
|
25 |
+
padding: 10px 0;
|
26 |
}
|
27 |
</style>
|
28 |
|
29 |
+
<table width="<?php echo $td_width ?>" align="left" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
|
|
|
|
30 |
<tr>
|
31 |
<td align="center" valign="top">
|
32 |
+
<?php echo TNP_Composer::image($media); ?>
|
33 |
</td>
|
34 |
</tr>
|
35 |
</table>
|
36 |
|
37 |
+
<table width="<?php echo $td_width ?>" align="right" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
38 |
<tr>
|
39 |
+
<td inline-class="title">
|
40 |
+
<?php echo $options['title'] ?>
|
41 |
</td>
|
42 |
</tr>
|
43 |
<tr>
|
44 |
+
<td inline-class="text">
|
45 |
+
<?php echo $options['text'] ?>
|
46 |
</td>
|
47 |
</tr>
|
48 |
|
emails/blocks/hero/block-right.php
CHANGED
@@ -1,58 +1,49 @@
|
|
1 |
<style>
|
2 |
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
3 |
.title {
|
4 |
-
font-family: <?php echo $
|
5 |
-
font-size: <?php echo $
|
6 |
-
font-weight: <?php echo $
|
7 |
-
color: <?php echo $
|
8 |
line-height: normal;
|
9 |
margin: 0;
|
10 |
text-align: center;
|
|
|
11 |
}
|
12 |
.text {
|
13 |
-
font-family: <?php echo $
|
14 |
-
font-size: <?php echo $
|
15 |
-
font-weight: <?php echo $
|
16 |
-
color: <?php echo $
|
17 |
-
padding:
|
18 |
-
line-height:
|
19 |
text-align: center;
|
20 |
margin: 0;
|
21 |
}
|
22 |
|
23 |
-
.image {
|
24 |
-
max-width: 100%!important;
|
25 |
-
display: block;
|
26 |
-
}
|
27 |
-
.image-a {
|
28 |
-
display: block;
|
29 |
-
}
|
30 |
-
|
31 |
.button {
|
32 |
-
padding
|
33 |
}
|
34 |
</style>
|
35 |
|
36 |
-
<!-- layout: right -->
|
37 |
-
|
38 |
<div dir="rtl">
|
39 |
|
40 |
-
<table width="
|
41 |
<tr>
|
42 |
-
<td align="center" valign="top"
|
43 |
-
|
44 |
</td>
|
45 |
</tr>
|
46 |
</table>
|
47 |
|
48 |
-
<table width="
|
49 |
<tr>
|
50 |
-
<td
|
51 |
<?php echo $options['title'] ?>
|
52 |
</td>
|
53 |
</tr>
|
54 |
<tr>
|
55 |
-
<td
|
56 |
<?php echo $options['text'] ?>
|
57 |
</td>
|
58 |
</tr>
|
1 |
<style>
|
2 |
/* Styles which will be removed and injected in the replacing the matching "inline-class" attribute */
|
3 |
.title {
|
4 |
+
font-family: <?php echo $title_style->font_family ?>;
|
5 |
+
font-size: <?php echo $title_style->font_size ?>px;
|
6 |
+
font-weight: <?php echo $title_style->font_weight ?>;
|
7 |
+
color: <?php echo $title_style->font_color ?>;
|
8 |
line-height: normal;
|
9 |
margin: 0;
|
10 |
text-align: center;
|
11 |
+
padding: 10px 0;
|
12 |
}
|
13 |
.text {
|
14 |
+
font-family: <?php echo $text_style->font_family ?>;
|
15 |
+
font-size: <?php echo $text_style->font_size ?>px;
|
16 |
+
font-weight: <?php echo $text_style->font_weight ?>;
|
17 |
+
color: <?php echo $text_style->font_color ?>;
|
18 |
+
padding: 10px 0;
|
19 |
+
line-height: 1.5em;
|
20 |
text-align: center;
|
21 |
margin: 0;
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
.button {
|
25 |
+
padding: 10px 0;
|
26 |
}
|
27 |
</style>
|
28 |
|
|
|
|
|
29 |
<div dir="rtl">
|
30 |
|
31 |
+
<table width="<?php echo $td_width ?>" align="right" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
32 |
<tr>
|
33 |
+
<td align="center" valign="top">
|
34 |
+
<?php echo TNP_Composer::image($media); ?>
|
35 |
</td>
|
36 |
</tr>
|
37 |
</table>
|
38 |
|
39 |
+
<table width="<?php echo $td_width ?>" align="left" class="responsive" border="0" cellspacing="0" cellpadding="0">
|
40 |
<tr>
|
41 |
+
<td inline-class="title" dir="ltr">
|
42 |
<?php echo $options['title'] ?>
|
43 |
</td>
|
44 |
</tr>
|
45 |
<tr>
|
46 |
+
<td inline-class="text" dir="ltr">
|
47 |
<?php echo $options['text'] ?>
|
48 |
</td>
|
49 |
</tr>
|
emails/blocks/hero/block.php
CHANGED
@@ -21,12 +21,12 @@ $defaults = array(
|
|
21 |
'title_font_weight' => '',
|
22 |
'title_font_color' => '',
|
23 |
'layout' => 'full',
|
24 |
-
'button_url'
|
25 |
-
'button_label'
|
26 |
-
'button_background'
|
27 |
-
'button_font_color'
|
28 |
'button_font_family' => '',
|
29 |
-
'button_font_size'
|
30 |
'button_font_weight' => '',
|
31 |
'block_padding_top' => 30,
|
32 |
'block_padding_bottom' => 30,
|
@@ -63,37 +63,26 @@ if ($layout == 'full') {
|
|
63 |
$options = array_merge(array('block_padding_left' => 15, 'block_padding_right' => 15), $options);
|
64 |
}
|
65 |
|
66 |
-
$
|
67 |
-
$
|
68 |
-
$title_font_color = empty( $options['title_font_color'] ) ? $global_title_font_color : $options['title_font_color'];
|
69 |
-
$title_font_weight = empty( $options['title_font_weight'] ) ? $global_title_font_weight : $options['title_font_weight'];
|
70 |
-
|
71 |
-
$text_font_family = empty( $options['font_family'] ) ? $global_text_font_family : $options['font_family'];
|
72 |
-
$text_font_size = empty( $options['font_size'] ) ? $global_text_font_size : $options['font_size'];
|
73 |
-
$text_font_color = empty( $options['font_color'] ) ? $global_text_font_color : $options['font_color'];
|
74 |
-
$text_font_weight = empty( $options['font_weight'] ) ? $global_text_font_weight : $options['font_weight'];
|
75 |
|
76 |
$layout = $options['layout'];
|
77 |
|
78 |
$button_options = $options;
|
79 |
-
$button_options['button_font_family'] = empty(
|
80 |
-
$button_options['button_font_size']
|
81 |
-
$button_options['button_font_color']
|
82 |
-
$button_options['button_font_weight'] = empty(
|
83 |
-
$button_options['button_background']
|
84 |
|
85 |
if (!empty($options['image']['id'])) {
|
86 |
-
if ($layout
|
87 |
-
$
|
88 |
-
|
89 |
-
$media->set_width(600 - $options['block_padding_left'] - $options['block_padding_right']);
|
90 |
-
}
|
91 |
} else {
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$media->set_width(300 - $options['block_padding_left']);
|
96 |
-
}
|
97 |
}
|
98 |
if ($media) {
|
99 |
if (!empty($options['image_alt'])) {
|
21 |
'title_font_weight' => '',
|
22 |
'title_font_color' => '',
|
23 |
'layout' => 'full',
|
24 |
+
'button_url' => '',
|
25 |
+
'button_label' => __('Click Here', 'newsletter'),
|
26 |
+
'button_background' => '',
|
27 |
+
'button_font_color' => '',
|
28 |
'button_font_family' => '',
|
29 |
+
'button_font_size' => '',
|
30 |
'button_font_weight' => '',
|
31 |
'block_padding_top' => 30,
|
32 |
'block_padding_bottom' => 30,
|
63 |
$options = array_merge(array('block_padding_left' => 15, 'block_padding_right' => 15), $options);
|
64 |
}
|
65 |
|
66 |
+
$title_style = TNP_Composer::get_style($options, 'title', $composer, 'title');
|
67 |
+
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
$layout = $options['layout'];
|
70 |
|
71 |
$button_options = $options;
|
72 |
+
$button_options['button_font_family'] = empty($options['button_font_family']) ? $global_button_font_family : $options['button_font_family'];
|
73 |
+
$button_options['button_font_size'] = empty($options['button_font_size']) ? $global_button_font_size : $options['button_font_size'];
|
74 |
+
$button_options['button_font_color'] = empty($options['button_font_color']) ? $global_button_font_color : $options['button_font_color'];
|
75 |
+
$button_options['button_font_weight'] = empty($options['button_font_weight']) ? $global_button_font_weight : $options['button_font_weight'];
|
76 |
+
$button_options['button_background'] = empty($options['button_background']) ? $global_button_background_color : $options['button_background'];
|
77 |
|
78 |
if (!empty($options['image']['id'])) {
|
79 |
+
if ($layout === 'full') {
|
80 |
+
$image_width = 600 - $options['block_padding_left'] - $options['block_padding_right'];
|
81 |
+
$media = tnp_resize_2x($options['image']['id'], [$image_width, 0]);
|
|
|
|
|
82 |
} else {
|
83 |
+
$td_width = round((600 - $options['block_padding_left'] - $options['block_padding_right'] - 20)/2);
|
84 |
+
//$image_width = 300 - $options['block_padding_left'];
|
85 |
+
$media = tnp_resize_2x($options['image']['id'], [$td_width, 0]);
|
|
|
|
|
86 |
}
|
87 |
if ($media) {
|
88 |
if (!empty($options['image_alt'])) {
|
emails/blocks/hero/style.css
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
@media all and (max-width: 525px) {
|
2 |
-
.hero-title {
|
3 |
-
padding-top: 15px;
|
4 |
-
}
|
5 |
-
}
|
|
|
|
|
|
|
|
|
|
emails/blocks/html/block.php
CHANGED
@@ -31,9 +31,9 @@ $options = array_merge($default_options, $options);
|
|
31 |
color: <?php echo $options['font_color']?>;
|
32 |
}
|
33 |
</style>
|
34 |
-
<table width="100%" border="0" cellpadding="0"
|
35 |
<tr>
|
36 |
-
<td
|
37 |
<?php echo $options['html'] ?>
|
38 |
</td>
|
39 |
</tr>
|
31 |
color: <?php echo $options['font_color']?>;
|
32 |
}
|
33 |
</style>
|
34 |
+
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
35 |
<tr>
|
36 |
+
<td valign="top" align="center" inline-class="html-td" class="html-td-global">
|
37 |
<?php echo $options['html'] ?>
|
38 |
</td>
|
39 |
</tr>
|
emails/blocks/image/block.php
CHANGED
@@ -57,22 +57,11 @@ if (!empty($options['image-alt'])) {
|
|
57 |
}
|
58 |
|
59 |
?>
|
60 |
-
<style>
|
61 |
-
.image {
|
62 |
-
max-width: 100% !important;
|
63 |
-
height: auto !important;
|
64 |
-
display: inline-block;
|
65 |
-
width: <?php echo $media->width ?>px;
|
66 |
-
line-height: 0;
|
67 |
-
margin: 0 auto;
|
68 |
-
}
|
69 |
-
</style>
|
70 |
|
71 |
-
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="responsive">
|
72 |
<tr>
|
73 |
-
<td align="<?php echo esc_attr($options['align']) ?>" valign="middle"
|
74 |
-
<?php echo TNP_Composer::image($media
|
75 |
</td>
|
76 |
</tr>
|
77 |
</table>
|
78 |
-
|
57 |
}
|
58 |
|
59 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="responsive" style="margin: 0;">
|
62 |
<tr>
|
63 |
+
<td align="<?php echo esc_attr($options['align']) ?>" valign="middle">
|
64 |
+
<?php echo TNP_Composer::image($media); ?>
|
65 |
</td>
|
66 |
</tr>
|
67 |
</table>
|
|
emails/blocks/posts/layout-big-image.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
$size = ['width' => 600, 'height' => 0];
|
3 |
?>
|
4 |
<style>
|
5 |
-
.
|
6 |
font-family: <?php echo $title_font_family ?>;
|
7 |
font-size: <?php echo $title_font_size ?>px;
|
8 |
font-weight: <?php echo $title_font_weight ?>;
|
@@ -11,7 +11,7 @@ $size = ['width' => 600, 'height' => 0];
|
|
11 |
padding: 0 0 5px 0;
|
12 |
}
|
13 |
|
14 |
-
.
|
15 |
font-family: <?php echo $text_font_family ?>;
|
16 |
font-size: <?php echo $text_font_size ?>px;
|
17 |
font-weight: <?php echo $text_font_weight ?>;
|
@@ -20,22 +20,16 @@ $size = ['width' => 600, 'height' => 0];
|
|
20 |
padding: 10px 0 15px 0;
|
21 |
}
|
22 |
|
23 |
-
.
|
24 |
font-family: <?php echo $text_font_family ?>;
|
25 |
color: <?php echo $text_font_color ?>;
|
26 |
-
font-size: <?php echo round($text_font_size * 0.8)
|
27 |
font-weight: normal;
|
28 |
padding: 0 0 5px 0;
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
-
font-family: <?php echo $text_font_family ?>;
|
33 |
-
color: <?php echo $text_font_color ?>;
|
34 |
-
font-size: <?php echo round($text_font_size * 0.8) ?>px;
|
35 |
-
font-weight: normal;
|
36 |
-
padding: 0 0 5px 0;
|
37 |
}
|
38 |
-
|
39 |
</style>
|
40 |
|
41 |
|
@@ -43,7 +37,7 @@ $size = ['width' => 600, 'height' => 0];
|
|
43 |
|
44 |
<?php
|
45 |
$url = tnp_post_permalink($post);
|
46 |
-
|
47 |
|
48 |
$media = null;
|
49 |
if ($show_image) {
|
@@ -54,13 +48,19 @@ $size = ['width' => 600, 'height' => 0];
|
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
?>
|
65 |
|
66 |
<?php if ($media) { ?>
|
@@ -73,32 +73,22 @@ $size = ['width' => 600, 'height' => 0];
|
|
73 |
</table>
|
74 |
<?php } ?>
|
75 |
|
76 |
-
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="responsive
|
77 |
<tr>
|
78 |
<td>
|
79 |
|
80 |
<!-- ARTICLE -->
|
81 |
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
82 |
-
<?php if ($
|
83 |
<tr>
|
84 |
-
<td align="<?php echo $align_left ?>" inline-class="
|
85 |
-
<?php echo
|
86 |
</td>
|
87 |
</tr>
|
88 |
<?php } ?>
|
89 |
-
|
90 |
-
<?php if ($show_author) { ?>
|
91 |
-
<tr>
|
92 |
-
<td align="<?php echo $align_left ?>" inline-class="post-author">
|
93 |
-
<?php echo $author ?>
|
94 |
-
</td>
|
95 |
-
</tr>
|
96 |
-
<?php } ?>
|
97 |
-
|
98 |
<tr>
|
99 |
-
<td align="<?php echo $align_left ?>"
|
100 |
-
inline-class="post-title"
|
101 |
-
class="tnpc-row-edit tnpc-inline-editable"
|
102 |
data-type="title" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
103 |
<?php
|
104 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'title', $post->ID) ?
|
@@ -109,8 +99,8 @@ $size = ['width' => 600, 'height' => 0];
|
|
109 |
</tr>
|
110 |
<tr>
|
111 |
<td align="<?php echo $align_left ?>"
|
112 |
-
inline-class="
|
113 |
-
class="
|
114 |
data-type="text" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
115 |
<?php
|
116 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
@@ -119,22 +109,19 @@ $size = ['width' => 600, 'height' => 0];
|
|
119 |
?>
|
120 |
</td>
|
121 |
</tr>
|
122 |
-
|
123 |
<tr>
|
124 |
-
<td align="<?php echo $align_left ?>">
|
125 |
-
|
126 |
-
<br><br>
|
127 |
</td>
|
128 |
</tr>
|
129 |
-
|
130 |
</table>
|
131 |
|
132 |
</td>
|
133 |
</tr>
|
134 |
</table>
|
135 |
|
136 |
-
|
137 |
-
|
138 |
<?php } ?>
|
139 |
|
140 |
|
2 |
$size = ['width' => 600, 'height' => 0];
|
3 |
?>
|
4 |
<style>
|
5 |
+
.title {
|
6 |
font-family: <?php echo $title_font_family ?>;
|
7 |
font-size: <?php echo $title_font_size ?>px;
|
8 |
font-weight: <?php echo $title_font_weight ?>;
|
11 |
padding: 0 0 5px 0;
|
12 |
}
|
13 |
|
14 |
+
.excerpt {
|
15 |
font-family: <?php echo $text_font_family ?>;
|
16 |
font-size: <?php echo $text_font_size ?>px;
|
17 |
font-weight: <?php echo $text_font_weight ?>;
|
20 |
padding: 10px 0 15px 0;
|
21 |
}
|
22 |
|
23 |
+
.meta {
|
24 |
font-family: <?php echo $text_font_family ?>;
|
25 |
color: <?php echo $text_font_color ?>;
|
26 |
+
font-size: <?php echo round($text_font_size * 0.8) ?>px;
|
27 |
font-weight: normal;
|
28 |
padding: 0 0 5px 0;
|
29 |
}
|
30 |
+
.button {
|
31 |
+
padding-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
|
|
33 |
</style>
|
34 |
|
35 |
|
37 |
|
38 |
<?php
|
39 |
$url = tnp_post_permalink($post);
|
40 |
+
$options['button_url'] = $url;
|
41 |
|
42 |
$media = null;
|
43 |
if ($show_image) {
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
|
52 |
+
$meta = [];
|
53 |
+
|
54 |
+
if ($show_date) {
|
55 |
+
$meta[] = tnp_post_date($post);
|
56 |
+
}
|
57 |
+
|
58 |
+
if ($show_author) {
|
59 |
+
$author_object = get_user_by('id', $post->post_author);
|
60 |
+
if ($author_object) {
|
61 |
+
$meta[] = $author_object->display_name;
|
62 |
+
}
|
63 |
+
}
|
64 |
?>
|
65 |
|
66 |
<?php if ($media) { ?>
|
73 |
</table>
|
74 |
<?php } ?>
|
75 |
|
76 |
+
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="responsive" style="margin: 0;">
|
77 |
<tr>
|
78 |
<td>
|
79 |
|
80 |
<!-- ARTICLE -->
|
81 |
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
82 |
+
<?php if ($meta) { ?>
|
83 |
<tr>
|
84 |
+
<td align="<?php echo $align_left ?>" inline-class="meta">
|
85 |
+
<?php echo esc_html(implode(' - ', $meta)) ?>
|
86 |
</td>
|
87 |
</tr>
|
88 |
<?php } ?>
|
89 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
<tr>
|
91 |
+
<td align="<?php echo $align_left ?>" inline-class="title" class="tnpc-row-edit tnpc-inline-editable"
|
|
|
|
|
92 |
data-type="title" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
93 |
<?php
|
94 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'title', $post->ID) ?
|
99 |
</tr>
|
100 |
<tr>
|
101 |
<td align="<?php echo $align_left ?>"
|
102 |
+
inline-class="excerpt"
|
103 |
+
class="tnpc-row-edit tnpc-inline-editable"
|
104 |
data-type="text" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
105 |
<?php
|
106 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
109 |
?>
|
110 |
</td>
|
111 |
</tr>
|
112 |
+
<?php if ($show_read_more_button) { ?>
|
113 |
<tr>
|
114 |
+
<td align="<?php echo $align_left ?>" inline-class="button">
|
115 |
+
<?php echo TNP_Composer::button($button_options) ?>
|
|
|
116 |
</td>
|
117 |
</tr>
|
118 |
+
<?php } ?>
|
119 |
</table>
|
120 |
|
121 |
</td>
|
122 |
</tr>
|
123 |
</table>
|
124 |
|
|
|
|
|
125 |
<?php } ?>
|
126 |
|
127 |
|
emails/blocks/posts/layout-one-2.php
CHANGED
@@ -31,6 +31,9 @@ $column_width = $total_width / 2 - 10;
|
|
31 |
padding: 0 0 5px 0;
|
32 |
line-height: normal !important;
|
33 |
}
|
|
|
|
|
|
|
34 |
</style>
|
35 |
|
36 |
|
@@ -48,7 +51,7 @@ $column_width = $total_width / 2 - 10;
|
|
48 |
$media->set_width($column_width);
|
49 |
}
|
50 |
}
|
51 |
-
|
52 |
$meta = [];
|
53 |
|
54 |
if ($show_date) {
|
@@ -61,8 +64,8 @@ $column_width = $total_width / 2 - 10;
|
|
61 |
$meta[] = $author_object->display_name;
|
62 |
}
|
63 |
}
|
64 |
-
|
65 |
-
$button_options['button_url'] = $url;
|
66 |
?>
|
67 |
|
68 |
<tr>
|
@@ -80,19 +83,19 @@ $column_width = $total_width / 2 - 10;
|
|
80 |
<td valign="top" style="padding: 20px 0 25px 0;">
|
81 |
|
82 |
<?php if ($media) { ?>
|
83 |
-
<table width="<?php echo $column_width ?>" cellpadding="0" cellspacing="0" border="0" align="left" class="responsive">
|
84 |
<tr>
|
85 |
<td>
|
86 |
-
<?php echo TNP_Composer::image($media
|
87 |
</td>
|
88 |
</tr>
|
89 |
</table>
|
90 |
<?php } ?>
|
91 |
|
92 |
-
<table width="<?php echo $media ? $column_width : '100%' ?>" cellpadding="0" cellspacing="0" border="0" class="responsive" align="right">
|
93 |
<tr>
|
94 |
<td>
|
95 |
-
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
96 |
<?php if ($meta) { ?>
|
97 |
<tr>
|
98 |
<td inline-class="meta" dir="<?php echo $dir ?>" align="<?php echo $align_left ?>">
|
@@ -102,8 +105,8 @@ $column_width = $total_width / 2 - 10;
|
|
102 |
<?php } ?>
|
103 |
|
104 |
<tr>
|
105 |
-
<td align="<?php echo $align_left ?>"
|
106 |
-
<a href="<?php $url ?>" inline-class="excerpt" class="tnpc-row-edit tnpc-inline-editable" data-type="text">
|
107 |
<?php
|
108 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
109 |
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $post->ID) :
|
@@ -112,11 +115,10 @@ $column_width = $total_width / 2 - 10;
|
|
112 |
</a>
|
113 |
</td>
|
114 |
</tr>
|
115 |
-
|
116 |
<?php if ($show_read_more_button) { ?>
|
117 |
<tr>
|
118 |
-
<td align="<?php echo $align_left ?>">
|
119 |
-
<br>
|
120 |
<?php echo TNP_Composer::button($button_options) ?>
|
121 |
</td>
|
122 |
</tr>
|
31 |
padding: 0 0 5px 0;
|
32 |
line-height: normal !important;
|
33 |
}
|
34 |
+
.button {
|
35 |
+
padding: 15px 0;
|
36 |
+
}
|
37 |
</style>
|
38 |
|
39 |
|
51 |
$media->set_width($column_width);
|
52 |
}
|
53 |
}
|
54 |
+
|
55 |
$meta = [];
|
56 |
|
57 |
if ($show_date) {
|
64 |
$meta[] = $author_object->display_name;
|
65 |
}
|
66 |
}
|
67 |
+
|
68 |
+
$button_options['button_url'] = $url;
|
69 |
?>
|
70 |
|
71 |
<tr>
|
83 |
<td valign="top" style="padding: 20px 0 25px 0;">
|
84 |
|
85 |
<?php if ($media) { ?>
|
86 |
+
<table width="<?php echo $column_width ?>" cellpadding="0" cellspacing="0" border="0" align="left" style="margin: 0;" class="responsive">
|
87 |
<tr>
|
88 |
<td>
|
89 |
+
<?php echo TNP_Composer::image($media) ?>
|
90 |
</td>
|
91 |
</tr>
|
92 |
</table>
|
93 |
<?php } ?>
|
94 |
|
95 |
+
<table width="<?php echo $media ? $column_width : '100%' ?>" cellpadding="0" cellspacing="0" border="0" style="margin: 0;" class="responsive" align="right">
|
96 |
<tr>
|
97 |
<td>
|
98 |
+
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin: 0;">
|
99 |
<?php if ($meta) { ?>
|
100 |
<tr>
|
101 |
<td inline-class="meta" dir="<?php echo $dir ?>" align="<?php echo $align_left ?>">
|
105 |
<?php } ?>
|
106 |
|
107 |
<tr>
|
108 |
+
<td align="<?php echo $align_left ?>" dir="<?php echo $dir ?>">
|
109 |
+
<a href="<?php $url ?>" data-id="<?php echo $post->ID ?>" inline-class="excerpt" class="tnpc-row-edit tnpc-inline-editable" data-type="text">
|
110 |
<?php
|
111 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
112 |
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $post->ID) :
|
115 |
</a>
|
116 |
</td>
|
117 |
</tr>
|
118 |
+
|
119 |
<?php if ($show_read_more_button) { ?>
|
120 |
<tr>
|
121 |
+
<td align="<?php echo $align_left ?>" inline-class="button">
|
|
|
122 |
<?php echo TNP_Composer::button($button_options) ?>
|
123 |
</td>
|
124 |
</tr>
|
emails/blocks/posts/layout-one.php
CHANGED
@@ -6,7 +6,7 @@ $column_width = $total_width / 2 - 10;
|
|
6 |
<style>
|
7 |
.title {
|
8 |
font-family: <?php echo $title_font_family ?>;
|
9 |
-
font-size: <?php echo round($title_font_size*0.9) ?>px;
|
10 |
font-weight: <?php echo $title_font_weight ?>;
|
11 |
color: <?php echo $title_font_color ?>;
|
12 |
line-height: normal !important;
|
@@ -30,6 +30,9 @@ $column_width = $total_width / 2 - 10;
|
|
30 |
padding: 0 0 10px 0;
|
31 |
line-height: normal !important;
|
32 |
}
|
|
|
|
|
|
|
33 |
</style>
|
34 |
|
35 |
|
@@ -60,17 +63,17 @@ $column_width = $total_width / 2 - 10;
|
|
60 |
$meta[] = $author_object->display_name;
|
61 |
}
|
62 |
}
|
63 |
-
|
64 |
$button_options['button_url'] = $url;
|
65 |
?>
|
66 |
|
67 |
<tr>
|
68 |
-
<td valign="top" style="padding: 20px 0 0 0;"
|
69 |
|
70 |
<?php if ($media) { ?>
|
71 |
<table width="<?php echo $column_width ?>" cellpadding="0" cellspacing="0" border="0" align="left" class="responsive">
|
72 |
<tr>
|
73 |
-
<td>
|
74 |
<?php echo TNP_Composer::image($media) ?>
|
75 |
</td>
|
76 |
</tr>
|
@@ -98,7 +101,7 @@ $column_width = $total_width / 2 - 10;
|
|
98 |
?>
|
99 |
</td>
|
100 |
</tr>
|
101 |
-
|
102 |
<tr>
|
103 |
<td align="<?php echo $align_left ?>" inline-class="excerpt" class="tnpc-row-edit tnpc-inline-editable"
|
104 |
data-type="text" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
@@ -109,13 +112,11 @@ $column_width = $total_width / 2 - 10;
|
|
109 |
?>
|
110 |
</td>
|
111 |
</tr>
|
112 |
-
|
113 |
<?php if ($show_read_more_button) { ?>
|
114 |
<tr>
|
115 |
-
<td align="<?php echo $align_left ?>">
|
116 |
-
<br>
|
117 |
<?php echo TNP_Composer::button($button_options) ?>
|
118 |
-
<br><br>
|
119 |
</td>
|
120 |
</tr>
|
121 |
<?php } ?>
|
6 |
<style>
|
7 |
.title {
|
8 |
font-family: <?php echo $title_font_family ?>;
|
9 |
+
font-size: <?php echo round($title_font_size * 0.9) ?>px;
|
10 |
font-weight: <?php echo $title_font_weight ?>;
|
11 |
color: <?php echo $title_font_color ?>;
|
12 |
line-height: normal !important;
|
30 |
padding: 0 0 10px 0;
|
31 |
line-height: normal !important;
|
32 |
}
|
33 |
+
.button {
|
34 |
+
padding: 15px 0;
|
35 |
+
}
|
36 |
</style>
|
37 |
|
38 |
|
63 |
$meta[] = $author_object->display_name;
|
64 |
}
|
65 |
}
|
66 |
+
|
67 |
$button_options['button_url'] = $url;
|
68 |
?>
|
69 |
|
70 |
<tr>
|
71 |
+
<td valign="top" style="padding: 20px 0 0 0;">
|
72 |
|
73 |
<?php if ($media) { ?>
|
74 |
<table width="<?php echo $column_width ?>" cellpadding="0" cellspacing="0" border="0" align="left" class="responsive">
|
75 |
<tr>
|
76 |
+
<td style="padding-bottom: 20px;">
|
77 |
<?php echo TNP_Composer::image($media) ?>
|
78 |
</td>
|
79 |
</tr>
|
101 |
?>
|
102 |
</td>
|
103 |
</tr>
|
104 |
+
|
105 |
<tr>
|
106 |
<td align="<?php echo $align_left ?>" inline-class="excerpt" class="tnpc-row-edit tnpc-inline-editable"
|
107 |
data-type="text" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
112 |
?>
|
113 |
</td>
|
114 |
</tr>
|
115 |
+
|
116 |
<?php if ($show_read_more_button) { ?>
|
117 |
<tr>
|
118 |
+
<td align="<?php echo $align_left ?>" inline-class="button">
|
|
|
119 |
<?php echo TNP_Composer::button($button_options) ?>
|
|
|
120 |
</td>
|
121 |
</tr>
|
122 |
<?php } ?>
|
emails/blocks/posts/layout-two.php
CHANGED
@@ -30,6 +30,17 @@ $column_width = $total_width / 2 - 20;
|
|
30 |
padding: 10px 0 0 0;
|
31 |
font-style: italic;
|
32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
</style>
|
35 |
|
@@ -60,7 +71,7 @@ $column_width = $total_width / 2 - 20;
|
|
60 |
$button_options['button_url'] = tnp_post_permalink($row[0]);
|
61 |
?>
|
62 |
<tr>
|
63 |
-
<td
|
64 |
|
65 |
|
66 |
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
@@ -101,15 +112,15 @@ $column_width = $total_width / 2 - 20;
|
|
101 |
</tr>
|
102 |
<?php if ($show_read_more_button) { ?>
|
103 |
<tr>
|
104 |
-
<td align="center">
|
105 |
-
|
106 |
</td>
|
107 |
</tr>
|
108 |
<?php } ?>
|
109 |
</table>
|
110 |
</td>
|
111 |
|
112 |
-
<td
|
113 |
<?php
|
114 |
if (isset($row[1])) {
|
115 |
|
@@ -132,7 +143,7 @@ $column_width = $total_width / 2 - 20;
|
|
132 |
$meta[] = $author_object->display_name;
|
133 |
}
|
134 |
}
|
135 |
-
|
136 |
$button_options['button_url'] = tnp_post_permalink($row[1]);
|
137 |
?>
|
138 |
|
@@ -173,8 +184,8 @@ $column_width = $total_width / 2 - 20;
|
|
173 |
</tr>
|
174 |
<?php if ($show_read_more_button) { ?>
|
175 |
<tr>
|
176 |
-
<td align="center">
|
177 |
-
|
178 |
</td>
|
179 |
</tr>
|
180 |
<?php } ?>
|
30 |
padding: 10px 0 0 0;
|
31 |
font-style: italic;
|
32 |
}
|
33 |
+
.button {
|
34 |
+
padding: 15px 0;
|
35 |
+
}
|
36 |
+
.column-left {
|
37 |
+
padding-right: 10px;
|
38 |
+
padding-bottom: 20px;
|
39 |
+
}
|
40 |
+
.column-right {
|
41 |
+
padding-left: 10px;
|
42 |
+
padding-bottom: 20px;
|
43 |
+
}
|
44 |
|
45 |
</style>
|
46 |
|
71 |
$button_options['button_url'] = tnp_post_permalink($row[0]);
|
72 |
?>
|
73 |
<tr>
|
74 |
+
<td inline-class="column-left" width="50%" valign="top" class="responsive">
|
75 |
|
76 |
|
77 |
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
112 |
</tr>
|
113 |
<?php if ($show_read_more_button) { ?>
|
114 |
<tr>
|
115 |
+
<td align="center" inline-class="button">
|
116 |
+
<?php echo TNP_Composer::button($button_options) ?>
|
117 |
</td>
|
118 |
</tr>
|
119 |
<?php } ?>
|
120 |
</table>
|
121 |
</td>
|
122 |
|
123 |
+
<td inline-class="column-right" width="50%" valign="top" class="responsive">
|
124 |
<?php
|
125 |
if (isset($row[1])) {
|
126 |
|
143 |
$meta[] = $author_object->display_name;
|
144 |
}
|
145 |
}
|
146 |
+
|
147 |
$button_options['button_url'] = tnp_post_permalink($row[1]);
|
148 |
?>
|
149 |
|
184 |
</tr>
|
185 |
<?php if ($show_read_more_button) { ?>
|
186 |
<tr>
|
187 |
+
<td align="center" inline-class="button">
|
188 |
+
<?php echo TNP_Composer::button($button_options) ?>
|
189 |
</td>
|
190 |
</tr>
|
191 |
<?php } ?>
|
emails/blocks/preheader/options.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
/* @var $fields NewsletterFields */
|
4 |
?>
|
|
|
5 |
|
6 |
<?php $fields->text('text', __('Text', 'newsletter')) ?>
|
7 |
<?php $fields->text('view', __('View online', 'newsletter')) ?>
|
2 |
|
3 |
/* @var $fields NewsletterFields */
|
4 |
?>
|
5 |
+
<p>Obsolete: use the snippet global option instead.</p>
|
6 |
|
7 |
<?php $fields->text('text', __('Text', 'newsletter')) ?>
|
8 |
<?php $fields->text('view', __('View online', 'newsletter')) ?>
|
emails/blocks/separator/block.php
CHANGED
@@ -24,7 +24,7 @@ $options = array_merge($default_options, $options);
|
|
24 |
?>
|
25 |
|
26 |
|
27 |
-
<table border="0" cellpadding="0"
|
28 |
<tr>
|
29 |
<td style="border-bottom: <?php echo $options['height'] ?>px solid <?php echo $options['color'] ?>;"></td>
|
30 |
</tr>
|
24 |
?>
|
25 |
|
26 |
|
27 |
+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
28 |
<tr>
|
29 |
<td style="border-bottom: <?php echo $options['height'] ?>px solid <?php echo $options['color'] ?>;"></td>
|
30 |
</tr>
|
emails/blocks/social/block.php
CHANGED
@@ -33,12 +33,17 @@ if (!$valid_socials) {
|
|
33 |
return;
|
34 |
}
|
35 |
?>
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
37 |
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="responsive">
|
38 |
<tr>
|
39 |
-
<td align="center" valign="middle"
|
40 |
<?php foreach ($valid_socials as &$social) { ?>
|
41 |
-
<a href="<?php echo esc_url($block_options[$social . '_url']) ?>"><img src="<?php echo $social_icon_url ?>/<?php echo $social ?>.png" alt="<?php echo $social ?>"></a
|
42 |
<?php } ?>
|
43 |
</td>
|
44 |
</tr>
|
33 |
return;
|
34 |
}
|
35 |
?>
|
36 |
+
<style>
|
37 |
+
.link {
|
38 |
+
line-height: normal;
|
39 |
+
text-decoration: none;
|
40 |
+
}
|
41 |
+
</style>
|
42 |
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="responsive">
|
43 |
<tr>
|
44 |
+
<td align="center" valign="middle">
|
45 |
<?php foreach ($valid_socials as &$social) { ?>
|
46 |
+
<a href="<?php echo esc_url($block_options[$social . '_url']) ?>" inline-class="link"><img src="<?php echo $social_icon_url ?>/<?php echo $social ?>.png" alt="<?php echo $social ?>"></a>
|
47 |
<?php } ?>
|
48 |
</td>
|
49 |
</tr>
|
emails/emails.php
CHANGED
@@ -2,224 +2,217 @@
|
|
2 |
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
-
class NewsletterEmails extends NewsletterModule
|
6 |
-
{
|
7 |
-
|
8 |
-
static $instance;
|
9 |
-
|
10 |
-
const EDITOR_COMPOSER = 2;
|
11 |
-
const EDITOR_HTML = 1;
|
12 |
-
const EDITOR_TINYMCE = 0;
|
13 |
-
|
14 |
-
static $PRESETS_LIST;
|
15 |
-
const PRESET_EMAIL_TYPE = 'composer_template';
|
16 |
-
|
17 |
-
// Cache
|
18 |
-
var $blocks = null;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @return NewsletterEmails
|
22 |
-
*/
|
23 |
-
static function instance() {
|
24 |
-
if ( self::$instance == null ) {
|
25 |
-
self::$instance = new NewsletterEmails();
|
26 |
-
}
|
27 |
-
|
28 |
-
return self::$instance;
|
29 |
-
}
|
30 |
-
|
31 |
-
function __construct() {
|
32 |
-
self::$PRESETS_LIST = array( "cta", "invite", "announcement", "posts", "sales", "product", "tour", "simple" );
|
33 |
-
$this->themes = new NewsletterThemes( 'emails' );
|
34 |
-
parent::__construct( 'emails', '1.1.5' );
|
35 |
-
add_action( 'newsletter_action', array( $this, 'hook_newsletter_action' ), 13, 3 );
|
36 |
-
|
37 |
-
if ( is_admin() ) {
|
38 |
-
add_action( 'wp_ajax_tnpc_render', array( $this, 'tnpc_render_callback' ) );
|
39 |
-
add_action( 'wp_ajax_tnpc_preview', array( $this, 'tnpc_preview_callback' ) );
|
40 |
-
add_action( 'wp_ajax_tnpc_css', array( $this, 'tnpc_css_callback' ) );
|
41 |
-
add_action( 'wp_ajax_tnpc_options', array( $this, 'hook_wp_ajax_tnpc_options' ) );
|
42 |
-
add_action( 'wp_ajax_tnpc_get_all_presets', array( $this, 'ajax_get_all_presets' ) );
|
43 |
-
add_action( 'wp_ajax_tnpc_get_preset', array( $this, 'ajax_get_preset' ) );
|
44 |
-
add_action( 'wp_ajax_tnpc_delete_preset', array( $this, 'hook_wp_ajax_tnpc_delete_preset' ) );
|
45 |
-
add_action( 'wp_ajax_tnpc_regenerate_email', array( $this, 'hook_wp_ajax_tnpc_regenerate_email' ) );
|
46 |
-
|
47 |
-
// Thank you to plugins which add the WP editor on other admin plugin pages...
|
48 |
-
if ( isset( $_GET['page'] ) && $_GET['page'] == 'newsletter_emails_edit' ) {
|
49 |
-
global $wp_actions;
|
50 |
-
$wp_actions['wp_enqueue_editor'] = 1;
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
function options_decode( $options ) {
|
56 |
-
|
57 |
-
// Start compatibility
|
58 |
-
if ( is_string( $options ) && strpos( $options, 'options[' ) !== false ) {
|
59 |
-
$opts = array();
|
60 |
-
parse_str( $options, $opts );
|
61 |
-
$options = $opts['options'];
|
62 |
-
}
|
63 |
-
// End compatibility
|
64 |
-
|
65 |
-
if ( is_array( $options ) ) {
|
66 |
-
return $options;
|
67 |
-
}
|
68 |
-
|
69 |
-
$tmp = json_decode( $options, true );
|
70 |
-
if ( is_null( $tmp ) ) {
|
71 |
-
return json_decode( base64_decode( $options ), true );
|
72 |
-
} else {
|
73 |
-
return $tmp;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
*
|
79 |
-
* @param array $options Options array
|
80 |
-
*/
|
81 |
-
function options_encode( $options ) {
|
82 |
-
return base64_encode( json_encode( $options, JSON_HEX_TAG | JSON_HEX_AMP ) );
|
83 |
-
}
|
84 |
-
|
85 |
-
function hook_wp_ajax_tnpc_options() {
|
86 |
-
global $wpdb;
|
87 |
-
|
88 |
-
// TODO: Uniform to use id everywhere
|
89 |
-
if ( ! isset( $_REQUEST['id'] ) ) {
|
90 |
-
$_REQUEST['id'] = $_REQUEST['b'];
|
91 |
-
}
|
92 |
-
|
93 |
-
$block = $this->get_block( $_REQUEST['id'] );
|
94 |
-
if ( ! $block ) {
|
95 |
-
die( 'Block not found with id ' . esc_html( $_REQUEST['id'] ) );
|
96 |
-
}
|
97 |
-
|
98 |
-
if ( ! class_exists( 'NewsletterControls' ) ) {
|
99 |
-
include NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
100 |
-
}
|
101 |
-
|
102 |
-
$options = $this->options_decode( stripslashes_deep( $_REQUEST['options'] ) );
|
103 |
-
$composer = isset( $_POST['composer'] ) ? $_POST['composer'] : [];
|
104 |
-
|
105 |
-
$context = array( 'type' => '' );
|
106 |
-
if ( isset( $_REQUEST['context_type'] ) ) {
|
107 |
-
$context['type'] = $_REQUEST['context_type'];
|
108 |
-
}
|
109 |
-
|
110 |
-
$controls = new NewsletterControls( $options );
|
111 |
-
$fields = new NewsletterFields( $controls );
|
112 |
-
|
113 |
-
$controls->init();
|
114 |
-
echo '<input type="hidden" name="action" value="tnpc_render">';
|
115 |
-
echo '<input type="hidden" name="b" value="' . esc_attr( $_REQUEST['id'] ) . '">';
|
116 |
-
echo '<input type="hidden" name="context_type" value="' . esc_attr( $context['type'] ) . '">';
|
117 |
-
$inline_edits = '';
|
118 |
-
if ( isset( $controls->data['inline_edits'] ) ) {
|
119 |
-
$inline_edits = $controls->data['inline_edits'];
|
120 |
-
}
|
121 |
-
echo '<input type="hidden" name="options[inline_edits]" value="' . $this->options_encode( $inline_edits ) . '">';
|
122 |
-
|
123 |
-
ob_start();
|
124 |
-
include $block['dir'] . '/options.php';
|
125 |
-
$content = ob_get_clean();
|
126 |
-
echo "<h2>", esc_html( $block["name"] ), "</h2>";
|
127 |
-
echo $content;
|
128 |
-
wp_die();
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Retrieves the presets list (no id in GET) or a specific preset id in GET)
|
133 |
-
*/
|
134 |
-
public function ajax_get_all_presets() {
|
135 |
-
wp_send_json_success( $this->get_all_preset() );
|
136 |
-
}
|
137 |
-
|
138 |
-
public function ajax_get_preset() {
|
139 |
-
|
140 |
-
if ( empty( $_REQUEST['id'] ) ) {
|
141 |
-
wp_send_json_error( [
|
142 |
-
'msg' => __( 'Invalid preset ID' )
|
143 |
-
] );
|
144 |
-
}
|
145 |
-
|
146 |
-
$preset_id = $_REQUEST['id'];
|
147 |
-
$preset_content = $this->get_preset_content( $preset_id );
|
148 |
-
$global_options = $this->get_preset_global_options( $preset_id );
|
149 |
-
|
150 |
-
wp_send_json_success( [
|
151 |
-
'content' => $preset_content,
|
152 |
-
'globalOptions' => $global_options,
|
153 |
-
] );
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
private function get_preset_content( $preset_id ) {
|
158 |
-
|
159 |
-
$content = '';
|
160 |
-
|
161 |
-
if ( $this->is_a_tnp_default_preset( $preset_id ) ) {
|
162 |
-
|
163 |
-
// Get preset from file
|
164 |
-
$preset = $this->get_preset_from_file( $preset_id );
|
165 |
-
|
166 |
-
foreach ( $preset->blocks as $item ) {
|
167 |
-
ob_start();
|
168 |
-
$this->render_block( $item->block, true, (array) $item->options );
|
169 |
-
$content .= trim( ob_get_clean() );
|
170 |
-
}
|
171 |
-
|
172 |
-
} else {
|
173 |
|
174 |
-
|
175 |
-
$preset_email = $this->get_email( intval( $preset_id ) );
|
176 |
-
$global_options = $this->extract_global_options_from( $preset_email );
|
177 |
-
$content = $this->regenerate_email_blocks( $preset_email->message, $global_options );
|
178 |
|
179 |
-
|
|
|
|
|
180 |
|
181 |
-
|
182 |
|
183 |
-
|
184 |
|
185 |
-
|
|
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
-
|
196 |
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
-
|
200 |
-
$global_options = [];
|
201 |
-
foreach ( $email->options as $global_option_name => $global_option ) {
|
202 |
-
if ( strpos( $global_option_name, 'composer_' ) === 0 ) {
|
203 |
-
$global_options[ str_replace( 'composer_', '', $global_option_name ) ] = $global_option;
|
204 |
-
}
|
205 |
-
}
|
206 |
|
207 |
-
|
208 |
-
}
|
209 |
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
return in_array($preset_id, self::$PRESETS_LIST);
|
213 |
}
|
214 |
|
215 |
-
private function get_all_preset()
|
216 |
-
{
|
217 |
|
218 |
$content = "<div class='tnpc-preset-container'>";
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
|
224 |
// LOAD USER PRESETS
|
225 |
$user_preset_list = $this->get_emails(self::PRESET_EMAIL_TYPE);
|
@@ -232,9 +225,9 @@ class NewsletterEmails extends NewsletterModule
|
|
232 |
$edit_preset_text = __('Edit', 'newsletter');
|
233 |
|
234 |
// esc_js() assumes the string will be in single quote (arghhh!!!)
|
235 |
-
$onclick_edit = 'tnpc_edit_preset(' . ((int)$user_preset->id) . ', \'' . esc_js($preset_name) . '\', event)';
|
236 |
-
$onclick_delete = 'tnpc_delete_preset(' . ((int)$user_preset->id) . ', \'' . esc_js($preset_name) . '\', event)';
|
237 |
-
$onclick_load = 'tnpc_load_preset(' . ((int)$user_preset->id) . ', \'' . esc_js($preset_name) . '\', event)';
|
238 |
|
239 |
$content .= "<div class='tnpc-preset' onclick='" . esc_attr($onclick_load) . "'>\n";
|
240 |
$content .= "<img src='$default_icon_url' title='" . esc_attr($preset_name) . "' alt='" . esc_attr($preset_name) . "'>\n";
|
@@ -242,7 +235,6 @@ class NewsletterEmails extends NewsletterModule
|
|
242 |
$content .= "<span class='tnpc-delete-preset' onclick='" . esc_attr($onclick_delete) . "' title='" . esc_attr($delete_preset_text) . "'><i class='fas fa-times'></i></span>\n";
|
243 |
$content .= "<span class='tnpc-edit-preset' onclick='" . esc_attr($onclick_edit) . "' title='" . esc_attr($edit_preset_text) . "'><i class='fas fa-pencil-alt'></i></span>\n";
|
244 |
$content .= "</div>";
|
245 |
-
|
246 |
}
|
247 |
|
248 |
// LOAD TNP PRESETS
|
@@ -255,68 +247,67 @@ class NewsletterEmails extends NewsletterModule
|
|
255 |
$content .= "</div>";
|
256 |
}
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
|
264 |
return $content;
|
|
|
265 |
|
|
|
|
|
266 |
}
|
267 |
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$result .= "</div>";
|
317 |
-
|
318 |
-
return $result;
|
319 |
-
}
|
320 |
|
321 |
/**
|
322 |
* Check if the preset name exists and adds an incremental suffix if the name exists.
|
@@ -325,22 +316,20 @@ class NewsletterEmails extends NewsletterModule
|
|
325 |
*
|
326 |
* @return string
|
327 |
*/
|
328 |
-
public function sanitize_preset_name($name)
|
329 |
-
{
|
330 |
global $wpdb;
|
331 |
|
332 |
$name = empty($name) ? __('Empty name preset', 'newsletter') : $name;
|
333 |
$name = sanitize_text_field($name);
|
334 |
$type = self::PRESET_EMAIL_TYPE;
|
335 |
-
$count = (int)$wpdb->get_var("SELECT COUNT(*) FROM " . NEWSLETTER_EMAILS_TABLE . " WHERE type='$type' and subject='$name'");
|
336 |
|
337 |
$name = $count > 0 ? $name . " - " . ($count + 1) : $name;
|
338 |
|
339 |
return $name;
|
340 |
}
|
341 |
|
342 |
-
function has_dynamic_blocks($theme)
|
343 |
-
{
|
344 |
preg_match_all('/data-json="(.*?)"/m', $theme, $matches, PREG_PATTERN_ORDER);
|
345 |
foreach ($matches[1] as $match) {
|
346 |
$a = html_entity_decode($match, ENT_QUOTES, 'UTF-8');
|
@@ -369,8 +358,7 @@ class NewsletterEmails extends NewsletterModule
|
|
369 |
* @param TNP_Email $email (Rinominare)
|
370 |
* @return string
|
371 |
*/
|
372 |
-
function regenerate($email, $context = [])
|
373 |
-
{
|
374 |
|
375 |
// Cannot be removed due to compatibility issues with old Automated versions
|
376 |
if (is_object($email)) {
|
@@ -438,7 +426,7 @@ class NewsletterEmails extends NewsletterModule
|
|
438 |
$x = strpos($theme, '>', $x);
|
439 |
$result = substr($theme, 0, $x + 1) . $result . '</body></html>';
|
440 |
} else {
|
441 |
-
|
442 |
}
|
443 |
|
444 |
if (is_object($email)) {
|
@@ -451,24 +439,20 @@ class NewsletterEmails extends NewsletterModule
|
|
451 |
return array('body' => $result, 'subject' => $subject);
|
452 |
}
|
453 |
|
454 |
-
function remove_block_data($text)
|
455 |
-
{
|
456 |
// TODO: Lavorare!
|
457 |
return $text;
|
458 |
}
|
459 |
|
460 |
-
static function get_outlook_wrapper_open($width = 600)
|
461 |
-
{
|
462 |
return '<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" align="center" cellspacing="0" width="' . $width . '"><tr><td width="' . $width . '" style="vertical-align:top;width:' . $width . 'px;"><![endif]-->';
|
463 |
}
|
464 |
|
465 |
-
static function get_outlook_wrapper_close()
|
466 |
-
{
|
467 |
return "<!--[if mso | IE]></td></tr></table><![endif]-->";
|
468 |
}
|
469 |
|
470 |
-
function hook_safe_style_css($rules)
|
471 |
-
{
|
472 |
$rules[] = 'display';
|
473 |
return $rules;
|
474 |
}
|
@@ -483,8 +467,7 @@ class NewsletterEmails extends NewsletterModule
|
|
483 |
* @param array $context
|
484 |
* @param array $composer
|
485 |
*/
|
486 |
-
function render_block($block_id = null, $wrapper = false, $options = [], $context = [], $composer = [])
|
487 |
-
{
|
488 |
static $kses_style_filter = false;
|
489 |
include_once NEWSLETTER_INCLUDES_DIR . '/helper.php';
|
490 |
|
@@ -576,7 +559,9 @@ class NewsletterEmails extends NewsletterModule
|
|
576 |
'block_padding_right' => 0,
|
577 |
'block_padding_left' => 0,
|
578 |
'block_background' => '',
|
579 |
-
'block_background_2' => ''
|
|
|
|
|
580 |
);
|
581 |
|
582 |
$options = array_merge($common_defaults, $options);
|
@@ -590,16 +575,18 @@ class NewsletterEmails extends NewsletterModule
|
|
590 |
// Requited for the server side parsing and rendering
|
591 |
$options['block_id'] = $block_id;
|
592 |
|
593 |
-
$options['block_padding_top'] = (int)str_replace('px', '', $options['block_padding_top']);
|
594 |
-
$options['block_padding_bottom'] = (int)str_replace('px', '', $options['block_padding_bottom']);
|
595 |
-
$options['block_padding_right'] = (int)str_replace('px', '', $options['block_padding_right']);
|
596 |
-
$options['block_padding_left'] = (int)str_replace('px', '', $options['block_padding_left']);
|
597 |
|
598 |
$block_background = empty($options['block_background']) ? $global_block_background : $options['block_background'];
|
599 |
|
600 |
// Internal TD wrapper
|
601 |
$style = 'text-align: center; ';
|
602 |
-
$style .= 'width: 100
|
|
|
|
|
603 |
$style .= 'padding-top: ' . $options['block_padding_top'] . 'px; ';
|
604 |
$style .= 'padding-left: ' . $options['block_padding_left'] . 'px; ';
|
605 |
$style .= 'padding-right: ' . $options['block_padding_right'] . 'px; ';
|
@@ -619,11 +606,11 @@ class NewsletterEmails extends NewsletterModule
|
|
619 |
}
|
620 |
|
621 |
// Container that fixes the width and makes the block responsive
|
622 |
-
echo $this->get_outlook_wrapper_open($
|
623 |
|
624 |
-
echo '<table type="options" data-json="', esc_attr($data), '" class="tnpc-block-content" border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: ', $
|
625 |
echo "<tr>";
|
626 |
-
echo '<td align="
|
627 |
|
628 |
//echo "<!-- block generated content -->\n";
|
629 |
echo trim($content);
|
@@ -647,8 +634,7 @@ class NewsletterEmails extends NewsletterModule
|
|
647 |
* @param type $block_id
|
648 |
* @param type $wrapper
|
649 |
*/
|
650 |
-
function tnpc_render_callback()
|
651 |
-
{
|
652 |
if (!check_ajax_referer('save')) {
|
653 |
$this->dienow('Expired request');
|
654 |
}
|
@@ -661,8 +647,7 @@ class NewsletterEmails extends NewsletterModule
|
|
661 |
wp_die();
|
662 |
}
|
663 |
|
664 |
-
function hook_wp_ajax_tnpc_regenerate_email()
|
665 |
-
{
|
666 |
|
667 |
$content = stripslashes($_POST['content']);
|
668 |
$global_options = $_POST['composer'];
|
@@ -673,11 +658,9 @@ class NewsletterEmails extends NewsletterModule
|
|
673 |
'content' => $regenerated_content,
|
674 |
'message' => __('Successfully updated', 'newsletter')
|
675 |
]);
|
676 |
-
|
677 |
}
|
678 |
|
679 |
-
private function regenerate_email_blocks($content, $global_options)
|
680 |
-
{
|
681 |
|
682 |
$raw_block_options = $this->extract_encoded_blocks_options($content);
|
683 |
|
@@ -685,8 +668,8 @@ class NewsletterEmails extends NewsletterModule
|
|
685 |
|
686 |
foreach ($raw_block_options as $raw_block_option) {
|
687 |
|
688 |
-
/*
|
689 |
-
|
690 |
|
691 |
$block_options = $this->options_decode($raw_block_option);
|
692 |
|
@@ -703,7 +686,6 @@ class NewsletterEmails extends NewsletterModule
|
|
703 |
}
|
704 |
|
705 |
return $regenerated_content;
|
706 |
-
|
707 |
}
|
708 |
|
709 |
/**
|
@@ -711,17 +693,14 @@ class NewsletterEmails extends NewsletterModule
|
|
711 |
*
|
712 |
* @return string[] Encoded options of email blocks
|
713 |
*/
|
714 |
-
private function extract_encoded_blocks_options($html_email_content)
|
715 |
-
{
|
716 |
|
717 |
preg_match_all('/data-json="(.*?)"/m', $html_email_content, $raw_block_options, PREG_PATTERN_ORDER);
|
718 |
|
719 |
return $raw_block_options[1];
|
720 |
-
|
721 |
}
|
722 |
|
723 |
-
function tnpc_preview_callback()
|
724 |
-
{
|
725 |
$email = Newsletter::instance()->get_email($_REQUEST['id'], ARRAY_A);
|
726 |
|
727 |
if (empty($email)) {
|
@@ -734,15 +713,13 @@ class NewsletterEmails extends NewsletterModule
|
|
734 |
wp_die();
|
735 |
}
|
736 |
|
737 |
-
function tnpc_css_callback()
|
738 |
-
{
|
739 |
include NEWSLETTER_DIR . '/emails/tnp-composer/css/newsletter.css';
|
740 |
wp_die();
|
741 |
}
|
742 |
|
743 |
/** Returns the correct admin page to edit the newsletter with the correct editor. */
|
744 |
-
function get_editor_url($email_id, $editor_type)
|
745 |
-
{
|
746 |
switch ($editor_type) {
|
747 |
case NewsletterEmails::EDITOR_COMPOSER:
|
748 |
return admin_url("admin.php") . '?page=newsletter_emails_composer&id=' . $email_id;
|
@@ -759,8 +736,7 @@ class NewsletterEmails extends NewsletterModule
|
|
759 |
*
|
760 |
* @param TNP_Email $email
|
761 |
*/
|
762 |
-
function get_edit_button($email, $only_icon = false)
|
763 |
-
{
|
764 |
|
765 |
$editor_type = $this->get_editor_type($email);
|
766 |
if ($email->status == 'new') {
|
@@ -781,18 +757,16 @@ class NewsletterEmails extends NewsletterModule
|
|
781 |
}
|
782 |
if ($only_icon) {
|
783 |
return '<a class="button-primary" href="' . $edit_url . '" title="' . esc_attr__('Edit', 'newsletter') . '">' .
|
784 |
-
|
785 |
-
|
786 |
} else {
|
787 |
return '<a class="button-primary" href="' . $edit_url . '" title="' . esc_attr__('Edit', 'newsletter') . '">' .
|
788 |
-
|
789 |
}
|
790 |
}
|
791 |
|
792 |
/** Returns the correct editor type for the provided newsletter. Contains backward compatibility code. */
|
793 |
-
function get_editor_type($email)
|
794 |
-
|
795 |
-
$email = (object)$email;
|
796 |
$editor_type = $email->editor;
|
797 |
|
798 |
// Backward compatibility
|
@@ -813,8 +787,7 @@ class NewsletterEmails extends NewsletterModule
|
|
813 |
* @return type
|
814 |
* @global wpdb $wpdb
|
815 |
*/
|
816 |
-
function hook_newsletter_action($action, $user, $email)
|
817 |
-
{
|
818 |
global $wpdb;
|
819 |
|
820 |
switch ($action) {
|
@@ -862,7 +835,7 @@ class NewsletterEmails extends NewsletterModule
|
|
862 |
break;
|
863 |
|
864 |
case 'emails-css':
|
865 |
-
$email_id = (int)$_GET['id'];
|
866 |
|
867 |
$body = Newsletter::instance()->get_email_field($email_id, 'message');
|
868 |
|
@@ -998,8 +971,7 @@ class NewsletterEmails extends NewsletterModule
|
|
998 |
}
|
999 |
}
|
1000 |
|
1001 |
-
function admin_menu()
|
1002 |
-
{
|
1003 |
$this->add_menu_page('index', 'Newsletters');
|
1004 |
$this->add_admin_page('list', 'Email List');
|
1005 |
$this->add_admin_page('new', 'Email New');
|
@@ -1017,8 +989,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1017 |
* @param string $dir
|
1018 |
* @return array | WP_Error
|
1019 |
*/
|
1020 |
-
function build_block($dir)
|
1021 |
-
{
|
1022 |
$file = basename($dir);
|
1023 |
$block_id = sanitize_key($file);
|
1024 |
$full_file = $dir . '/block.php';
|
@@ -1053,8 +1024,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1053 |
* @param type $dir
|
1054 |
* @return type
|
1055 |
*/
|
1056 |
-
function scan_blocks_dir($dir)
|
1057 |
-
{
|
1058 |
|
1059 |
if (!is_dir($dir)) {
|
1060 |
return array();
|
@@ -1086,8 +1056,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1086 |
*
|
1087 |
* @return array
|
1088 |
*/
|
1089 |
-
function get_blocks()
|
1090 |
-
{
|
1091 |
|
1092 |
if (!is_null($this->blocks)) {
|
1093 |
return $this->blocks;
|
@@ -1135,8 +1104,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1135 |
* @param string $id
|
1136 |
* @return array
|
1137 |
*/
|
1138 |
-
function get_block($id)
|
1139 |
-
{
|
1140 |
switch ($id) {
|
1141 |
case 'content-03-text.block':
|
1142 |
$id = 'text';
|
@@ -1184,8 +1152,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1184 |
return $blocks[$id];
|
1185 |
}
|
1186 |
|
1187 |
-
function scan_presets_dir($dir = null)
|
1188 |
-
{
|
1189 |
|
1190 |
if (is_null($dir)) {
|
1191 |
$dir = __DIR__ . '/presets';
|
@@ -1220,8 +1187,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1220 |
return $list;
|
1221 |
}
|
1222 |
|
1223 |
-
function get_preset_from_file($id, $dir = null)
|
1224 |
-
{
|
1225 |
|
1226 |
if (is_null($dir)) {
|
1227 |
$dir = __DIR__ . '/presets';
|
@@ -1241,8 +1207,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1241 |
return $json;
|
1242 |
}
|
1243 |
|
1244 |
-
function get_composer_css()
|
1245 |
-
{
|
1246 |
$css = file_get_contents(__DIR__ . '/tnp-composer/css/newsletter.css');
|
1247 |
$blocks = $this->get_blocks();
|
1248 |
foreach ($blocks as $block) {
|
@@ -1262,8 +1227,7 @@ class NewsletterEmails extends NewsletterModule
|
|
1262 |
* @param TNP_Email $email Could be any object with the TNP_Email attributes
|
1263 |
* @param NewsletterControls $controls
|
1264 |
*/
|
1265 |
-
function send_test_email($email, $controls)
|
1266 |
-
{
|
1267 |
if (!$email) {
|
1268 |
$controls->errors = __('Newsletter should be saved before send a test', 'newsletter');
|
1269 |
return;
|
@@ -1278,8 +1242,8 @@ class NewsletterEmails extends NewsletterModule
|
|
1278 |
$users = NewsletterUsers::instance()->get_test_users();
|
1279 |
if (count($users) == 0) {
|
1280 |
$controls->errors = '' . __('There are no test subscribers to send to', 'newsletter') .
|
1281 |
-
|
1282 |
-
|
1283 |
} else {
|
1284 |
$r = Newsletter::instance()->send($email, $users, true);
|
1285 |
$emails = array();
|
@@ -1299,15 +1263,14 @@ class NewsletterEmails extends NewsletterModule
|
|
1299 |
$controls->messages .= ' ' . implode(', ', $emails);
|
1300 |
$controls->messages .= '.<br>';
|
1301 |
$controls->messages .= '<a href="https://www.thenewsletterplugin.com/documentation/subscribers#test" target="_blank"><strong>' .
|
1302 |
-
|
1303 |
$controls->messages .= '<a href="https://www.thenewsletterplugin.com/documentation/email-sending-issues" target="_blank"><strong>' . __('Read more about delivery issues', 'newsletter') . '</strong></a>.';
|
1304 |
}
|
1305 |
}
|
1306 |
$email->subject = $original_subject;
|
1307 |
}
|
1308 |
|
1309 |
-
function restore_options_from_request()
|
1310 |
-
{
|
1311 |
|
1312 |
if (isset($_POST['options']) && is_array($_POST['options'])) {
|
1313 |
// Get all block options
|
@@ -1350,14 +1313,13 @@ class NewsletterEmails extends NewsletterModule
|
|
1350 |
return array();
|
1351 |
}
|
1352 |
|
1353 |
-
public function hook_wp_ajax_tnpc_delete_preset()
|
1354 |
-
{
|
1355 |
|
1356 |
if (!wp_verify_nonce($_POST['_wpnonce'], 'preset')) {
|
1357 |
wp_send_json_error('Expired request');
|
1358 |
}
|
1359 |
|
1360 |
-
$preset_id = (int)$_REQUEST['presetId'];
|
1361 |
|
1362 |
$newsletter = Newsletter::instance();
|
1363 |
|
@@ -1370,11 +1332,9 @@ class NewsletterEmails extends NewsletterModule
|
|
1370 |
} else {
|
1371 |
wp_send_json_error(__('Is not a preset!', 'newsletter'));
|
1372 |
}
|
1373 |
-
|
1374 |
} else {
|
1375 |
wp_send_json_error();
|
1376 |
}
|
1377 |
-
|
1378 |
}
|
1379 |
|
1380 |
}
|
2 |
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
class NewsletterEmails extends NewsletterModule {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
static $instance;
|
|
|
|
|
|
|
8 |
|
9 |
+
const EDITOR_COMPOSER = 2;
|
10 |
+
const EDITOR_HTML = 1;
|
11 |
+
const EDITOR_TINYMCE = 0;
|
12 |
|
13 |
+
static $PRESETS_LIST;
|
14 |
|
15 |
+
const PRESET_EMAIL_TYPE = 'composer_template';
|
16 |
|
17 |
+
// Cache
|
18 |
+
var $blocks = null;
|
19 |
|
20 |
+
/**
|
21 |
+
* @return NewsletterEmails
|
22 |
+
*/
|
23 |
+
static function instance() {
|
24 |
+
if (self::$instance == null) {
|
25 |
+
self::$instance = new NewsletterEmails();
|
26 |
+
}
|
27 |
+
|
28 |
+
return self::$instance;
|
29 |
+
}
|
30 |
+
|
31 |
+
function __construct() {
|
32 |
+
self::$PRESETS_LIST = array("cta", "invite", "announcement", "posts", "sales", "product", "tour", "simple");
|
33 |
+
$this->themes = new NewsletterThemes('emails');
|
34 |
+
parent::__construct('emails', '1.1.5');
|
35 |
+
add_action('newsletter_action', array($this, 'hook_newsletter_action'), 13, 3);
|
36 |
+
|
37 |
+
if (is_admin()) {
|
38 |
+
add_action('wp_ajax_tnpc_render', array($this, 'tnpc_render_callback'));
|
39 |
+
add_action('wp_ajax_tnpc_preview', array($this, 'tnpc_preview_callback'));
|
40 |
+
add_action('wp_ajax_tnpc_css', array($this, 'tnpc_css_callback'));
|
41 |
+
add_action('wp_ajax_tnpc_options', array($this, 'hook_wp_ajax_tnpc_options'));
|
42 |
+
add_action('wp_ajax_tnpc_get_all_presets', array($this, 'ajax_get_all_presets'));
|
43 |
+
add_action('wp_ajax_tnpc_get_preset', array($this, 'ajax_get_preset'));
|
44 |
+
add_action('wp_ajax_tnpc_delete_preset', array($this, 'hook_wp_ajax_tnpc_delete_preset'));
|
45 |
+
add_action('wp_ajax_tnpc_regenerate_email', array($this, 'hook_wp_ajax_tnpc_regenerate_email'));
|
46 |
+
|
47 |
+
// Thank you to plugins which add the WP editor on other admin plugin pages...
|
48 |
+
if (isset($_GET['page']) && $_GET['page'] == 'newsletter_emails_edit') {
|
49 |
+
global $wp_actions;
|
50 |
+
$wp_actions['wp_enqueue_editor'] = 1;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
function options_decode($options) {
|
56 |
+
|
57 |
+
// Start compatibility
|
58 |
+
if (is_string($options) && strpos($options, 'options[') !== false) {
|
59 |
+
$opts = array();
|
60 |
+
parse_str($options, $opts);
|
61 |
+
$options = $opts['options'];
|
62 |
+
}
|
63 |
+
// End compatibility
|
64 |
+
|
65 |
+
if (is_array($options)) {
|
66 |
+
return $options;
|
67 |
+
}
|
68 |
+
|
69 |
+
$tmp = json_decode($options, true);
|
70 |
+
if (is_null($tmp)) {
|
71 |
+
return json_decode(base64_decode($options), true);
|
72 |
+
} else {
|
73 |
+
return $tmp;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
*
|
79 |
+
* @param array $options Options array
|
80 |
+
*/
|
81 |
+
function options_encode($options) {
|
82 |
+
return base64_encode(json_encode($options, JSON_HEX_TAG | JSON_HEX_AMP));
|
83 |
+
}
|
84 |
+
|
85 |
+
function hook_wp_ajax_tnpc_options() {
|
86 |
+
global $wpdb;
|
87 |
|
88 |
+
// TODO: Uniform to use id everywhere
|
89 |
+
if (!isset($_REQUEST['id'])) {
|
90 |
+
$_REQUEST['id'] = $_REQUEST['b'];
|
91 |
+
}
|
92 |
+
|
93 |
+
$block = $this->get_block($_REQUEST['id']);
|
94 |
+
if (!$block) {
|
95 |
+
die('Block not found with id ' . esc_html($_REQUEST['id']));
|
96 |
+
}
|
97 |
+
|
98 |
+
if (!class_exists('NewsletterControls')) {
|
99 |
+
include NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
100 |
+
}
|
101 |
+
|
102 |
+
$options = $this->options_decode(stripslashes_deep($_REQUEST['options']));
|
103 |
+
$composer = isset($_POST['composer']) ? $_POST['composer'] : [];
|
104 |
+
|
105 |
+
$context = array('type' => '');
|
106 |
+
if (isset($_REQUEST['context_type'])) {
|
107 |
+
$context['type'] = $_REQUEST['context_type'];
|
108 |
+
}
|
109 |
+
|
110 |
+
$controls = new NewsletterControls($options);
|
111 |
+
$fields = new NewsletterFields($controls);
|
112 |
+
|
113 |
+
$controls->init();
|
114 |
+
echo '<input type="hidden" name="action" value="tnpc_render">';
|
115 |
+
echo '<input type="hidden" name="b" value="' . esc_attr($_REQUEST['id']) . '">';
|
116 |
+
echo '<input type="hidden" name="context_type" value="' . esc_attr($context['type']) . '">';
|
117 |
+
$inline_edits = '';
|
118 |
+
if (isset($controls->data['inline_edits'])) {
|
119 |
+
$inline_edits = $controls->data['inline_edits'];
|
120 |
+
}
|
121 |
+
echo '<input type="hidden" name="options[inline_edits]" value="' . $this->options_encode($inline_edits) . '">';
|
122 |
+
|
123 |
+
ob_start();
|
124 |
+
include $block['dir'] . '/options.php';
|
125 |
+
$content = ob_get_clean();
|
126 |
+
echo "<h2>", esc_html($block["name"]), "</h2>";
|
127 |
+
echo $content;
|
128 |
+
wp_die();
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Retrieves the presets list (no id in GET) or a specific preset id in GET)
|
133 |
+
*/
|
134 |
+
public function ajax_get_all_presets() {
|
135 |
+
wp_send_json_success($this->get_all_preset());
|
136 |
+
}
|
137 |
|
138 |
+
public function ajax_get_preset() {
|
139 |
|
140 |
+
if (empty($_REQUEST['id'])) {
|
141 |
+
wp_send_json_error([
|
142 |
+
'msg' => __('Invalid preset ID')
|
143 |
+
]);
|
144 |
+
}
|
145 |
+
|
146 |
+
$preset_id = $_REQUEST['id'];
|
147 |
+
$preset_content = $this->get_preset_content($preset_id);
|
148 |
+
$global_options = $this->get_preset_global_options($preset_id);
|
149 |
+
|
150 |
+
wp_send_json_success([
|
151 |
+
'content' => $preset_content,
|
152 |
+
'globalOptions' => $global_options,
|
153 |
+
]);
|
154 |
+
}
|
155 |
|
156 |
+
private function get_preset_content($preset_id) {
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
+
$content = '';
|
|
|
159 |
|
160 |
+
if ($this->is_a_tnp_default_preset($preset_id)) {
|
161 |
+
|
162 |
+
// Get preset from file
|
163 |
+
$preset = $this->get_preset_from_file($preset_id);
|
164 |
+
|
165 |
+
foreach ($preset->blocks as $item) {
|
166 |
+
ob_start();
|
167 |
+
$this->render_block($item->block, true, (array) $item->options);
|
168 |
+
$content .= trim(ob_get_clean());
|
169 |
+
}
|
170 |
+
} else {
|
171 |
+
|
172 |
+
// Get preset from db
|
173 |
+
$preset_email = $this->get_email(intval($preset_id));
|
174 |
+
$global_options = $this->extract_global_options_from($preset_email);
|
175 |
+
$content = $this->regenerate_email_blocks($preset_email->message, $global_options);
|
176 |
+
}
|
177 |
+
|
178 |
+
return $content;
|
179 |
+
}
|
180 |
+
|
181 |
+
private function get_preset_global_options($preset_id) {
|
182 |
+
|
183 |
+
if ($this->is_a_tnp_default_preset($preset_id)) {
|
184 |
+
return [];
|
185 |
+
}
|
186 |
+
|
187 |
+
// Get preset from db
|
188 |
+
$preset_email = $this->get_email(intval($preset_id));
|
189 |
+
$global_options = $this->extract_global_options_from($preset_email);
|
190 |
+
|
191 |
+
return $global_options;
|
192 |
+
}
|
193 |
+
|
194 |
+
private function extract_global_options_from($email) {
|
195 |
+
$global_options = [];
|
196 |
+
foreach ($email->options as $global_option_name => $global_option) {
|
197 |
+
if (strpos($global_option_name, 'composer_') === 0) {
|
198 |
+
$global_options[str_replace('composer_', '', $global_option_name)] = $global_option;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
return $global_options;
|
203 |
+
}
|
204 |
+
|
205 |
+
private function is_a_tnp_default_preset($preset_id) {
|
206 |
return in_array($preset_id, self::$PRESETS_LIST);
|
207 |
}
|
208 |
|
209 |
+
private function get_all_preset() {
|
|
|
210 |
|
211 |
$content = "<div class='tnpc-preset-container'>";
|
212 |
|
213 |
+
if ($this->is_normal_context_request()) {
|
214 |
+
$content .= "<div class='tnpc-preset-legacy-themes'><a href='" . $this->get_admin_page_url('theme') . "'>" . __('Looking for legacy themes?', 'newsletter') . "</a></div>";
|
215 |
+
}
|
216 |
|
217 |
// LOAD USER PRESETS
|
218 |
$user_preset_list = $this->get_emails(self::PRESET_EMAIL_TYPE);
|
225 |
$edit_preset_text = __('Edit', 'newsletter');
|
226 |
|
227 |
// esc_js() assumes the string will be in single quote (arghhh!!!)
|
228 |
+
$onclick_edit = 'tnpc_edit_preset(' . ((int) $user_preset->id) . ', \'' . esc_js($preset_name) . '\', event)';
|
229 |
+
$onclick_delete = 'tnpc_delete_preset(' . ((int) $user_preset->id) . ', \'' . esc_js($preset_name) . '\', event)';
|
230 |
+
$onclick_load = 'tnpc_load_preset(' . ((int) $user_preset->id) . ', \'' . esc_js($preset_name) . '\', event)';
|
231 |
|
232 |
$content .= "<div class='tnpc-preset' onclick='" . esc_attr($onclick_load) . "'>\n";
|
233 |
$content .= "<img src='$default_icon_url' title='" . esc_attr($preset_name) . "' alt='" . esc_attr($preset_name) . "'>\n";
|
235 |
$content .= "<span class='tnpc-delete-preset' onclick='" . esc_attr($onclick_delete) . "' title='" . esc_attr($delete_preset_text) . "'><i class='fas fa-times'></i></span>\n";
|
236 |
$content .= "<span class='tnpc-edit-preset' onclick='" . esc_attr($onclick_edit) . "' title='" . esc_attr($edit_preset_text) . "'><i class='fas fa-pencil-alt'></i></span>\n";
|
237 |
$content .= "</div>";
|
|
|
238 |
}
|
239 |
|
240 |
// LOAD TNP PRESETS
|
247 |
$content .= "</div>";
|
248 |
}
|
249 |
|
250 |
+
if ($this->is_normal_context_request()) {
|
251 |
+
$content .= $this->get_automated_spot_element();
|
252 |
+
$content .= $this->get_autoresponder_spot_element();
|
253 |
+
$content .= $this->get_raw_html_preset_element();
|
254 |
+
}
|
255 |
|
256 |
return $content;
|
257 |
+
}
|
258 |
|
259 |
+
private function is_normal_context_request() {
|
260 |
+
return empty($_REQUEST['context_type']);
|
261 |
}
|
262 |
|
263 |
+
private function is_automated_context_request() {
|
264 |
+
return isset($_REQUEST['context_type']) && $_REQUEST['context_type'] === 'automated';
|
265 |
+
}
|
266 |
+
|
267 |
+
private function is_autoresponder_context_request() {
|
268 |
+
return isset($_REQUEST['context_type']) && $_REQUEST['context_type'] === 'autoresponder';
|
269 |
+
}
|
270 |
+
|
271 |
+
private function get_automated_spot_element() {
|
272 |
+
$result = "<div class='tnpc-preset'>";
|
273 |
+
if (class_exists('NewsletterAutomated')) {
|
274 |
+
$result .= "<a href='?page=newsletter_automated_index'>";
|
275 |
+
} else {
|
276 |
+
$result .= "<a href='https://www.thenewsletterplugin.com/automated?utm_source=plugin&utm_campaign=automated&utm_medium=composer'>";
|
277 |
+
}
|
278 |
+
$result .= "<img src='" . plugins_url('newsletter') . "/emails/images/automated.png' title='Automated addon' alt='Automated'/>";
|
279 |
+
$result .= "<span class='tnpc-preset-label'>Daily, weekly and monthly newsletters</span></a>";
|
280 |
+
$result .= "</div>";
|
281 |
+
|
282 |
+
return $result;
|
283 |
+
}
|
284 |
+
|
285 |
+
private function get_autoresponder_spot_element() {
|
286 |
+
$result = "<div class='tnpc-preset'>";
|
287 |
+
if (class_exists('NewsletterAutoresponder')) {
|
288 |
+
$result .= "<a href='?page=newsletter_autoresponder_index'>";
|
289 |
+
} else {
|
290 |
+
$result .= "<a href='https://www.thenewsletterplugin.com/autoresponder?utm_source=plugin&utm_campaign=autoresponder&utm_medium=composer' target='_blank'>";
|
291 |
+
}
|
292 |
+
$result .= "<img src='" . plugins_url('newsletter') . "/emails/images/autoresponder.png' title='Autoresponder addon' alt='Autoresponder'/>";
|
293 |
+
$result .= "<span class='tnpc-preset-label'>Autoresponders</span></a>";
|
294 |
+
$result .= "</div>";
|
295 |
+
|
296 |
+
return $result;
|
297 |
+
}
|
298 |
+
|
299 |
+
private function get_raw_html_preset_element() {
|
300 |
+
|
301 |
+
$result = "<div class='tnpc-preset tnpc-preset-html' onclick='location.href=\"" . wp_nonce_url('admin.php?page=newsletter_emails_new&id=rawhtml', 'newsletter-new') . "\"'>";
|
302 |
+
$result .= "<img src='" . plugins_url('newsletter') . "/emails/images/rawhtml.png' title='RAW HTML' alt='RAW'/>";
|
303 |
+
$result .= "<span class='tnpc-preset-label'>Raw HTML</span>";
|
304 |
+
$result .= "</div>";
|
305 |
+
|
306 |
+
$result .= "<div class='clear'></div>";
|
307 |
+
$result .= "</div>";
|
308 |
+
|
309 |
+
return $result;
|
310 |
+
}
|
|
|
|
|
|
|
|
|
311 |
|
312 |
/**
|
313 |
* Check if the preset name exists and adds an incremental suffix if the name exists.
|
316 |
*
|
317 |
* @return string
|
318 |
*/
|
319 |
+
public function sanitize_preset_name($name) {
|
|
|
320 |
global $wpdb;
|
321 |
|
322 |
$name = empty($name) ? __('Empty name preset', 'newsletter') : $name;
|
323 |
$name = sanitize_text_field($name);
|
324 |
$type = self::PRESET_EMAIL_TYPE;
|
325 |
+
$count = (int) $wpdb->get_var("SELECT COUNT(*) FROM " . NEWSLETTER_EMAILS_TABLE . " WHERE type='$type' and subject='$name'");
|
326 |
|
327 |
$name = $count > 0 ? $name . " - " . ($count + 1) : $name;
|
328 |
|
329 |
return $name;
|
330 |
}
|
331 |
|
332 |
+
function has_dynamic_blocks($theme) {
|
|
|
333 |
preg_match_all('/data-json="(.*?)"/m', $theme, $matches, PREG_PATTERN_ORDER);
|
334 |
foreach ($matches[1] as $match) {
|
335 |
$a = html_entity_decode($match, ENT_QUOTES, 'UTF-8');
|
358 |
* @param TNP_Email $email (Rinominare)
|
359 |
* @return string
|
360 |
*/
|
361 |
+
function regenerate($email, $context = []) {
|
|
|
362 |
|
363 |
// Cannot be removed due to compatibility issues with old Automated versions
|
364 |
if (is_object($email)) {
|
426 |
$x = strpos($theme, '>', $x);
|
427 |
$result = substr($theme, 0, $x + 1) . $result . '</body></html>';
|
428 |
} else {
|
429 |
+
|
430 |
}
|
431 |
|
432 |
if (is_object($email)) {
|
439 |
return array('body' => $result, 'subject' => $subject);
|
440 |
}
|
441 |
|
442 |
+
function remove_block_data($text) {
|
|
|
443 |
// TODO: Lavorare!
|
444 |
return $text;
|
445 |
}
|
446 |
|
447 |
+
static function get_outlook_wrapper_open($width = 600) {
|
|
|
448 |
return '<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" align="center" cellspacing="0" width="' . $width . '"><tr><td width="' . $width . '" style="vertical-align:top;width:' . $width . 'px;"><![endif]-->';
|
449 |
}
|
450 |
|
451 |
+
static function get_outlook_wrapper_close() {
|
|
|
452 |
return "<!--[if mso | IE]></td></tr></table><![endif]-->";
|
453 |
}
|
454 |
|
455 |
+
function hook_safe_style_css($rules) {
|
|
|
456 |
$rules[] = 'display';
|
457 |
return $rules;
|
458 |
}
|
467 |
* @param array $context
|
468 |
* @param array $composer
|
469 |
*/
|
470 |
+
function render_block($block_id = null, $wrapper = false, $options = [], $context = [], $composer = []) {
|
|
|
471 |
static $kses_style_filter = false;
|
472 |
include_once NEWSLETTER_INCLUDES_DIR . '/helper.php';
|
473 |
|
559 |
'block_padding_right' => 0,
|
560 |
'block_padding_left' => 0,
|
561 |
'block_background' => '',
|
562 |
+
'block_background_2' => '',
|
563 |
+
'block_width' => 600,
|
564 |
+
'block_align' => 'center'
|
565 |
);
|
566 |
|
567 |
$options = array_merge($common_defaults, $options);
|
575 |
// Requited for the server side parsing and rendering
|
576 |
$options['block_id'] = $block_id;
|
577 |
|
578 |
+
$options['block_padding_top'] = (int) str_replace('px', '', $options['block_padding_top']);
|
579 |
+
$options['block_padding_bottom'] = (int) str_replace('px', '', $options['block_padding_bottom']);
|
580 |
+
$options['block_padding_right'] = (int) str_replace('px', '', $options['block_padding_right']);
|
581 |
+
$options['block_padding_left'] = (int) str_replace('px', '', $options['block_padding_left']);
|
582 |
|
583 |
$block_background = empty($options['block_background']) ? $global_block_background : $options['block_background'];
|
584 |
|
585 |
// Internal TD wrapper
|
586 |
$style = 'text-align: center; ';
|
587 |
+
$style .= 'width: 100% !important; ';
|
588 |
+
$style .= 'line-height: normal !important; ';
|
589 |
+
$style .= 'letter-spacing: normal; ';
|
590 |
$style .= 'padding-top: ' . $options['block_padding_top'] . 'px; ';
|
591 |
$style .= 'padding-left: ' . $options['block_padding_left'] . 'px; ';
|
592 |
$style .= 'padding-right: ' . $options['block_padding_right'] . 'px; ';
|
606 |
}
|
607 |
|
608 |
// Container that fixes the width and makes the block responsive
|
609 |
+
echo $this->get_outlook_wrapper_open($options['block_width']);
|
610 |
|
611 |
+
echo '<table type="options" data-json="', esc_attr($data), '" class="tnpc-block-content" border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: ', $options['block_width'], 'px!important">', "\n";
|
612 |
echo "<tr>";
|
613 |
+
echo '<td align="', esc_attr($options['block_align']), '" style="', $style, '" bgcolor="', $block_background, '" width="100%">';
|
614 |
|
615 |
//echo "<!-- block generated content -->\n";
|
616 |
echo trim($content);
|
634 |
* @param type $block_id
|
635 |
* @param type $wrapper
|
636 |
*/
|
637 |
+
function tnpc_render_callback() {
|
|
|
638 |
if (!check_ajax_referer('save')) {
|
639 |
$this->dienow('Expired request');
|
640 |
}
|
647 |
wp_die();
|
648 |
}
|
649 |
|
650 |
+
function hook_wp_ajax_tnpc_regenerate_email() {
|
|
|
651 |
|
652 |
$content = stripslashes($_POST['content']);
|
653 |
$global_options = $_POST['composer'];
|
658 |
'content' => $regenerated_content,
|
659 |
'message' => __('Successfully updated', 'newsletter')
|
660 |
]);
|
|
|
661 |
}
|
662 |
|
663 |
+
private function regenerate_email_blocks($content, $global_options) {
|
|
|
664 |
|
665 |
$raw_block_options = $this->extract_encoded_blocks_options($content);
|
666 |
|
668 |
|
669 |
foreach ($raw_block_options as $raw_block_option) {
|
670 |
|
671 |
+
/* $a = html_entity_decode( $raw_block_option, ENT_QUOTES, 'UTF-8' );
|
672 |
+
$block_options = $this->options_decode( $a ); */
|
673 |
|
674 |
$block_options = $this->options_decode($raw_block_option);
|
675 |
|
686 |
}
|
687 |
|
688 |
return $regenerated_content;
|
|
|
689 |
}
|
690 |
|
691 |
/**
|
693 |
*
|
694 |
* @return string[] Encoded options of email blocks
|
695 |
*/
|
696 |
+
private function extract_encoded_blocks_options($html_email_content) {
|
|
|
697 |
|
698 |
preg_match_all('/data-json="(.*?)"/m', $html_email_content, $raw_block_options, PREG_PATTERN_ORDER);
|
699 |
|
700 |
return $raw_block_options[1];
|
|
|
701 |
}
|
702 |
|
703 |
+
function tnpc_preview_callback() {
|
|
|
704 |
$email = Newsletter::instance()->get_email($_REQUEST['id'], ARRAY_A);
|
705 |
|
706 |
if (empty($email)) {
|
713 |
wp_die();
|
714 |
}
|
715 |
|
716 |
+
function tnpc_css_callback() {
|
|
|
717 |
include NEWSLETTER_DIR . '/emails/tnp-composer/css/newsletter.css';
|
718 |
wp_die();
|
719 |
}
|
720 |
|
721 |
/** Returns the correct admin page to edit the newsletter with the correct editor. */
|
722 |
+
function get_editor_url($email_id, $editor_type) {
|
|
|
723 |
switch ($editor_type) {
|
724 |
case NewsletterEmails::EDITOR_COMPOSER:
|
725 |
return admin_url("admin.php") . '?page=newsletter_emails_composer&id=' . $email_id;
|
736 |
*
|
737 |
* @param TNP_Email $email
|
738 |
*/
|
739 |
+
function get_edit_button($email, $only_icon = false) {
|
|
|
740 |
|
741 |
$editor_type = $this->get_editor_type($email);
|
742 |
if ($email->status == 'new') {
|
757 |
}
|
758 |
if ($only_icon) {
|
759 |
return '<a class="button-primary" href="' . $edit_url . '" title="' . esc_attr__('Edit', 'newsletter') . '">' .
|
760 |
+
'<i class="fas fa-' . $icon_class . '"></i></a>';
|
|
|
761 |
} else {
|
762 |
return '<a class="button-primary" href="' . $edit_url . '" title="' . esc_attr__('Edit', 'newsletter') . '">' .
|
763 |
+
'<i class="fas fa-' . $icon_class . '"></i> ' . __('Edit', 'newsletter') . '</a>';
|
764 |
}
|
765 |
}
|
766 |
|
767 |
/** Returns the correct editor type for the provided newsletter. Contains backward compatibility code. */
|
768 |
+
function get_editor_type($email) {
|
769 |
+
$email = (object) $email;
|
|
|
770 |
$editor_type = $email->editor;
|
771 |
|
772 |
// Backward compatibility
|
787 |
* @return type
|
788 |
* @global wpdb $wpdb
|
789 |
*/
|
790 |
+
function hook_newsletter_action($action, $user, $email) {
|
|
|
791 |
global $wpdb;
|
792 |
|
793 |
switch ($action) {
|
835 |
break;
|
836 |
|
837 |
case 'emails-css':
|
838 |
+
$email_id = (int) $_GET['id'];
|
839 |
|
840 |
$body = Newsletter::instance()->get_email_field($email_id, 'message');
|
841 |
|
971 |
}
|
972 |
}
|
973 |
|
974 |
+
function admin_menu() {
|
|
|
975 |
$this->add_menu_page('index', 'Newsletters');
|
976 |
$this->add_admin_page('list', 'Email List');
|
977 |
$this->add_admin_page('new', 'Email New');
|
989 |
* @param string $dir
|
990 |
* @return array | WP_Error
|
991 |
*/
|
992 |
+
function build_block($dir) {
|
|
|
993 |
$file = basename($dir);
|
994 |
$block_id = sanitize_key($file);
|
995 |
$full_file = $dir . '/block.php';
|
1024 |
* @param type $dir
|
1025 |
* @return type
|
1026 |
*/
|
1027 |
+
function scan_blocks_dir($dir) {
|
|
|
1028 |
|
1029 |
if (!is_dir($dir)) {
|
1030 |
return array();
|
1056 |
*
|
1057 |
* @return array
|
1058 |
*/
|
1059 |
+
function get_blocks() {
|
|
|
1060 |
|
1061 |
if (!is_null($this->blocks)) {
|
1062 |
return $this->blocks;
|
1104 |
* @param string $id
|
1105 |
* @return array
|
1106 |
*/
|
1107 |
+
function get_block($id) {
|
|
|
1108 |
switch ($id) {
|
1109 |
case 'content-03-text.block':
|
1110 |
$id = 'text';
|
1152 |
return $blocks[$id];
|
1153 |
}
|
1154 |
|
1155 |
+
function scan_presets_dir($dir = null) {
|
|
|
1156 |
|
1157 |
if (is_null($dir)) {
|
1158 |
$dir = __DIR__ . '/presets';
|
1187 |
return $list;
|
1188 |
}
|
1189 |
|
1190 |
+
function get_preset_from_file($id, $dir = null) {
|
|
|
1191 |
|
1192 |
if (is_null($dir)) {
|
1193 |
$dir = __DIR__ . '/presets';
|
1207 |
return $json;
|
1208 |
}
|
1209 |
|
1210 |
+
function get_composer_css() {
|
|
|
1211 |
$css = file_get_contents(__DIR__ . '/tnp-composer/css/newsletter.css');
|
1212 |
$blocks = $this->get_blocks();
|
1213 |
foreach ($blocks as $block) {
|
1227 |
* @param TNP_Email $email Could be any object with the TNP_Email attributes
|
1228 |
* @param NewsletterControls $controls
|
1229 |
*/
|
1230 |
+
function send_test_email($email, $controls) {
|
|
|
1231 |
if (!$email) {
|
1232 |
$controls->errors = __('Newsletter should be saved before send a test', 'newsletter');
|
1233 |
return;
|
1242 |
$users = NewsletterUsers::instance()->get_test_users();
|
1243 |
if (count($users) == 0) {
|
1244 |
$controls->errors = '' . __('There are no test subscribers to send to', 'newsletter') .
|
1245 |
+
'. <a href="https://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank"><strong>' .
|
1246 |
+
__('Read more', 'newsletter') . '</strong></a>.';
|
1247 |
} else {
|
1248 |
$r = Newsletter::instance()->send($email, $users, true);
|
1249 |
$emails = array();
|
1263 |
$controls->messages .= ' ' . implode(', ', $emails);
|
1264 |
$controls->messages .= '.<br>';
|
1265 |
$controls->messages .= '<a href="https://www.thenewsletterplugin.com/documentation/subscribers#test" target="_blank"><strong>' .
|
1266 |
+
__('Read more about test subscribers', 'newsletter') . '</strong></a>.<br>';
|
1267 |
$controls->messages .= '<a href="https://www.thenewsletterplugin.com/documentation/email-sending-issues" target="_blank"><strong>' . __('Read more about delivery issues', 'newsletter') . '</strong></a>.';
|
1268 |
}
|
1269 |
}
|
1270 |
$email->subject = $original_subject;
|
1271 |
}
|
1272 |
|
1273 |
+
function restore_options_from_request() {
|
|
|
1274 |
|
1275 |
if (isset($_POST['options']) && is_array($_POST['options'])) {
|
1276 |
// Get all block options
|
1313 |
return array();
|
1314 |
}
|
1315 |
|
1316 |
+
public function hook_wp_ajax_tnpc_delete_preset() {
|
|
|
1317 |
|
1318 |
if (!wp_verify_nonce($_POST['_wpnonce'], 'preset')) {
|
1319 |
wp_send_json_error('Expired request');
|
1320 |
}
|
1321 |
|
1322 |
+
$preset_id = (int) $_REQUEST['presetId'];
|
1323 |
|
1324 |
$newsletter = Newsletter::instance();
|
1325 |
|
1332 |
} else {
|
1333 |
wp_send_json_error(__('Is not a preset!', 'newsletter'));
|
1334 |
}
|
|
|
1335 |
} else {
|
1336 |
wp_send_json_error();
|
1337 |
}
|
|
|
1338 |
}
|
1339 |
|
1340 |
}
|
emails/tnp-composer/css/newsletter.css
CHANGED
@@ -17,71 +17,22 @@ img.aligncenter{display:block;margin:0 auto;}
|
|
17 |
width:100% !important;
|
18 |
}
|
19 |
|
20 |
-
table[class="
|
21 |
-
width:100% !important;
|
22 |
-
}
|
23 |
-
|
24 |
-
img[class="mobile-full-width"] {
|
25 |
-
width:100% !important;
|
26 |
-
display: block;
|
27 |
-
}
|
28 |
-
|
29 |
-
/* ADJUSTS LAYOUT OF LOGO IMAGE */
|
30 |
-
td[class="logo"]{
|
31 |
-
text-align: left;
|
32 |
-
padding: 20px 0 20px 0 !important;
|
33 |
-
}
|
34 |
-
|
35 |
-
td[class="logo"] img{
|
36 |
-
margin:0 auto!important;
|
37 |
-
}
|
38 |
-
|
39 |
-
/* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
|
40 |
-
td[class="mobile-hide"]{
|
41 |
-
display:none;}
|
42 |
-
|
43 |
-
img[class="mobile-hide"]{
|
44 |
-
display: none !important;
|
45 |
-
}
|
46 |
-
|
47 |
-
img[class="img-max"]{
|
48 |
-
max-width: 100% !important;
|
49 |
-
/*width: 100% !important;*/
|
50 |
-
height:auto !important;
|
51 |
-
}
|
52 |
-
|
53 |
-
/* FULL-WIDTH TABLES */
|
54 |
-
table[class="responsive-table"]{
|
55 |
-
width:100%!important;
|
56 |
-
max-width: 100%!important;
|
57 |
-
}
|
58 |
-
|
59 |
-
.responsive {
|
60 |
width:100%!important;
|
61 |
-
max-width: 100%!important;
|
62 |
float: none;
|
63 |
-
display:
|
64 |
padding-left: 0;
|
65 |
padding-right: 0;
|
66 |
}
|
67 |
-
|
68 |
-
|
69 |
-
width:100%!important;
|
70 |
-
max-width: 100%!important;
|
71 |
-
float: none;
|
72 |
-
display: block;
|
73 |
-
}
|
74 |
-
|
75 |
-
img.responsive {
|
76 |
-
width:100%!important;
|
77 |
max-width: 100%!important;
|
78 |
}
|
79 |
-
|
80 |
-
|
81 |
.block {
|
82 |
display: block;
|
83 |
}
|
84 |
-
|
85 |
td[class="responsive"]{
|
86 |
width:100%!important;
|
87 |
max-width: 100%!important;
|
@@ -91,29 +42,6 @@ img.aligncenter{display:block;margin:0 auto;}
|
|
91 |
float: none;
|
92 |
}
|
93 |
|
94 |
-
/* UTILITY CLASSES FOR ADJUSTING PADDING ON MOBILE */
|
95 |
-
td[class="padding"]{
|
96 |
-
padding: 10px 5% 15px 5% !important;
|
97 |
-
}
|
98 |
-
|
99 |
-
td[class="padding-copy"]{
|
100 |
-
padding: 10px 5% 10px 5% !important;
|
101 |
-
text-align: center;
|
102 |
-
}
|
103 |
-
|
104 |
-
td[class="padding-meta"]{
|
105 |
-
padding: 30px 5% 0px 5% !important;
|
106 |
-
text-align: center;
|
107 |
-
}
|
108 |
-
|
109 |
-
td[class="no-pad"]{
|
110 |
-
padding: 0 0 20px 0 !important;
|
111 |
-
}
|
112 |
-
|
113 |
-
td[class="no-padding"]{
|
114 |
-
padding: 0 !important;
|
115 |
-
}
|
116 |
-
|
117 |
td[class="section-padding"]{
|
118 |
padding: 50px 15px 50px 15px !important;
|
119 |
}
|
@@ -126,7 +54,7 @@ img.aligncenter{display:block;margin:0 auto;}
|
|
126 |
td[class="mobile-wrapper"]{
|
127 |
padding: 10px 5% 15px 5% !important;
|
128 |
}
|
129 |
-
|
130 |
td[class="responsive"]{
|
131 |
display: block;
|
132 |
width: 100% !important;
|
@@ -143,4 +71,8 @@ img.aligncenter{display:block;margin:0 auto;}
|
|
143 |
border: 0 !important;
|
144 |
font-size: 16px !important;
|
145 |
}
|
|
|
|
|
|
|
|
|
146 |
}
|
17 |
width:100% !important;
|
18 |
}
|
19 |
|
20 |
+
table[class="responsive"]{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
width:100%!important;
|
|
|
22 |
float: none;
|
23 |
+
display: table;
|
24 |
padding-left: 0;
|
25 |
padding-right: 0;
|
26 |
}
|
27 |
+
|
28 |
+
img[class="responsive"] {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
max-width: 100%!important;
|
30 |
}
|
31 |
+
|
|
|
32 |
.block {
|
33 |
display: block;
|
34 |
}
|
35 |
+
|
36 |
td[class="responsive"]{
|
37 |
width:100%!important;
|
38 |
max-width: 100%!important;
|
42 |
float: none;
|
43 |
}
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
td[class="section-padding"]{
|
46 |
padding: 50px 15px 50px 15px !important;
|
47 |
}
|
54 |
td[class="mobile-wrapper"]{
|
55 |
padding: 10px 5% 15px 5% !important;
|
56 |
}
|
57 |
+
|
58 |
td[class="responsive"]{
|
59 |
display: block;
|
60 |
width: 100% !important;
|
71 |
border: 0 !important;
|
72 |
font-size: 16px !important;
|
73 |
}
|
74 |
+
|
75 |
+
.tnp-grid-column {
|
76 |
+
max-width: 100%!important;
|
77 |
+
}
|
78 |
}
|
includes/composer.php
CHANGED
@@ -81,16 +81,45 @@ class TNP_Composer {
|
|
81 |
return preg_match($pattern, $block);
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
static function get_html_open($email) {
|
85 |
$open = "<!DOCTYPE html>\n";
|
86 |
-
$open .= "<html>\n<head>\n<title>{email_subject}</title>\n";
|
87 |
$open .= "<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
$open .= "<style type=\"text/css\">\n";
|
90 |
$open .= NewsletterEmails::instance()->get_composer_css();
|
91 |
$open .= "\n</style>\n";
|
92 |
$open .= "</head>\n";
|
93 |
-
$open .= '<body style="margin: 0; padding: 0;" dir="' . (is_rtl() ? 'rtl' : 'ltr') . '">';
|
94 |
$open .= "\n";
|
95 |
$open .= self::get_html_preheader($email);
|
96 |
|
@@ -323,7 +352,7 @@ class TNP_Composer {
|
|
323 |
|
324 |
$options = array_merge($defaults, array_filter($options));
|
325 |
|
326 |
-
$b = '<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="
|
327 |
if (!empty($options[$prefix . '_align'])) {
|
328 |
$b .= ' align="' . esc_attr($options[$prefix . '_align']) . '"';
|
329 |
}
|
@@ -352,9 +381,9 @@ class TNP_Composer {
|
|
352 |
static function image($media, $attr = []) {
|
353 |
|
354 |
$default_attrs = [
|
355 |
-
'style' => 'max-width: 100%; height: auto;',
|
356 |
'class' => null,
|
357 |
-
'link-style' => 'text-decoration: none;',
|
358 |
'link-class' => null,
|
359 |
];
|
360 |
|
@@ -378,16 +407,18 @@ class TNP_Composer {
|
|
378 |
|
379 |
$b = '';
|
380 |
if ($media->link) {
|
381 |
-
$b .= '<a href="' . esc_attr($media->link) . '" target="_blank" rel="noopener nofollow"
|
382 |
}
|
383 |
|
384 |
if ($media) {
|
385 |
-
$b .= '<img src="' . esc_attr($media->url) . '" width="' . esc_attr($media->width) . '"'
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
. '
|
|
|
|
|
391 |
. '>';
|
392 |
}
|
393 |
|
@@ -402,6 +433,8 @@ class TNP_Composer {
|
|
402 |
* Returns a WP media ID for the specified post (or false if nothing can be found)
|
403 |
* looking for the featured image or, if missing, taking the first media in the gallery and
|
404 |
* if again missing, searching the first reference to a media in the post content.
|
|
|
|
|
405 |
*
|
406 |
* @param int $post_id
|
407 |
* @return int
|
@@ -434,6 +467,28 @@ class TNP_Composer {
|
|
434 |
return false;
|
435 |
}
|
436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
static function post_content($post) {
|
438 |
$content = $post->post_content;
|
439 |
$content = wpautop($content);
|
@@ -484,6 +539,66 @@ class TNP_Composer {
|
|
484 |
];
|
485 |
}
|
486 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
}
|
488 |
|
489 |
/**
|
81 |
return preg_match($pattern, $block);
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Sources:
|
86 |
+
* - https://webdesign.tutsplus.com/tutorials/creating-a-future-proof-responsive-email-without-media-queries--cms-23919
|
87 |
+
*
|
88 |
+
* @param type $email
|
89 |
+
* @return type
|
90 |
+
*/
|
91 |
static function get_html_open($email) {
|
92 |
$open = "<!DOCTYPE html>\n";
|
93 |
+
$open .= "<html xmlns=\"https://www.w3.org/1999/xhtml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">\n<head>\n<title>{email_subject}</title>\n";
|
94 |
$open .= "<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
|
95 |
+
|
96 |
+
$open .= '<!--[if !mso]><!-->' . "\n";
|
97 |
+
$open .= '<meta http-equiv="X-UA-Compatible" content="IE=edge" />' . "\n";
|
98 |
+
$open .= '<!--<![endif]-->' . "\n";
|
99 |
+
|
100 |
+
$open .= '<!--[if mso]>' . "\n";
|
101 |
+
;
|
102 |
+
$open .= '<style type="text/css">';
|
103 |
+
$open .= 'table {border-collapse:collapse;border-spacing:0;margin:0;}';
|
104 |
+
$open .= 'div, td {padding:0;}';
|
105 |
+
$open .= 'div {margin:0 !important;}';
|
106 |
+
$open .= '</style>';
|
107 |
+
$open .= "\n";
|
108 |
+
$open .= '<noscript>';
|
109 |
+
$open .= '<xml>';
|
110 |
+
$open .= '<o:OfficeDocumentSettings>';
|
111 |
+
$open .= '<o:PixelsPerInch>96</o:PixelsPerInch>';
|
112 |
+
$open .= '</o:OfficeDocumentSettings>';
|
113 |
+
$open .= '</xml>';
|
114 |
+
$open .= '</noscript>';
|
115 |
+
$open .= "\n";
|
116 |
+
$open .= '<![endif]-->';
|
117 |
+
$open .= "\n";
|
118 |
$open .= "<style type=\"text/css\">\n";
|
119 |
$open .= NewsletterEmails::instance()->get_composer_css();
|
120 |
$open .= "\n</style>\n";
|
121 |
$open .= "</head>\n";
|
122 |
+
$open .= '<body style="margin: 0; padding: 0; line-height: normal; word-spacing: normal;" dir="' . (is_rtl() ? 'rtl' : 'ltr') . '">';
|
123 |
$open .= "\n";
|
124 |
$open .= self::get_html_preheader($email);
|
125 |
|
352 |
|
353 |
$options = array_merge($defaults, array_filter($options));
|
354 |
|
355 |
+
$b = '<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="margin: 0 auto"';
|
356 |
if (!empty($options[$prefix . '_align'])) {
|
357 |
$b .= ' align="' . esc_attr($options[$prefix . '_align']) . '"';
|
358 |
}
|
381 |
static function image($media, $attr = []) {
|
382 |
|
383 |
$default_attrs = [
|
384 |
+
'style' => 'max-width: 100%; height: auto; display: inline-block',
|
385 |
'class' => null,
|
386 |
+
'link-style' => 'text-decoration: none; display: inline-block',
|
387 |
'link-class' => null,
|
388 |
];
|
389 |
|
407 |
|
408 |
$b = '';
|
409 |
if ($media->link) {
|
410 |
+
$b .= '<a href="' . esc_attr($media->link) . '" target="_blank" rel="noopener nofollow" style="display: inline-block; font-size: 0; text-decoration: none; line-height: normal!important">';
|
411 |
}
|
412 |
|
413 |
if ($media) {
|
414 |
+
$b .= '<img src="' . esc_attr($media->url) . '" width="' . esc_attr($media->width) . '"';
|
415 |
+
if ($media->height) {
|
416 |
+
$b .= ' height="' . esc_attr($media->height) . '"';
|
417 |
+
}
|
418 |
+
$b .= ' alt="' . esc_attr($media->alt) . '"'
|
419 |
+
. ' border="0"'
|
420 |
+
. ' style="display: inline-block; max-width: 100%!important; padding: 0; border: 0;"'
|
421 |
+
. ' class="" '
|
422 |
. '>';
|
423 |
}
|
424 |
|
433 |
* Returns a WP media ID for the specified post (or false if nothing can be found)
|
434 |
* looking for the featured image or, if missing, taking the first media in the gallery and
|
435 |
* if again missing, searching the first reference to a media in the post content.
|
436 |
+
*
|
437 |
+
* The media ID is not checked for real existance of the associated attachment.
|
438 |
*
|
439 |
* @param int $post_id
|
440 |
* @return int
|
467 |
return false;
|
468 |
}
|
469 |
|
470 |
+
/**
|
471 |
+
* Builds a TNP_Media object to be used in newsletters from a WP media/attachement ID. The returned
|
472 |
+
* media has a size which best match the one requested (this is the standard WP behavior, plugins
|
473 |
+
* could change it).
|
474 |
+
*
|
475 |
+
* @param int $media_id
|
476 |
+
* @param array $size
|
477 |
+
* @return \TNP_Media
|
478 |
+
*/
|
479 |
+
function get_media($media_id, $size) {
|
480 |
+
$src = wp_get_attachment_image_src($media_id, $size);
|
481 |
+
if (!$src) {
|
482 |
+
return null;
|
483 |
+
}
|
484 |
+
$media = new TNP_Media();
|
485 |
+
$media->id = $media_id;
|
486 |
+
$media->url = $src[0];
|
487 |
+
$media->width = $src[1];
|
488 |
+
$media->height = $src[2];
|
489 |
+
return $media;
|
490 |
+
}
|
491 |
+
|
492 |
static function post_content($post) {
|
493 |
$content = $post->post_content;
|
494 |
$content = wpautop($content);
|
539 |
];
|
540 |
}
|
541 |
|
542 |
+
/**
|
543 |
+
* Inspired by: https://webdesign.tutsplus.com/tutorials/creating-a-future-proof-responsive-email-without-media-queries--cms-23919
|
544 |
+
* @param string[] $items
|
545 |
+
* @param array $attrs
|
546 |
+
* @return string
|
547 |
+
*/
|
548 |
+
static function grid($items = [], $attrs = []) {
|
549 |
+
$attrs = wp_parse_args($attrs, ['width' => 600, 'columns' => 2, 'padding' => 10]);
|
550 |
+
$width = (int) $attrs['width'];
|
551 |
+
$columns = (int) $attrs['columns'];
|
552 |
+
$padding = (int) $attrs['padding'];
|
553 |
+
$column_width = $width / $columns;
|
554 |
+
$td_width = 100 / $columns;
|
555 |
+
$chunks = array_chunk($items, $columns);
|
556 |
+
|
557 |
+
$e = '<div style="text-align:center;font-size:0;">';
|
558 |
+
foreach ($chunks as &$chunk) {
|
559 |
+
|
560 |
+
$e .= '<!--[if mso]><table role="presentation" width="100%"><tr><![endif]-->';
|
561 |
+
foreach ($chunk as &$item) {
|
562 |
+
$e .= '<!--[if mso]><td style="width:' . $td_width . '%;padding:' . $padding . 'px" valign="top"><![endif]-->';
|
563 |
+
|
564 |
+
$e .= '<div class="tnp-grid-column" style="width:100%;max-width:' . $column_width . 'px;display:inline-block;vertical-align: top;box-sizing: border-box;">';
|
565 |
+
|
566 |
+
// This element to add padding without deal with border-box not well supported
|
567 |
+
$e .= '<div style="padding:' . $padding . 'px;">';
|
568 |
+
$e .= $item;
|
569 |
+
$e .= '</div>';
|
570 |
+
$e .= '</div>';
|
571 |
+
|
572 |
+
$e .= '<!--[if mso]></td><![endif]-->';
|
573 |
+
}
|
574 |
+
$e .= '<!--[if mso]></tr></table><![endif]-->';
|
575 |
+
$e .= '</div>';
|
576 |
+
}
|
577 |
+
return $e;
|
578 |
+
}
|
579 |
+
|
580 |
+
static function get_style($options, $prefix, $composer, $type = 'text') {
|
581 |
+
$style = new TNP_Style();
|
582 |
+
if (!empty($prefix)) $prefix .= '_';
|
583 |
+
|
584 |
+
$style->font_family = empty($options[$prefix . 'font_family']) ? $composer[$type . '_font_family'] : $options[$prefix . 'font_family'];
|
585 |
+
$style->font_size = empty($options[$prefix . 'font_size']) ? $composer[$type . '_font_size'] : $options[$prefix . 'font_size'];
|
586 |
+
$style->font_color = empty($options[$prefix . 'font_color']) ? $composer[$type . '_font_color'] : $options[$prefix . 'font_color'];
|
587 |
+
$style->font_weight = empty($options[$prefix . 'font_weight']) ? $composer[$type . '_font_weight'] : $options[$prefix . 'font_weight'];
|
588 |
+
if ($type === 'button') {
|
589 |
+
$style->background = empty($options[$prefix . 'background']) ? $composer[$type . '_background_color'] : $options[$prefix . 'background'];
|
590 |
+
}
|
591 |
+
return $style;
|
592 |
+
}
|
593 |
+
|
594 |
+
}
|
595 |
+
|
596 |
+
class TNP_Style {
|
597 |
+
var $font_family;
|
598 |
+
var $font_size;
|
599 |
+
var $font_weight;
|
600 |
+
var $font_color;
|
601 |
+
var $background;
|
602 |
}
|
603 |
|
604 |
/**
|
includes/helper.php
CHANGED
@@ -177,6 +177,20 @@ function _tnp_get_default_media($media_id, $size) {
|
|
177 |
return null;
|
178 |
}
|
179 |
$media = new TNP_Media();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
$media->url = $src[0];
|
181 |
$media->width = $src[1];
|
182 |
$media->height = $src[2];
|
@@ -226,6 +240,7 @@ function tnp_resize($media_id, $size) {
|
|
226 |
}
|
227 |
$new_size = $editor->get_size();
|
228 |
$media = new TNP_Media();
|
|
|
229 |
$media->width = $new_size['width'];
|
230 |
$media->height = $new_size['height'];
|
231 |
if ($media->width > $width) {
|
177 |
return null;
|
178 |
}
|
179 |
$media = new TNP_Media();
|
180 |
+
$media->id = $media_id;
|
181 |
+
$media->url = $src[0];
|
182 |
+
$media->width = $src[1];
|
183 |
+
$media->height = $src[2];
|
184 |
+
return $media;
|
185 |
+
}
|
186 |
+
|
187 |
+
function tnp_get_media($media_id, $size) {
|
188 |
+
$src = wp_get_attachment_image_src($media_id, $size);
|
189 |
+
if (!$src) {
|
190 |
+
return null;
|
191 |
+
}
|
192 |
+
$media = new TNP_Media();
|
193 |
+
$media->id = $media_id;
|
194 |
$media->url = $src[0];
|
195 |
$media->width = $src[1];
|
196 |
$media->height = $src[2];
|
240 |
}
|
241 |
$new_size = $editor->get_size();
|
242 |
$media = new TNP_Media();
|
243 |
+
$media->id = $media_id;
|
244 |
$media->width = $new_size['width'];
|
245 |
$media->height = $new_size['height'];
|
246 |
if ($media->width > $width) {
|
includes/module.php
CHANGED
@@ -11,6 +11,7 @@ require_once __DIR__ . '/themes.php';
|
|
11 |
|
12 |
class TNP_Media {
|
13 |
|
|
|
14 |
var $url;
|
15 |
var $width;
|
16 |
var $height;
|
@@ -20,9 +21,16 @@ class TNP_Media {
|
|
20 |
|
21 |
/** Sets the width recalculating the height */
|
22 |
public function set_width($width) {
|
23 |
-
$this->height = floor($width / $this->width * $this->height);
|
24 |
$this->width = $width;
|
25 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
}
|
28 |
|
11 |
|
12 |
class TNP_Media {
|
13 |
|
14 |
+
var $id;
|
15 |
var $url;
|
16 |
var $width;
|
17 |
var $height;
|
21 |
|
22 |
/** Sets the width recalculating the height */
|
23 |
public function set_width($width) {
|
24 |
+
$this->height = floor(($width / $this->width) * $this->height);
|
25 |
$this->width = $width;
|
26 |
}
|
27 |
+
|
28 |
+
/** Sets the height recalculating the width */
|
29 |
+
public function set_height($height) {
|
30 |
+
$height = (int)$height;
|
31 |
+
$this->width = floor(($height / $this->height) * $this->width);
|
32 |
+
$this->height = $height;
|
33 |
+
}
|
34 |
|
35 |
}
|
36 |
|
main/status.php
CHANGED
@@ -880,7 +880,7 @@ function tnp_status_print_flag($condition) {
|
|
880 |
<?php } else { ?>
|
881 |
|
882 |
<?php } ?>
|
883 |
-
|
884 |
<br>
|
885 |
<a href="https://www.thenewsletterplugin.com/documentation/delivery-and-spam/newsletter-delivery-engine/" target="_blank">Read more</a>
|
886 |
</td>
|
880 |
<?php } else { ?>
|
881 |
|
882 |
<?php } ?>
|
883 |
+
Cron URL: <?php echo esc_html(site_url('/wp-cron.php')) ?><br>
|
884 |
<br>
|
885 |
<a href="https://www.thenewsletterplugin.com/documentation/delivery-and-spam/newsletter-delivery-engine/" target="_blank">Read more</a>
|
886 |
</td>
|
plugin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
-
Version: 7.1.
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -35,7 +35,7 @@ if (version_compare(phpversion(), '5.6', '<')) {
|
|
35 |
return;
|
36 |
}
|
37 |
|
38 |
-
define('NEWSLETTER_VERSION', '7.1.
|
39 |
|
40 |
global $newsletter, $wpdb;
|
41 |
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
+
Version: 7.1.5
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
35 |
return;
|
36 |
}
|
37 |
|
38 |
+
define('NEWSLETTER_VERSION', '7.1.5');
|
39 |
|
40 |
global $newsletter, $wpdb;
|
41 |
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Tags: email, email marketing, newsletter, newsletter subscribers, welcome email, signup forms, contact, lead generation, popup, marketing automation
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 5.7.1
|
5 |
-
Stable tag: 7.1.
|
6 |
Requires PHP: 5.6
|
7 |
Contributors: satollo,webagile,michael-travan
|
8 |
License: GPLv2 or later
|
@@ -121,6 +121,12 @@ Thank you, The Newsletter Team
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
= 7.1.4 =
|
125 |
|
126 |
* [COMPOSER] Fixed image block for Outlook
|
2 |
Tags: email, email marketing, newsletter, newsletter subscribers, welcome email, signup forms, contact, lead generation, popup, marketing automation
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 5.7.1
|
5 |
+
Stable tag: 7.1.5
|
6 |
Requires PHP: 5.6
|
7 |
Contributors: satollo,webagile,michael-travan
|
8 |
License: GPLv2 or later
|
121 |
|
122 |
== Changelog ==
|
123 |
|
124 |
+
= 7.1.5 =
|
125 |
+
|
126 |
+
* [COMPOSER] Improve buttons on posts layout
|
127 |
+
* [COMPOSER] Improved header layout and logo
|
128 |
+
* [COMPOSER] Genrally improved block spacing
|
129 |
+
|
130 |
= 7.1.4 =
|
131 |
|
132 |
* [COMPOSER] Fixed image block for Outlook
|