Version Description
- Added filter on newsletter message before online view
- Added excerpt lenght in character (useful for Chinese) on posts block
- Improved the excerpt extraction
- Add link on excerpt on posts block
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 7.5.8 |
Comparing to | |
See all releases |
Code changes from version 7.5.7 to 7.5.8
- emails/blocks/posts/block.php +3 -0
- emails/blocks/posts/layout-big-image.php +132 -126
- emails/blocks/posts/layout-one-2.php +138 -138
- emails/blocks/posts/layout-one.php +1 -1
- emails/blocks/posts/layout-two.php +1 -1
- emails/blocks/posts/options.php +37 -34
- emails/emails.php +1 -1
- includes/helper.php +430 -415
- plugin.php +2 -2
- readme.txt +8 -1
emails/blocks/posts/block.php
CHANGED
@@ -37,6 +37,7 @@ $defaults = array(
|
|
37 |
'block_padding_bottom' => 15,
|
38 |
'block_background' => '',
|
39 |
'excerpt_length' => 30,
|
|
|
40 |
'post_offset' => 0,
|
41 |
'automated_include' => 'new',
|
42 |
'inline_edits' => [],
|
@@ -119,6 +120,8 @@ remove_all_filters('excerpt_more');
|
|
119 |
$image_placeholder_url = plugins_url('newsletter') . '/emails/blocks/posts/images/blank-240x160.png';
|
120 |
|
121 |
$excerpt_length = $options['excerpt_length'];
|
|
|
|
|
122 |
|
123 |
$show_image = !empty($options['show_image']);
|
124 |
$show_date = !empty($options['show_date']);
|
37 |
'block_padding_bottom' => 15,
|
38 |
'block_background' => '',
|
39 |
'excerpt_length' => 30,
|
40 |
+
'excerpt_length_type' => '',
|
41 |
'post_offset' => 0,
|
42 |
'automated_include' => 'new',
|
43 |
'inline_edits' => [],
|
120 |
$image_placeholder_url = plugins_url('newsletter') . '/emails/blocks/posts/images/blank-240x160.png';
|
121 |
|
122 |
$excerpt_length = $options['excerpt_length'];
|
123 |
+
$excerpt_length_in_chars = $options['excerpt_length_type'] == 'chars';
|
124 |
+
|
125 |
|
126 |
$show_image = !empty($options['show_image']);
|
127 |
$show_date = !empty($options['show_date']);
|
emails/blocks/posts/layout-big-image.php
CHANGED
@@ -1,126 +1,132 @@
|
|
1 |
-
<?php
|
2 |
-
$size = ['width' => 600, 'height' => 0];
|
3 |
-
$content_width = 600 - $options['block_padding_left'] - $options['block_padding_right'];
|
4 |
-
$title_style = TNP_Composer::get_title_style($options, 'title', $composer);
|
5 |
-
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
6 |
-
?>
|
7 |
-
<style>
|
8 |
-
.title {
|
9 |
-
<?php echo $title_style->echo_css() ?>
|
10 |
-
line-height: normal!important;
|
11 |
-
padding: 0 0 5px 0;
|
12 |
-
}
|
13 |
-
|
14 |
-
.excerpt {
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
if ($
|
53 |
-
$
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
<?php
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$size = ['width' => 600, 'height' => 0];
|
3 |
+
$content_width = 600 - $options['block_padding_left'] - $options['block_padding_right'];
|
4 |
+
$title_style = TNP_Composer::get_title_style($options, 'title', $composer);
|
5 |
+
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
6 |
+
?>
|
7 |
+
<style>
|
8 |
+
.title {
|
9 |
+
<?php echo $title_style->echo_css() ?>
|
10 |
+
line-height: normal!important;
|
11 |
+
padding: 0 0 5px 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
.excerpt-td {
|
15 |
+
padding: 10px 0 15px 0;
|
16 |
+
}
|
17 |
+
|
18 |
+
.excerpt {
|
19 |
+
<?php echo $text_style->echo_css() ?>
|
20 |
+
line-height: 1.5em!important;
|
21 |
+
text-decoration: none;
|
22 |
+
}
|
23 |
+
|
24 |
+
.meta {
|
25 |
+
<?php echo $text_style->echo_css(0.9) ?>
|
26 |
+
line-height: normal!important;
|
27 |
+
padding: 0 0 5px 0;
|
28 |
+
font-style: italic;
|
29 |
+
}
|
30 |
+
</style>
|
31 |
+
|
32 |
+
|
33 |
+
<?php foreach ($posts as $post) { ?>
|
34 |
+
|
35 |
+
<?php
|
36 |
+
$url = tnp_post_permalink($post);
|
37 |
+
$button_options['button_url'] = $url;
|
38 |
+
|
39 |
+
$media = null;
|
40 |
+
if ($show_image) {
|
41 |
+
$media = tnp_composer_block_posts_get_media($post, $size);
|
42 |
+
|
43 |
+
if ($media) {
|
44 |
+
$media->set_width($content_width);
|
45 |
+
$media->link = $url;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
$meta = [];
|
51 |
+
|
52 |
+
if ($show_date) {
|
53 |
+
$meta[] = tnp_post_date($post);
|
54 |
+
}
|
55 |
+
|
56 |
+
if ($show_author) {
|
57 |
+
$author_object = get_user_by('id', $post->post_author);
|
58 |
+
if ($author_object) {
|
59 |
+
$meta[] = $author_object->display_name;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
63 |
+
|
64 |
+
<?php if ($media) { ?>
|
65 |
+
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-bottom: 20px">
|
66 |
+
<tr>
|
67 |
+
<td align="center">
|
68 |
+
<?php echo TNP_Composer::image($media) ?>
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
+
</table>
|
72 |
+
<?php } ?>
|
73 |
+
|
74 |
+
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="responsive" style="margin: 0;">
|
75 |
+
<tr>
|
76 |
+
<td>
|
77 |
+
|
78 |
+
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
79 |
+
|
80 |
+
|
81 |
+
<tr>
|
82 |
+
<td align="<?php echo $align_left ?>" inline-class="title" class="tnpc-row-edit tnpc-inline-editable"
|
83 |
+
data-type="title" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
84 |
+
<?php
|
85 |
+
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'title', $post->ID) ?
|
86 |
+
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'title', $post->ID) :
|
87 |
+
tnp_post_title($post)
|
88 |
+
?>
|
89 |
+
</td>
|
90 |
+
</tr>
|
91 |
+
|
92 |
+
<?php if ($meta) { ?>
|
93 |
+
<tr>
|
94 |
+
<td align="<?php echo $align_left ?>" inline-class="meta">
|
95 |
+
<?php echo esc_html(implode(' - ', $meta)) ?>
|
96 |
+
</td>
|
97 |
+
</tr>
|
98 |
+
<?php } ?>
|
99 |
+
|
100 |
+
<?php if ($excerpt_length) { ?>
|
101 |
+
<tr>
|
102 |
+
<td align="<?php echo $align_left ?>" inline-class="excerpt-td" dir="<?php echo $dir ?>">
|
103 |
+
<a href="<?php $url ?>" data-id="<?php echo $post->ID ?>" inline-class="excerpt" class="tnpc-row-edit tnpc-inline-editable" data-type="text">
|
104 |
+
<?php
|
105 |
+
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
106 |
+
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $post->ID) :
|
107 |
+
tnp_post_excerpt($post, $excerpt_length, $excerpt_length_in_chars)
|
108 |
+
?>
|
109 |
+
</a>
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
<?php } ?>
|
113 |
+
|
114 |
+
<?php if ($show_read_more_button) { ?>
|
115 |
+
<tr>
|
116 |
+
<td align="<?php echo $align_left ?>" inline-class="button">
|
117 |
+
<?php echo TNP_Composer::button($button_options) ?>
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
<?php } ?>
|
121 |
+
<tr>
|
122 |
+
<td style="padding: 10px"> </td>
|
123 |
+
</tr>
|
124 |
+
</table>
|
125 |
+
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
</table>
|
129 |
+
|
130 |
+
<?php } ?>
|
131 |
+
|
132 |
+
|
emails/blocks/posts/layout-one-2.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
$size = ['width' => 600, 'height' => 0];
|
3 |
-
$total_width = 600 - $options['block_padding_left'] - $options['block_padding_right'];
|
4 |
-
$column_width = $total_width / 2 - 10;
|
5 |
-
|
6 |
-
$title_style = TNP_Composer::get_style($options, 'title', $composer, 'title');
|
7 |
-
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
8 |
-
?>
|
9 |
-
<style>
|
10 |
-
.title {
|
11 |
-
<?php $title_style->echo_css() ?>
|
12 |
-
line-height: normal;
|
13 |
-
padding: 0 0 10px 0;
|
14 |
-
}
|
15 |
-
|
16 |
-
.excerpt {
|
17 |
-
<?php $text_style->echo_css() ?>
|
18 |
-
line-height: 1.5em;
|
19 |
-
padding: 0 0 15px 0;
|
20 |
-
text-decoration: none;
|
21 |
-
}
|
22 |
-
|
23 |
-
.meta {
|
24 |
-
font-family: <?php echo $text_style->font_family ?>;
|
25 |
-
color: <?php echo $text_style->font_color ?>;
|
26 |
-
font-size: <?php echo round($text_style->font_size * 0.9) ?>px;
|
27 |
-
font-weight: <?php echo $text_style->font_weight ?>;
|
28 |
-
padding: 0 0 5px 0;
|
29 |
-
line-height: normal !important;
|
30 |
-
font-style: italic;
|
31 |
-
}
|
32 |
-
.button {
|
33 |
-
padding: 15px 0;
|
34 |
-
}
|
35 |
-
</style>
|
36 |
-
|
37 |
-
|
38 |
-
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="responsive">
|
39 |
-
|
40 |
-
<?php foreach ($posts as $post) { ?>
|
41 |
-
<?php
|
42 |
-
$url = tnp_post_permalink($post);
|
43 |
-
|
44 |
-
$media = null;
|
45 |
-
if ($show_image) {
|
46 |
-
$media = tnp_composer_block_posts_get_media($post, $size);
|
47 |
-
if ($media) {
|
48 |
-
$media->link = $url;
|
49 |
-
$media->set_width($column_width);
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
$meta = [];
|
54 |
-
|
55 |
-
if ($show_date) {
|
56 |
-
$meta[] = tnp_post_date($post);
|
57 |
-
}
|
58 |
-
|
59 |
-
if ($show_author) {
|
60 |
-
$author_object = get_user_by('id', $post->post_author);
|
61 |
-
if ($author_object) {
|
62 |
-
$meta[] = $author_object->display_name;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
$button_options['button_url'] = $url;
|
67 |
-
$button_options['button_align'] = 'left';
|
68 |
-
?>
|
69 |
-
|
70 |
-
<tr>
|
71 |
-
<td align="<?php echo $align_left ?>" inline-class="title" class="tnpc-row-edit tnpc-inline-editable" data-type="title" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
72 |
-
<?php
|
73 |
-
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'title', $post->ID) ?
|
74 |
-
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'title', $post->ID) :
|
75 |
-
tnp_post_title($post)
|
76 |
-
?>
|
77 |
-
</td>
|
78 |
-
</tr>
|
79 |
-
|
80 |
-
<tr>
|
81 |
-
|
82 |
-
<td valign="top" style="padding: 20px 0 25px 0;">
|
83 |
-
|
84 |
-
<?php if ($media) { ?>
|
85 |
-
<table width="<?php echo $column_width ?>" cellpadding="0" cellspacing="0" border="0" align="left" style="margin: 0;" class="responsive">
|
86 |
-
<tr>
|
87 |
-
<td class="pb-1">
|
88 |
-
<?php echo TNP_Composer::image($media, ['class' => 'fluid']) ?>
|
89 |
-
</td>
|
90 |
-
</tr>
|
91 |
-
</table>
|
92 |
-
<?php } ?>
|
93 |
-
|
94 |
-
<table width="<?php echo $media ? $column_width : '100%' ?>" cellpadding="0" cellspacing="0" border="0" style="margin: 0;" class="responsive" align="right">
|
95 |
-
<tr>
|
96 |
-
<td>
|
97 |
-
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin: 0;">
|
98 |
-
<?php if ($meta) { ?>
|
99 |
-
<tr>
|
100 |
-
<td inline-class="meta" dir="<?php echo $dir ?>" align="<?php echo $align_left ?>">
|
101 |
-
<?php echo esc_html(implode(' - ', $meta)) ?>
|
102 |
-
</td>
|
103 |
-
</tr>
|
104 |
-
<?php } ?>
|
105 |
-
|
106 |
-
<?php if ($excerpt_length) { ?>
|
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) :
|
113 |
-
tnp_post_excerpt($post, $excerpt_length)
|
114 |
-
?>
|
115 |
-
</a>
|
116 |
-
</td>
|
117 |
-
</tr>
|
118 |
-
<?php } ?>
|
119 |
-
|
120 |
-
<?php if ($show_read_more_button) { ?>
|
121 |
-
<tr>
|
122 |
-
<td align="<?php echo $align_left ?>" inline-class="button">
|
123 |
-
<?php echo TNP_Composer::button($button_options) ?>
|
124 |
-
</td>
|
125 |
-
</tr>
|
126 |
-
<?php } ?>
|
127 |
-
</table>
|
128 |
-
|
129 |
-
</td>
|
130 |
-
</tr>
|
131 |
-
</table>
|
132 |
-
|
133 |
-
</td>
|
134 |
-
</tr>
|
135 |
-
|
136 |
-
<?php } ?>
|
137 |
-
|
138 |
-
</table>
|
1 |
+
<?php
|
2 |
+
$size = ['width' => 600, 'height' => 0];
|
3 |
+
$total_width = 600 - $options['block_padding_left'] - $options['block_padding_right'];
|
4 |
+
$column_width = $total_width / 2 - 10;
|
5 |
+
|
6 |
+
$title_style = TNP_Composer::get_style($options, 'title', $composer, 'title');
|
7 |
+
$text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
8 |
+
?>
|
9 |
+
<style>
|
10 |
+
.title {
|
11 |
+
<?php $title_style->echo_css() ?>
|
12 |
+
line-height: normal;
|
13 |
+
padding: 0 0 10px 0;
|
14 |
+
}
|
15 |
+
|
16 |
+
.excerpt {
|
17 |
+
<?php $text_style->echo_css() ?>
|
18 |
+
line-height: 1.5em;
|
19 |
+
padding: 0 0 15px 0;
|
20 |
+
text-decoration: none;
|
21 |
+
}
|
22 |
+
|
23 |
+
.meta {
|
24 |
+
font-family: <?php echo $text_style->font_family ?>;
|
25 |
+
color: <?php echo $text_style->font_color ?>;
|
26 |
+
font-size: <?php echo round($text_style->font_size * 0.9) ?>px;
|
27 |
+
font-weight: <?php echo $text_style->font_weight ?>;
|
28 |
+
padding: 0 0 5px 0;
|
29 |
+
line-height: normal !important;
|
30 |
+
font-style: italic;
|
31 |
+
}
|
32 |
+
.button {
|
33 |
+
padding: 15px 0;
|
34 |
+
}
|
35 |
+
</style>
|
36 |
+
|
37 |
+
|
38 |
+
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="responsive">
|
39 |
+
|
40 |
+
<?php foreach ($posts as $post) { ?>
|
41 |
+
<?php
|
42 |
+
$url = tnp_post_permalink($post);
|
43 |
+
|
44 |
+
$media = null;
|
45 |
+
if ($show_image) {
|
46 |
+
$media = tnp_composer_block_posts_get_media($post, $size);
|
47 |
+
if ($media) {
|
48 |
+
$media->link = $url;
|
49 |
+
$media->set_width($column_width);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
$meta = [];
|
54 |
+
|
55 |
+
if ($show_date) {
|
56 |
+
$meta[] = tnp_post_date($post);
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($show_author) {
|
60 |
+
$author_object = get_user_by('id', $post->post_author);
|
61 |
+
if ($author_object) {
|
62 |
+
$meta[] = $author_object->display_name;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
$button_options['button_url'] = $url;
|
67 |
+
$button_options['button_align'] = 'left';
|
68 |
+
?>
|
69 |
+
|
70 |
+
<tr>
|
71 |
+
<td align="<?php echo $align_left ?>" inline-class="title" class="tnpc-row-edit tnpc-inline-editable" data-type="title" data-id="<?php echo $post->ID ?>" dir="<?php echo $dir ?>">
|
72 |
+
<?php
|
73 |
+
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'title', $post->ID) ?
|
74 |
+
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'title', $post->ID) :
|
75 |
+
tnp_post_title($post)
|
76 |
+
?>
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
+
|
80 |
+
<tr>
|
81 |
+
|
82 |
+
<td valign="top" style="padding: 20px 0 25px 0;">
|
83 |
+
|
84 |
+
<?php if ($media) { ?>
|
85 |
+
<table width="<?php echo $column_width ?>" cellpadding="0" cellspacing="0" border="0" align="left" style="margin: 0;" class="responsive">
|
86 |
+
<tr>
|
87 |
+
<td class="pb-1">
|
88 |
+
<?php echo TNP_Composer::image($media, ['class' => 'fluid']) ?>
|
89 |
+
</td>
|
90 |
+
</tr>
|
91 |
+
</table>
|
92 |
+
<?php } ?>
|
93 |
+
|
94 |
+
<table width="<?php echo $media ? $column_width : '100%' ?>" cellpadding="0" cellspacing="0" border="0" style="margin: 0;" class="responsive" align="right">
|
95 |
+
<tr>
|
96 |
+
<td>
|
97 |
+
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin: 0;">
|
98 |
+
<?php if ($meta) { ?>
|
99 |
+
<tr>
|
100 |
+
<td inline-class="meta" dir="<?php echo $dir ?>" align="<?php echo $align_left ?>">
|
101 |
+
<?php echo esc_html(implode(' - ', $meta)) ?>
|
102 |
+
</td>
|
103 |
+
</tr>
|
104 |
+
<?php } ?>
|
105 |
+
|
106 |
+
<?php if ($excerpt_length) { ?>
|
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) :
|
113 |
+
tnp_post_excerpt($post, $excerpt_length, $excerpt_length_in_chars)
|
114 |
+
?>
|
115 |
+
</a>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<?php } ?>
|
119 |
+
|
120 |
+
<?php if ($show_read_more_button) { ?>
|
121 |
+
<tr>
|
122 |
+
<td align="<?php echo $align_left ?>" inline-class="button">
|
123 |
+
<?php echo TNP_Composer::button($button_options) ?>
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
<?php } ?>
|
127 |
+
</table>
|
128 |
+
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
</table>
|
132 |
+
|
133 |
+
</td>
|
134 |
+
</tr>
|
135 |
+
|
136 |
+
<?php } ?>
|
137 |
+
|
138 |
+
</table>
|
emails/blocks/posts/layout-one.php
CHANGED
@@ -113,7 +113,7 @@ $text_style = TNP_Composer::get_style($options, '', $composer, 'text');
|
|
113 |
<?php
|
114 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
115 |
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $post->ID) :
|
116 |
-
tnp_post_excerpt($post, $excerpt_length)
|
117 |
?>
|
118 |
</a>
|
119 |
</td>
|
113 |
<?php
|
114 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $post->ID) ?
|
115 |
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $post->ID) :
|
116 |
+
tnp_post_excerpt($post, $excerpt_length, $excerpt_length_in_chars)
|
117 |
?>
|
118 |
</a>
|
119 |
</td>
|
emails/blocks/posts/layout-two.php
CHANGED
@@ -115,7 +115,7 @@ $items = [];
|
|
115 |
<?php
|
116 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $p->ID) ?
|
117 |
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $p->ID) :
|
118 |
-
tnp_post_excerpt($p, $excerpt_length)
|
119 |
?>
|
120 |
</a>
|
121 |
</td>
|
115 |
<?php
|
116 |
echo TNP_Composer::is_post_field_edited_inline($options['inline_edits'], 'text', $p->ID) ?
|
117 |
TNP_Composer::get_edited_inline_post_field($options['inline_edits'], 'text', $p->ID) :
|
118 |
+
tnp_post_excerpt($p, $excerpt_length, $excerpt_length_in_chars)
|
119 |
?>
|
120 |
</a>
|
121 |
</td>
|
emails/blocks/posts/options.php
CHANGED
@@ -14,40 +14,40 @@ if (class_exists('NewsletterExtensions')) {
|
|
14 |
|
15 |
<?php if ($context['type'] == 'automated') { ?>
|
16 |
|
17 |
-
<div class="tnp-field-box">
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
</div>
|
|
|
48 |
</div>
|
49 |
-
<div style="clear: both"></div>
|
50 |
-
</div>
|
51 |
<?php } ?>
|
52 |
|
53 |
|
@@ -87,10 +87,13 @@ $fields->select('layout', __('Layout', 'newsletter'),
|
|
87 |
</div>
|
88 |
|
89 |
<div class="tnp-field-row">
|
90 |
-
<div class="tnp-field-col-
|
91 |
-
<?php $fields->number('excerpt_length', __('Excerpt
|
92 |
</div>
|
93 |
-
<div class="tnp-field-col-
|
|
|
|
|
|
|
94 |
<?php $fields->yesno('show_read_more_button', 'Show read more button') ?>
|
95 |
</div>
|
96 |
<div style="clear: both"></div>
|
14 |
|
15 |
<?php if ($context['type'] == 'automated') { ?>
|
16 |
|
17 |
+
<div class="tnp-field-box">
|
18 |
+
<p>
|
19 |
+
<strong>AUTOMATED</strong><br>
|
20 |
+
While composing all posts are shown while on sending posts are extrated following the rules below.
|
21 |
+
<a href="https://www.thenewsletterplugin.com/documentation/addons/extended-features/automated-extension/#regeneration" target="_blank">Read more</a>.
|
22 |
+
</p>
|
23 |
+
<?php $fields->select('automated_disabled', '', ['' => 'Use the last newsletter date and...', '1' => 'Do not consider the last newsletter']) ?>
|
24 |
|
25 |
+
<div class="tnp-field-row">
|
26 |
+
<div class="tnp-field-col-2">
|
27 |
+
<?php
|
28 |
+
$fields->select('automated_include', __('If there are new posts', 'newsletter'),
|
29 |
+
[
|
30 |
+
'new' => __('Include only new posts', 'newsletter'),
|
31 |
+
'max' => __('Include specified max posts', 'newsletter')
|
32 |
+
],
|
33 |
+
['description' => '', 'class' => 'tnp-small'])
|
34 |
+
?>
|
35 |
+
</div>
|
36 |
+
<div class="tnp-field-col-2">
|
37 |
+
<?php
|
38 |
+
$fields->select('automated', __('If there are not new posts', 'newsletter'),
|
39 |
+
[
|
40 |
+
'' => 'Show the message below',
|
41 |
+
'1' => 'Do not send the newsletter',
|
42 |
+
'2' => 'Remove this block'
|
43 |
+
],
|
44 |
+
['description' => '', 'class' => 'tnp-small'])
|
45 |
+
?>
|
46 |
+
<?php $fields->text('automated_no_contents', null, ['placeholder' => 'No new posts message']) ?>
|
47 |
+
</div>
|
48 |
</div>
|
49 |
+
<div style="clear: both"></div>
|
50 |
</div>
|
|
|
|
|
51 |
<?php } ?>
|
52 |
|
53 |
|
87 |
</div>
|
88 |
|
89 |
<div class="tnp-field-row">
|
90 |
+
<div class="tnp-field-col-3">
|
91 |
+
<?php $fields->number('excerpt_length', __('Excerpt length', 'newsletter'), array('min' => 0)); ?>
|
92 |
</div>
|
93 |
+
<div class="tnp-field-col-3">
|
94 |
+
<?php $fields->select('excerpt_length_type', 'Count', ['' => __('Words', 'newsletter'), 'chars' => __('Chars', 'newsletter')]); ?>
|
95 |
+
</div>
|
96 |
+
<div class="tnp-field-col-3">
|
97 |
<?php $fields->yesno('show_read_more_button', 'Show read more button') ?>
|
98 |
</div>
|
99 |
<div style="clear: both"></div>
|
emails/emails.php
CHANGED
@@ -781,7 +781,7 @@ class NewsletterEmails extends NewsletterModule {
|
|
781 |
header('X-Robots-Tag: noindex,nofollow,noarchive');
|
782 |
header('Cache-Control: no-cache,no-store,private');
|
783 |
|
784 |
-
echo $this->replace($email->message, $user, $email);
|
785 |
|
786 |
die();
|
787 |
break;
|
781 |
header('X-Robots-Tag: noindex,nofollow,noarchive');
|
782 |
header('Cache-Control: no-cache,no-store,private');
|
783 |
|
784 |
+
echo apply_filters('newsletter_view_message', $this->replace($email->message, $user, $email));
|
785 |
|
786 |
die();
|
787 |
break;
|
includes/helper.php
CHANGED
@@ -1,415 +1,430 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
defined('ABSPATH') || exit;
|
4 |
-
|
5 |
-
function tnp_post_thumbnail_src($post, $size = 'thumbnail', $alternative = '') {
|
6 |
-
if (is_object($post)) {
|
7 |
-
$post = $post->ID;
|
8 |
-
}
|
9 |
-
|
10 |
-
// Find a media id to be used as featured image
|
11 |
-
$media_id = get_post_thumbnail_id($post);
|
12 |
-
if (empty($media_id)) {
|
13 |
-
$attachments = get_children(array('numberpost' => 1, 'post_parent' => $post, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'));
|
14 |
-
if (!empty($attachments)) {
|
15 |
-
foreach ($attachments as $id => &$attachment) {
|
16 |
-
$media_id = $id;
|
17 |
-
break;
|
18 |
-
}
|
19 |
-
}
|
20 |
-
}
|
21 |
-
|
22 |
-
if (!$media_id) {
|
23 |
-
return $alternative;
|
24 |
-
}
|
25 |
-
|
26 |
-
if (!defined('NEWSLETTER_MEDIA_RESIZE') || NEWSLETTER_MEDIA_RESIZE) {
|
27 |
-
if (is_array($size)) {
|
28 |
-
$src = tnp_media_resize($media_id, $size);
|
29 |
-
if (is_wp_error($src)) {
|
30 |
-
Newsletter::instance()->logger->error($src);
|
31 |
-
return $alternative;
|
32 |
-
} else {
|
33 |
-
return $src;
|
34 |
-
}
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
$media = wp_get_attachment_image_src($media_id, $size);
|
39 |
-
if (strpos($media[0], 'http') !== 0) {
|
40 |
-
$media[0] = 'http:' . $media[0];
|
41 |
-
}
|
42 |
-
return $media[0];
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
//
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
function
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
if (
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
$
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
$
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
$
|
177 |
-
|
178 |
-
|
179 |
-
$src
|
180 |
-
return $
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
$media
|
217 |
-
$media->
|
218 |
-
$media->
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
$
|
250 |
-
|
251 |
-
$
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
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 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
if (
|
324 |
-
Newsletter::instance()->logger->error(
|
325 |
-
return _tnp_get_default_media($media_id, $size);
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
$
|
330 |
-
|
331 |
-
$
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
$
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
function
|
360 |
-
$
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
* @param
|
371 |
-
*
|
372 |
-
* @return
|
373 |
-
*/
|
374 |
-
function
|
375 |
-
$
|
376 |
-
foreach ($
|
377 |
-
$
|
378 |
-
}
|
379 |
-
|
380 |
-
return $
|
381 |
-
}
|
382 |
-
|
383 |
-
/**
|
384 |
-
*
|
385 |
-
*
|
386 |
-
*
|
387 |
-
* @
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
$
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
defined('ABSPATH') || exit;
|
4 |
+
|
5 |
+
function tnp_post_thumbnail_src($post, $size = 'thumbnail', $alternative = '') {
|
6 |
+
if (is_object($post)) {
|
7 |
+
$post = $post->ID;
|
8 |
+
}
|
9 |
+
|
10 |
+
// Find a media id to be used as featured image
|
11 |
+
$media_id = get_post_thumbnail_id($post);
|
12 |
+
if (empty($media_id)) {
|
13 |
+
$attachments = get_children(array('numberpost' => 1, 'post_parent' => $post, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'));
|
14 |
+
if (!empty($attachments)) {
|
15 |
+
foreach ($attachments as $id => &$attachment) {
|
16 |
+
$media_id = $id;
|
17 |
+
break;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
if (!$media_id) {
|
23 |
+
return $alternative;
|
24 |
+
}
|
25 |
+
|
26 |
+
if (!defined('NEWSLETTER_MEDIA_RESIZE') || NEWSLETTER_MEDIA_RESIZE) {
|
27 |
+
if (is_array($size)) {
|
28 |
+
$src = tnp_media_resize($media_id, $size);
|
29 |
+
if (is_wp_error($src)) {
|
30 |
+
Newsletter::instance()->logger->error($src);
|
31 |
+
return $alternative;
|
32 |
+
} else {
|
33 |
+
return $src;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$media = wp_get_attachment_image_src($media_id, $size);
|
39 |
+
if (strpos($media[0], 'http') !== 0) {
|
40 |
+
$media[0] = 'http:' . $media[0];
|
41 |
+
}
|
42 |
+
return $media[0];
|
43 |
+
}
|
44 |
+
|
45 |
+
$tnp_excerpt_length = 0;
|
46 |
+
function tnp_excerpt_length($length) {
|
47 |
+
global $tnp_excerpt_length;
|
48 |
+
return $tnp_excerpt_length;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param WP_Post $post
|
53 |
+
* @param int $length
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
function tnp_post_excerpt($post, $length = 30, $characters = false) {
|
58 |
+
global $tnp_excerpt_length;
|
59 |
+
|
60 |
+
if (!$length) return '';
|
61 |
+
|
62 |
+
$tnp_excerpt_length = (int)($length*1.5);
|
63 |
+
|
64 |
+
add_filter('excerpt_length', 'tnp_excerpt_length', PHP_INT_MAX);
|
65 |
+
|
66 |
+
$excerpt = get_the_excerpt($post->ID);
|
67 |
+
|
68 |
+
remove_filter('excerpt_length', 'tnp_excerpt_length', PHP_INT_MAX);
|
69 |
+
|
70 |
+
$excerpt = tnp_delete_all_shordcodes_tags($excerpt);
|
71 |
+
$excerpt = trim($excerpt);
|
72 |
+
$excerpt = str_replace(' ', '', $excerpt);
|
73 |
+
|
74 |
+
if ($characters) {
|
75 |
+
if (mb_strlen($excerpt) > $length) {
|
76 |
+
$excerpt = mb_substr($excerpt, 0, $length);
|
77 |
+
$i = mb_strrpos($excerpt, ' ');
|
78 |
+
if ($i) {
|
79 |
+
$excerpt = mb_substr($excerpt, 0, $i);
|
80 |
+
$excerpt .= '…';
|
81 |
+
}
|
82 |
+
}
|
83 |
+
} else {
|
84 |
+
$excerpt = wp_trim_words($excerpt, $length);
|
85 |
+
}
|
86 |
+
|
87 |
+
return $excerpt;
|
88 |
+
}
|
89 |
+
|
90 |
+
function tnp_delete_all_shordcodes_tags($post_content = '') {
|
91 |
+
//Delete open tags
|
92 |
+
$post_content = preg_replace("/\[[a-zA-Z0-9_-]*?(\s.*?)?\]/", '', $post_content);
|
93 |
+
//Delete close tags
|
94 |
+
$post_content = preg_replace("/\[\/[a-zA-Z0-9_-]*?\]/", '', $post_content);
|
95 |
+
|
96 |
+
return $post_content;
|
97 |
+
}
|
98 |
+
|
99 |
+
function tnp_post_permalink($post) {
|
100 |
+
return get_permalink($post->ID);
|
101 |
+
}
|
102 |
+
|
103 |
+
function tnp_post_content($post) {
|
104 |
+
return $post->post_content;
|
105 |
+
}
|
106 |
+
|
107 |
+
function tnp_post_title($post) {
|
108 |
+
//return $post->post_title;
|
109 |
+
return get_the_title($post);
|
110 |
+
}
|
111 |
+
|
112 |
+
function tnp_post_date($post, $format = null) {
|
113 |
+
return get_the_date( $format, $post );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Tries to create a resized version of a media uploaded to the media library.
|
118 |
+
* Returns an empty string if the media does not exists or generally if the attached file
|
119 |
+
* cannot be found. If the resize fails for whatever reason, fall backs to the
|
120 |
+
* standard image source returned by WP which is usually not exactly the
|
121 |
+
* requested size.
|
122 |
+
*
|
123 |
+
* @param int $media_id
|
124 |
+
* @param array $size
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
function tnp_media_resize($media_id, $size) {
|
128 |
+
if (empty($media_id)) {
|
129 |
+
return '';
|
130 |
+
}
|
131 |
+
|
132 |
+
$relative_file = get_post_meta($media_id, '_wp_attached_file', true);
|
133 |
+
if (empty($relative_file)) {
|
134 |
+
return '';
|
135 |
+
}
|
136 |
+
|
137 |
+
$width = $size[0];
|
138 |
+
$height = $size[1];
|
139 |
+
$crop = false;
|
140 |
+
if (isset($size[2])) {
|
141 |
+
$crop = (boolean) $size[2];
|
142 |
+
}
|
143 |
+
|
144 |
+
$uploads = wp_upload_dir();
|
145 |
+
|
146 |
+
// Based on _wp_relative_upload_path() function for blog which store the
|
147 |
+
// full patch of media files
|
148 |
+
if (0 === strpos($relative_file, $uploads['basedir'])) {
|
149 |
+
$relative_file = str_replace($uploads['basedir'], '', $relative_file);
|
150 |
+
$relative_file = ltrim($relative_file, '/');
|
151 |
+
}
|
152 |
+
|
153 |
+
$absolute_file = $uploads['basedir'] . '/' . $relative_file;
|
154 |
+
// Relative and absolute name of the thumbnail.
|
155 |
+
$pathinfo = pathinfo($relative_file);
|
156 |
+
|
157 |
+
// We don't know why, but on some systems files with non-ascii characters loose the file name (grrr...)
|
158 |
+
if (empty($pathinfo['filename'])) {
|
159 |
+
$src = wp_get_attachment_image_src($media_id, 'full');
|
160 |
+
return $src[0];
|
161 |
+
}
|
162 |
+
|
163 |
+
$relative_thumb = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $width . 'x' .
|
164 |
+
$height . ($crop ? '-c' : '') . '.' . $pathinfo['extension'];
|
165 |
+
$absolute_thumb = $uploads['basedir'] . '/newsletter/thumbnails/' . $relative_thumb;
|
166 |
+
|
167 |
+
// Thumbnail generation if needed.
|
168 |
+
if (!file_exists($absolute_thumb) || filemtime($absolute_thumb) < filemtime($absolute_file)) {
|
169 |
+
$r = wp_mkdir_p($uploads['basedir'] . '/newsletter/thumbnails/' . $pathinfo['dirname']);
|
170 |
+
|
171 |
+
if (!$r) {
|
172 |
+
$src = wp_get_attachment_image_src($media_id, 'full');
|
173 |
+
return $src[0];
|
174 |
+
}
|
175 |
+
|
176 |
+
$editor = wp_get_image_editor($absolute_file);
|
177 |
+
if (is_wp_error($editor)) {
|
178 |
+
$src = wp_get_attachment_image_src($media_id, 'full');
|
179 |
+
return $src[0];
|
180 |
+
//return $editor;
|
181 |
+
//return $uploads['baseurl'] . '/' . $relative_file;
|
182 |
+
}
|
183 |
+
|
184 |
+
$original_size = $editor->get_size();
|
185 |
+
if ($width > $original_size['width'] || $height > $original_size['height']) {
|
186 |
+
$src = wp_get_attachment_image_src($media_id, 'full');
|
187 |
+
return $src[0];
|
188 |
+
}
|
189 |
+
|
190 |
+
$editor->set_quality(80);
|
191 |
+
$resized = $editor->resize($width, $height, $crop);
|
192 |
+
|
193 |
+
if (is_wp_error($resized)) {
|
194 |
+
$src = wp_get_attachment_image_src($media_id, 'full');
|
195 |
+
return $src[0];
|
196 |
+
}
|
197 |
+
|
198 |
+
$saved = $editor->save($absolute_thumb);
|
199 |
+
if (is_wp_error($saved)) {
|
200 |
+
$src = wp_get_attachment_image_src($media_id, 'full');
|
201 |
+
return $src[0];
|
202 |
+
//return $saved;
|
203 |
+
//return $uploads['baseurl'] . '/' . $relative_file;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
return $uploads['baseurl'] . '/newsletter/thumbnails/' . $relative_thumb;
|
208 |
+
}
|
209 |
+
|
210 |
+
function _tnp_get_default_media($media_id, $size) {
|
211 |
+
|
212 |
+
$src = wp_get_attachment_image_src($media_id, $size);
|
213 |
+
if (!$src) {
|
214 |
+
return null;
|
215 |
+
}
|
216 |
+
$media = new TNP_Media();
|
217 |
+
$media->id = $media_id;
|
218 |
+
$media->url = $src[0];
|
219 |
+
$media->width = $src[1];
|
220 |
+
$media->height = $src[2];
|
221 |
+
return $media;
|
222 |
+
}
|
223 |
+
|
224 |
+
function tnp_get_media($media_id, $size) {
|
225 |
+
$src = wp_get_attachment_image_src($media_id, $size);
|
226 |
+
if (!$src) {
|
227 |
+
return null;
|
228 |
+
}
|
229 |
+
$media = new TNP_Media();
|
230 |
+
$media->id = $media_id;
|
231 |
+
$media->url = $src[0];
|
232 |
+
$media->width = $src[1];
|
233 |
+
$media->height = $src[2];
|
234 |
+
return $media;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Create a resized version of the media stored in the WP media library.
|
239 |
+
*
|
240 |
+
* @param int $media_id
|
241 |
+
* @param array $size
|
242 |
+
* @return TNP_Media
|
243 |
+
*/
|
244 |
+
function tnp_resize($media_id, $size) {
|
245 |
+
if (empty($media_id)) {
|
246 |
+
return null;
|
247 |
+
}
|
248 |
+
|
249 |
+
$relative_file = get_post_meta($media_id, '_wp_attached_file', true);
|
250 |
+
|
251 |
+
if (empty($relative_file)) {
|
252 |
+
return null;
|
253 |
+
}
|
254 |
+
|
255 |
+
$uploads = wp_upload_dir();
|
256 |
+
|
257 |
+
// Based on _wp_relative_upload_path() function for blog which store the
|
258 |
+
// full path of media files
|
259 |
+
if (0 === strpos($relative_file, $uploads['basedir'])) {
|
260 |
+
$relative_file = str_replace($uploads['basedir'], '', $relative_file);
|
261 |
+
$relative_file = ltrim($relative_file, '/');
|
262 |
+
}
|
263 |
+
|
264 |
+
$width = $size[0];
|
265 |
+
$height = $size[1];
|
266 |
+
$crop = false;
|
267 |
+
if (isset($size[2])) {
|
268 |
+
$crop = (boolean) $size[2];
|
269 |
+
}
|
270 |
+
|
271 |
+
$absolute_file = $uploads['basedir'] . '/' . $relative_file;
|
272 |
+
|
273 |
+
if (substr($relative_file, -4) === '.gif') {
|
274 |
+
$editor = wp_get_image_editor($absolute_file);
|
275 |
+
if (is_wp_error($editor)) {
|
276 |
+
return _tnp_get_default_media($media_id, $size);
|
277 |
+
}
|
278 |
+
$new_size = $editor->get_size();
|
279 |
+
$media = new TNP_Media();
|
280 |
+
$media->id = $media_id;
|
281 |
+
$media->width = $new_size['width'];
|
282 |
+
$media->height = $new_size['height'];
|
283 |
+
if ($media->width > $width) {
|
284 |
+
$media->set_width($width);
|
285 |
+
}
|
286 |
+
$media->url = $uploads['baseurl'] . '/' . $relative_file;
|
287 |
+
return $media;
|
288 |
+
}
|
289 |
+
|
290 |
+
// Relative and absolute name of the thumbnail.
|
291 |
+
$pathinfo = pathinfo($relative_file);
|
292 |
+
|
293 |
+
// We don't know why, but on some systems files with non-ascii characters loose the file name (grrr...)
|
294 |
+
if (empty($pathinfo['filename'])) {
|
295 |
+
return _tnp_get_default_media($media_id, $size);
|
296 |
+
}
|
297 |
+
|
298 |
+
$relative_thumb = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $width . 'x' . $height . ($crop ? '-c' : '') . '.' . $pathinfo['extension'];
|
299 |
+
$absolute_thumb = $uploads['basedir'] . '/newsletter/thumbnails/' . $relative_thumb;
|
300 |
+
|
301 |
+
// Thumbnail generation if needed.
|
302 |
+
if (!file_exists($absolute_thumb) || filemtime($absolute_thumb) < filemtime($absolute_file)) {
|
303 |
+
$r = wp_mkdir_p($uploads['basedir'] . '/newsletter/thumbnails/' . $pathinfo['dirname']);
|
304 |
+
|
305 |
+
if (!$r) {
|
306 |
+
Newsletter::instance()->logger->error('Unable to create dir ' . $uploads['basedir'] . '/newsletter/thumbnails/' . $pathinfo['dirname']);
|
307 |
+
return _tnp_get_default_media($media_id, $size);
|
308 |
+
}
|
309 |
+
|
310 |
+
$editor = wp_get_image_editor($absolute_file);
|
311 |
+
if (is_wp_error($editor)) {
|
312 |
+
Newsletter::instance()->logger->error($editor);
|
313 |
+
Newsletter::instance()->logger->error('File: ' . $absolute_file);
|
314 |
+
return _tnp_get_default_media($media_id, $size);
|
315 |
+
}
|
316 |
+
|
317 |
+
$original_size = $editor->get_size();
|
318 |
+
if ($width > $original_size['width'] && ($height > $original_size['height'] || $height == 0)) {
|
319 |
+
Newsletter::instance()->logger->error('Requested size larger than the original one');
|
320 |
+
return _tnp_get_default_media($media_id, $size);
|
321 |
+
}
|
322 |
+
|
323 |
+
if ($height > $original_size['height'] && ($width > $original_size['width'] || $width == 0)) {
|
324 |
+
Newsletter::instance()->logger->error('Requested size larger than the original one');
|
325 |
+
return _tnp_get_default_media($media_id, $size);
|
326 |
+
}
|
327 |
+
|
328 |
+
$editor->set_quality(85);
|
329 |
+
$resized = $editor->resize($width, $height, $crop);
|
330 |
+
|
331 |
+
if (is_wp_error($resized)) {
|
332 |
+
Newsletter::instance()->logger->error($resized);
|
333 |
+
Newsletter::instance()->logger->error('File: ' . $absolute_file);
|
334 |
+
return _tnp_get_default_media($media_id, $size);
|
335 |
+
}
|
336 |
+
|
337 |
+
$saved = $editor->save($absolute_thumb);
|
338 |
+
if (is_wp_error($saved)) {
|
339 |
+
Newsletter::instance()->logger->error($saved);
|
340 |
+
return _tnp_get_default_media($media_id, $size);
|
341 |
+
}
|
342 |
+
$new_size = $editor->get_size();
|
343 |
+
|
344 |
+
$media = new TNP_Media();
|
345 |
+
$media->width = $new_size['width'];
|
346 |
+
$media->height = $new_size['height'];
|
347 |
+
$media->url = $uploads['baseurl'] . '/newsletter/thumbnails/' . $relative_thumb;
|
348 |
+
} else {
|
349 |
+
$media = new TNP_Media();
|
350 |
+
$new_size = getimagesize($absolute_thumb);
|
351 |
+
$media->width = $new_size[0];
|
352 |
+
$media->height = $new_size[1];
|
353 |
+
$media->url = $uploads['baseurl'] . '/newsletter/thumbnails/' . $relative_thumb;
|
354 |
+
}
|
355 |
+
|
356 |
+
return $media;
|
357 |
+
}
|
358 |
+
|
359 |
+
function tnp_resize_2x($media_id, $size) {
|
360 |
+
$size[0] = $size[0] * 2;
|
361 |
+
$size[1] = $size[1] * 2;
|
362 |
+
$media = tnp_resize($media_id, $size);
|
363 |
+
if (!$media)
|
364 |
+
return $media;
|
365 |
+
$media->set_width($size[0] / 2);
|
366 |
+
return $media;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* @param TNP_Media[] $images
|
371 |
+
*
|
372 |
+
* @return int
|
373 |
+
*/
|
374 |
+
function tnp_get_max_height_of($images) {
|
375 |
+
$max_height = 0;
|
376 |
+
foreach ($images as $image) {
|
377 |
+
$max_height = $image->height > $max_height ? $image->height : $max_height;
|
378 |
+
}
|
379 |
+
|
380 |
+
return $max_height;
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* @param WP_Post[] $product_list
|
385 |
+
* @param array $size
|
386 |
+
*
|
387 |
+
* @return TNP_Media[]
|
388 |
+
*/
|
389 |
+
function tnp_resize_product_list_featured_image($product_list, $size) {
|
390 |
+
$images = [];
|
391 |
+
foreach ($product_list as $p) {
|
392 |
+
$images[$p->ID] = tnp_resize_2x(TNP_Composer::get_post_thumbnail_id($p->ID), $size);
|
393 |
+
}
|
394 |
+
|
395 |
+
return $images;
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Get media for "posts" composer block
|
400 |
+
*
|
401 |
+
* @param WP_Post post
|
402 |
+
* @param array $size
|
403 |
+
* @param string $default_image_url
|
404 |
+
*
|
405 |
+
* @return TNP_Media
|
406 |
+
*/
|
407 |
+
function tnp_composer_block_posts_get_media($post, $size, $default_image_url = null) {
|
408 |
+
$post_thumbnail_id = TNP_Composer::get_post_thumbnail_id($post);
|
409 |
+
|
410 |
+
$media = null;
|
411 |
+
|
412 |
+
if (!empty($post_thumbnail_id)) {
|
413 |
+
$media = tnp_resize($post_thumbnail_id, array_values($size));
|
414 |
+
} else if ($default_image_url) {
|
415 |
+
Newsletter::instance()->logger->error('Thumbnail id not found');
|
416 |
+
$media = new TNP_Media();
|
417 |
+
$media->url = $default_image_url;
|
418 |
+
$media->width = $size['width'];
|
419 |
+
$media->height = $size['height'];
|
420 |
+
}
|
421 |
+
return $media;
|
422 |
+
}
|
423 |
+
|
424 |
+
function tnp_outlook_wrapper_open($width = 600) {
|
425 |
+
return NewsletterEmails::get_outlook_wrapper_open($width);
|
426 |
+
}
|
427 |
+
|
428 |
+
function tnp_outlook_wrapper_close() {
|
429 |
+
return NewsletterEmails::get_outlook_wrapper_close();
|
430 |
+
}
|
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.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.
|
@@ -37,7 +37,7 @@ if (version_compare(phpversion(), '5.6', '<')) {
|
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
-
define('NEWSLETTER_VERSION', '7.5.
|
41 |
|
42 |
global $newsletter, $wpdb;
|
43 |
|
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.5.8
|
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.
|
37 |
return;
|
38 |
}
|
39 |
|
40 |
+
define('NEWSLETTER_VERSION', '7.5.8');
|
41 |
|
42 |
global $newsletter, $wpdb;
|
43 |
|
readme.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
=== Newsletter - Send awesome emails from WordPress ===
|
2 |
Tags: newsletter, email marketing, welcome email, signup forms, lead generation, marketing automation
|
3 |
Tested up to: 6.1.1
|
4 |
-
Stable tag: 7.5.
|
5 |
Contributors: satollo,webagile,michael-travan
|
6 |
License: GPLv2 or later
|
7 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -126,6 +126,13 @@ Thank you, The Newsletter Team
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
= 7.5.7 =
|
130 |
|
131 |
* Check on ctype_space function (there are installation without it)
|
1 |
=== Newsletter - Send awesome emails from WordPress ===
|
2 |
Tags: newsletter, email marketing, welcome email, signup forms, lead generation, marketing automation
|
3 |
Tested up to: 6.1.1
|
4 |
+
Stable tag: 7.5.8
|
5 |
Contributors: satollo,webagile,michael-travan
|
6 |
License: GPLv2 or later
|
7 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 7.5.8 =
|
130 |
+
|
131 |
+
* Added filter on newsletter message before online view
|
132 |
+
* Added excerpt lenght in character (useful for Chinese) on posts block
|
133 |
+
* Improved the excerpt extraction
|
134 |
+
* Add link on excerpt on posts block
|
135 |
+
|
136 |
= 7.5.7 =
|
137 |
|
138 |
* Check on ctype_space function (there are installation without it)
|