Newsletter - Version 7.1.1

Version Description

  • [GENERAL] Improved profile related functions
  • [GENERAL] Fixed check on field names (thanks Peter P.)
  • [COMPOSER] Fix on preset selection
  • [GENERAL] Fix ajax subscription on error
Download this release

Release Info

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

Code changes from version 7.1.0 to 7.1.1

emails/emails.php CHANGED
@@ -195,7 +195,10 @@ class NewsletterEmails extends NewsletterModule
195
  {
196
 
197
  $content = "<div class='tnpc-preset-container'>";
198
- $content .= "<div class='tnpc-preset-legacy-themes'><a href='" . $this->get_admin_page_url('theme') . "'>" . __('Looking for legacy themes?', 'newsletter') . "</a></div>";
 
 
 
199
 
200
  // LOAD USER PRESETS
201
  $user_preset_list = $this->get_emails(self::PRESET_EMAIL_TYPE);
@@ -231,41 +234,69 @@ class NewsletterEmails extends NewsletterModule
231
  $content .= "</div>";
232
  }
233
 
234
- // Automated spot
235
- $content .= "<div class='tnpc-preset'>";
236
- if (class_exists('NewsletterAutomated')) {
237
- $content .= "<a href='?page=newsletter_automated_index'>";
238
- } else {
239
- $content .= "<a href='https://www.thenewsletterplugin.com/automated?utm_source=plugin&utm_campaign=automated&utm_medium=composer'>";
240
- }
241
- $content .= "<img src='" . plugins_url('newsletter') . "/emails/images/automated.png' title='Automated addon' alt='Automated'/>";
242
- $content .= "<span class='tnpc-preset-label'>Daily, weekly and monthly newsletters</span></a>";
243
- $content .= "</div>";
244
-
245
- // Autoresponder spot
246
- $content .= "<div class='tnpc-preset'>";
247
- if (class_exists('NewsletterAutoresponder')) {
248
- $content .= "<a href='?page=newsletter_autoresponder_index'>";
249
- } else {
250
- $content .= "<a href='https://www.thenewsletterplugin.com/autoresponder?utm_source=plugin&utm_campaign=autoresponder&utm_medium=composer' target='_blank'>";
251
- }
252
- $content .= "<img src='" . plugins_url('newsletter') . "/emails/images/autoresponder.png' title='Autoresponder addon' alt='Autoresponder'/>";
253
- $content .= "<span class='tnpc-preset-label'>Autoresponders</span></a>";
254
- $content .= "</div>";
255
-
256
- // RAW HTML
257
- $content .= "<div class='tnpc-preset tnpc-preset-html' onclick='location.href=\"" . wp_nonce_url('admin.php?page=newsletter_emails_new&id=rawhtml', 'newsletter-new') . "\"'>";
258
- $content .= "<img src='" . plugins_url('newsletter') . "/emails/images/rawhtml.png' title='RAW HTML' alt='RAW'/>";
259
- $content .= "<span class='tnpc-preset-label'>Raw HTML</span>";
260
- $content .= "</div>";
261
-
262
- $content .= "<div class='clear'></div>";
263
- $content .= "</div>";;
264
 
265
  return $content;
266
 
