Newsletter - Version 6.8.4

Version Description

  • Code update for WordPress 5.5 compatibility (PHPMailer)
  • Added dummy user-related-links on newsletter preview
  • Fixed optin form option for the minimal subsbscription form
Download this release

Release Info

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

Code changes from version 6.8.3 to 6.8.4

emails/blocks/text/block.php CHANGED
@@ -32,7 +32,7 @@ $options['html'] = str_replace('<p', '<p inline-class="text-p"', $options['html'
32
  font-family: <?php echo $options['font_family']?>;
33
  font-size: <?php echo $options['font_size']?>px;
34
  color: <?php echo $options['font_color']?>;
35
- line-height: 1.5rem;
36
  }
37
  .text-p {
38
  font-family: <?php echo $options['font_family']?>;
32
  font-family: <?php echo $options['font_family']?>;
33
  font-size: <?php echo $options['font_size']?>px;
34
  color: <?php echo $options['font_color']?>;
35
+ line-height: 1.5;
36
  }
37
  .text-p {
38
  font-family: <?php echo $options['font_family']?>;
includes/PHPMailerLoader.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace TNP\Mailer;
4
+
5
+ class PHPMailerLoader {
6
+
7
+ /**
8
+ *
9
+ */
10
+ public static function load() {
11
+
12
+ global $wp_version;
13
+
14
+ if ( class_exists( 'PHPMailer' ) ) {
15
+ return;
16
+ }
17
+
18
+ if ( version_compare( $wp_version, '5.4.9' ) > 0 ) {
19
+ require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
20
+ require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
21
+ require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
22
+
23
+ class_alias( \PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer' );
24
+ class_alias( \PHPMailer\PHPMailer\SMTP::class, 'SMTP' );
25
+ class_alias( \PHPMailer\PHPMailer\Exception::class, 'phpmailerException' );
26
+ } else {
27
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
28
+ require_once ABSPATH . WPINC . '/class-smtp.php';
29
+ }
30
+
31
+ }
32
+
33
+ public static function make_instance() {
34
+ self::load();
35
+
36
+ return new \PHPMailer( false );
37
+ }
38
+
39
+
40
+ }
includes/controls.php CHANGED
@@ -1277,10 +1277,10 @@ class NewsletterControls {
1277
  echo '<option value="">-</option>';
1278
  for ($i = 1; $i <= 12; $i++) {
1279
  echo '<option value="' . $i . '"';
1280
- if ($month - 1 == $i) {
1281
  echo ' selected';
1282
  }
1283
- echo '>' . date('F', mktime(0, 0, 0, $i + 1, 1, 2000)) . '</option>';
1284
  }
1285
  echo '</select>';
1286
 
1277
  echo '<option value="">-</option>';
1278
  for ($i = 1; $i <= 12; $i++) {
1279
  echo '<option value="' . $i . '"';
1280
+ if ($month == $i) {
1281
  echo ' selected';
1282
  }
1283
+ echo '>' . date_i18n('F', mktime(0, 0, 0, $i, 1, 2000)) . '</option>';
1284
  }
1285
  echo '</select>';
1286
 
includes/mailer.php CHANGED
@@ -1,7 +1,9 @@
1
  <?php
2
 
 
 
3
  /**
4
- *
5
  */
6
  class NewsletterMailer {
7
 
@@ -41,7 +43,7 @@ class NewsletterMailer {
41
  }
42
 
43
  /**
44
- *
45
  * @param TNP_Mailer_Message $message
46
  * @return bool|WP_Error
47
  */
@@ -62,7 +64,7 @@ class NewsletterMailer {
62
  }
63
 
64
  /**
65
- *
66
  * @param TNP_Mailer_Message[] $messages
67
  * @return bool|WP_Error
68
  */
@@ -110,7 +112,7 @@ class NewsletterMailer {
110
  }
111
 
112
  /**
113
- *
114
  * @return NewsletterLogger
115
  */
116
  function get_logger() {
@@ -122,7 +124,7 @@ class NewsletterMailer {
122
  }
123
 
124
  /**
125
- *
126
  * @param TNP_Mailer_Message $message
127
  * @return bool|WP_Error
128
  */
@@ -162,7 +164,7 @@ class NewsletterMailer {
162
  /**
163
  * Original mail function simulation for compatibility.
164
  * @deprecated
165
- *
166
  * @param string $to
167
  * @param string $subject
168
  * @param array $message
@@ -196,12 +198,12 @@ class NewsletterMailer {
196
  }
197
 
198
  /**
199
- * @property string $to
200
- * @property string $subject
201
  * @property string $body
202
- * @property array $headers
203
  * @property string $from
204
- * @property string $from_name
205
  */
206
  class TNP_Mailer_Message {
207
 
@@ -226,7 +228,7 @@ class NewsletterMailMethodWrapper extends NewsletterMailer {
226
 
227
  /**
228
  * The reference to the mail method.
229
- *
230
  * @param callback $callable Must be an array with object and method to call, no other callback formats allowed.
231
  */
232
  function __construct($callable) {
@@ -278,7 +280,7 @@ class NewsletterOldMailerWrapper extends NewsletterMailer {
278
 
279
  /**
280
  * Only send() needs to be implemented all other method will use the defail base-class implementation
281
- *
282
  * @param TNP_Mailer_Message $message
283
  * @return \WP_Error|boolean
284
  */
@@ -308,7 +310,7 @@ class NewsletterDefaultMailer extends NewsletterMailer {
308
 
309
  /**
310
  * Static to be accessed in the hook: on some installation the object $this is not working, we're still trying to understand why
311
- * @var TNP_Mailer_Message
312
  */
313
  var $current_message = null;
314
 
@@ -417,7 +419,7 @@ class NewsletterDefaultSMTPMailer extends NewsletterMailer {
417
  }
418
 
419
  /**
420
- *
421
  * @param TNP_Mailer_Message $message
422
  * @return \WP_Error|boolean
423
  */
@@ -473,29 +475,22 @@ class NewsletterDefaultSMTPMailer extends NewsletterMailer {
473
  }
474
 
475
  /**
476
- *
477
  * @return PHPMailer
478
  */
479
  function get_mailer() {
480
  global $wp_version;
481
-
482
  if ($this->mailer) {
483
  return $this->mailer;
484
  }
485
 
486
  $logger = $this->get_logger();
487
  $logger->debug('Setting up PHP mailer');
488
- if (version_compare($wp_version, '5.4.9') > 0) {
489
- require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
490
- require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
491
- require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
492
- $this->mailer = new PHPMailer\PHPMailer\PHPMailer(false);
493
- } else {
494
- require_once ABSPATH . WPINC . '/class-phpmailer.php';
495
- require_once ABSPATH . WPINC . '/class-smtp.php';
496
- $this->mailer = new PHPMailer();
497
- }
498
-
499
  $this->mailer->IsSMTP();
500
  $this->mailer->Host = $this->options['host'];
501
  if (!empty($this->options['port'])) {
1
  <?php
2
 
3
+ use TNP\Mailer\PHPMailerLoader;
4
+
5
  /**
6
+ *
7
  */
8
  class NewsletterMailer {
9
 
43
  }
44
 
45
  /**
46
+ *
47
  * @param TNP_Mailer_Message $message
48
  * @return bool|WP_Error
49
  */
64
  }
65
 
66
  /**
67
+ *
68
  * @param TNP_Mailer_Message[] $messages
69
  * @return bool|WP_Error
70
  */
112
  }
113
 
114
  /**
115
+ *
116
  * @return NewsletterLogger
117
  */
118
  function get_logger() {
124
  }
125
 
126
  /**
127
+ *
128
  * @param TNP_Mailer_Message $message
129
  * @return bool|WP_Error
130
  */
164
  /**
165
  * Original mail function simulation for compatibility.
166
  * @deprecated
167
+ *
168
  * @param string $to
169
  * @param string $subject
170
  * @param array $message
198
  }
199
 
200
  /**
201
+ * @property string $to
202
+ * @property string $subject
203
  * @property string $body
204
+ * @property array $headers
205
  * @property string $from
206
+ * @property string $from_name
207
  */
208
  class TNP_Mailer_Message {
209
 
228
 
229
  /**
230
  * The reference to the mail method.
231
+ *
232
  * @param callback $callable Must be an array with object and method to call, no other callback formats allowed.
233
  */
234
  function __construct($callable) {
280
 
281
  /**
282
  * Only send() needs to be implemented all other method will use the defail base-class implementation
283
+ *
284
  * @param TNP_Mailer_Message $message
285
  * @return \WP_Error|boolean
286
  */
310
 
311
  /**
312
  * Static to be accessed in the hook: on some installation the object $this is not working, we're still trying to understand why
313
+ * @var TNP_Mailer_Message
314
  */
315
  var $current_message = null;
316
 
419
  }
420
 
421
  /**
422
+ *
423
  * @param TNP_Mailer_Message $message
424
  * @return \WP_Error|boolean
425
  */
475
  }
476
 
477
  /**
478
+ *
479
  * @return PHPMailer
480
  */
481
  function get_mailer() {
482
  global $wp_version;
483
+
484
  if ($this->mailer) {
485
  return $this->mailer;
486
  }
487
 
488
  $logger = $this->get_logger();
489
  $logger->debug('Setting up PHP mailer');
490
+
491
+ require_once 'PHPMailerLoader.php';
492
+ $this->mailer = PHPMailerLoader::make_instance();
493
+
 
 
 
 
 
 
 
494
  $this->mailer->IsSMTP();
495
  $this->mailer->Host = $this->options['host'];
496
  if (!empty($this->options['port'])) {
includes/module.php CHANGED
@@ -1723,7 +1723,7 @@ class NewsletterModule {
1723
  }
1724
 
1725
 
1726
- $text = apply_filters('newsletter_replace', $text, $user, $email);
1727
 
1728
  $text = $this->replace_url($text, 'BLOG_URL', $home_url);
1729
  $text = $this->replace_url($text, 'HOME_URL', $home_url);
1723
  }
1724
 
1725
 
1726
+ $text = apply_filters('newsletter_replace', $text, $user, $email, $esc_html);
1727
 
1728
  $text = $this->replace_url($text, 'BLOG_URL', $home_url);
1729
  $text = $this->replace_url($text, 'HOME_URL', $home_url);
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: 6.8.3
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', '6.8.3');
39
 
40
  global $newsletter, $wpdb;
41
 
@@ -135,7 +135,7 @@ class Newsletter extends NewsletterModule {
135
  }
136
 
137
  function __construct() {
138
-
139
  // Grab it before a plugin decides to remove it.
140
  if (isset($_GET['na'])) {
141
  $this->action = $_GET['na'];
@@ -263,6 +263,10 @@ class Newsletter extends NewsletterModule {
263
  die();
264
  }
265
 
 
 
 
 
266
  $user = $this->get_user_from_request();
267
  $email = $this->get_email_from_request();
268
  do_action('newsletter_action', $this->action, $user, $email);
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: 6.8.4
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', '6.8.4');
39
 
40
  global $newsletter, $wpdb;
41
 
135
  }
136
 
137
  function __construct() {
138
+
139
  // Grab it before a plugin decides to remove it.
140
  if (isset($_GET['na'])) {
141
  $this->action = $_GET['na'];
263
  die();
264
  }
265
 
266
+ if ($this->action === 'nul') {
267
+ $this->dienow('This link is not active on newsletter preview', 'You can send a test message to test subscriber to have the real working link.');
268
+ }
269
+
270
  $user = $this->get_user_from_request();
271
  $email = $this->get_email_from_request();
272
  do_action('newsletter_action', $this->action, $user, $email);
profile/profile.php CHANGED
@@ -19,7 +19,7 @@ class NewsletterProfile extends NewsletterModule {
19
  function __construct() {
20
  parent::__construct('profile', '1.1.0');
21
  add_shortcode('newsletter_profile', array($this, 'shortcode_newsletter_profile'));
22
- add_filter('newsletter_replace', array($this, 'hook_newsletter_replace'), 10, 3);
23
  add_filter('newsletter_page_text', array($this, 'hook_newsletter_page_text'), 10, 3);
24
  add_action('newsletter_action', array($this, 'hook_newsletter_action'), 12, 3);
25
  }
@@ -80,8 +80,9 @@ class NewsletterProfile extends NewsletterModule {
80
  return $this->build_action_url('profile', $user, $email);
81
  }
82
 
83
- function hook_newsletter_replace($text, $user, $email) {
84
  if (!$user) {
 
85
  return $text;
86
  }
87
 
19
  function __construct() {
20
  parent::__construct('profile', '1.1.0');
21
  add_shortcode('newsletter_profile', array($this, 'shortcode_newsletter_profile'));
22
+ add_filter('newsletter_replace', array($this, 'hook_newsletter_replace'), 10, 4);
23
  add_filter('newsletter_page_text', array($this, 'hook_newsletter_page_text'), 10, 3);
24
  add_action('newsletter_action', array($this, 'hook_newsletter_action'), 12, 3);
25
  }
80
  return $this->build_action_url('profile', $user, $email);
81
  }
82
 
83
+ function hook_newsletter_replace($text, $user, $email, $html = true) {
84
  if (!$user) {
85
+ $text = $this->replace_url($text, 'PROFILE_URL', $this->build_action_url('nul'));
86
  return $text;
87
  }
88
 
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.4.2
5
- Stable tag: 6.8.3
6
  Requires PHP: 5.6
7
  Contributors: satollo,webagile,michael-travan
8
 
@@ -113,6 +113,12 @@ Thank you, The Newsletter Team
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
116
  = 6.8.3 =
117
 
118
  * Changed the administrative notification of subscription removing the lists and linking the user profile
@@ -129,6 +135,7 @@ Thank you, The Newsletter Team
129
  * Multilanguage on validation JS (but will be removed in favor of pure HTML validation)
130
  * Fixed label "for" attribute for extra fields on custom forms
131
  * Better test message from status panel
 
132
 
133
  = 6.8.2 =
134
 
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.4.2
5
+ Stable tag: 6.8.4
6
  Requires PHP: 5.6
7
  Contributors: satollo,webagile,michael-travan
8
 
113
 
114
  == Changelog ==
115
 
116
+ = 6.8.4 =
117
+
118
+ * Code update for WordPress 5.5 compatibility (PHPMailer)
119
+ * Added dummy user-related-links on newsletter preview
120
+ * Fixed optin form option for the minimal subsbscription form
121
+
122
  = 6.8.3 =
123
 
124
  * Changed the administrative notification of subscription removing the lists and linking the user profile
135
  * Multilanguage on validation JS (but will be removed in favor of pure HTML validation)
136
  * Fixed label "for" attribute for extra fields on custom forms
137
  * Better test message from status panel
138
+ * Fixed vulnerability reported by WordFence
139
 
140
  = 6.8.2 =
141
 
subscription/subscription.php CHANGED
@@ -14,7 +14,7 @@ class NewsletterSubscription extends NewsletterModule {
14
  * @var array
15
  */
16
  var $options_profile;
17
-
18
  /**
19
  * Contains the options for the current language to build a subscription form. Must be initialized with
20
  * setup_form_options() before use.
@@ -22,7 +22,7 @@ class NewsletterSubscription extends NewsletterModule {
22
  * @var array
23
  */
24
  var $form_options = null;
25
-
26
  /**
27
  * Contains the antibot/antispam options. Must be initialized with
28
  * setup_antibot_options() before use.
@@ -142,7 +142,7 @@ class NewsletterSubscription extends NewsletterModule {
142
 
143
  function is_ip_blacklisted($ip) {
144
  $this->setup_antibot_options();
145
-
146
  if (empty($this->antibot_options['ip_blacklist'])) {
147
  return false;
148
  }
@@ -175,9 +175,9 @@ class NewsletterSubscription extends NewsletterModule {
175
 
176
  function is_flood($email, $ip) {
177
  global $wpdb;
178
-
179
  $this->setup_antibot_options();
180
-
181
  if (empty($this->antibot_options['antiflood'])) {
182
  return false;
183
  }
@@ -205,17 +205,17 @@ class NewsletterSubscription extends NewsletterModule {
205
  }
206
 
207
  function is_spam_by_akismet($email, $name, $ip, $agent, $referrer) {
208
-
209
  if (!class_exists('Akismet')) {
210
  return false;
211
  }
212
-
213
  $this->setup_antibot_options();
214
 
215
  if (empty($this->antibot_options['akismet'])) {
216
  return false;
217
  }
218
-
219
 
220
  $this->logger->debug('Akismet check');
221
  $request = 'blog=' . urlencode(home_url()) . '&referrer=' . urlencode($referrer) .
@@ -580,7 +580,7 @@ class NewsletterSubscription extends NewsletterModule {
580
  }
581
  return parent::get_options($sub, $language);
582
  }
583
-
584
  /**
585
  * Prepares the options used to build a subscription form for the current language
586
  * in internal variable $form_options (for optimization). Can be called many times.
@@ -590,13 +590,13 @@ class NewsletterSubscription extends NewsletterModule {
590
  $this->form_options = $this->get_options('profile', $this->get_current_language());
591
  }
592
  }
593
-
594
  function setup_antibot_options() {
595
  if (empty($this->antibot_options)) {
596
  $this->antibot_options = $this->get_options('antibot');
597
  }
598
  }
599
-
600
  function get_form_options($language = '') {
601
  return $this->get_options('profile', $language);
602
  }
@@ -1040,7 +1040,7 @@ class NewsletterSubscription extends NewsletterModule {
1040
 
1041
  var $privacy_url = false;
1042
 
1043
- /**
1044
  * Generates the privacy URL and cache it.
1045
  *
1046
  * @return string
@@ -1100,7 +1100,7 @@ class NewsletterSubscription extends NewsletterModule {
1100
  $buffer .= '</script>' . "\n\n";
1101
  return $buffer;
1102
  }
1103
-
1104
  /**
1105
  * Manages the custom forms made with [newsletter_form] and internal [newsletter_field] shorcodes.
1106
  *
@@ -1112,7 +1112,7 @@ class NewsletterSubscription extends NewsletterModule {
1112
  if (!is_array($attrs)) {
1113
  $attrs = [];
1114
  }
1115
-
1116
  $this->setup_form_options();
1117
 
1118
  $attrs = array_merge(['class' => 'newsletter', 'style' => ''], $attrs);
@@ -1140,7 +1140,7 @@ class NewsletterSubscription extends NewsletterModule {
1140
  }
1141
  $buffer .= "<input type='hidden' name='ncu' value='" . esc_attr($attrs['confirmation_url']) . "'>\n";
1142
  }
1143
-
1144
  // Compatibility
1145
  if (isset($attrs['list'])) {
1146
  $attrs['lists'] = $attrs['list'];
@@ -1203,7 +1203,7 @@ class NewsletterSubscription extends NewsletterModule {
1203
  $buffer .= "</label>\n";
1204
  return $buffer;
1205
  }
1206
-
1207
  function build_field_admin_notice($message) {
1208
  if (!current_user_can('administrator')) {
1209
  return '';
@@ -1214,7 +1214,7 @@ class NewsletterSubscription extends NewsletterModule {
1214
  function shortcode_newsletter_field($attrs, $content) {
1215
  $this->setup_form_options();
1216
  $language = $this->get_current_language();
1217
-
1218
  $name = $attrs['name'];
1219
 
1220
  $buffer = '';
@@ -1276,20 +1276,20 @@ class NewsletterSubscription extends NewsletterModule {
1276
  if (!isset($attrs['number'])) {
1277
  return $this->build_field_admin_notice('List number not specified.');
1278
  }
1279
- $number = (int)$attrs['number'];
1280
  $list = $this->get_list($number, $language);
1281
  if (!$list) {
1282
- return $this->build_field_admin_notice('List ' . $number . ' is not configured, cannot be shown.');
1283
  }
1284
-
1285
  if ($list->status == 0 || $list->forced) {
1286
- return $this->build_field_admin_notice('List ' . $number . ' is private or enforced cannot be shown.');
1287
  }
1288
-
1289
  if (isset($attrs['hidden'])) {
1290
  return '<input type="hidden" name="nl[]" value="' . esc_attr($list->id) . '">';
1291
  }
1292
-
1293
  $buffer .= '<div class="tnp-field tnp-field-checkbox tnp-field-list"><label for="nl' . esc_attr($list->id) . '">';
1294
  $buffer .= '<input type="checkbox" id="nl' . esc_attr($list->id) . '" name="nl[]" value="' . esc_attr($list->id) . '"';
1295
  if (isset($attrs['checked'])) {
@@ -1340,7 +1340,7 @@ class NewsletterSubscription extends NewsletterModule {
1340
  if (!isset($attrs['number'])) {
1341
  return $this->build_field_admin_notice('Extra profile number not specified.');
1342
  }
1343
-
1344
  $number = (int) $attrs['number'];
1345
 
1346
  $profile = TNP_Profile_Service::get_profile_by_id($number, $language);
@@ -1452,7 +1452,7 @@ class NewsletterSubscription extends NewsletterModule {
1452
 
1453
  $buffer .= "</label>";
1454
 
1455
- return $pre_html . $buffer . $post_html;
1456
  }
1457
 
1458
  /**
@@ -1743,18 +1743,25 @@ class NewsletterSubscription extends NewsletterModule {
1743
 
1744
  $language = $this->get_current_language();
1745
  $this->setup_form_options();
1746
-
1747
  if (!is_array($attrs)) {
1748
  $attrs = [];
1749
  }
1750
-
1751
  $attrs = array_merge(array('class' => '', 'referrer' => 'minimal',
1752
  'button' => $this->form_options['subscribe'], 'button_color' => '',
1753
  'button_radius' => '', 'placeholder' => $this->form_options['email']), $attrs);
1754
 
1755
  $form = '';
 
 
1756
  $form .= '<div class="tnp tnp-subscription-minimal ' . $attrs['class'] . '">';
1757
  $form .= '<form action="' . esc_attr($this->build_action_url('s')) . '" method="post">';
 
 
 
 
 
1758
  if (isset($attrs['lists'])) {
1759
  $arr = explode(',', $attrs['lists']);
1760
  foreach ($arr as $a) {
@@ -1784,17 +1791,17 @@ class NewsletterSubscription extends NewsletterModule {
1784
  if (!empty($content)) {
1785
  return $this->get_subscription_form_custom($attrs, $content);
1786
  }
1787
-
1788
  // Custom form hand coded and saved in the custom forms option
1789
  if (isset($attrs['form'])) {
1790
  return $this->get_form((int) $attrs['form']);
1791
  }
1792
-
1793
  // Custom hand coded form (as above, new syntax)
1794
  if (isset($attrs['number'])) {
1795
  return $this->get_form((int) $attrs['number']);
1796
- }
1797
-
1798
  return $this->get_subscription_form(null, null, $attrs);
1799
  }
1800
 
14
  * @var array
15
  */
16
  var $options_profile;
17
+
18
  /**
19
  * Contains the options for the current language to build a subscription form. Must be initialized with
20
  * setup_form_options() before use.
22
  * @var array
23
  */
24
  var $form_options = null;
25
+
26
  /**
27
  * Contains the antibot/antispam options. Must be initialized with
28
  * setup_antibot_options() before use.
142
 
143
  function is_ip_blacklisted($ip) {
144
  $this->setup_antibot_options();
145
+
146
  if (empty($this->antibot_options['ip_blacklist'])) {
147
  return false;
148
  }
175
 
176
  function is_flood($email, $ip) {
177
  global $wpdb;
178
+
179
  $this->setup_antibot_options();
180
+
181
  if (empty($this->antibot_options['antiflood'])) {
182
  return false;
183
  }
205
  }
206
 
207
  function is_spam_by_akismet($email, $name, $ip, $agent, $referrer) {
208
+
209
  if (!class_exists('Akismet')) {
210
  return false;
211
  }
212
+
213
  $this->setup_antibot_options();
214
 
215
  if (empty($this->antibot_options['akismet'])) {
216
  return false;
217
  }
218
+
219
 
220
  $this->logger->debug('Akismet check');
221
  $request = 'blog=' . urlencode(home_url()) . '&referrer=' . urlencode($referrer) .
580
  }
581
  return parent::get_options($sub, $language);
582
  }
583
+
584
  /**
585
  * Prepares the options used to build a subscription form for the current language
586
  * in internal variable $form_options (for optimization). Can be called many times.
590
  $this->form_options = $this->get_options('profile', $this->get_current_language());
591
  }
592
  }
593
+
594
  function setup_antibot_options() {
595
  if (empty($this->antibot_options)) {
596
  $this->antibot_options = $this->get_options('antibot');
597
  }
598
  }
599
+
600
  function get_form_options($language = '') {
601
  return $this->get_options('profile', $language);
602
  }
1040
 
1041
  var $privacy_url = false;
1042
 
1043
+ /**
1044
  * Generates the privacy URL and cache it.
1045
  *
1046
  * @return string
1100
  $buffer .= '</script>' . "\n\n";
1101
  return $buffer;
1102
  }
1103
+
1104
  /**
1105
  * Manages the custom forms made with [newsletter_form] and internal [newsletter_field] shorcodes.
1106
  *
1112
  if (!is_array($attrs)) {
1113
  $attrs = [];
1114
  }
1115
+
1116
  $this->setup_form_options();
1117
 
1118
  $attrs = array_merge(['class' => 'newsletter', 'style' => ''], $attrs);
1140
  }
1141
  $buffer .= "<input type='hidden' name='ncu' value='" . esc_attr($attrs['confirmation_url']) . "'>\n";
1142
  }
1143
+
1144
  // Compatibility
1145
  if (isset($attrs['list'])) {
1146
  $attrs['lists'] = $attrs['list'];
1203
  $buffer .= "</label>\n";
1204
  return $buffer;
1205
  }
1206
+
1207
  function build_field_admin_notice($message) {
1208
  if (!current_user_can('administrator')) {
1209
  return '';
1214
  function shortcode_newsletter_field($attrs, $content) {
1215
  $this->setup_form_options();
1216
  $language = $this->get_current_language();
1217
+
1218
  $name = $attrs['name'];
1219
 
1220
  $buffer = '';
1276
  if (!isset($attrs['number'])) {
1277
  return $this->build_field_admin_notice('List number not specified.');
1278
  }
1279
+ $number = (int) $attrs['number'];
1280
  $list = $this->get_list($number, $language);
1281
  if (!$list) {
1282
+ return $this->build_field_admin_notice('List ' . $number . ' is not configured, cannot be shown.');
1283
  }
1284
+
1285
  if ($list->status == 0 || $list->forced) {
1286
+ return $this->build_field_admin_notice('List ' . $number . ' is private or enforced cannot be shown.');
1287
  }
1288
+
1289
  if (isset($attrs['hidden'])) {
1290
  return '<input type="hidden" name="nl[]" value="' . esc_attr($list->id) . '">';
1291
  }
1292
+
1293
  $buffer .= '<div class="tnp-field tnp-field-checkbox tnp-field-list"><label for="nl' . esc_attr($list->id) . '">';
1294
  $buffer .= '<input type="checkbox" id="nl' . esc_attr($list->id) . '" name="nl[]" value="' . esc_attr($list->id) . '"';
1295
  if (isset($attrs['checked'])) {
1340
  if (!isset($attrs['number'])) {
1341
  return $this->build_field_admin_notice('Extra profile number not specified.');
1342
  }
1343
+
1344
  $number = (int) $attrs['number'];
1345
 
1346
  $profile = TNP_Profile_Service::get_profile_by_id($number, $language);
1452
 
1453
  $buffer .= "</label>";
1454
 
1455
+ return $pre_html . $buffer . $post_html;
1456
  }
1457
 
1458
  /**
1743
 
1744
  $language = $this->get_current_language();
1745
  $this->setup_form_options();
1746
+
1747
  if (!is_array($attrs)) {
1748
  $attrs = [];
1749
  }
1750
+
1751
  $attrs = array_merge(array('class' => '', 'referrer' => 'minimal',
1752
  'button' => $this->form_options['subscribe'], 'button_color' => '',
1753
  'button_radius' => '', 'placeholder' => $this->form_options['email']), $attrs);
1754
 
1755
  $form = '';
1756
+
1757
+
1758
  $form .= '<div class="tnp tnp-subscription-minimal ' . $attrs['class'] . '">';
1759
  $form .= '<form action="' . esc_attr($this->build_action_url('s')) . '" method="post">';
1760
+
1761
+ if (isset($attrs['optin'])) {
1762
+ $form .= $this->build_optin_field($attrs['optin']);
1763
+ }
1764
+
1765
  if (isset($attrs['lists'])) {
1766
  $arr = explode(',', $attrs['lists']);
1767
  foreach ($arr as $a) {
1791
  if (!empty($content)) {
1792
  return $this->get_subscription_form_custom($attrs, $content);
1793
  }
1794
+
1795
  // Custom form hand coded and saved in the custom forms option
1796
  if (isset($attrs['form'])) {
1797
  return $this->get_form((int) $attrs['form']);
1798
  }
1799
+
1800
  // Custom hand coded form (as above, new syntax)
1801
  if (isset($attrs['number'])) {
1802
  return $this->get_form((int) $attrs['number']);
1803
+ }
1804
+
1805
  return $this->get_subscription_form(null, null, $attrs);
1806
  }
1807
 
unsubscription/unsubscription.php CHANGED
@@ -19,7 +19,7 @@ class NewsletterUnsubscription extends NewsletterModule {
19
  function __construct() {
20
  parent::__construct('unsubscription', '1.0.3');
21
 
22
- add_filter('newsletter_replace', array($this, 'hook_newsletter_replace'), 10, 3);
23
  add_filter('newsletter_page_text', array($this, 'hook_newsletter_page_text'), 10, 3);
24
  add_filter('newsletter_message_headers', array($this, 'hook_add_unsubscribe_headers_to_email'), 10, 3);
25
 
@@ -141,15 +141,15 @@ class NewsletterUnsubscription extends NewsletterModule {
141
  do_action('newsletter_user_reactivated', $user);
142
  }
143
 
144
- function hook_newsletter_replace($text, $user, $email) {
145
 
146
  if ($user) {
147
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $this->build_action_url('uc', $user, $email));
148
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $this->build_action_url('u', $user, $email));
149
  $text = $this->replace_url($text, 'REACTIVATE_URL', $this->build_action_url('reactivate', $user, $email));
150
  } else {
151
- $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', '#');
152
- $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', '#');
153
  }
154
 
155
  return $text;
19
  function __construct() {
20
  parent::__construct('unsubscription', '1.0.3');
21
 
22
+ add_filter('newsletter_replace', array($this, 'hook_newsletter_replace'), 10, 4);
23
  add_filter('newsletter_page_text', array($this, 'hook_newsletter_page_text'), 10, 3);
24
  add_filter('newsletter_message_headers', array($this, 'hook_add_unsubscribe_headers_to_email'), 10, 3);
25
 
141
  do_action('newsletter_user_reactivated', $user);
142
  }
143
 
144
+ function hook_newsletter_replace($text, $user, $email, $html = true) {
145
 
146
  if ($user) {
147
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $this->build_action_url('uc', $user, $email));
148
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $this->build_action_url('u', $user, $email));
149
  $text = $this->replace_url($text, 'REACTIVATE_URL', $this->build_action_url('reactivate', $user, $email));
150
  } else {
151
+ $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $this->build_action_url('nul'));
152
+ $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $this->build_action_url('nul'));
153
  }
154
 
155
  return $text;