Newsletter - Version 5.8.9

Version Description

  • Global constant to block the media resizing
  • Resized thumbnails folder changed to the uploads folder (newsletter/thumbnails subfolder)
  • Fall back on first post gallery image if the featured image is missing
  • Patch to block third party plugins visual editor injection in out pages
  • Fix media selector button on visual composer
Download this release

Release Info

Developer satollo
Plugin Icon 128x128 Newsletter
Version 5.8.9
Comparing to
See all releases

Code changes from version 5.8.8 to 5.8.9

admin.css CHANGED
@@ -773,7 +773,7 @@ p.description {
773
  }
774
 
775
  #tnp-heading div p {
776
- color: #666;
777
  }
778
 
779
  #tnp-heading h2 {
@@ -2089,12 +2089,13 @@ iframe.tnp-editor-preview-desktop {
2089
  /* Form inserimento licenza in Addons Manager */
2090
 
2091
  #tnp-license-control {
2092
- border: 2px solid #27313C;
2093
  display: inline-block;
2094
- padding: 15px 25px;
2095
  margin-left: -10px;
2096
  margin-top: 15px;
2097
  border-radius: 2px;
 
2098
  }
2099
 
2100
  #tnp-license-control form {
773
  }
774
 
775
  #tnp-heading div p {
776
+ color: #565656;
777
  }
778
 
779
  #tnp-heading h2 {
2089
  /* Form inserimento licenza in Addons Manager */
2090
 
2091
  #tnp-license-control {
2092
+ border-left: 5px solid #27ae60;
2093
  display: inline-block;
2094
+ padding: 15px 20px;
2095
  margin-left: -10px;
2096
  margin-top: 15px;
2097
  border-radius: 2px;
2098
+ background-color: #fff;
2099
  }
2100
 
2101
  #tnp-license-control form {
emails/emails.php CHANGED
@@ -29,6 +29,13 @@ class NewsletterEmails extends NewsletterModule {
29
  add_action('wp_ajax_tnpc_preview', array($this, 'tnpc_preview_callback'));
30
  add_action('wp_ajax_tnpc_css', array($this, 'tnpc_css_callback'));
31
  add_action('wp_ajax_tnpc_options', array($this, 'hook_wp_ajax_tnpc_options'));
 
 
 
 
 
 
 
32
  }
33
  }
34
 
29
  add_action('wp_ajax_tnpc_preview', array($this, 'tnpc_preview_callback'));
30
  add_action('wp_ajax_tnpc_css', array($this, 'tnpc_css_callback'));
31
  add_action('wp_ajax_tnpc_options', array($this, 'hook_wp_ajax_tnpc_options'));
32
+
33
+ // Thank you to plugins which add the WP editor on other admin plugin pages...
34
+ if (isset($_GET['page']) && $_GET['page'] == 'newsletter_emails_edit') {
35
+ global $wp_actions;
36
+ $wp_actions['wp_enqueue_editor'] = 1;
37
+ }
38
+
39
  }
40
  }
41
 