267
  }
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  /**
270
  * Check if the preset name exists and adds an incremental suffix if the name exists.
271
  *
@@ -354,20 +385,22 @@ class NewsletterEmails extends NewsletterModule
354
 
355
  ob_start();
356
  $out = $this->render_block($options['block_id'], true, $options, $context);
357
- if ($out['return_empty_message'] || $out['stop']) {
358
- if (is_object($email)) {
359
- return false;
 
 
 
360
  }
361
- return array();
362
- }
363
- if ($out['skip']) {
364
- if (NEWSLETTER_DEBUG) {
365
- $result .= 'Block removed by request';
 
 
 
366
  }
367
- continue;
368
- }
369
- if (empty($subject) && !empty($out['subject'])) {
370
- $subject = $out['subject'];
371
  }
372
  $block_html = ob_get_clean();
373
  $result .= $block_html;
195
  {
196
 
197
  $content = "<div class='tnpc-preset-container'>";
198
+
199
+ if ( $this->is_normal_context_request() ) {
200
+ $content .= "<div class='tnpc-preset-legacy-themes'><a href='" . $this->get_admin_page_url( 'theme' ) . "'>" . __( 'Looking for legacy themes?', 'newsletter' ) . "</a></div>";
201
+ }
202
 
203
  // LOAD USER PRESETS
204
  $user_preset_list = $this->get_emails(self::PRESET_EMAIL_TYPE);
234
  $content .= "</div>";
235
  }
236
 
237
+ if ( $this->is_normal_context_request() ) {
238
+ $content .= $this->get_automated_spot_element();
239
+ $content .= $this->get_autoresponder_spot_element();
240
+ $content .= $this->get_raw_html_preset_element();
241
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
  return $content;
244
 
245
  }
246
 
247
+ private function is_normal_context_request() {
248
+ return empty( $_REQUEST['context_type'] );
249
+ }
250
+
251
+ private function is_automated_context_request() {
252
+ return isset( $_REQUEST['context_type'] ) && $_REQUEST['context_type'] === 'automated';
253
+ }
254
+
255
+ private function is_autoresponder_context_request() {
256
+ return isset( $_REQUEST['context_type'] ) && $_REQUEST['context_type'] === 'autoresponder';
257
+ }
258
+
259
+ private function get_automated_spot_element() {
260
+ $result = "<div class='tnpc-preset'>";
261
+ if ( class_exists( 'NewsletterAutomated' ) ) {
262
+ $result .= "<a href='?page=newsletter_automated_index'>";
263
+ } else {
264
+ $result .= "<a href='https://www.thenewsletterplugin.com/automated?utm_source=plugin&utm_campaign=automated&utm_medium=composer'>";
265
+ }
266
+ $result .= "<img src='" . plugins_url( 'newsletter' ) . "/emails/images/automated.png' title='Automated addon' alt='Automated'/>";
267
+ $result .= "<span class='tnpc-preset-label'>Daily, weekly and monthly newsletters</span></a>";
268
+ $result .= "</div>";
269
+
270
+ return $result;
271
+ }
272
+
273
+ private function get_autoresponder_spot_element() {
274
+ $result = "<div class='tnpc-preset'>";
275
+ if ( class_exists( 'NewsletterAutoresponder' ) ) {
276
+ $result .= "<a href='?page=newsletter_autoresponder_index'>";
277
+ } else {
278
+ $result .= "<a href='https://www.thenewsletterplugin.com/autoresponder?utm_source=plugin&utm_campaign=autoresponder&utm_medium=composer' target='_blank'>";
279
+ }
280
+ $result .= "<img src='" . plugins_url( 'newsletter' ) . "/emails/images/autoresponder.png' title='Autoresponder addon' alt='Autoresponder'/>";
281
+ $result .= "<span class='tnpc-preset-label'>Autoresponders</span></a>";
282
+ $result .= "</div>";
283
+
284
+ return $result;
285
+ }
286
+
287
+ private function get_raw_html_preset_element() {
288
+
289
+ $result = "<div class='tnpc-preset tnpc-preset-html' onclick='location.href=\"" . wp_nonce_url( 'admin.php?page=newsletter_emails_new&id=rawhtml', 'newsletter-new' ) . "\"'>";
290
+ $result .= "<img src='" . plugins_url( 'newsletter' ) . "/emails/images/rawhtml.png' title='RAW HTML' alt='RAW'/>";
291
+ $result .= "<span class='tnpc-preset-label'>Raw HTML</span>";
292
+ $result .= "</div>";
293
+
294
+ $result .= "<div class='clear'></div>";
295
+ $result .= "</div>";
296
+
297
+ return $result;
298
+ }
299
+
300
  /**
301
  * Check if the preset name exists and adds an incremental suffix if the name exists.
302
  *
385
 
386
  ob_start();
387
  $out = $this->render_block($options['block_id'], true, $options, $context);
388
+ if (is_array($out)) {
389
+ if ($out['return_empty_message'] || $out['stop']) {
390
+ if (is_object($email)) {
391
+ return false;
392
+ }
393
+ return array();
394
  }
395
+ if ($out['skip']) {
396
+ if (NEWSLETTER_DEBUG) {
397
+ $result .= 'Block removed by request';
398
+ }
399
+ continue;
400
+ }
401
+ if (empty($subject) && !empty($out['subject'])) {
402
+ $subject = $out['subject'];
403
  }
 
 
 
 
404
  }
405
  $block_html = ob_get_clean();
406
  $result .= $block_html;
emails/tnp-composer/_scripts/newsletter-builder-v2.js CHANGED
@@ -505,6 +505,7 @@ function tnpc_show_presets() {
505
 
506
  jQuery(elModalContent).load(ajaxurl, {
507
  action: "tnpc_presets",
 
508
  });
509
 
510
  }
505
 
506
  jQuery(elModalContent).load(ajaxurl, {
507
  action: "tnpc_presets",
508
+ context_type: tnp_context_type,
509
  });
510
 
511
  }
includes/module.php CHANGED
@@ -1366,6 +1366,10 @@ class NewsletterModule {
1366
  }
1367
  return $user_count;
1368
  }
 
 
 
 
1369
 
1370
  /**
1371
  * @param string $language The language for the list labels (it does not affect the lists returned)
1366
  }
1367
  return $user_count;
1368
  }
1369
+
1370
+ function get_profile($id, $language = '') {
1371
+ return TNP_Profile_Service::get_profile_by_id($id, $language);
1372
+ }
1373
 
1374
  /**
1375
  * @param string $language The language for the list labels (it does not affect the lists returned)
includes/store.php CHANGED
@@ -34,7 +34,7 @@ class NewsletterStore {
34
  function get_field($table, $id, $field_name) {
35
  global $wpdb;
36
  $field_name = (string)$field_name;
37
- if (preg_match('/^[a-zA-Z_]+$/', $field_name) == 0) {
38
  $this->logger->fatal('Invalis field name: ' . $field_name);
39
  return false;
40
  }
@@ -159,7 +159,7 @@ class NewsletterStore {
159
  $id = (int)$id;
160
  $field = (string)$field;
161
 
162
- if (preg_match('/^[a-zA-Z_]+$/', $field) == 0) {
163
  $this->logger->error('Invalis field name: ' . $field);
164
  return false;
165
  }
@@ -221,7 +221,7 @@ class NewsletterStore {
221
  $id = (int)$id;
222
  $value = (string)$value;
223
 
224
- if (preg_match('/^[a-zA-Z_]+$/', $field) == 0) {
225
  $this->logger->error('Invalis field name: ' . $field_name);
226
  return false;
227
  }
34
  function get_field($table, $id, $field_name) {
35
  global $wpdb;
36
  $field_name = (string)$field_name;
37
+ if (preg_match('/^[a-zA-Z0-9_]+$/', $field_name) == 0) {
38
  $this->logger->fatal('Invalis field name: ' . $field_name);
39
  return false;
40
  }
159
  $id = (int)$id;
160
  $field = (string)$field;
161
 
162
+ if (preg_match('/^[a-zA-Z0-9_]+$/', $field) == 0) {
163
  $this->logger->error('Invalis field name: ' . $field);
164
  return false;
165
  }
221
  $id = (int)$id;
222
  $value = (string)$value;
223
 
224
+ if (preg_match('/^[a-zA-Z0-9_]+$/', $field) == 0) {
225
  $this->logger->error('Invalis field name: ' . $field_name);
226
  return false;
227
  }
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.0
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.0');
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.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
  return;
36
  }
37
 
38
+ define('NEWSLETTER_VERSION', '7.1.1');
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
5
- Stable tag: 7.1.0
6
  Requires PHP: 5.6
7
  Contributors: satollo,webagile,michael-travan
8
  License: GPLv2 or later
@@ -121,6 +121,13 @@ Thank you, The Newsletter Team
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
 
124
  = 7.1.0 =
125
 
126
  * [COMPOSER] Added link to tags documentation to inject subscriber's data
@@ -138,7 +145,7 @@ Thank you, The Newsletter Team
138
  * [CAPTCHA] Fixed button label translation
139
  * [DELIVERY] Mailing fatal error management with newsletter stop and reporting
140
  * [SMTP] Marked obsolete the internal SMTP and made available the free SMTP addon
141
- * [DELIVERY] Bettere management of delivery fatal errors with a new "error" status for newsletters
142
  * [GENERAL] New log files panel
143
  * [IMPORT] Old import panel replaced by the new (really better) import addon (file, copy and paste, bounced addresses import)
144
  * [NEWSLETTERS] It's now possible to specify the sender name and email per newsletter (thanks to Matthew S.)
@@ -146,7 +153,7 @@ Thank you, The Newsletter Team
146
  = 7.0.8 =
147
 
148
  * [SUBSCRIBERS] Changed action buttons
149
- * [GENERAL] Reoganization of CSS and removal of unused files
150
  * [DASHBOARD] New window open for links and fix of invalid URLs
151
  * [NEWSLETTERS] New action buttons
152
  * [GENERAL] Minor fixes and optimizations
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
5
+ Stable tag: 7.1.1
6
  Requires PHP: 5.6
7
  Contributors: satollo,webagile,michael-travan
8
  License: GPLv2 or later
121
 
122
  == Changelog ==
123
 
124
+ = 7.1.1 =
125
+
126
+ * [GENERAL] Improved profile related functions
127
+ * [GENERAL] Fixed check on field names (thanks Peter P.)
128
+ * [COMPOSER] Fix on preset selection
129
+ * [GENERAL] Fix ajax subscription on error
130
+
131
  = 7.1.0 =
132
 
133
  * [COMPOSER] Added link to tags documentation to inject subscriber's data
145
  * [CAPTCHA] Fixed button label translation
146
  * [DELIVERY] Mailing fatal error management with newsletter stop and reporting
147
  * [SMTP] Marked obsolete the internal SMTP and made available the free SMTP addon
148
+ * [DELIVERY] Better management of delivery fatal errors with a new "error" status for newsletters
149
  * [GENERAL] New log files panel
150
  * [IMPORT] Old import panel replaced by the new (really better) import addon (file, copy and paste, bounced addresses import)
151
  * [NEWSLETTERS] It's now possible to specify the sender name and email per newsletter (thanks to Matthew S.)
153
  = 7.0.8 =
154
 
155
  * [SUBSCRIBERS] Changed action buttons
156
+ * [GENERAL] Reorganization of CSS and removal of unused files
157
  * [DASHBOARD] New window open for links and fix of invalid URLs
158
  * [NEWSLETTERS] New action buttons
159
  * [GENERAL] Minor fixes and optimizations
subscription/subscription.php CHANGED
@@ -143,7 +143,7 @@ class NewsletterSubscription extends NewsletterModule {
143
  $options_antibot = $this->get_options('antibot');
144
 
145
  $captcha = !empty($options_antibot['captcha']);
146
-
147
 
148
  if (!empty($options_antibot['disabled']) || $this->antibot_form_check($captcha)) {
149
 
@@ -167,7 +167,7 @@ class NewsletterSubscription extends NewsletterModule {
167
  $this->show_message('confirmation', $user);
168
  }
169
  } else {
170
- $language = isset($_REQUEST['nlang'])?$_REQUEST['nlang']:'';
171
  $options = $this->get_form_options($language);
172
  $this->request_to_antibot_form($options['subscribe'], $captcha);
173
  }
@@ -185,15 +185,20 @@ class NewsletterSubscription extends NewsletterModule {
185
  $user = $this->subscribe2($subscription);
186
 
187
  if (is_wp_error($user)) {
188
- $this->dienow('Registration failed.', $user->get_error_message(), 400);
189
- }
190
-
191
- if ($user->status == TNP_User::STATUS_CONFIRMED) {
192
- $key = 'confirmed';
193
- }
 
 
 
 
194
 
195
- if ($user->status == TNP_User::STATUS_NOT_CONFIRMED) {
196
- $key = 'confirmation';
 
197
  }
198
 
199
  $message = $this->replace($this->options[$key . '_text'], $user);
143
  $options_antibot = $this->get_options('antibot');
144
 
145
  $captcha = !empty($options_antibot['captcha']);
146
+
147
 
148
  if (!empty($options_antibot['disabled']) || $this->antibot_form_check($captcha)) {
149
 
167
  $this->show_message('confirmation', $user);
168
  }
169
  } else {
170
+ $language = isset($_REQUEST['nlang']) ? $_REQUEST['nlang'] : '';
171
  $options = $this->get_form_options($language);
172
  $this->request_to_antibot_form($options['subscribe'], $captcha);
173
  }
185
  $user = $this->subscribe2($subscription);
186
 
187
  if (is_wp_error($user)) {
188
+ if ($user->get_error_code() === 'exists') {
189
+ echo $this->options['error_text'];
190
+ die();
191
+ } else {
192
+ $this->dienow('Registration failed.', $user->get_error_message(), 400);
193
+ }
194
+ } else {
195
+ if ($user->status == TNP_User::STATUS_CONFIRMED) {
196
+ $key = 'confirmed';
197
+ }
198
 
199
+ if ($user->status == TNP_User::STATUS_NOT_CONFIRMED) {
200
+ $key = 'confirmation';
201
+ }
202
  }
203
 
204
  $message = $this->replace($this->options[$key . '_text'], $user);