emails/tnp-composer/edit.php CHANGED
@@ -41,9 +41,6 @@ function tnp_buttons_row() {
41
  // Create the media frame.
42
  file_frame = wp.media.frames.file_frame = wp.media({
43
  title: jQuery('#tnpc-edit-image .image').val(),
44
- button: {
45
- text: '',
46
- },
47
  multiple: false // Set to true to allow multiple files to be selected
48
  });
49
  // When an image is selected, run a callback.
@@ -73,10 +70,7 @@ function tnp_buttons_row() {
73
  <div class="tnpc-edit-box-content-text"><?php _e("URL", "newsletter") ?> <span>(full address including http://)</span></div>
74
  <div class="tnpc-edit-box-content-field"><input type="text" class="tnpc-edit-box-content-field-input url"/></div>
75
  </div>
76
- <div class="tnpc-edit-box-buttons">
77
- <div class="tnpc-edit-box-buttons-save"><?php _e("Save", "newsletter") ?></div>
78
- <div class="tnpc-edit-box-buttons-cancel"><?php _e("Cancel", "newsletter") ?></div>
79
- </div>
80
  </div>
81
  </div>
82
 
@@ -94,10 +88,7 @@ function tnp_buttons_row() {
94
  <div class="tnpc-edit-box-content-text"><?php _e("Background Color", "newsletter") ?></div>
95
  <div class="tnpc-edit-box-content-field"><input type="text" class="tnpc-edit-box-content-field-input bgcolor"/></div>
96
  </div>
97
- <div class="tnpc-edit-box-buttons">
98
- <div class="tnpc-edit-box-buttons-save"><?php _e("Save", "newsletter") ?></div>
99
- <div class="tnpc-edit-box-buttons-cancel"><?php _e("Cancel", "newsletter") ?></div>
100
- </div>
101
  </div>
102
  </div>
103
 
@@ -149,10 +140,7 @@ function tnp_buttons_row() {
149
  </select>
150
  </div>
151
  </div>
152
- <div class="tnpc-edit-box-buttons">
153
- <div class="tnpc-edit-box-buttons-save"><?php _e("Save", "newsletter") ?></div>
154
- <div class="tnpc-edit-box-buttons-cancel"><?php _e("Cancel", "newsletter") ?></div>
155
- </div>
156
  </div>
157
  </div>
158
 
@@ -165,10 +153,7 @@ function tnp_buttons_row() {
165
  <div class="tnpc-edit-box-content-text"><?php _e("Text", "newsletter") ?></div>
166
  <div class="tnpc-edit-box-content-field"><textarea class="tnpc-edit-box-content-field-textarea text"></textarea></div>
167
  </div>
168
- <div class="tnpc-edit-box-buttons">
169
- <div class="tnpc-edit-box-buttons-save"><?php _e("Save", "newsletter") ?></div>
170
- <div class="tnpc-edit-box-buttons-cancel"><?php _e("Cancel", "newsletter") ?></div>
171
- </div>
172
  </div>
173
  </div>
174
 
@@ -209,10 +194,7 @@ function tnp_buttons_row() {
209
  </select>
210
  </div>
211
  </div>
212
- <div class="tnpc-edit-box-buttons">
213
- <div class="tnpc-edit-box-buttons-save"><?php _e("Save", "newsletter") ?></div>
214
- <div class="tnpc-edit-box-buttons-cancel"><?php _e("Cancel", "newsletter") ?></div>
215
- </div>
216
  </div>
217
  </div>
218
 
@@ -255,12 +237,9 @@ function tnp_buttons_row() {
255
  </div>
256
  <div class="tnpc-edit-box-content-text"><?php _e("Tags (comma separated)", "newsletter") ?></div>
257
  <div class="tnpc-edit-box-content-field"><input type="text" class="tnpc-edit-box-content-field-input tags"/></div>
258
- </div>
259
- <div class="tnpc-edit-box-buttons">
260
  <?php _e("Any prior changes to single posts will be lost when editing these settings.", "newsletter") ?>
261
- <div class="tnpc-edit-box-buttons-save"><?php _e("Save", "newsletter") ?></div>
262
- <div class="tnpc-edit-box-buttons-cancel"><?php _e("Cancel", "newsletter") ?></div>
263
  </div>
 
264
  </div>
265
  </div>
266
 
41
  // Create the media frame.
42
  file_frame = wp.media.frames.file_frame = wp.media({
43
  title: jQuery('#tnpc-edit-image .image').val(),
 
 
 
44
  multiple: false // Set to true to allow multiple files to be selected
45
  });
46
  // When an image is selected, run a callback.
70
  <div class="tnpc-edit-box-content-text"><?php _e("URL", "newsletter") ?> <span>(full address including http://)</span></div>
71
  <div class="tnpc-edit-box-content-field"><input type="text" class="tnpc-edit-box-content-field-input url"/></div>
72
  </div>
73
+ <?php tnp_buttons_row() ?>
 
 
 
74
  </div>
75
  </div>
76
 
88
  <div class="tnpc-edit-box-content-text"><?php _e("Background Color", "newsletter") ?></div>
89
  <div class="tnpc-edit-box-content-field"><input type="text" class="tnpc-edit-box-content-field-input bgcolor"/></div>
90
  </div>
91
+ <?php tnp_buttons_row() ?>
 
 
 
92
  </div>
93
  </div>
94
 
140
  </select>
141
  </div>
142
  </div>
143
+ <?php tnp_buttons_row() ?>
 
 
 
144
  </div>
145
  </div>
146
 
153
  <div class="tnpc-edit-box-content-text"><?php _e("Text", "newsletter") ?></div>
154
  <div class="tnpc-edit-box-content-field"><textarea class="tnpc-edit-box-content-field-textarea text"></textarea></div>
155
  </div>
156
+ <?php tnp_buttons_row() ?>
 
 
 
157
  </div>
158
  </div>
159
 
194
  </select>
195
  </div>
196
  </div>
197
+ <?php tnp_buttons_row() ?>
 
 
 
198
  </div>
199
  </div>
200
 
237
  </div>
238
  <div class="tnpc-edit-box-content-text"><?php _e("Tags (comma separated)", "newsletter") ?></div>
239
  <div class="tnpc-edit-box-content-field"><input type="text" class="tnpc-edit-box-content-field-input tags"/></div>
 
 
240
  <?php _e("Any prior changes to single posts will be lost when editing these settings.", "newsletter") ?>
 
 
241
  </div>
242
+ <?php tnp_buttons_row() ?>
243
  </div>
244
  </div>
245
 
includes/controls.php CHANGED
@@ -1332,6 +1332,14 @@ class NewsletterControls {
1332
  return NewsletterUsers::instance()->get_test_users();
1333
  }
1334
 
 
 
 
 
 
 
 
 
1335
  function css_font($name = 'font', $attrs = array()) {
1336
  $default = array('color' => true, 'weight'=>true);
1337
  $attrs = array_merge($default, $attrs);
1332
  return NewsletterUsers::instance()->get_test_users();
1333
  }
1334
 
1335
+ /**
1336
+ * Attributes:
1337
+ * weight: [true|false]
1338
+ * color: [true|false]
1339
+ *
1340
+ * @param string $name
1341
+ * @param array $attrs
1342
+ */
1343
  function css_font($name = 'font', $attrs = array()) {
1344
  $default = array('color' => true, 'weight'=>true);
1345
  $attrs = array_merge($default, $attrs);
includes/helper.php CHANGED
@@ -1,28 +1,41 @@
1
  <?php
2
 
3
- if (!defined('ABSPATH'))
4
- exit;
5
 
6
  function tnp_post_thumbnail_src($post, $size = 'thumbnail', $alternative = '') {
7
  if (is_object($post)) {
8
  $post = $post->ID;
9
  }
10
 
11
- if (is_array($size)) {
12
- $media_id = get_post_thumbnail_id($post);
13
- if (!$media_id) {
14
- return $alternative;
 
 
 
 
 
15
  }
16
- $src = tnp_media_resize($media_id, $size);
17
- if (is_wp_error($src)) {
18
- Newsletter::instance()->logger->error($src);
19
- return $alternative;
20
- } else {
21
- return $src;
 
 
 
 
 
 
 
 
 
22
  }
23
  }
24
 
25
- $media = wp_get_attachment_image_src(get_post_thumbnail_id($post), $size);
26
  if (strpos($media[0], 'http') !== 0) {
27
  $media[0] = 'http:' . $media[0];
28
  }
@@ -70,10 +83,12 @@ function tnp_post_date($post, $format = null) {
70
  * @return string
71
  */
72
  function tnp_media_resize($media_id, $size) {
73
- if (empty($media_id)) return '';
 
74
  $relative_file = get_post_meta($media_id, '_wp_attached_file', true);
75
- if (empty($relative_file)) return '';
76
-
 
77
  $width = $size[0];
78
  $height = $size[1];
79
  $crop = false;
@@ -87,17 +102,17 @@ function tnp_media_resize($media_id, $size) {
87
  $pathinfo = pathinfo($relative_file);
88
  $relative_thumb = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $width . 'x' .
89
  $height . ($crop ? '-c' : '') . '.' . $pathinfo['extension'];
90
- $absolute_thumb = WP_CONTENT_DIR . '/newsletter/thumbnails/' . $relative_thumb;
91
 
92
  // Thumbnail generation if needed.
93
  if (!file_exists($absolute_thumb) || filemtime($absolute_thumb) < filemtime($absolute_file)) {
94
- $r = wp_mkdir_p(WP_CONTENT_DIR . '/newsletter/thumbnails/' . $pathinfo['dirname']);
95
-
96
  if (!$r) {
97
  $src = wp_get_attachment_image_src($media_id, $size);
98
  return $src[0];
99
  }
100
-
101
  $editor = wp_get_image_editor($absolute_file);
102
  if (is_wp_error($editor)) {
103
  $src = wp_get_attachment_image_src($media_id, $size);
@@ -123,5 +138,7 @@ function tnp_media_resize($media_id, $size) {
123
  }
124
  }
125
 
126
- return WP_CONTENT_URL . '/newsletter/thumbnails/' . $relative_thumb;
 
 
127
  }
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
  }
83
  * @return string
84
  */
85
  function tnp_media_resize($media_id, $size) {
86
+ if (empty($media_id))
87
+ return '';
88
  $relative_file = get_post_meta($media_id, '_wp_attached_file', true);
89
+ if (empty($relative_file))
90
+ return '';
91
+
92
  $width = $size[0];
93
  $height = $size[1];
94
  $crop = false;
102
  $pathinfo = pathinfo($relative_file);
103
  $relative_thumb = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $width . 'x' .
104
  $height . ($crop ? '-c' : '') . '.' . $pathinfo['extension'];
105
+ $absolute_thumb = $uploads['basedir'] . '/newsletter/thumbnails/' . $relative_thumb;
106
 
107
  // Thumbnail generation if needed.
108
  if (!file_exists($absolute_thumb) || filemtime($absolute_thumb) < filemtime($absolute_file)) {
109
+ $r = wp_mkdir_p($uploads['basedir'] . '/newsletter/thumbnails/' . $pathinfo['dirname']);
110
+
111
  if (!$r) {
112
  $src = wp_get_attachment_image_src($media_id, $size);
113
  return $src[0];
114
  }
115
+
116
  $editor = wp_get_image_editor($absolute_file);
117
  if (is_wp_error($editor)) {
118
  $src = wp_get_attachment_image_src($media_id, $size);
138
  }
139
  }
140
 
141
+
142
+
143
+ return $uploads['baseurl'] . '/newsletter/thumbnails/' . $relative_thumb;
144
  }
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: 5.8.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.
@@ -29,7 +29,7 @@
29
  */
30
 
31
  // Used as dummy parameter on css and js links
32
- define('NEWSLETTER_VERSION', '5.8.8');
33
 
34
  global $newsletter, $wpdb;
35
 
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: 5.8.9
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.
29
  */
30
 
31
  // Used as dummy parameter on css and js links
32
+ define('NEWSLETTER_VERSION', '5.8.9');
33
 
34
  global $newsletter, $wpdb;
35
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated,mailing list
3
  Requires at least: 3.4.0
4
  Tested up to: 5.0.3
5
- Stable tag: 5.8.8
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -122,10 +122,17 @@ Thank you, The Newsletter Team
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
 
 
 
125
  = 5.8.8 =
126
 
127
  * Fixed multilanguage text for newsletter page
128
-
129
  * Fixed a profile panel debug notice
130
 
131
  = 5.8.7 =
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated,mailing list
3
  Requires at least: 3.4.0
4
  Tested up to: 5.0.3
5
+ Stable tag: 5.8.9
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
122
 
123
  == Changelog ==
124
 
125
+ = 5.8.9 =
126
+
127
+ * Global constant to block the media resizing
128
+ * Resized thumbnails folder changed to the uploads folder (newsletter/thumbnails subfolder)
129
+ * Fall back on first post gallery image if the featured image is missing
130
+ * Patch to block third party plugins visual editor injection in out pages
131
+ * Fix media selector button on visual composer
132
+
133
  = 5.8.8 =
134
 
135
  * Fixed multilanguage text for newsletter page
 
136
  * Fixed a profile panel debug notice
137
 
138
  = 5.8.7 =
tnp-header.php CHANGED
@@ -88,7 +88,9 @@ $warning |= empty($status_options['mail']);
88
  </li>
89
  <li><a href="#"><i class="fa fa-newspaper-o"></i> <?php _e('Newsletters', 'newsletter') ?> <i class="fa fa-chevron-down"></i></a>
90
  <ul>
91
- <li><a href="?page=newsletter_emails_index"><i class="fa fa-newspaper-o"></i> <?php _e('Single Newsletter', 'newsletter') ?>
 
 
92
  <small><?php _e('The classic "write & send" newsletters', 'newsletter') ?></small></a></li>
93
  <li><a href="?page=<?php echo apply_filters('newsletter_admin_page', 'newsletter_statistics_index') ?>"><i class="fa fa-bar-chart"></i> <?php _e('Statistics', 'newsletter') ?>
94
  <small><?php _e('Tracking configuration and basic data', 'newsletter') ?></small></a></li>
88
  </li>
89
  <li><a href="#"><i class="fa fa-newspaper-o"></i> <?php _e('Newsletters', 'newsletter') ?> <i class="fa fa-chevron-down"></i></a>
90
  <ul>
91
+ <li><a href="?page=newsletter_emails_theme"><i class="fa fa-plus"></i> <?php _e('Create newsletter', 'newsletter') ?>
92
+ <small><?php _e('Start your new campaign', 'newsletter') ?></small></a></li>
93
+ <li><a href="?page=newsletter_emails_index"><i class="fa fa-newspaper-o"></i> <?php _e('Newsletters', 'newsletter') ?>
94
  <small><?php _e('The classic "write & send" newsletters', 'newsletter') ?></small></a></li>
95
  <li><a href="?page=<?php echo apply_filters('newsletter_admin_page', 'newsletter_statistics_index') ?>"><i class="fa fa-bar-chart"></i> <?php _e('Statistics', 'newsletter') ?>
96
  <small><?php _e('Tracking configuration and basic data', 'newsletter') ?></small></a></li>