Newsletter - Version 5.5.4

Version Description

  • WPML integration. Read our integration page
Download this release

Release Info

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

Code changes from version 5.5.3 to 5.5.4

admin.css CHANGED
@@ -161,6 +161,7 @@
161
  background-color: #fff;
162
  padding: 10px;
163
  margin: 15px 0;
 
164
  }
165
 
166
  .tnp-warning {
@@ -168,6 +169,7 @@
168
  background-color: #fff;
169
  padding: 10px;
170
  margin: 15px 0;
 
171
  }
172
 
173
  .tnp-message {
@@ -1163,7 +1165,8 @@ span.wp-media-buttons-icon:before {
1163
  }
1164
 
1165
  .notice a {
1166
- color: #000 !important;
 
1167
  }
1168
 
1169
  .tnp-chart {
161
  background-color: #fff;
162
  padding: 10px;
163
  margin: 15px 0;
164
+ font-size: 1.2em;
165
  }
166
 
167
  .tnp-warning {
169
  background-color: #fff;
170
  padding: 10px;
171
  margin: 15px 0;
172
+ font-size: 1.2em;
173
  }
174
 
175
  .tnp-message {
1165
  }
1166
 
1167
  .notice a {
1168
+ color: #27AE60 !important;
1169
+ text-decoration: underline!important;
1170
  }
1171
 
1172
  .tnp-chart {
emails/blocks/giphy/block.php CHANGED
@@ -15,12 +15,14 @@ $default_options = array(
15
  'block_background'=>'#ffffff',
16
  'font_family'=>$font_family,
17
  'font_size'=>13,
18
- 'color'=>'#999999'
 
 
 
 
19
  );
20
 
21
  $options = array_merge($default_options, $options);
22
- $options['block_padding_top'] = '15px';
23
- $options['block_padding_bottom'] = '15px';
24
 
25
  ?>
26
 
15
  'block_background'=>'#ffffff',
16
  'font_family'=>$font_family,
17
  'font_size'=>13,
18
+ 'color'=>'#999999',
19
+ 'block_padding_top'=>15,
20
+ 'block_padding_bottom'=>15,
21
+ 'block_padding_left'=>0,
22
+ 'block_padding_right'=>0
23
  );
24
 
25
  $options = array_merge($default_options, $options);
 
 
26
 
27
  ?>
28
 
emails/blocks/giphy/options.php CHANGED
@@ -30,6 +30,18 @@
30
  <div id="giphy-preview"></div>
31
  </td>
32
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
33
  </table>
34
 
35
  <script type="text/javascript">
30
  <div id="giphy-preview"></div>
31
  </td>
32
  </tr>
33
+ <tr>
34
+ <th><?php _e('Background', 'newsletter') ?></th>
35
+ <td>
36
+ <?php $controls->block_background() ?>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th><?php _e('Padding', 'newsletter') ?></th>
41
+ <td>
42
+ <?php $controls->block_padding() ?>
43
+ </td>
44
+ </tr>
45
  </table>
46
 
47
  <script type="text/javascript">
emails/blocks/posts/block.php CHANGED
@@ -20,7 +20,9 @@ $defaults = array(
20
  'categories' => '',
21
  'tags' => '',
22
  'block_background' => '#ffffff',
23
- 'layout' => 'one'
 
 
24
  );
25
 
26
  $options = array_merge($defaults, $options);
@@ -36,10 +38,11 @@ if (!empty($options['tags'])) {
36
  $filters['tag'] = $options['tags'];
37
  }
38
 
39
- $posts = get_posts($filters);
40
 
41
- $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.png';
42
 
 
43
  ?>
44
 
45
  <?php if ($options['layout'] == 'one') { ?>
@@ -47,21 +50,21 @@ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.pn
47
  .posts-title {
48
  padding: 0 0 10px 0;
49
  font-size: 25px;
50
- font-family: <?php echo $font_family?>;
51
  font-weight: normal;
52
  color: #333333;
53
  }
54
  .posts-post-date {
55
  padding: 0 0 5px 25px;
56
  font-size: 13px;
57
- font-family: <?php echo $font_family?>;
58
  font-weight: normal;
59
  color: #aaaaaa;
60
  }
61
  .posts-post-title {
62
  padding: 0 0 5px 25px;
63
  font-size: 22px;
64
- font-family: <?php echo $font_family?>;
65
  font-weight: normal;
66
  color: #333333;
67
  }
@@ -84,7 +87,7 @@ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.pn
84
  <?php foreach ($posts AS $post) { ?>
85
 
86
  <tr>
87
- <td valign="top" style="padding: 40px 0 0 0;" class="mobile-hide tnpc-row-edit" data-type="image">
88
  <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank">
89
  <img src="<?php echo tnp_post_thumbnail_src($post, array(105, 105, true), $alternative) ?>" width="105" height="105" border="0" style="display: block; font-family: Arial; color: #666666; font-size: 14px; width: 105px!important; height: 105px!important;">
90
  </a>
@@ -92,11 +95,13 @@ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.pn
92
  <td style="padding: 40px 0 0 0;" class="no-padding">
93
  <!-- ARTICLE -->
94
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
95
- <tr>
96
- <td align="left" inline-class="posts-post-date" class="padding-meta">
97
- <?php echo tnp_post_date($post) ?>
98
- </td>
99
- </tr>
 
 
100
  <tr>
101
  <td align="left" inline-class="posts-post-title" class="padding-copy tnpc-row-edit" data-type="title">
102
  <?php echo tnp_post_title($post) ?>
@@ -119,7 +124,7 @@ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.pn
119
  <table border="0" cellspacing="0" cellpadding="0" class="responsive-table">
120
  <tr>
121
  <td align="center">
122
- <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank" style="font-size: 15px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #ffffff; text-decoration: none; background-color: #256F9C; border-top: 10px solid #256F9C; border-bottom: 10px solid #256F9C; border-left: 20px solid #256F9C; border-right: 20px solid #256F9C; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;" class="mobile-button tnpc-row-edit" data-type="link"><?php echo $options['read_more'] ?></a>
123
  </td>
124
  </tr>
125
  </table>
@@ -147,26 +152,26 @@ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.pn
147
  .posts-title {
148
  font-size: 25px;
149
  line-height: 30px;
150
- font-family: <?php echo $font_family?>;
151
  color: #333333;
152
  }
153
  .post-subtitle {
154
  padding: 20px 0 20px 0;
155
  font-size: 16px;
156
  line-height: 25px;
157
- font-family: <?php echo $font_family?>;
158
  color: #666666;
159
  }
160
  .posts-post-title {
161
  padding: 15px 0 0 0;
162
- font-family: <?php echo $font_family?>;
163
  color: #333333;
164
  font-size: 20px;
165
  line-height: 25px;
166
  }
167
  .posts-post-excerpt {
168
  padding: 5px 0 0 0;
169
- font-family: <?php echo $font_family?>;
170
  color: #666666;
171
  font-size: 14px;
172
  line-height: 20px;
20
  'categories' => '',
21
  'tags' => '',
22
  'block_background' => '#ffffff',
23
+ 'layout' => 'one',
24
+ 'language' => '',
25
+ 'button_color' => '#256F9C'
26
  );
27
 
28
  $options = array_merge($defaults, $options);
38
  $filters['tag'] = $options['tags'];
39
  }
40
 
41
+ $posts = Newsletter::instance()->get_posts($filters, $options['language']);
42
 
43
+ $button_color = $options['button_color'];
44
 
45
+ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.png';
46
  ?>
47
 
48
  <?php if ($options['layout'] == 'one') { ?>
50
  .posts-title {
51
  padding: 0 0 10px 0;
52
  font-size: 25px;
53
+ font-family: <?php echo $font_family ?>;
54
  font-weight: normal;
55
  color: #333333;
56
  }
57
  .posts-post-date {
58
  padding: 0 0 5px 25px;
59
  font-size: 13px;
60
+ font-family: <?php echo $font_family ?>;
61
  font-weight: normal;
62
  color: #aaaaaa;
63
  }
64
  .posts-post-title {
65
  padding: 0 0 5px 25px;
66
  font-size: 22px;
67
+ font-family: <?php echo $font_family ?>;
68
  font-weight: normal;
69
  color: #333333;
70
  }
87
  <?php foreach ($posts AS $post) { ?>
88
 
89
  <tr>
90
+ <td valign="top" style="padding: 40px 0 0 0;" class="mobile-hide">
91
  <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank">
92
  <img src="<?php echo tnp_post_thumbnail_src($post, array(105, 105, true), $alternative) ?>" width="105" height="105" border="0" style="display: block; font-family: Arial; color: #666666; font-size: 14px; width: 105px!important; height: 105px!important;">
93
  </a>
95
  <td style="padding: 40px 0 0 0;" class="no-padding">
96
  <!-- ARTICLE -->
97
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
98
+ <?php if (!empty($options['show_date'])) { ?>
99
+ <tr>
100
+ <td align="left" inline-class="posts-post-date" class="padding-meta">
101
+ <?php echo tnp_post_date($post) ?>
102
+ </td>
103
+ </tr>
104
+ <?php } ?>
105
  <tr>
106
  <td align="left" inline-class="posts-post-title" class="padding-copy tnpc-row-edit" data-type="title">
107
  <?php echo tnp_post_title($post) ?>
124
  <table border="0" cellspacing="0" cellpadding="0" class="responsive-table">
125
  <tr>
126
  <td align="center">
127
+ <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank" style="font-size: 15px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #ffffff; text-decoration: none; background-color: <?php echo $button_color?>; border-top: 10px solid <?php echo $button_color?>; border-bottom: 10px solid <?php echo $button_color?>; border-left: 20px solid <?php echo $button_color?>; border-right: 20px solid <?php echo $button_color?>; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;" class="mobile-button tnpc-row-edit" data-type="link"><?php echo $options['read_more'] ?></a>
128
  </td>
129
  </tr>
130
  </table>
152
  .posts-title {
153
  font-size: 25px;
154
  line-height: 30px;
155
+ font-family: <?php echo $font_family ?>;
156
  color: #333333;
157
  }
158
  .post-subtitle {
159
  padding: 20px 0 20px 0;
160
  font-size: 16px;
161
  line-height: 25px;
162
+ font-family: <?php echo $font_family ?>;
163
  color: #666666;
164
  }
165
  .posts-post-title {
166
  padding: 15px 0 0 0;
167
+ font-family: <?php echo $font_family ?>;
168
  color: #333333;
169
  font-size: 20px;
170
  line-height: 25px;
171
  }
172
  .posts-post-excerpt {
173
  padding: 5px 0 0 0;
174
+ font-family: <?php echo $font_family ?>;
175
  color: #666666;
176
  font-size: 14px;
177
  line-height: 20px;
emails/blocks/posts/options.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
- /*
3
- * @var $options array contains all the options the current block we're ediging contains
4
- * @var $controls NewsletterControls
5
- */
6
  ?>
7
 
 
8
  <table class="form-table">
9
  <tr>
10
  <th><?php _e('Title', 'newsletter') ?></th>
@@ -13,9 +13,13 @@
13
  </td>
14
  </tr>
15
  <tr>
16
- <th><?php _e('Read more label', 'newsletter') ?></th>
17
  <td>
18
- <?php $controls->text('read_more'); ?>
 
 
 
 
19
  </td>
20
  </tr>
21
  <tr>
@@ -23,6 +27,12 @@
23
  <td>
24
  <?php $controls->select_number('max', 1, 20); ?>
25
  </td>
 
 
 
 
 
 
26
  </tr>
27
  <tr>
28
  <th><?php _e('Categories', 'newsletter') ?></th>
@@ -37,15 +47,15 @@
37
  </td>
38
  </tr>
39
  <tr>
40
- <th><?php _e('View', 'newsletter') ?></th>
41
  <td>
42
- <?php $controls->text('view', 70) ?>
43
  </td>
44
  </tr>
45
  <tr>
46
- <th><?php _e('Layout', 'newsletter') ?></th>
47
  <td>
48
- <?php $controls->select('layout', array('one' => 'One column', 'two' => 'Two columns')) ?>
49
  </td>
50
  </tr>
51
  <tr>
1
  <?php
2
+ /* @var $options array contains all the options the current block we're ediging contains */
3
+ /* @var $controls NewsletterControls */
4
+
 
5
  ?>
6
 
7
+ <p>Saving the options the block is recreated.</p>
8
  <table class="form-table">
9
  <tr>
10
  <th><?php _e('Title', 'newsletter') ?></th>
13
  </td>
14
  </tr>
15
  <tr>
16
+ <th><?php _e('Button', 'newsletter') ?></th>
17
  <td>
18
+ <?php $controls->text('read_more', 30, __('Label', 'newsletter')); ?>
19
+
20
+ <?php $controls->color('button_color') ?>
21
+ </td>
22
+ </tr>
23
  </td>
24
  </tr>
25
  <tr>
27
  <td>
28
  <?php $controls->select_number('max', 1, 20); ?>
29
  </td>
30
+ </tr>
31
+ <tr>
32
+ <th><?php _e('Language', 'newsletter') ?></th>
33
+ <td>
34
+ <?php $controls->language(); ?>
35
+ </td>
36
  </tr>
37
  <tr>
38
  <th><?php _e('Categories', 'newsletter') ?></th>
47
  </td>
48
  </tr>
49
  <tr>
50
+ <th><?php _e('Layout', 'newsletter') ?></th>
51
  <td>
52
+ <?php $controls->select('layout', array('one' => 'One column', 'two' => 'Two columns')) ?>
53
  </td>
54
  </tr>
55
  <tr>
56
+ <th><?php _e('Show date', 'newsletter') ?></th>
57
  <td>
58
+ <?php $controls->yesno('show_date') ?>
59
  </td>
60
  </tr>
61
  <tr>
emails/emails.php CHANGED
@@ -107,12 +107,14 @@ class NewsletterEmails extends NewsletterModule {
107
  $content = $this->inline_css($content, true);
108
 
109
  // CSS driven by the block
110
- if (!isset($options['block_background'])) $options['block_background'] = '';
111
- $style = '';
112
- if (isset($options['block_padding_top'])) $style .= 'padding-top: ' . $options['block_padding_top'] . '; ';
113
- if (isset($options['block_padding_left'])) $style .= 'padding-left: ' . $options['block_padding_left'] . '; ';
114
- if (isset($options['block_padding_right'])) $style .= 'padding-right: ' . $options['block_padding_right'] . '; ';
115
- if (isset($options['block_padding_bottom'])) $style .= 'padding-bottom: ' . $options['block_padding_bottom'] . '; ';
 
 
116
 
117
  // Old block type
118
  if ($is_old_block) {
107
  $content = $this->inline_css($content, true);
108
 
109
  // CSS driven by the block
110
+ if (!isset($options['block_background'])) {
111
+ $options['block_background'] = '';
112
+ }
113
+ $style = '';
114
+ if (isset($options['block_padding_top'])) $style .= 'padding-top: ' . $options['block_padding_top'] . 'px; ';
115
+ if (isset($options['block_padding_left'])) $style .= 'padding-left: ' . $options['block_padding_left'] . 'px; ';
116
+ if (isset($options['block_padding_right'])) $style .= 'padding-right: ' . $options['block_padding_right'] . 'px; ';
117
+ if (isset($options['block_padding_bottom'])) $style .= 'padding-bottom: ' . $options['block_padding_bottom'] . 'px; ';
118
 
119
  // Old block type
120
  if ($is_old_block) {
emails/themes/default/theme-options.php CHANGED
@@ -20,6 +20,12 @@ defined('ABSPATH') || exit;
20
 
21
  <h3><?php _e('Posts', 'newsletter') ?></h3>
22
  <table class="form-table">
 
 
 
 
 
 
23
  <tr>
24
  <th>&nbsp;</th>
25
  <td>
20
 
21
  <h3><?php _e('Posts', 'newsletter') ?></h3>
22
  <table class="form-table">
23
+ <tr>
24
+ <th>Language</th>
25
+ <td>
26
+ <?php $controls->language(); ?>
27
+ </td>
28
+ </tr>
29
  <tr>
30
  <th>&nbsp;</th>
31
  <td>
emails/themes/default/theme.php CHANGED
@@ -14,30 +14,38 @@ global $newsletter, $post;
14
 
15
  defined('ABSPATH') || exit;
16
 
17
- if (empty($theme_options['theme_color'])) $color = '#555555';
18
- else $color = $theme_options['theme_color'];
 
 
19
 
20
  if (isset($theme_options['theme_posts'])) {
21
  $filters = array();
22
-
23
- if (empty($theme_options['theme_max_posts'])) $filters['posts_per_page'] = 10;
24
- else $filters['posts_per_page'] = (int)$theme_options['theme_max_posts'];
25
-
 
 
26
  if (!empty($theme_options['theme_categories'])) {
27
  $filters['category__in'] = $theme_options['theme_categories'];
28
  }
29
-
30
  if (!empty($theme_options['theme_tags'])) {
31
  $filters['tag'] = $theme_options['theme_tags'];
32
  }
33
-
34
  if (!empty($theme_options['theme_post_types'])) {
35
  $filters['post_type'] = $theme_options['theme_post_types'];
36
- }
37
-
 
 
 
 
 
38
  $posts = get_posts($filters);
39
  }
40
-
41
  ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
42
  <html>
43
  <head>
@@ -51,72 +59,75 @@ if (isset($theme_options['theme_posts'])) {
51
  </head>
52
  <body style="margin: 0!important; padding: 0!important">
53
  <div style="background-color: #f4f4f4; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #666; margin: 0 auto; padding: 0;">
54
-
55
- <br>
56
- <table align="center" bgcolor="#ffffff" width="100%" style="max-width: 600px; width: 100%; border-collapse: collapse; background-color: #000" cellpadding="0" cellspacing="0" border="0">
57
- <tr>
58
- <td valign="top" bgcolor="#ffffff" width="100%" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #666;">
59
- <div style="text-align: left; background-color: #fff;">
60
- <div style="text-align: center">
61
- <?php //HEADER
 
62
  // if (!empty($theme_options['theme_banner'])) {
63
  // echo $theme_options['theme_banner'];
64
- if (!empty($theme_options['theme_header_logo']['url'])) { ?>
65
- <img style="max-width: 500px" alt="<?php echo esc_attr($theme_options['main_header_title']) ?>" src="<?php echo esc_attr($theme_options['theme_header_logo']['url']) ?>">
66
- <?php } elseif (!empty($theme_options['main_header_logo']['url'])) { ?>
67
- <img style="max-width: 500px" alt="<?php echo esc_attr($theme_options['main_header_title']) ?>" src="<?php echo esc_attr($theme_options['main_header_logo']['url']) ?>">
68
- <?php } elseif (!empty($theme_options['main_header_title'])) { ?>
69
- <div style="padding: 30px 0; color: #000; font-size: 28px; background-color: #EFEFEF; border-bottom: 1px solid #ddd; text-align: center;">
70
- <?php echo $theme_options['main_header_title'] ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  </div>
72
- <?php if (!empty($theme_options['main_header_sub'])) { ?>
73
- <div style="padding: 10px 0; color: #000; font-size: 16px; text-align: center;">
74
- <?php echo $theme_options['main_header_sub'] ?>
75
- </div>
76
- <?php } ?>
77
- <?php } else { ?>
78
- <div style="padding: 30px 20px; color: #000; font-size: 28px; background-color: #EFEFEF; border-bottom: 1px solid #ddd; text-align: center;">
79
- <?php echo get_option('blogname'); ?>
80
- </div>
81
- <?php if (!empty($theme_options['main_header_sub'])) { ?>
82
- <div style="padding: 10px 0; color: #000; font-size: 16px; text-align: center;">
83
- <?php echo $theme_options['main_header_sub'] ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  </div>
85
- <?php } ?>
86
- <?php } ?>
87
- </div>
88
-
89
-
90
- <div style="padding: 10px 20px 20px 20px; background-color: #fff; line-height: 18px">
91
-
92
- <p style="text-align: center; font-size: small;"><a target="_blank" href="{email_url}">View this email online</a></p>
93
-
94
- <p>Here you can start to write your message. Be polite with your readers! Don't forget the subject of this message.</p>
95
- <?php if (!empty($posts)) { ?>
96
- <table cellpadding="5">
97
- <?php foreach ($posts as $post) { setup_postdata($post); ?>
98
- <tr>
99
- <?php if (isset($theme_options['theme_thumbnails'])) { ?>
100
- <td valign="top"><a target="_blank" href="<?php echo get_permalink($post); ?>"><img width="75" style="width: 75px; min-width: 75px" src="<?php echo newsletter_get_post_image($post->ID); ?>" alt="image"></a></td>
101
- <?php } ?>
102
- <td valign="top">
103
- <a target="_blank" href="<?php echo get_permalink(); ?>" style="font-size: 20px; line-height: 26px"><?php the_title(); ?></a>
104
- <?php if (isset($theme_options['theme_excerpts'])) newsletter_the_excerpt($post); ?>
105
- </td>
106
- </tr>
107
- <?php } ?>
108
- </table>
109
- <?php } ?>
110
-
111
- <?php include WP_PLUGIN_DIR . '/newsletter/emails/themes/default/footer.php'; ?>
112
 
113
  </div>
114
-
115
- </div>
116
- </td>
117
- </tr>
118
- </table>
119
- <br><br>
120
  </div>
121
  </body>
122
  </html>
14
 
15
  defined('ABSPATH') || exit;
16
 
17
+ if (empty($theme_options['theme_color']))
18
+ $color = '#555555';
19
+ else
20
+ $color = $theme_options['theme_color'];
21
 
22
  if (isset($theme_options['theme_posts'])) {
23
  $filters = array();
24
+
25
+ if (empty($theme_options['theme_max_posts']))
26
+ $filters['posts_per_page'] = 10;
27
+ else
28
+ $filters['posts_per_page'] = (int) $theme_options['theme_max_posts'];
29
+
30
  if (!empty($theme_options['theme_categories'])) {
31
  $filters['category__in'] = $theme_options['theme_categories'];
32
  }
33
+
34
  if (!empty($theme_options['theme_tags'])) {
35
  $filters['tag'] = $theme_options['theme_tags'];
36
  }
37
+
38
  if (!empty($theme_options['theme_post_types'])) {
39
  $filters['post_type'] = $theme_options['theme_post_types'];
40
+ }
41
+
42
+ if (!empty($theme_options['language'])) {
43
+ $filters['suppress_filters'] = false;
44
+ do_action('wpml_switch_language', $theme_options['language']);
45
+ }
46
+
47
  $posts = get_posts($filters);
48
  }
 
49
  ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
50
  <html>
51
  <head>
59
  </head>
60
  <body style="margin: 0!important; padding: 0!important">
61
  <div style="background-color: #f4f4f4; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #666; margin: 0 auto; padding: 0;">
62
+
63
+ <br>
64
+ <table align="center" bgcolor="#ffffff" width="100%" style="max-width: 600px; width: 100%; border-collapse: collapse; background-color: #000" cellpadding="0" cellspacing="0" border="0">
65
+ <tr>
66
+ <td valign="top" bgcolor="#ffffff" width="100%" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #666;">
67
+ <div style="text-align: left; background-color: #fff;">
68
+ <div style="text-align: center">
69
+ <?php
70
+ //HEADER
71
  // if (!empty($theme_options['theme_banner'])) {
72
  // echo $theme_options['theme_banner'];
73
+ if (!empty($theme_options['theme_header_logo']['url'])) {
74
+ ?>
75
+ <img style="max-width: 500px" alt="<?php echo esc_attr($theme_options['main_header_title']) ?>" src="<?php echo esc_attr($theme_options['theme_header_logo']['url']) ?>">
76
+ <?php } elseif (!empty($theme_options['main_header_logo']['url'])) { ?>
77
+ <img style="max-width: 500px" alt="<?php echo esc_attr($theme_options['main_header_title']) ?>" src="<?php echo esc_attr($theme_options['main_header_logo']['url']) ?>">
78
+ <?php } elseif (!empty($theme_options['main_header_title'])) { ?>
79
+ <div style="padding: 30px 0; color: #000; font-size: 28px; background-color: #EFEFEF; border-bottom: 1px solid #ddd; text-align: center;">
80
+ <?php echo $theme_options['main_header_title'] ?>
81
+ </div>
82
+ <?php if (!empty($theme_options['main_header_sub'])) { ?>
83
+ <div style="padding: 10px 0; color: #000; font-size: 16px; text-align: center;">
84
+ <?php echo $theme_options['main_header_sub'] ?>
85
+ </div>
86
+ <?php } ?>
87
+ <?php } else { ?>
88
+ <div style="padding: 30px 20px; color: #000; font-size: 28px; background-color: #EFEFEF; border-bottom: 1px solid #ddd; text-align: center;">
89
+ <?php echo get_option('blogname'); ?>
90
+ </div>
91
+ <?php if (!empty($theme_options['main_header_sub'])) { ?>
92
+ <div style="padding: 10px 0; color: #000; font-size: 16px; text-align: center;">
93
+ <?php echo $theme_options['main_header_sub'] ?>
94
+ </div>
95
+ <?php } ?>
96
+ <?php } ?>
97
  </div>
98
+
99
+
100
+ <div style="padding: 10px 20px 20px 20px; background-color: #fff; line-height: 18px">
101
+
102
+ <p style="text-align: center; font-size: small;"><a target="_blank" href="{email_url}">View this email online</a></p>
103
+
104
+ <p>Here you can start to write your message. Be polite with your readers! Don't forget the subject of this message.</p>
105
+ <?php if (!empty($posts)) { ?>
106
+ <table cellpadding="5">
107
+ <?php foreach ($posts as $post) {
108
+ setup_postdata($post); ?>
109
+ <tr>
110
+ <?php if (isset($theme_options['theme_thumbnails'])) { ?>
111
+ <td valign="top"><a target="_blank" href="<?php echo get_permalink($post); ?>"><img width="75" style="width: 75px; min-width: 75px" src="<?php echo newsletter_get_post_image($post->ID); ?>" alt="image"></a></td>
112
+ <?php } ?>
113
+ <td valign="top">
114
+ <a target="_blank" href="<?php echo get_permalink(); ?>" style="font-size: 20px; line-height: 26px"><?php the_title(); ?></a>
115
+ <?php if (isset($theme_options['theme_excerpts'])) newsletter_the_excerpt($post); ?>
116
+ </td>
117
+ </tr>
118
+ <?php } ?>
119
+ </table>
120
+ <?php } ?>
121
+
122
+ <?php include WP_PLUGIN_DIR . '/newsletter/emails/themes/default/footer.php'; ?>
123
+
124
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  </div>
127
+ </td>
128
+ </tr>
129
+ </table>
130
+ <br><br>
 
 
131
  </div>
132
  </body>
133
  </html>
emails/tnp-composer/_css/newsletter-builder.css CHANGED
@@ -166,10 +166,14 @@
166
  }
167
  .tnpc-row:hover {
168
  cursor: move;
 
169
  -webkit-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
170
  -moz-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
171
  box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
172
  }
 
 
 
173
  .tnpc-row-delete, .tnpc-row-edit-block {
174
  height: 30px;
175
  width: 30px;
166
  }
167
  .tnpc-row:hover {
168
  cursor: move;
169
+ /*border: 2px dashed #999;*/
170
  -webkit-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
171
  -moz-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
172
  box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
173
  }
174
+ .tnpc-row.ui-sortable-helper {
175
+ max-width: 700px!important;
176
+ }
177
  .tnpc-row-delete, .tnpc-row-edit-block {
178
  height: 30px;
179
  width: 30px;
emails/tnp-composer/_scripts/newsletter-builder.js CHANGED
@@ -333,6 +333,12 @@ jQuery(function () {
333
  forcePlaceholderSize: true,
334
  opacity: 0.6,
335
  tolerance: "pointer",
 
 
 
 
 
 
336
  update: function (event, ui) {
337
  //console.log(event);
338
  //console.log(ui.item.data("id"));
333
  forcePlaceholderSize: true,
334
  opacity: 0.6,
335
  tolerance: "pointer",
336
+ // helper: function(e) {
337
+ // //console.log(e.currentTarget.dataset.id);
338
+ // //debugger;
339
+ // var helper = jQuery(document.getElementById("sortable-helper")).clone();
340
+ // return helper;
341
+ // },
342
  update: function (event, ui) {
343
  //console.log(event);
344
  //console.log(ui.item.data("id"));
emails/tnp-composer/index.php CHANGED
@@ -86,6 +86,7 @@ $block_options = get_option('newsletter_main');
86
  <div style="display: none">
87
  <div id="newsletter-preloaded-export"></div>
88
  <div id="draggable-helper" style="width: 500px; border: 3px dashed #ddd; opacity: .7; background-color: #fff; text-align: center; text-transform: uppercase; font-size: 14px; color: #aaa; padding: 20px;"></div>
 
89
  </div>
90
 
91
  <div id="tnp-body" style="margin: 0; padding: 0; overflow: hidden; border: 0;">
@@ -106,4 +107,4 @@ $block_options = get_option('newsletter_main');
106
  //jQuery("#tnp-mobile-preview").niceScroll();
107
  tnp_mobile_preview();
108
  });
109
- </script>
86
  <div style="display: none">
87
  <div id="newsletter-preloaded-export"></div>
88
  <div id="draggable-helper" style="width: 500px; border: 3px dashed #ddd; opacity: .7; background-color: #fff; text-align: center; text-transform: uppercase; font-size: 14px; color: #aaa; padding: 20px;"></div>
89
+ <div id="sortable-helper" style="width: 700px; height: 75px;border: 3px dashed #ddd; opacity: .7; background-color: #fff; text-align: center; text-transform: uppercase; font-size: 14px; color: #aaa; padding: 20px;"></div>
90
  </div>
91
 
92
  <div id="tnp-body" style="margin: 0; padding: 0; overflow: hidden; border: 0;">
107
  //jQuery("#tnp-mobile-preview").niceScroll();
108
  tnp_mobile_preview();
109
  });
110
+ </script>
includes/TNP.php CHANGED
@@ -65,18 +65,7 @@ class TNP {
65
 
66
  // A second subscription always require confirmation otherwise anywan can change other users' data
67
  $user->status = 'S';
68
-
69
- $prefix = 'confirmation_';
70
-
71
- if (empty($options[$prefix . 'disabled'])) {
72
-
73
- $message = $options[$prefix . 'message'];
74
- // TODO: This is always empty!
75
- //$message_text = $options[$prefix . 'message_text'];
76
- $subject = $options[$prefix . 'subject'];
77
- $message = $subscription->add_microdata($message);
78
- $newsletter->mail($user->email, $newsletter->replace($subject, $user), $newsletter->replace($message, $user));
79
- }
80
 
81
  return $user;
82
  }
@@ -126,7 +115,6 @@ class TNP {
126
 
127
  $user = TNP::add_subscriber($params);
128
 
129
-
130
  if (is_wp_error($user)) {
131
  return ($user);
132
  }
@@ -142,21 +130,9 @@ class TNP {
142
  return $user;
143
  }
144
 
145
- $prefix = ($user->status == 'C') ? 'confirmed_' : 'confirmation_';
146
-
147
- if (empty($options[$prefix . 'disabled'])) {
148
- $message = $options[$prefix . 'message'];
149
-
150
- if ($user->status == 'S') {
151
- $message = $subscription->add_microdata($message);
152
- }
153
-
154
- // TODO: This is always empty!
155
- //$message_text = $options[$prefix . 'message_text'];
156
- $subject = $options[$prefix . 'subject'];
157
-
158
- $newsletter->mail($user->email, $newsletter->replace($subject, $user), $newsletter->replace($message, $user));
159
- }
160
  return $user;
161
  }
162
 
65
 
66
  // A second subscription always require confirmation otherwise anywan can change other users' data
67
  $user->status = 'S';
68
+ $subscription->send_activation_email($user);
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  return $user;
71
  }
115
 
116
  $user = TNP::add_subscriber($params);
117
 
 
118
  if (is_wp_error($user)) {
119
  return ($user);
120
  }
130
  return $user;
131
  }
132
 
133
+ $message_type = ($user->status == 'C') ? 'confirmed' : 'confirmation';
134
+ $subscription->send_message($message_type, $user);
135
+
 
 
 
 
 
 
 
 
 
 
 
 
136
  return $user;
137
  }
138
 
includes/controls.php CHANGED
@@ -374,7 +374,7 @@ class NewsletterControls {
374
  }
375
  $this->messages .= __('Saved.', 'newsletter');
376
  }
377
-
378
  function add_message_deleted() {
379
  if (!empty($this->messages)) {
380
  $this->messages .= '<br><br>';
@@ -387,7 +387,7 @@ class NewsletterControls {
387
  $this->messages .= '<br><br>';
388
  }
389
  $this->messages .= __('Options reset.', 'newsletter');
390
- }
391
 
392
  function add_message_done() {
393
  if (!empty($this->messages)) {
@@ -539,11 +539,26 @@ class NewsletterControls {
539
  $this->select($name, $options);
540
  }
541
 
542
- function page($name = 'page', $first = null) {
543
- $pages = get_pages();
 
 
 
 
 
 
 
 
 
 
544
  $options = array();
545
  foreach ($pages as $page) {
546
- $options[$page->ID] = $page->post_title;
 
 
 
 
 
547
  }
548
  $this->select($name, $options, $first);
549
  }
@@ -749,7 +764,6 @@ class NewsletterControls {
749
  function button_save($function = null) {
750
  $this->button_primary('save', '<i class="fa fa-save"></i> ' . __('Save', 'newsletter'), $function);
751
  }
752
-
753
 
754
  function button_reset($data = '') {
755
  echo '<button class="button-secondary" onclick="this.form.btn.value=\'' . esc_attr($data) . '\';this.form.act.value=\'reset\';if (!confirm(\'';
@@ -1431,6 +1445,22 @@ class NewsletterControls {
1431
  echo $output;
1432
  }
1433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1434
  /**
1435
  * Prints a formatted date using the formats and timezone of WP, including the current date and time and the
1436
  * time left to the passed time.
@@ -1514,4 +1544,19 @@ class NewsletterControls {
1514
  echo '<span title="', esc_attr($text), '">', esc_html($sub), '...</span>';
1515
  }
1516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1517
  }
374
  }
375
  $this->messages .= __('Saved.', 'newsletter');
376
  }
377
+
378
  function add_message_deleted() {
379
  if (!empty($this->messages)) {
380
  $this->messages .= '<br><br>';
387
  $this->messages .= '<br><br>';
388
  }
389
  $this->messages .= __('Options reset.', 'newsletter');
390
+ }
391
 
392
  function add_message_done() {
393
  if (!empty($this->messages)) {
539
  $this->select($name, $options);
540
  }
541
 
542
+ function page($name = 'page', $first = null, $language = '') {
543
+ $args = array(
544
+ 'post_type'=>'page',
545
+ 'posts_per_page' => 1000,
546
+ 'offset' => 0,
547
+ 'orderby' => 'post_title',
548
+ 'post_status' => 'any',
549
+ 'suppress_filters' => true
550
+ );
551
+
552
+ $pages = get_posts($args);
553
+ //$pages = get_pages();
554
  $options = array();
555
  foreach ($pages as $page) {
556
+ /* @var $page WP_Post */
557
+ $label = $page->post_title;
558
+ if ($page->post_status != 'publish') {
559
+ $label .= ' (' . $page->post_status . ')';
560
+ }
561
+ $options[$page->ID] = $label;
562
  }
563
  $this->select($name, $options, $first);
564
  }
764
  function button_save($function = null) {
765
  $this->button_primary('save', '<i class="fa fa-save"></i> ' . __('Save', 'newsletter'), $function);
766
  }
 
767
 
768
  function button_reset($data = '') {
769
  echo '<button class="button-secondary" onclick="this.form.btn.value=\'' . esc_attr($data) . '\';this.form.act.value=\'reset\';if (!confirm(\'';
1445
  echo $output;
1446
  }
1447
 
1448
+ function language($name = 'language') {
1449
+ if (!class_exists('SitePress')) {
1450
+ echo __('Install WPML for multilangue support', 'newsletter');
1451
+ return;
1452
+ }
1453
+
1454
+ $languages = apply_filters('wpml_active_languages', null);
1455
+ $language_options = array('' => 'All');
1456
+ foreach ($languages as $language) {
1457
+ $language_options[$language['language_code']] = $language['translated_name'];
1458
+ }
1459
+
1460
+
1461
+ $this->select('language', $language_options);
1462
+ }
1463
+
1464
  /**
1465
  * Prints a formatted date using the formats and timezone of WP, including the current date and time and the
1466
  * time left to the passed time.
1544
  echo '<span title="', esc_attr($text), '">', esc_html($sub), '...</span>';
1545
  }
1546
 
1547
+ function block_background($name = 'block_background') {
1548
+ $this->color($name);
1549
+ }
1550
+
1551
+ function block_padding($name = 'block_padding') {
1552
+ $this->text($name . '_top', 5);
1553
+ echo 'px (top)<br>';
1554
+ $this->text($name . '_right', 5);
1555
+ echo 'px (right)<br>';
1556
+ $this->text($name . '_bottom', 5);
1557
+ echo 'px (bottom)<br>';
1558
+ $this->text($name . '_left', 5);
1559
+ echo 'px (left)<br>';
1560
+ }
1561
+
1562
  }
includes/logger.php CHANGED
@@ -43,7 +43,7 @@ class NewsletterLogger {
43
  function log($text, $level = self::ERROR) {
44
  global $current_user;
45
 
46
- if ($this->level < $level) return;
47
 
48
  if ($current_user) {
49
  $user_id = $current_user->ID;
@@ -75,10 +75,6 @@ class NewsletterLogger {
75
  $this->level = self::NONE;
76
  }
77
  }
78
-
79
- function get_user_id() {
80
-
81
- }
82
 
83
  function error($text) {
84
  self::log($text, self::ERROR);
43
  function log($text, $level = self::ERROR) {
44
  global $current_user;
45
 
46
+ if ($level != self::FATAL && $this->level < $level) return;
47
 
48
  if ($current_user) {
49
  $user_id = $current_user->ID;
75
  $this->level = self::NONE;
76
  }
77
  }
 
 
 
 
78
 
79
  function error($text) {
80
  self::log($text, self::ERROR);
includes/mailer.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class TNP_Mailer {
4
+
5
+ var $queue = array();
6
+ var $errors = array();
7
+ var $name = '';
8
+
9
+ public function __construct($name) {
10
+ $this->name = $name;
11
+ }
12
+
13
+ abstract public function mail($to, $subject, $message, $headers = null, $enqueue = false, $from = false);
14
+
15
+ /**
16
+ * @return WP_Error[] A list of errors associated to flushed messages
17
+ */
18
+ public function flush() {
19
+ $this->queue = array();
20
+ }
21
+
22
+ function get_errors() {
23
+ return $this->errors;
24
+ }
25
+
26
+ function clear_errors() {
27
+ $this->errors = array();
28
+ }
29
+
30
+ /**
31
+ * @return NewsletterLogger
32
+ */
33
+ function get_logger() {
34
+ static $logger = null;
35
+ if (is_null($logger)) {
36
+ $logger = new NewsletterLogger($this->name);
37
+ }
38
+
39
+ return $logger;
40
+ }
41
+
42
+ }
includes/module.php CHANGED
@@ -24,7 +24,8 @@ abstract class TNP_List {
24
  * @property string $name The subscriber name or first name
25
  * @property string $surname The subscriber last name
26
  * @property string $status The subscriber status
27
- * */
 
28
  abstract class TNP_User {
29
 
30
  const STATUS_CONFIRMED = 'C';
@@ -212,17 +213,26 @@ class NewsletterModule {
212
  * @param string $sub
213
  * @return string The prefix for names
214
  */
215
- function get_prefix($sub = '') {
216
- return $this->prefix . (!empty($sub) ? '_' : '') . $sub;
217
  }
218
 
219
  /**
220
  * Returns the options of a module, if not found an empty array.
221
  */
222
- function get_options($sub = '') {
223
- $options = get_option($this->get_prefix($sub), array());
 
224
  if (!is_array($options)) {
225
- return array();
 
 
 
 
 
 
 
 
226
  }
227
  return $options;
228
  }
@@ -258,9 +268,9 @@ class NewsletterModule {
258
  * @param array $options
259
  * @param string $sub
260
  */
261
- function save_options($options, $sub = '', $autoload = null) {
262
- update_option($this->get_prefix($sub), $options, $autoload);
263
- if (empty($sub)) {
264
  $this->options = $options;
265
  if (isset($this->themes) && isset($options['theme'])) {
266
  $this->themes->save_options($options['theme'], $options);
@@ -275,11 +285,11 @@ class NewsletterModule {
275
  }
276
  }
277
 
278
- function merge_options($options, $sub = '') {
279
  if (!is_array($options))
280
  $options = array();
281
- $old_options = $this->get_options($sub);
282
- $this->save_options(array_merge($old_options, $options), $sub);
283
  }
284
 
285
  function backup_options($sub) {
@@ -932,14 +942,14 @@ class NewsletterModule {
932
  *
933
  * @return TNP_List[]
934
  */
935
- function get_lists() {
936
- static $lists = null;
937
- if (is_array($lists)) {
938
- return $lists;
939
  }
940
 
941
- $lists = array();
942
- $data = NewsletterSubscription::instance()->options_lists;
943
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
944
  if (empty($data['list_' . $i])) {
945
  continue;
@@ -950,30 +960,30 @@ class NewsletterModule {
950
  $list->forced = !empty($data['list_' . $i . '_forced']);
951
  $list->status = (int) $data['list_' . $i . '_status'];
952
  $list->checked = !empty($data['list_' . $i . '_checked']);
953
- $lists[] = $list;
954
  }
955
- return $lists;
956
  }
957
 
958
  /**
959
  *
960
  * @return TNP_List[]
961
  */
962
- function get_lists_public() {
963
- static $lists = null;
964
- if (is_array($lists)) {
965
- return $lists;
966
  }
967
 
968
- $lists = array();
969
- $all = $this->get_lists();
970
  foreach ($all as $list) {
971
  if ($list->status == TNP_List::STATUS_PRIVATE) {
972
  continue;
973
  }
974
- $lists[] = $list;
975
  }
976
- return $lists;
977
  }
978
 
979
  /**
@@ -981,21 +991,21 @@ class NewsletterModule {
981
  *
982
  * @return TNP_List[]
983
  */
984
- function get_lists_for_subscription() {
985
- static $lists = null;
986
- if (is_array($lists)) {
987
- return $lists;
988
  }
989
 
990
- $lists = array();
991
- $all = $this->get_lists();
992
  foreach ($all as $list) {
993
  if ($list->status != TNP_List::STATUS_PUBLIC || $list->forced) {
994
  continue;
995
  }
996
- $lists[] = $list;
997
  }
998
- return $lists;
999
  }
1000
 
1001
  /**
@@ -1003,21 +1013,21 @@ class NewsletterModule {
1003
  *
1004
  * @return TNP_List[]
1005
  */
1006
- function get_lists_for_profile() {
1007
- static $lists = null;
1008
- if (is_array($lists)) {
1009
- return $lists;
1010
  }
1011
 
1012
- $lists = array();
1013
- $all = $this->get_lists();
1014
  foreach ($all as $list) {
1015
  if ($list->status == TNP_List::STATUS_PRIVATE || $list->status == TNP_List::STATUS_HIDDEN) {
1016
  continue;
1017
  }
1018
- $lists[] = $list;
1019
  }
1020
- return $lists;
1021
  }
1022
 
1023
  /**
@@ -1026,12 +1036,12 @@ class NewsletterModule {
1026
  * @param int $id
1027
  * @return TNP_List
1028
  */
1029
- function get_list($id) {
1030
  $id = (int) $id;
1031
  if (!$id) {
1032
  return null;
1033
  }
1034
- $data = NewsletterSubscription::instance()->options_lists;
1035
  $list = new stdClass();
1036
  $list->name = $data['list_' . $id];
1037
  $list->id = $id;
@@ -1151,11 +1161,13 @@ class NewsletterModule {
1151
  */
1152
  function build_message_url($url = '', $message_key = '', $user = null, $email = null, $alert = '') {
1153
  $params = 'nm=' . urlencode($message_key);
1154
-
1155
  if ($user) {
1156
- if (!is_object($user))
1157
  $user = $this->get_user($user);
 
1158
  $params .= '&nk=' . urlencode($this->get_user_key($user));
 
1159
  }
1160
 
1161
  if ($email) {
@@ -1170,14 +1182,14 @@ class NewsletterModule {
1170
  }
1171
 
1172
  if (empty($url)) {
1173
- $url = Newsletter::instance()->get_newsletter_page_url();
1174
  }
1175
 
1176
  return self::add_qs($url, $params, false);
1177
  }
1178
 
1179
  function build_action_url($action, $user = null, $email = null) {
1180
- $url = $this->get_home_url() . '?na=' . urlencode($action);
1181
  if ($user) {
1182
  $url .= '&nk=' . urlencode($this->get_user_key($user));
1183
  }
@@ -1324,6 +1336,18 @@ class NewsletterModule {
1324
  function get_user_by_wp_user_id($wp_user_id, $format = OBJECT) {
1325
  return $this->store->get_single_by_field(NEWSLETTER_USERS_TABLE, 'wp_user_id', $wp_user_id, $format);
1326
  }
 
 
 
 
 
 
 
 
 
 
 
 
1327
 
1328
  /**
1329
  * Replaces every possible Newsletter tag ({...}) in a piece of text or HTML.
@@ -1449,11 +1473,6 @@ class NewsletterModule {
1449
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
1450
  $text = $this->replace_url($text, 'ACTIVATION_URL', $home_url . '?na=c&nk=' . $nk);
1451
 
1452
- $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $home_url . '?na=uc&nk=' . $nk . ($nek ? '&nek=' . $nek : ''));
1453
- $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $home_url . '?na=u&nk=' . $nk . ($nek ? '&nek=' . $nek : ''));
1454
-
1455
- $text = $this->replace_url($text, 'REACTIVATE_URL', $home_url . '?na=reactivate&nk=' . $nk . ($nek ? '&nek=' . $nek : ''));
1456
-
1457
  // Obsolete.
1458
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
1459
  $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
@@ -1690,6 +1709,72 @@ class NewsletterModule {
1690
  return $url;
1691
  }
1692
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1693
  }
1694
 
1695
  /**
24
  * @property string $name The subscriber name or first name
25
  * @property string $surname The subscriber last name
26
  * @property string $status The subscriber status
27
+ * @property string $language The subscriber language code 2 chars lowercase
28
+ */
29
  abstract class TNP_User {
30
 
31
  const STATUS_CONFIRMED = 'C';
213
  * @param string $sub
214
  * @return string The prefix for names
215
  */
216
+ function get_prefix($sub = '', $language = '') {
217
+ return $this->prefix . (!empty($sub) ? '_' : '') . $sub . (!empty($language) ? '_' : '') . $language;
218
  }
219
 
220
  /**
221
  * Returns the options of a module, if not found an empty array.
222
  */
223
+ function get_options($sub = '', $language = '') {
224
+ $options = get_option($this->get_prefix($sub, $language), array());
225
+ // Protection against scarmled database...
226
  if (!is_array($options)) {
227
+ $options = array();
228
+ }
229
+ if ($language) {
230
+ $main_options = get_option($this->get_prefix($sub));
231
+ // Protection against scarmled database...
232
+ if (!is_array($main_options))
233
+ $main_options = array();
234
+ //$options = array_merge($main_options, array_filter($options));
235
+ $options = array_merge($main_options, $options);
236
  }
237
  return $options;
238
  }
268
  * @param array $options
269
  * @param string $sub
270
  */
271
+ function save_options($options, $sub = '', $autoload = null, $language = '') {
272
+ update_option($this->get_prefix($sub, $language), $options, $autoload);
273
+ if (empty($sub) && empty($language)) {
274
  $this->options = $options;
275
  if (isset($this->themes) && isset($options['theme'])) {
276
  $this->themes->save_options($options['theme'], $options);
285
  }
286
  }
287
 
288
+ function merge_options($options, $sub = '', $language = '') {
289
  if (!is_array($options))
290
  $options = array();
291
+ $old_options = $this->get_options($sub, $language);
292
+ $this->save_options(array_merge($old_options, $options), $sub, null, $language);
293
  }
294
 
295
  function backup_options($sub) {
942
  *
943
  * @return TNP_List[]
944
  */
945
+ function get_lists($language = '') {
946
+ static $lists = array();
947
+ if (isset($lists[$language])) {
948
+ return $lists[$language];
949
  }
950
 
951
+ $lists[$language] = array();
952
+ $data = NewsletterSubscription::instance()->get_options('lists', $language);
953
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
954
  if (empty($data['list_' . $i])) {
955
  continue;
960
  $list->forced = !empty($data['list_' . $i . '_forced']);
961
  $list->status = (int) $data['list_' . $i . '_status'];
962
  $list->checked = !empty($data['list_' . $i . '_checked']);
963
+ $lists[$language][] = $list;
964
  }
965
+ return $lists[$language];
966
  }
967
 
968
  /**
969
  *
970
  * @return TNP_List[]
971
  */
972
+ function get_lists_public($language = '') {
973
+ static $lists = array();
974
+ if (isset($lists[$language])) {
975
+ return $lists[$language];
976
  }
977
 
978
+ $lists[$language] = array();
979
+ $all = $this->get_lists($language);
980
  foreach ($all as $list) {
981
  if ($list->status == TNP_List::STATUS_PRIVATE) {
982
  continue;
983
  }
984
+ $lists[$language][] = $list;
985
  }
986
+ return $lists[$language];
987
  }
988
 
989
  /**
991
  *
992
  * @return TNP_List[]
993
  */
994
+ function get_lists_for_subscription($language = '') {
995
+ static $lists = array();
996
+ if (isset($lists[$language])) {
997
+ return $lists[$language];
998
  }
999
 
1000
+ $lists[$language] = array();
1001
+ $all = $this->get_lists($language);
1002
  foreach ($all as $list) {
1003
  if ($list->status != TNP_List::STATUS_PUBLIC || $list->forced) {
1004
  continue;
1005
  }
1006
+ $lists[$language][] = $list;
1007
  }
1008
+ return $lists[$language];
1009
  }
1010
 
1011
  /**
1013
  *
1014
  * @return TNP_List[]
1015
  */
1016
+ function get_lists_for_profile($language = '') {
1017
+ static $lists = array();
1018
+ if (isset($lists[$language])) {
1019
+ return $lists[$language];
1020
  }
1021
 
1022
+ $lists[$language] = array();
1023
+ $all = $this->get_lists($language);
1024
  foreach ($all as $list) {
1025
  if ($list->status == TNP_List::STATUS_PRIVATE || $list->status == TNP_List::STATUS_HIDDEN) {
1026
  continue;
1027
  }
1028
+ $lists[$language][] = $list;
1029
  }
1030
+ return $lists[$language];
1031
  }
1032
 
1033
  /**
1036
  * @param int $id
1037
  * @return TNP_List
1038
  */
1039
+ function get_list($id, $language = '') {
1040
  $id = (int) $id;
1041
  if (!$id) {
1042
  return null;
1043
  }
1044
+ $data = NewsletterSubscription::instance()->get_options('lists', $language);
1045
  $list = new stdClass();
1046
  $list->name = $data['list_' . $id];
1047
  $list->id = $id;
1161
  */
1162
  function build_message_url($url = '', $message_key = '', $user = null, $email = null, $alert = '') {
1163
  $params = 'nm=' . urlencode($message_key);
1164
+ $language = '';
1165
  if ($user) {
1166
+ if (!is_object($user)) {
1167
  $user = $this->get_user($user);
1168
+ }
1169
  $params .= '&nk=' . urlencode($this->get_user_key($user));
1170
+ $language = $this->get_user_language($user->language);
1171
  }
1172
 
1173
  if ($email) {
1182
  }
1183
 
1184
  if (empty($url)) {
1185
+ $url = Newsletter::instance()->get_newsletter_page_url($language);
1186
  }
1187
 
1188
  return self::add_qs($url, $params, false);
1189
  }
1190
 
1191
  function build_action_url($action, $user = null, $email = null) {
1192
+ $url = $this->add_qs($this->get_home_url(), 'na=' . urlencode($action));
1193
  if ($user) {
1194
  $url .= '&nk=' . urlencode($this->get_user_key($user));
1195
  }
1336
  function get_user_by_wp_user_id($wp_user_id, $format = OBJECT) {
1337
  return $this->store->get_single_by_field(NEWSLETTER_USERS_TABLE, 'wp_user_id', $wp_user_id, $format);
1338
  }
1339
+
1340
+ /**
1341
+ * Returns the user language IF there is a supported mutilanguage plugin installed.
1342
+ * @param TNP_User $user
1343
+ * @return string Language code or empty
1344
+ */
1345
+ function get_user_language($user) {
1346
+ if ($user && $this->is_multilanguage()) {
1347
+ return $user->language;
1348
+ }
1349
+ return '';
1350
+ }
1351
 
1352
  /**
1353
  * Replaces every possible Newsletter tag ({...}) in a piece of text or HTML.
1473
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
1474
  $text = $this->replace_url($text, 'ACTIVATION_URL', $home_url . '?na=c&nk=' . $nk);
1475
 
 
 
 
 
 
1476
  // Obsolete.
1477
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
1478
  $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
1709
  return $url;
1710
  }
1711
 
1712
+ function get_current_language() {
1713
+ if (class_exists('SitePress')) {
1714
+ $current_language = apply_filters('wpml_current_language', '');
1715
+ if ($current_language == 'all') {
1716
+ $current_language = '';
1717
+ }
1718
+ return $current_language;
1719
+ }
1720
+ if (function_exists('pll_current_language')) {
1721
+ return pll_current_language();
1722
+ }
1723
+ return '';
1724
+ }
1725
+
1726
+ function get_default_language() {
1727
+ if (class_exists('SitePress')) {
1728
+ return $current_language = apply_filters('wpml_current_language', '');
1729
+ }
1730
+ if (function_exists('pll_default_language')) {
1731
+ return pll_default_language();
1732
+ }
1733
+ return '';
1734
+ }
1735
+
1736
+ function is_all_languages() {
1737
+ return $this->get_current_language() == '';
1738
+ }
1739
+
1740
+ function is_default_language() {
1741
+ return $this->get_current_language() == $this->get_default_language();
1742
+ }
1743
+
1744
+ function switch_language($language) {
1745
+ if (class_exists('SitePress')) {
1746
+ if (empty($language)) $language = 'all';
1747
+ do_action('wpml_switch_language', $language);
1748
+ return;
1749
+ }
1750
+ }
1751
+
1752
+ function is_multilanguage() {
1753
+ return class_exists('SitePress') || function_exists('pll_default_language');
1754
+ }
1755
+
1756
+ function get_posts($filters = array(), $language = '') {
1757
+ $current_language = $this->get_current_language();
1758
+
1759
+ // Language switch for WPML
1760
+ if ($language) {
1761
+ if (class_exists('SitePress')) {
1762
+ $this->switch_language($language);
1763
+ $filters['suppress_filters'] = false;
1764
+ }
1765
+ if (class_exists('Polylang')) {
1766
+ $filters['lang'] = $language;
1767
+ }
1768
+ }
1769
+ $posts = get_posts($filters);
1770
+ if ($language) {
1771
+ if (class_exists('SitePress')) {
1772
+ $this->switch_language($current_language);
1773
+ }
1774
+ }
1775
+ return $posts;
1776
+ }
1777
+
1778
  }
1779
 
1780
  /**
main/main.php CHANGED
@@ -14,13 +14,13 @@ if (!$controls->is_action()) {
14
 
15
  // Validation
16
  $controls->data['sender_email'] = $module->normalize_email($controls->data['sender_email']);
17
- if (!$newsletter->is_email($controls->data['sender_email'])) {
18
  $controls->errors .= __('The sender email address is not correct.', 'newsletter') . '<br>';
19
  } else {
20
  $controls->data['sender_email'] = $module->normalize_email($controls->data['sender_email']);
21
  }
22
 
23
- if (!$newsletter->is_email($controls->data['return_path'], true)) {
24
  $controls->errors .= __('Return path email is not correct.', 'newsletter') . '<br>';
25
  } else {
26
  $controls->data['return_path'] = $module->normalize_email($controls->data['return_path']);
@@ -58,12 +58,17 @@ if (!$controls->is_action()) {
58
  $page['comment_status'] = 'closed';
59
  $page['ping_status'] = 'closed';
60
  $page['post_category'] = array(1);
61
-
 
 
62
  // Insert the post into the database
63
  $page_id = wp_insert_post($page);
 
64
 
65
  $controls->data['page'] = $page_id;
66
  $module->merge_options($controls->data);
 
 
67
  }
68
  }
69
 
@@ -140,6 +145,7 @@ if (!empty($return_path)) {
140
 
141
  </div>
142
  <div id="tnp-body" class="tnp-main-main">
 
143
 
144
  <form method="post" action="">
145
  <?php $controls->init(); ?>
@@ -333,6 +339,7 @@ if (!empty($return_path)) {
333
  </p>
334
 
335
  </form>
 
336
  </div>
337
 
338
  <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
14
 
15
  // Validation
16
  $controls->data['sender_email'] = $module->normalize_email($controls->data['sender_email']);
17
+ if (!$module->is_email($controls->data['sender_email'])) {
18
  $controls->errors .= __('The sender email address is not correct.', 'newsletter') . '<br>';
19
  } else {
20
  $controls->data['sender_email'] = $module->normalize_email($controls->data['sender_email']);
21
  }
22
 
23
+ if (!$module->is_email($controls->data['return_path'], true)) {
24
  $controls->errors .= __('Return path email is not correct.', 'newsletter') . '<br>';
25
  } else {
26
  $controls->data['return_path'] = $module->normalize_email($controls->data['return_path']);
58
  $page['comment_status'] = 'closed';
59
  $page['ping_status'] = 'closed';
60
  $page['post_category'] = array(1);
61
+
62
+ $current_language = $module->get_current_language();
63
+ $module->switch_language('');
64
  // Insert the post into the database
65
  $page_id = wp_insert_post($page);
66
+ $module->switch_language($current_language);
67
 
68
  $controls->data['page'] = $page_id;
69
  $module->merge_options($controls->data);
70
+
71
+ $controls->messages = 'A new page has been created';
72
  }
73
  }
74
 
145
 
146
  </div>
147
  <div id="tnp-body" class="tnp-main-main">
148
+
149
 
150
  <form method="post" action="">
151
  <?php $controls->init(); ?>
339
  </p>
340
 
341
  </form>
342
+
343
  </div>
344
 
345
  <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
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.5.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.
@@ -14,7 +14,7 @@
14
  */
15
 
16
  // Used as dummy parameter on css and js links
17
- define('NEWSLETTER_VERSION', '5.5.3');
18
 
19
  global $newsletter, $wpdb;
20
 
@@ -124,7 +124,7 @@ class Newsletter extends NewsletterModule {
124
 
125
  // Here because the upgrade is called by the parent constructor and uses the scheduler
126
  add_filter('cron_schedules', array($this, 'hook_cron_schedules'), 1000);
127
- parent::__construct('main', '1.4.9', null, array('info', 'smtp'));
128
 
129
  $max = $this->options['scheduler_max'];
130
  if (!is_numeric($max)) {
@@ -227,6 +227,7 @@ class Newsletter extends NewsletterModule {
227
 
228
  $sql = "CREATE TABLE `" . $wpdb->prefix . "newsletter_emails` (
229
  `id` int(11) NOT NULL AUTO_INCREMENT,
 
230
  `subject` varchar(255) NOT NULL DEFAULT '',
231
  `message` longtext,
232
  `subject2` varchar(255) NOT NULL DEFAULT '',
@@ -351,7 +352,6 @@ class Newsletter extends NewsletterModule {
351
  global $cache_stop, $hyper_cache_stop, $wpdb;
352
 
353
  if (isset($this->options['debug']) && $this->options['debug'] == 1) {
354
- error_reporting(E_ALL | E_NOTICE);
355
  ini_set('log_errors', 1);
356
  ini_set('error_log', WP_CONTENT_DIR . '/logs/newsletter/php-' . date('Y-m') . '-' . get_option('newsletter_logger_secret') . '.txt');
357
  }
@@ -391,6 +391,8 @@ class Newsletter extends NewsletterModule {
391
  } else {
392
  add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
393
  }
 
 
394
 
395
  if (empty($this->action)) {
396
  return;
@@ -416,10 +418,34 @@ class Newsletter extends NewsletterModule {
416
  die();
417
  }
418
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
 
420
  function hook_admin_notices() {
421
  // Check of Newsletter dedicated page
422
- if ($this->options['page']) {
423
  if (get_post_status($this->options['page']) !== 'publish') {
424
  echo '<div class="notice notice-error"><p>The Newsletter dedicated page is not published. <a href="', site_url('/wp-admin/post.php') . '?post=', $this->options['page'], '&action=edit"><strong>Edit the page</strong></a> or <a href="admin.php?page=newsletter_main_main"><strong>review the main settings</strong></a>.</p></div>';
425
  } else {
@@ -612,9 +638,6 @@ class Newsletter extends NewsletterModule {
612
  // Before try to send, check the limits.
613
  if (!$test && $this->limits_exceeded()) {
614
  $result = false;
615
- if ($this->the_mailer != null) {
616
- $this->the_mailer->flush();
617
- }
618
  break;
619
  }
620
 
@@ -660,23 +683,23 @@ class Newsletter extends NewsletterModule {
660
  $this->email_limit--;
661
  $count++;
662
  }
 
 
663
  if ($this->the_mailer != null) {
664
- $this->logger->debug('Flushing');
665
- $result = $this->the_mailer->flush();
666
- if (is_wp_error($result)) {
667
- //$this->logger->debug($result);
668
- /* @var $result WP_Error */
669
- $wp_error_data = $result->get_error_data();
670
- if (is_array($wp_error_data)) {
671
- foreach ($wp_error_data as &$item) {
672
- if (!isset($item['email'])) {
673
- continue;
674
- }
675
- $this->save_sent($item['email'], $email, 1, $item['error']);
676
- }
677
  }
678
- } else {
679
- $this->logger->debug('No errors');
 
 
 
 
680
  }
681
  }
682
 
@@ -698,23 +721,25 @@ class Newsletter extends NewsletterModule {
698
  global $wpdb;
699
  //$this->logger->debug('Saving sent data');
700
  $user_id = 0;
701
- if (is_numeric($user))
702
  $user_id = $user;
703
- else if (is_array($user) && isset($user['id']))
704
  $user_id = $user['id'];
705
- else if (is_object($user) && isset($user->id))
706
  $user_id = $user->id;
707
- else if (is_string($user)) {
708
  // is an email
709
  $user = $this->get_user($user);
710
- if ($user)
711
  $user_id = $user->id;
 
712
  }
713
 
714
  $email_id = $this->to_int_id($email);
715
 
716
- if (!$user_id)
717
  return;
 
718
  //$this->logger->debug('Query');
719
  $wpdb->query($wpdb->prepare("insert into " . $wpdb->prefix . 'newsletter_sent (user_id, email_id, time, status, error) values (%d, %d, %d, %d, %s) on duplicate key update time=%d, status=%d, error=%s', $user_id, $email_id, time(), $status, $error, time(), $status, $error));
720
  }
@@ -1209,16 +1234,25 @@ class Newsletter extends NewsletterModule {
1209
  * @return string
1210
  */
1211
  var $newsletter_page_url = false;
1212
- function get_newsletter_page_url() {
1213
-
1214
- if (!$this->newsletter_page_url) {
 
1215
  if (!empty($this->options['page'])) {
1216
  $this->newsletter_page_url = get_permalink($this->options['page']);
 
 
 
 
 
 
 
 
1217
  }
1218
  if (!$this->newsletter_page_url) {
1219
  $this->newsletter_page_url = self::get_home_url() . '?na=m';
1220
  }
1221
- }
1222
  return $this->newsletter_page_url;
1223
  }
1224
 
@@ -1227,6 +1261,7 @@ class Newsletter extends NewsletterModule {
1227
  $newsletter = Newsletter::instance();
1228
 
1229
  require_once NEWSLETTER_DIR . '/subscription/subscription.php';
 
1230
  require_once NEWSLETTER_DIR . '/profile/profile.php';
1231
  require_once NEWSLETTER_DIR . '/emails/emails.php';
1232
  require_once NEWSLETTER_DIR . '/users/users.php';
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.5.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.
14
  */
15
 
16
  // Used as dummy parameter on css and js links
17
+ define('NEWSLETTER_VERSION', '5.5.4');
18
 
19
  global $newsletter, $wpdb;
20
 
124
 
125
  // Here because the upgrade is called by the parent constructor and uses the scheduler
126
  add_filter('cron_schedules', array($this, 'hook_cron_schedules'), 1000);
127
+ parent::__construct('main', '1.5.0', null, array('info', 'smtp'));
128
 
129
  $max = $this->options['scheduler_max'];
130
  if (!is_numeric($max)) {
227
 
228
  $sql = "CREATE TABLE `" . $wpdb->prefix . "newsletter_emails` (
229
  `id` int(11) NOT NULL AUTO_INCREMENT,
230
+ `language` varchar(10) NOT NULL DEFAULT '',
231
  `subject` varchar(255) NOT NULL DEFAULT '',
232
  `message` longtext,
233
  `subject2` varchar(255) NOT NULL DEFAULT '',
352
  global $cache_stop, $hyper_cache_stop, $wpdb;
353
 
354
  if (isset($this->options['debug']) && $this->options['debug'] == 1) {
 
355
  ini_set('log_errors', 1);
356
  ini_set('error_log', WP_CONTENT_DIR . '/logs/newsletter/php-' . date('Y-m') . '-' . get_option('newsletter_logger_secret') . '.txt');
357
  }
391
  } else {
392
  add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
393
  }
394
+
395
+ //add_filter('site_transient_update_plugins', array($this, 'hook_site_transient_update_plugins'));
396
 
397
  if (empty($this->action)) {
398
  return;
418
  die();
419
  }
420
  }
421
+
422
+ // function hook_site_transient_update_plugins($value) {
423
+ // //return null;
424
+ // //var_dump($value);
425
+ // //die('xxx');
426
+ // if (!isset($value->response['newsletter/plugin.php'])) {
427
+ // $value->response['newsletter/plugin.php'] = $value->no_update['newsletter/plugin.php'];
428
+ // }
429
+ //
430
+ // // Add caching
431
+ // $response = wp_remote_get('http://plugins.svn.wordpress.org/newsletter/');
432
+ // $body = wp_remote_retrieve_body($response);
433
+ //
434
+ // $x = strpos($body, 'Revision');
435
+ // $x += 9;
436
+ // $y = strpos($body, ':', $x);
437
+ // $version = substr($body, $x, $y-$x);
438
+ // $value->checked['newsletter/plugin.php'] = $version;
439
+ // $value->response['newsletter/plugin.php']->new_version = $version;
440
+ // $value->response['newsletter/plugin.php']->package = 'https://downloads.wordpress.org/plugin/newsletter.zip';
441
+ //
442
+ // return $value;
443
+ //
444
+ // }
445
 
446
  function hook_admin_notices() {
447
  // Check of Newsletter dedicated page
448
+ if (!empty($this->options['page'])) {
449
  if (get_post_status($this->options['page']) !== 'publish') {
450
  echo '<div class="notice notice-error"><p>The Newsletter dedicated page is not published. <a href="', site_url('/wp-admin/post.php') . '?post=', $this->options['page'], '&action=edit"><strong>Edit the page</strong></a> or <a href="admin.php?page=newsletter_main_main"><strong>review the main settings</strong></a>.</p></div>';
451
  } else {
638
  // Before try to send, check the limits.
639
  if (!$test && $this->limits_exceeded()) {
640
  $result = false;
 
 
 
641
  break;
642
  }
643
 
683
  $this->email_limit--;
684
  $count++;
685
  }
686
+
687
+
688
  if ($this->the_mailer != null) {
689
+ $this->logger->debug('Flushing and checking errors');
690
+ $this->the_mailer->flush();
691
+ if (method_exists($this->the_mailer, 'get_errors')) {
692
+ $errors = $this->the_mailer->get_errors();
693
+ foreach ($errors as $error) {
694
+ $this->logger->debug('Error on email ' . $error['email']);
695
+ $this->save_sent($error['email'], $email, 1, $error['message']);
 
 
 
 
 
 
696
  }
697
+
698
+ }
699
+
700
+ $this->logger->debug('Clearing errors');
701
+ if (method_exists($this->the_mailer, 'get_errors')) {
702
+ $this->the_mailer->clear_errors();
703
  }
704
  }
705
 
721
  global $wpdb;
722
  //$this->logger->debug('Saving sent data');
723
  $user_id = 0;
724
+ if (is_numeric($user)) {
725
  $user_id = $user;
726
+ } else if (is_array($user) && isset($user['id'])) {
727
  $user_id = $user['id'];
728
+ } else if (is_object($user) && isset($user->id)) {
729
  $user_id = $user->id;
730
+ } else if (is_string($user)) {
731
  // is an email
732
  $user = $this->get_user($user);
733
+ if ($user) {
734
  $user_id = $user->id;
735
+ }
736
  }
737
 
738
  $email_id = $this->to_int_id($email);
739
 
740
+ if (!$user_id) {
741
  return;
742
+ }
743
  //$this->logger->debug('Query');
744
  $wpdb->query($wpdb->prepare("insert into " . $wpdb->prefix . 'newsletter_sent (user_id, email_id, time, status, error) values (%d, %d, %d, %d, %s) on duplicate key update time=%d, status=%d, error=%s', $user_id, $email_id, time(), $status, $error, time(), $status, $error));
745
  }
1234
  * @return string
1235
  */
1236
  var $newsletter_page_url = false;
1237
+ function get_newsletter_page_url($language = '') {
1238
+
1239
+ // TODO: Reintroduce the cache
1240
+ //if (!$this->newsletter_page_url) {
1241
  if (!empty($this->options['page'])) {
1242
  $this->newsletter_page_url = get_permalink($this->options['page']);
1243
+ if ($language && $this->newsletter_page_url) {
1244
+ if (class_exists('SitePress')) {
1245
+ $this->newsletter_page_url = apply_filters('wpml_permalink', $this->newsletter_page_url , $language);
1246
+ }
1247
+ if (function_exists('pll_get_post')) {
1248
+ $this->newsletter_page_url = get_permalink(pll_get_post($this->options['page']));
1249
+ }
1250
+ }
1251
  }
1252
  if (!$this->newsletter_page_url) {
1253
  $this->newsletter_page_url = self::get_home_url() . '?na=m';
1254
  }
1255
+ //}
1256
  return $this->newsletter_page_url;
1257
  }
1258
 
1261
  $newsletter = Newsletter::instance();
1262
 
1263
  require_once NEWSLETTER_DIR . '/subscription/subscription.php';
1264
+ require_once NEWSLETTER_DIR . '/unsubscription/unsubscription.php';
1265
  require_once NEWSLETTER_DIR . '/profile/profile.php';
1266
  require_once NEWSLETTER_DIR . '/emails/emails.php';
1267
  require_once NEWSLETTER_DIR . '/users/users.php';
profile/index.php CHANGED
@@ -6,19 +6,27 @@ require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
  $controls = new NewsletterControls();
7
  $module = NewsletterProfile::instance();
8
 
 
 
 
 
 
 
 
 
9
  // Profile options are still inside the main options
10
  if ($controls->is_action()) {
11
  if ($controls->is_action('save')) {
12
- $module->save_options($controls->data);
13
  $controls->add_message_saved();
14
  }
15
  if ($controls->is_action('reset')) {
16
  $module->reset_options();
17
- $controls->data = $module->get_options();
18
  $controls->add_message_reset();
19
  }
20
  } else {
21
- $controls->data = $module->get_options();
22
  }
23
  ?>
24
 
@@ -29,11 +37,11 @@ if ($controls->is_action()) {
29
  <div id="tnp-heading">
30
 
31
  <h2><?php _e('The subscriber profile page', 'newsletter') ?></h2>
32
- <?php $controls->page_help('https://www.thenewsletterplugin.com/documentation/profile-page')?>
33
  </div>
34
 
35
  <div id="tnp-body">
36
-
37
 
38
  <form id="channel" method="post" action="">
39
  <?php $controls->init(); ?>
@@ -67,10 +75,10 @@ if ($controls->is_action()) {
67
 
68
  </table>
69
 
70
- <h3><?php _e('Messages', 'newsletter')?></h3>
71
  <table class="form-table">
72
  <tr>
73
- <th><?php _e('Profile saved', 'newsletter')?></th>
74
  <td>
75
  <?php $controls->text('saved', 80); ?>
76
  </td>
@@ -78,7 +86,7 @@ if ($controls->is_action()) {
78
 
79
  <tr>
80
  <tr>
81
- <th><?php _e('Email changed alert', 'newsletter')?></th>
82
  <td>
83
  <?php $controls->text('email_changed', 80); ?>
84
  </td>
@@ -88,7 +96,7 @@ if ($controls->is_action()) {
88
 
89
  <tr>
90
  <tr>
91
- <th><?php _e('General error', 'newsletter')?></th>
92
  <td>
93
  <?php $controls->text('error', 80); ?>
94
  </td>
@@ -96,42 +104,49 @@ if ($controls->is_action()) {
96
 
97
  </table>
98
 
99
- <h3><?php _e('Labels', 'newsletter')?></h3>
100
  <table class="form-table">
101
  <tr>
102
- <th><?php _e('"Save" label', 'newsletter')?></th>
103
  <td>
104
  <?php $controls->text('save_label'); ?>
105
  </td>
106
  </tr>
107
-
108
  <tr>
109
- <th><?php _e('Privacy link text', 'newsletter')?></th>
110
  <td>
111
  <?php $controls->text('privacy_label', 80); ?>
112
  <p class="description">
113
-
114
  </p>
115
  </td>
116
  </tr>
117
-
118
  </table>
119
  </div>
120
-
121
- <div id="tabs-general">
122
 
123
-
124
- <table class="form-table">
125
-
126
- <tr>
127
- <th>
128
- <?php _e('Log of sent newsletters', 'newsletter') ?>
129
- </th>
130
- <td>
131
- <?php $controls->yesno('export_newsletters'); ?>
132
- </td>
133
- </tr>
134
- </table>
 
 
 
 
 
 
 
 
 
135
  </div>
136
 
137
  </div>
6
  $controls = new NewsletterControls();
7
  $module = NewsletterProfile::instance();
8
 
9
+ $current_language = $module->get_current_language();
10
+
11
+ $is_all_languages = $module->is_all_languages();
12
+
13
+ if (!$is_all_languages) {
14
+ $controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
15
+ }
16
+
17
  // Profile options are still inside the main options
18
  if ($controls->is_action()) {
19
  if ($controls->is_action('save')) {
20
+ $module->save_options($controls->data, '', null, $current_language);
21
  $controls->add_message_saved();
22
  }
23
  if ($controls->is_action('reset')) {
24
  $module->reset_options();
25
+ $controls->data = $module->get_options('', $current_language);
26
  $controls->add_message_reset();
27
  }
28
  } else {
29
+ $controls->data = $module->get_options('', $current_language);
30
  }
31
  ?>
32
 
37
  <div id="tnp-heading">
38
 
39
  <h2><?php _e('The subscriber profile page', 'newsletter') ?></h2>
40
+ <?php $controls->page_help('https://www.thenewsletterplugin.com/documentation/profile-page') ?>
41
  </div>
42
 
43
  <div id="tnp-body">
44
+
45
 
46
  <form id="channel" method="post" action="">
47
  <?php $controls->init(); ?>
75
 
76
  </table>
77
 
78
+ <h3><?php _e('Messages', 'newsletter') ?></h3>
79
  <table class="form-table">
80
  <tr>
81
+ <th><?php _e('Profile saved', 'newsletter') ?></th>
82
  <td>
83
  <?php $controls->text('saved', 80); ?>
84
  </td>
86
 
87
  <tr>
88
  <tr>
89
+ <th><?php _e('Email changed alert', 'newsletter') ?></th>
90
  <td>
91
  <?php $controls->text('email_changed', 80); ?>
92
  </td>
96
 
97
  <tr>
98
  <tr>
99
+ <th><?php _e('General error', 'newsletter') ?></th>
100
  <td>
101
  <?php $controls->text('error', 80); ?>
102
  </td>
104
 
105
  </table>
106
 
107
+ <h3><?php _e('Labels', 'newsletter') ?></h3>
108
  <table class="form-table">
109
  <tr>
110
+ <th><?php _e('"Save" label', 'newsletter') ?></th>
111
  <td>
112
  <?php $controls->text('save_label'); ?>
113
  </td>
114
  </tr>
115
+
116
  <tr>
117
+ <th><?php _e('Privacy link text', 'newsletter') ?></th>
118
  <td>
119
  <?php $controls->text('privacy_label', 80); ?>
120
  <p class="description">
121
+
122
  </p>
123
  </td>
124
  </tr>
125
+
126
  </table>
127
  </div>
 
 
128
 
129
+ <div id="tabs-export">
130
+ <?php if ($is_all_languages) { ?>
131
+
132
+ <table class="form-table">
133
+
134
+ <tr>
135
+ <th>
136
+ <?php _e('Log of sent newsletters', 'newsletter') ?>
137
+ </th>
138
+ <td>
139
+ <?php $controls->yesno('export_newsletters'); ?>
140
+ </td>
141
+ </tr>
142
+ </table>
143
+ <?php } else { ?>
144
+
145
+ <p>Switch to your main language to manage these options.</p>
146
+
147
+
148
+
149
+ <?php } ?>
150
  </div>
151
 
152
  </div>
profile/profile.php CHANGED
@@ -189,8 +189,9 @@ class NewsletterProfile extends NewsletterModule {
189
 
190
  function get_profile_form($user) {
191
  // Do not pay attention to option name here, it's a compatibility problem
192
- $options = NewsletterSubscription::instance()->options_profile;
193
- $options_lists = NewsletterSubscription::instance()->options_lists;
 
194
 
195
  $buffer = '';
196
 
@@ -263,7 +264,7 @@ class NewsletterProfile extends NewsletterModule {
263
  }
264
 
265
  // Lists
266
- $lists = $this->get_lists_for_profile();
267
  $tmp = '';
268
  foreach ($lists as $list) {
269
 
@@ -446,10 +447,11 @@ class NewsletterProfile extends NewsletterModule {
446
 
447
  // Patch to avoid conflicts with the "newsletter_profile" option of the subscription module
448
  // TODO: Fix it
449
- public function get_prefix($sub = '') {
450
- if (empty($sub))
451
  $sub = 'main';
452
- return parent::get_prefix($sub);
 
453
  }
454
 
455
  }
189
 
190
  function get_profile_form($user) {
191
  // Do not pay attention to option name here, it's a compatibility problem
192
+
193
+ $language = $this->get_user_language($user);
194
+ $options = NewsletterSubscription::instance()->get_options('profile', $language);
195
 
196
  $buffer = '';
197
 
264
  }
265
 
266
  // Lists
267
+ $lists = $this->get_lists_for_profile($language);
268
  $tmp = '';
269
  foreach ($lists as $list) {
270
 
447
 
448
  // Patch to avoid conflicts with the "newsletter_profile" option of the subscription module
449
  // TODO: Fix it
450
+ public function get_prefix($sub = '', $language='') {
451
+ if (empty($sub)) {
452
  $sub = 'main';
453
+ }
454
+ return parent::get_prefix($sub, $language);
455
  }
456
 
457
  }
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
3
  Requires at least: 3.4.0
4
  Tested up to: 4.9.6
5
- Stable tag: 5.5.3
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -28,7 +28,9 @@ delivery service) you should check with that service if some sort of agreement i
28
 
29
  * **Unlimited subscribers** with statistics
30
  * **Unlimited newsletter** with tracking
 
31
  * Subscription spam check with domain/ip black lists, Akismet, captcha
 
32
  * [GDPR ready](https://www.thenewsletterplugin.com/documentation/gdpr-compliancy)
33
  * **Responsive email Drag & Drop composer**
34
  * Customizable **subscription widget**, **page** or **custom form**
@@ -38,10 +40,11 @@ delivery service) you should check with that service if some sort of agreement i
38
  * PHP API and REST API for coders and integrations
39
  * SMTP-Ready
40
  * Customizable Themes
41
- * Newsletter with Html and Text message versions
42
- * All messages are **fully translatable** from Admin Panel (no .po/.mo)
43
  * Diagnostics Panel to check your blog mailing capability
44
- * **Compatible with Postman, WP Mail SMTP, Easy WP SMTP, Easy SMTP Mail, WP Mail Bank**
 
 
45
 
46
  = Integration with WordPress registration =
47
 
@@ -49,7 +52,7 @@ delivery service) you should check with that service if some sort of agreement i
49
  * Auto confirmation on first login
50
  * Imports already registered users
51
 
52
- = Free Extension =
53
 
54
  Find and install them from the Extensions panel in your blog.
55
 
@@ -71,7 +74,9 @@ our **premium, professional Extensions**! Let us introduce just two of them : )
71
 
72
  = Support =
73
 
74
- We provide support for our plugin on [Wordpress.org forums](https://wordpress.org/support/plugin/newsletter) and through our official [forum here](https://www.thenewsletterplugin.com/forums), but only Premium Users with an active license have access to one-to-one support via our [ticketing system](https://www.thenewsletterplugin.com/support-ticket).
 
 
75
 
76
  = Follow Us =
77
 
@@ -102,6 +107,10 @@ Thank you, The Newsletter Team
102
 
103
  == Changelog ==
104
 
 
 
 
 
105
  = 5.5.3 =
106
 
107
  * Updated tinyMCE for Edge compatibility
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
3
  Requires at least: 3.4.0
4
  Tested up to: 4.9.6
5
+ Stable tag: 5.5.4
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
28
 
29
  * **Unlimited subscribers** with statistics
30
  * **Unlimited newsletter** with tracking
31
+ * Multilist ready with list combinations targeting (all in, at least one, exclusions, ...)
32
  * Subscription spam check with domain/ip black lists, Akismet, captcha
33
+ * **Delivery speed** fine control (from 12 emails per hour to as much as your blog can manage)
34
  * [GDPR ready](https://www.thenewsletterplugin.com/documentation/gdpr-compliancy)
35
  * **Responsive email Drag & Drop composer**
36
  * Customizable **subscription widget**, **page** or **custom form**
40
  * PHP API and REST API for coders and integrations
41
  * SMTP-Ready
42
  * Customizable Themes
43
+ * All messages are **fully translatable** from administration panels (no .po/.mo file to edit)
 
44
  * Diagnostics Panel to check your blog mailing capability
45
+ * **Compatible with every SMTP plugin**: Postman, WP Mail SMTP, Easy WP SMTP, Easy SMTP Mail, WP Mail Bank, ...
46
+ * Subscribers massive **import** from file
47
+ * Newsletter with Html and Text message versions
48
 
49
  = Integration with WordPress registration =
50
 
52
  * Auto confirmation on first login
53
  * Imports already registered users
54
 
55
+ = Free Extensions =
56
 
57
  Find and install them from the Extensions panel in your blog.
58
 
74
 
75
  = Support =
76
 
77
+ We provide support for our plugin on [Wordpress.org forums](https://wordpress.org/support/plugin/newsletter) and through our [official forum](https://www.thenewsletterplugin.com/forums).
78
+
79
+ Premium Users with an active license have access to one-to-one support via our [ticketing system](https://www.thenewsletterplugin.com/support-ticket).
80
 
81
  = Follow Us =
82
 
107
 
108
  == Changelog ==
109
 
110
+ = 5.5.4 =
111
+
112
+ * WPML integration. [Read our integration page](https://www.thenewsletterplugin.com/documentation/multilanguage)
113
+
114
  = 5.5.3 =
115
 
116
  * Updated tinyMCE for Edge compatibility
subscription/defaults.php CHANGED
@@ -53,17 +53,4 @@ $options['confirmed_message'] =
53
  '<p><a href="{profile_url}">' . __('Change your profile', 'newsletter') . '</p>';
54
 
55
  $options['confirmed_tracking'] = '';
56
-
57
- // Unsubscription process
58
-
59
- $options['unsubscription_text'] = '<p>' . __('Please confirm you want to unsubscribe <a href="{unsubscription_confirm_url}">clicking here</a>.', 'newsletter') . '</p>';
60
- $options['unsubscription_error_text'] = '<p>' . __("Subscriber not found, it probably has already been removed. No further actions are required.", 'newsletter') . '</p>';
61
-
62
- // When you finally loosed your subscriber
63
- $options['unsubscribed_text'] = "<p>" . __('Your subscription has been deleted. If that was an error you can <a href="{reactivate_url}">subscribe again here</a>.', 'newsletter') . "</p>";
64
-
65
- $options['unsubscribed_subject'] = __("Goodbye", 'newsletter');
66
-
67
- $options['unsubscribed_message'] = '<p>' . __('This message confirms that you have unsubscribed from our newsletter. Thank you.') . '</p>';
68
-
69
- $options['reactivated_text'] = '<p>' . __('Your subscription has been reactivated.') . '</p>';
53
  '<p><a href="{profile_url}">' . __('Change your profile', 'newsletter') . '</p>';
54
 
55
  $options['confirmed_tracking'] = '';
56
+
 
 
 
 
 
 
 
 
 
 
 
 
 
subscription/lists.php CHANGED
@@ -5,11 +5,19 @@ defined('ABSPATH') || exit;
5
  $controls = new NewsletterControls();
6
  $module = NewsletterSubscription::instance();
7
 
 
 
 
 
 
 
 
 
8
  if (!$controls->is_action()) {
9
- $controls->data = $module->get_options('lists');
10
  } else {
11
  if ($controls->is_action('save')) {
12
- $module->save_options($controls->data, 'lists');
13
  $controls->add_message_saved();
14
  }
15
  if ($controls->is_action('unlink')) {
@@ -54,16 +62,18 @@ $status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => '
54
  <p>
55
  <?php $controls->button_save(); ?>
56
  </p>
57
- <table class="widefat">
58
  <thead>
59
  <tr>
60
  <th>#</th>
61
  <th><?php _e('Name', 'newsletter')?></th>
 
62
  <th><?php _e('Visibility', 'newsletter')?></th>
63
  <th><?php _e('Pre-checked', 'newsletter')?></th>
64
  <th><?php _e('Pre-assigned', 'newsletter')?></th>
65
  <th><?php _e('Subscribers', 'newsletter')?></th>
66
  <th>&nbsp;</th>
 
67
  <th><?php _e('Notes', 'newsletter') ?></th>
68
  </tr>
69
  </thead>
@@ -71,13 +81,14 @@ $status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => '
71
  <tr>
72
  <td><?php echo $i; ?></td>
73
  <td><?php $controls->text('list_' . $i, 50); ?></td>
 
74
  <td><?php $controls->select('list_' . $i . '_status', $status); ?></td>
75
  <td><?php $controls->select('list_' . $i . '_checked', array(0 => 'No', 1 => 'Yes')); ?></td>
76
  <td><?php $controls->select('list_' . $i . '_forced', array(0 => 'No', 1 => 'Yes')); ?></td>
77
  <td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
78
 
79
  <td><?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?></td>
80
-
81
  <td>
82
  <?php $notes = apply_filters('newsletter_lists_notes', array(), $i); ?>
83
  <?php
5
  $controls = new NewsletterControls();
6
  $module = NewsletterSubscription::instance();
7
 
8
+ $current_language = $module->get_current_language();
9
+
10
+ $is_all_languages = $module->is_all_languages();
11
+
12
+ if (!$is_all_languages) {
13
+ $controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
14
+ }
15
+
16
  if (!$controls->is_action()) {
17
+ $controls->data = $module->get_options('lists', $current_language);
18
  } else {
19
  if ($controls->is_action('save')) {
20
+ $module->save_options($controls->data, 'lists', null, $current_language);
21
  $controls->add_message_saved();
22
  }
23
  if ($controls->is_action('unlink')) {
62
  <p>
63
  <?php $controls->button_save(); ?>
64
  </p>
65
+ <table class="widefat" style="width: auto">
66
  <thead>
67
  <tr>
68
  <th>#</th>
69
  <th><?php _e('Name', 'newsletter')?></th>
70
+ <?php if ($is_all_languages) { ?>
71
  <th><?php _e('Visibility', 'newsletter')?></th>
72
  <th><?php _e('Pre-checked', 'newsletter')?></th>
73
  <th><?php _e('Pre-assigned', 'newsletter')?></th>
74
  <th><?php _e('Subscribers', 'newsletter')?></th>
75
  <th>&nbsp;</th>
76
+ <?php } ?>
77
  <th><?php _e('Notes', 'newsletter') ?></th>
78
  </tr>
79
  </thead>
81
  <tr>
82
  <td><?php echo $i; ?></td>
83
  <td><?php $controls->text('list_' . $i, 50); ?></td>
84
+ <?php if ($is_all_languages) { ?>
85
  <td><?php $controls->select('list_' . $i . '_status', $status); ?></td>
86
  <td><?php $controls->select('list_' . $i . '_checked', array(0 => 'No', 1 => 'Yes')); ?></td>
87
  <td><?php $controls->select('list_' . $i . '_forced', array(0 => 'No', 1 => 'Yes')); ?></td>
88
  <td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
89
 
90
  <td><?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?></td>
91
+ <?php } ?>
92
  <td>
93
  <?php $notes = apply_filters('newsletter_lists_notes', array(), $i); ?>
94
  <?php
subscription/options.php CHANGED
@@ -5,8 +5,16 @@ defined('ABSPATH') || exit;
5
  $controls = new NewsletterControls();
6
  $module = NewsletterSubscription::instance();
7
 
 
 
 
 
 
 
 
 
8
  // TODO: Remove and use the $module->options.
9
- $options = get_option('newsletter', array());
10
 
11
  if ($controls->is_action()) {
12
  if ($controls->is_action('save')) {
@@ -50,7 +58,7 @@ if ($controls->is_action()) {
50
  $controls->data['confirmed_url'] = trim($controls->data['confirmed_url']);
51
  $controls->data['confirmation_url'] = trim($controls->data['confirmation_url']);
52
 
53
- $module->merge_options($controls->data);
54
  $controls->add_message_saved();
55
  }
56
 
@@ -86,7 +94,7 @@ if ($controls->is_action()) {
86
  $controls->errors = 'There are no test subscribers. Read more about test subscribers <a href="https://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank">here</a>.';
87
  } else {
88
  $addresses = array();
89
- foreach ($users as &$user) {
90
  $addresses[] = $user->email;
91
  $res = $module->mail($user->email, $module->replace($module->options['confirmed_subject']), $module->replace($module->options['confirmed_message'], $user));
92
  if (!$res) {
@@ -100,7 +108,7 @@ if ($controls->is_action()) {
100
  }
101
  }
102
  } else {
103
- $controls->data = get_option('newsletter', array());
104
  }
105
 
106
  ?>
@@ -117,6 +125,7 @@ if ($controls->is_action()) {
117
  </div>
118
 
119
  <div id="tnp-body">
 
120
 
121
  <form method="post" action="">
122
  <?php $controls->init(); ?>
@@ -129,7 +138,9 @@ if ($controls->is_action()) {
129
  </ul>
130
 
131
  <div id="tabs-general">
 
132
  <table class="form-table">
 
133
  <tr>
134
  <th><?php _e('Opt In', 'newsletter') ?></th>
135
  <td>
@@ -160,6 +171,10 @@ if ($controls->is_action()) {
160
  </td>
161
  </tr>
162
  </table>
 
 
 
 
163
  </div>
164
 
165
 
5
  $controls = new NewsletterControls();
6
  $module = NewsletterSubscription::instance();
7
 
8
+ $current_language = $module->get_current_language();
9
+
10
+ $is_all_languages = $module->is_all_languages();
11
+
12
+ if (!$is_all_languages) {
13
+ $controls->warnings[] = 'You are configuring the language <strong>' . $current_language . '</strong>. Switch to "all languages" to see every options.';
14
+ }
15
+
16
  // TODO: Remove and use the $module->options.
17
+ $options = $module->get_options('', $current_language);
18
 
19
  if ($controls->is_action()) {
20
  if ($controls->is_action('save')) {
58
  $controls->data['confirmed_url'] = trim($controls->data['confirmed_url']);
59
  $controls->data['confirmation_url'] = trim($controls->data['confirmation_url']);
60
 
61
+ $module->save_options($controls->data, '', null, $current_language);
62
  $controls->add_message_saved();
63
  }
64
 
94
  $controls->errors = 'There are no test subscribers. Read more about test subscribers <a href="https://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#test" target="_blank">here</a>.';
95
  } else {
96
  $addresses = array();
97
+ foreach ($users as $user) {
98
  $addresses[] = $user->email;
99
  $res = $module->mail($user->email, $module->replace($module->options['confirmed_subject']), $module->replace($module->options['confirmed_message'], $user));
100
  if (!$res) {
108
  }
109
  }
110
  } else {
111
+ $controls->data = $module->get_options('', $current_language);
112
  }
113
 
114
  ?>
125
  </div>
126
 
127
  <div id="tnp-body">
128
+
129
 
130
  <form method="post" action="">
131
  <?php $controls->init(); ?>
138
  </ul>
139
 
140
  <div id="tabs-general">
141
+ <?php if ($is_all_languages) { ?>
142
  <table class="form-table">
143
+
144
  <tr>
145
  <th><?php _e('Opt In', 'newsletter') ?></th>
146
  <td>
171
  </td>
172
  </tr>
173
  </table>
174
+ <?php } else { ?>
175
+ <p>Switch to your main language to manage these options.</p>
176
+ <?php } ?>
177
+
178
  </div>
179
 
180
 
subscription/page.php CHANGED
@@ -18,13 +18,14 @@ $module = NewsletterSubscription::instance();
18
  $user = $module->get_user_from_request(true);
19
  $message_key = $module->get_message_key_from_request();
20
  $message = apply_filters('newsletter_page_text', '', $message_key);
 
21
  if (!$message) {
22
- $message = $module->options[$message_key . '_text'];
23
  }
24
  $message = $module->replace($message, $user);
25
 
26
- if (isset($module->options[$message_key . '_tracking'])) {
27
- $message .= $module->options[$message_key . '_tracking'];
28
  }
29
  $alert = '';
30
  if (isset($_REQUEST['alert'])) $alert = stripslashes($_REQUEST['alert']);
18
  $user = $module->get_user_from_request(true);
19
  $message_key = $module->get_message_key_from_request();
20
  $message = apply_filters('newsletter_page_text', '', $message_key);
21
+ $options = $module->get_options('', $module->get_user_language($user));
22
  if (!$message) {
23
+ $message = $options[$message_key . '_text'];
24
  }
25
  $message = $module->replace($message, $user);
26
 
27
+ if (isset($options[$message_key . '_tracking'])) {
28
+ $message .= $options[$message_key . '_tracking'];
29
  }
30
  $alert = '';
31
  if (isset($_REQUEST['alert'])) $alert = stripslashes($_REQUEST['alert']);
subscription/profile.php CHANGED
@@ -6,11 +6,19 @@ if (!defined('ABSPATH'))
6
  $controls = new NewsletterControls();
7
  $module = NewsletterSubscription::instance();
8
 
 
 
 
 
 
 
 
 
9
  if (!$controls->is_action()) {
10
- $controls->data = $module->get_options('profile');
11
  } else {
12
  if ($controls->is_action('save')) {
13
- $module->merge_options($controls->data, 'profile');
14
  $controls->add_message_saved();
15
  }
16
 
@@ -73,8 +81,10 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
73
  <td>
74
  <table class="newsletter-option-grid">
75
  <tr><th>Field label</th><td><?php $controls->text('name', 50); ?></td></tr>
 
76
  <tr><th>When to show</th><td><?php $controls->select('name_status', $status); ?></td></tr>
77
  <tr><th>Rules</th><td><?php $controls->select('name_rules', $rules); ?></td></tr>
 
78
  <tr><th>Error message</th><td><?php $controls->text('name_error', 50); ?></td></tr>
79
  </table>
80
  <p class="description">
@@ -88,8 +98,10 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
88
  <td>
89
  <table class="newsletter-option-grid">
90
  <tr><th>Field label</th><td><?php $controls->text('surname', 50); ?></td></tr>
 
91
  <tr><th>When to show</th><td><?php $controls->select('surname_status', $status); ?></td></tr>
92
  <tr><th>Rules</th><td><?php $controls->select('surname_rules', $rules); ?></td></tr>
 
93
  <tr><th>Error message</th><td><?php $controls->text('surname_error', 50); ?></td></tr>
94
  </table>
95
  </td>
@@ -99,13 +111,16 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
99
  <td>
100
  <table class="newsletter-option-grid">
101
  <tr><th>Field label</th><td><?php $controls->text('sex', 50); ?></td></tr>
 
102
  <tr><th>When to show</th><td><?php $controls->select('sex_status', $status); ?></td></tr>
 
 
103
  <tr><th>Value labels</th><td>
104
  female: <?php $controls->text('sex_female'); ?>
105
  male: <?php $controls->text('sex_male'); ?>
106
  not specified: <?php $controls->text('sex_none'); ?>
107
  </td></tr>
108
- <tr><th>Rules</th><td><?php $controls->select('sex_rules', $rules); ?></td></tr>
109
 
110
  <tr><th>Salutation titles</th><td>
111
 
@@ -136,7 +151,9 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
136
  <th>Privacy checkbox/notice</th>
137
  <td>
138
  <table class="newsletter-option-grid">
 
139
  <tr><th>Enabled?</th><td><?php $controls->select('privacy_status', array(0 => 'No', 1 => 'Yes', 2 => 'Only the notice')); ?></td></tr>
 
140
  <tr><th>Label</th><td><?php $controls->text('privacy', 50); ?></td></tr>
141
  <tr><th>Privacy URL</th><td>
142
  <?php if (function_exists('get_privacy_policy_url') && get_privacy_policy_url()) { ?>
@@ -187,12 +204,14 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
187
  </thead>
188
  <?php for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) { ?>
189
  <tr>
190
- <td>Profile <?php echo $i; ?></td>
191
  <td><?php $controls->text('profile_' . $i); ?></td>
192
  <td><?php $controls->text('profile_' . $i . '_placeholder'); ?></td>
 
193
  <td><?php $controls->select('profile_' . $i . '_status', $status); ?></td>
194
  <td><?php $controls->select('profile_' . $i . '_type', array('text' => 'Text', 'select' => 'List')); ?></td>
195
  <td><?php $controls->select('profile_' . $i . '_rules', $rules); ?></td>
 
196
  <td>
197
  <?php $controls->textarea_fixed('profile_' . $i . '_options', '200px', '50px'); ?>
198
  </td>
6
  $controls = new NewsletterControls();
7
  $module = NewsletterSubscription::instance();
8
 
9
+ $current_language = $module->get_current_language();
10
+
11
+ $is_all_languages = $module->is_all_languages();
12
+
13
+ if (!$is_all_languages) {
14
+ $controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
15
+ }
16
+
17
  if (!$controls->is_action()) {
18
+ $controls->data = $module->get_options('profile', $current_language);
19
  } else {
20
  if ($controls->is_action('save')) {
21
+ $module->save_options($controls->data, 'profile', null, $current_language);
22
  $controls->add_message_saved();
23
  }
24
 
81
  <td>
82
  <table class="newsletter-option-grid">
83
  <tr><th>Field label</th><td><?php $controls->text('name', 50); ?></td></tr>
84
+ <?php if ($is_all_languages) { ?>
85
  <tr><th>When to show</th><td><?php $controls->select('name_status', $status); ?></td></tr>
86
  <tr><th>Rules</th><td><?php $controls->select('name_rules', $rules); ?></td></tr>
87
+ <?php } ?>
88
  <tr><th>Error message</th><td><?php $controls->text('name_error', 50); ?></td></tr>
89
  </table>
90
  <p class="description">
98
  <td>
99
  <table class="newsletter-option-grid">
100
  <tr><th>Field label</th><td><?php $controls->text('surname', 50); ?></td></tr>
101
+ <?php if ($is_all_languages) { ?>
102
  <tr><th>When to show</th><td><?php $controls->select('surname_status', $status); ?></td></tr>
103
  <tr><th>Rules</th><td><?php $controls->select('surname_rules', $rules); ?></td></tr>
104
+ <?php } ?>
105
  <tr><th>Error message</th><td><?php $controls->text('surname_error', 50); ?></td></tr>
106
  </table>
107
  </td>
111
  <td>
112
  <table class="newsletter-option-grid">
113
  <tr><th>Field label</th><td><?php $controls->text('sex', 50); ?></td></tr>
114
+ <?php if ($is_all_languages) { ?>
115
  <tr><th>When to show</th><td><?php $controls->select('sex_status', $status); ?></td></tr>
116
+ <tr><th>Rules</th><td><?php $controls->select('sex_rules', $rules); ?></td></tr>
117
+ <?php } ?>
118
  <tr><th>Value labels</th><td>
119
  female: <?php $controls->text('sex_female'); ?>
120
  male: <?php $controls->text('sex_male'); ?>
121
  not specified: <?php $controls->text('sex_none'); ?>
122
  </td></tr>
123
+
124
 
125
  <tr><th>Salutation titles</th><td>
126
 
151
  <th>Privacy checkbox/notice</th>
152
  <td>
153
  <table class="newsletter-option-grid">
154
+ <?php if ($is_all_languages) { ?>
155
  <tr><th>Enabled?</th><td><?php $controls->select('privacy_status', array(0 => 'No', 1 => 'Yes', 2 => 'Only the notice')); ?></td></tr>
156
+ <?php } ?>
157
  <tr><th>Label</th><td><?php $controls->text('privacy', 50); ?></td></tr>
158
  <tr><th>Privacy URL</th><td>
159
  <?php if (function_exists('get_privacy_policy_url') && get_privacy_policy_url()) { ?>
204
  </thead>
205
  <?php for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) { ?>
206
  <tr>
207
+ <td><?php echo $i; ?></td>
208
  <td><?php $controls->text('profile_' . $i); ?></td>
209
  <td><?php $controls->text('profile_' . $i . '_placeholder'); ?></td>
210
+ <?php if ($is_all_languages) { ?>
211
  <td><?php $controls->select('profile_' . $i . '_status', $status); ?></td>
212
  <td><?php $controls->select('profile_' . $i . '_type', array('text' => 'Text', 'select' => 'List')); ?></td>
213
  <td><?php $controls->select('profile_' . $i . '_rules', $rules); ?></td>
214
+ <?php } ?>
215
  <td>
216
  <?php $controls->textarea_fixed('profile_' . $i . '_options', '200px', '50px'); ?>
217
  </td>
subscription/subscription.php CHANGED
@@ -326,13 +326,13 @@ class NewsletterSubscription extends NewsletterModule {
326
  $user = $this->subscribe();
327
 
328
  if ($user->status == 'E')
329
- $this->show_message('error', $user->id);
330
  if ($user->status == 'C')
331
- $this->show_message('confirmed', $user->id);
332
  if ($user->status == 'A')
333
- $this->show_message('already_confirmed', $user->id);
334
  if ($user->status == 'S')
335
- $this->show_message('confirmation', $user->id);
336
  }
337
  } else {
338
  // Temporary store data
@@ -362,42 +362,6 @@ class NewsletterSubscription extends NewsletterModule {
362
  echo $message;
363
  die();
364
 
365
- case 'u':
366
- $user = $this->get_user_from_request();
367
- $email = $this->get_email_from_request();
368
- if ($user == null) {
369
- $this->show_message('unsubscription_error', null);
370
- } else {
371
- $this->show_message('unsubscription', $user, null, $email);
372
- }
373
- die();
374
- break;
375
- case 'uc':
376
- if ($this->antibot_form_check()) {
377
- $user = $this->unsubscribe();
378
- if ($user->status == 'E') {
379
- $this->show_message('unsubscription_error', $user);
380
- } else {
381
- $this->show_message('unsubscribed', $user);
382
- }
383
- return;
384
- } else {
385
- $this->request_to_antibot_form('Unsubscribe');
386
- }
387
- die();
388
- break;
389
-
390
- case 'reactivate':
391
- if ($this->antibot_form_check()) {
392
- $user = $this->reactivate();
393
- $this->show_message('reactivated', $user);
394
- } else {
395
- $this->request_to_antibot_form('Unsubscribe');
396
- }
397
- die();
398
-
399
- break;
400
-
401
  case 'c':
402
  case 'confirm':
403
  if ($this->antibot_form_check()) {
@@ -516,7 +480,6 @@ class NewsletterSubscription extends NewsletterModule {
516
  $this->add_admin_page('lists', 'Lists');
517
  $this->add_admin_page('lists-edit', 'List edit');
518
  $this->add_admin_page('template', 'Template');
519
- $this->add_admin_page('unsubscription', 'Unsubscription');
520
  }
521
 
522
  /**
@@ -530,16 +493,24 @@ class NewsletterSubscription extends NewsletterModule {
530
  * @param array $options
531
  * @param string $sub
532
  */
533
- function save_options($options, $sub = '', $autoload = null) {
534
- if ($sub == '') {
535
  // For compatibility the options are wrongly named
536
  return update_option('newsletter', $options, $autoload);
537
  }
538
 
 
 
 
 
539
  if ($sub == 'profile') {
 
 
 
 
 
 
540
  // For compatibility the options are wrongly named
541
- $this->options_profile = $options;
542
- return update_option('newsletter_profile', $options, $autoload);
543
  }
544
 
545
  if ($sub == 'forms') {
@@ -550,27 +521,40 @@ class NewsletterSubscription extends NewsletterModule {
550
  if ($sub == 'lists') {
551
  $this->options_lists = $options;
552
  }
553
- return parent::save_options($options, $sub, $autoload);
554
  }
555
 
556
- function get_options($sub = '') {
557
  if ($sub == '') {
558
  // For compatibility the options are wrongly named
559
- $options = get_option('newsletter', array());
 
 
 
 
 
560
  if (!is_array($options)) {
561
  $options = array();
562
  }
 
563
  return $options;
564
  }
565
  if ($sub == 'profile') {
 
 
 
 
 
 
 
566
  // For compatibility the options are wrongly named
567
- return get_option('newsletter_profile', array());
568
  }
569
  if ($sub == 'forms') {
570
  // For compatibility the options are wrongly named
571
  return get_option('newsletter_forms', array());
572
  }
573
- return parent::get_options($sub);
574
  }
575
 
576
  function set_updated($user, $time = 0, $ip = '') {
@@ -762,6 +746,10 @@ class NewsletterSubscription extends NewsletterModule {
762
  $user['referrer'] = strip_tags(trim($_REQUEST['nr']));
763
  }
764
 
 
 
 
 
765
  // From the antibot form
766
  if (isset($_REQUEST['nhr'])) {
767
  $user['http_referer'] = strip_tags(trim($_REQUEST['nhr']));
@@ -769,8 +757,9 @@ class NewsletterSubscription extends NewsletterModule {
769
  $user['http_referer'] = strip_tags(trim($_SERVER['HTTP_REFERER']));
770
  }
771
 
772
- if (strlen($user['http_referer']) > 200)
773
- $user['http_referer'] = substr($user['http_referer'], 0, 200);
 
774
 
775
  // New profiles
776
  for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
@@ -835,21 +824,6 @@ class NewsletterSubscription extends NewsletterModule {
835
  return Newsletter::instance()->mail($to, $subject, $message, $headers);
836
  }
837
 
838
- /**
839
- * Reactivate the subscriber extracted from the request setting his status
840
- * to confirmed and logging. No email are sent. Dies on subscriber extraction failure.
841
- *
842
- * @return TNP_User
843
- */
844
- function reactivate() {
845
- $user = $this->get_user_from_request(true);
846
-
847
- $user = $this->set_user_status($user, TNP_User::STATUS_CONFIRMED);
848
- $this->add_user_log($user, 'reactivate');
849
-
850
- return $user;
851
- }
852
-
853
  /**
854
  * Confirms a subscription changing the user status and, possibly, merging the
855
  * temporary data if present.
@@ -910,57 +884,23 @@ class NewsletterSubscription extends NewsletterModule {
910
  * and checking if the message itself is disabled
911
  *
912
  * @param string $type
913
- * @param type $user
914
  */
915
  function send_message($type, $user, $force = false) {
916
  if (!$force && !empty($this->options[$type . '_disabled'])) {
917
- $this->logger->debug("Message of type '$type' is disabled");
918
  return true;
919
  }
920
-
921
- $message = $this->options[$type . '_message'];
 
922
  if ($user->status == Newsletter::STATUS_NOT_CONFIRMED) {
923
  $message = $this->add_microdata($message);
924
  }
925
- $subject = $this->options[$type . '_subject'];
926
 
927
  return $this->mail($user->email, $this->replace($subject, $user), $this->replace($message, $user));
928
  }
929
 
930
- /**
931
- * Unsubscribes the subscriber from the request. Die on subscriber extraction failure.
932
- *
933
- * @return TNP_User
934
- */
935
- function unsubscribe() {
936
- $user = $this->get_user_from_request(true);
937
-
938
- if ($user->status == 'U') {
939
- return $user;
940
- }
941
-
942
- $this->set_user_status($user, TNP_User::STATUS_UNSUBSCRIBED);
943
-
944
- $user = $this->get_user($user);
945
-
946
- $this->add_user_log($user, 'unsubscribe');
947
-
948
- do_action('newsletter_unsubscribed', $user);
949
-
950
- global $wpdb;
951
-
952
- $email = $this->get_email_from_request();
953
- if ($email) {
954
- $wpdb->update(NEWSLETTER_USERS_TABLE, array('unsub_email_id' => (int) $email_id, 'unsub_time' => time()), array('id' => $user->id));
955
- }
956
-
957
- $this->send_message('unsubscribed', $user);
958
-
959
- $this->notify_admin($user, 'Newsletter unsubscription');
960
-
961
- return $user;
962
- }
963
-
964
  /**
965
  * Saves the subscriber data.
966
  *
@@ -992,10 +932,13 @@ class NewsletterSubscription extends NewsletterModule {
992
  $url = '';
993
 
994
  if (isset($_REQUEST['ncu'])) {
 
995
  $url = $_REQUEST['ncu'];
996
  } else {
997
- if (!empty($this->options[$key . '_url'])) {
998
- $url = $this->options[$key . '_url'];
 
 
999
  }
1000
  }
1001
 
@@ -1085,7 +1028,7 @@ class NewsletterSubscription extends NewsletterModule {
1085
 
1086
  $attrs = array_merge(array('class' => 'newsletter', 'style' => ''), $attrs);
1087
 
1088
- $action = esc_attr(home_url('/') . '?na=s');
1089
  $class = esc_attr($attrs['class']);
1090
  $style = esc_attr($attrs['style']);
1091
  $buffer = '<form method="post" action="' . $action . '" class="' . $class . '" style="' . $style . '">' . "\n";
@@ -1376,6 +1319,10 @@ class NewsletterSubscription extends NewsletterModule {
1376
  * @return string
1377
  */
1378
  function get_subscription_form($referrer = null, $action = null, $attrs = array()) {
 
 
 
 
1379
  if (isset($attrs['action'])) {
1380
  $action = $attrs['action'];
1381
  }
@@ -1385,8 +1332,10 @@ class NewsletterSubscription extends NewsletterModule {
1385
 
1386
  $buffer = '';
1387
 
 
 
1388
  if (empty($action)) {
1389
- $action = home_url('/') . '?na=s';
1390
  }
1391
 
1392
  if ($referrer != 'widget') {
@@ -1398,6 +1347,8 @@ class NewsletterSubscription extends NewsletterModule {
1398
  }
1399
  $buffer .= '<form method="post" action="' . esc_attr($action) . '" onsubmit="return newsletter_check(this)">' . "\n\n";
1400
 
 
 
1401
  if (!empty($referrer)) {
1402
  $buffer .= '<input type="hidden" name="nr" value="' . esc_attr($referrer) . '">' . "\n";
1403
  }
@@ -1418,38 +1369,38 @@ class NewsletterSubscription extends NewsletterModule {
1418
  }
1419
  }
1420
 
1421
- if ($this->options_profile['name_status'] == 2) {
1422
- $buffer .= '<div class="tnp-field tnp-field-firstname"><label>' . esc_html($this->options_profile['name']) . '</label>';
1423
- $buffer .= '<input class="tnp-firstname" type="text" name="nn" ' . ($this->options_profile['name_rules'] == 1 ? 'required' : '') . '></div>';
1424
  $buffer .= "\n";
1425
  }
1426
 
1427
- if ($this->options_profile['surname_status'] == 2) {
1428
- $buffer .= '<div class="tnp-field tnp-field-lastname"><label>' . esc_html($this->options_profile['surname']) . '</label>';
1429
- $buffer .= '<input class="tnp-lastname" type="text" name="ns" ' . ($this->options_profile['surname_rules'] == 1 ? 'required' : '') . '></div>';
1430
  $buffer .= "\n";
1431
  }
1432
 
1433
- $buffer .= '<div class="tnp-field tnp-field-email"><label>' . esc_html($this->options_profile['email']) . '</label>';
1434
  $buffer .= '<input class="tnp-email" type="email" name="ne" required></div>';
1435
  $buffer .= "\n";
1436
 
1437
- if (isset($this->options_profile['sex_status']) && $this->options_profile['sex_status'] == 2) {
1438
- $buffer .= '<div class="tnp-field tnp-field-gender"><label>' . esc_html($this->options_profile['sex']) . '</label>';
1439
  $buffer .= '<select name="nx" class="tnp-gender"';
1440
- if ($this->options_profile['sex_rules'] == 1) {
1441
  $buffer .= ' required><option value=""></option>';
1442
  } else {
1443
- $buffer .= '><option value="n">' . esc_html($this->options_profile['sex_none']) . '</option>';
1444
  }
1445
- $buffer .= '<option value="m">' . esc_html($this->options_profile['sex_male']) . '</option>';
1446
- $buffer .= '<option value="f">' . esc_html($this->options_profile['sex_female']) . '</option>';
1447
  $buffer .= '</select></div>';
1448
  $buffer .= "\n";
1449
  }
1450
 
1451
  $tmp = '';
1452
- $lists = $this->get_lists_for_subscription();
1453
  if (!empty($attrs['lists_field_layout']) && $attrs['lists_field_layout'] == 'dropdown') {
1454
  foreach ($lists as $list) {
1455
 
@@ -1495,24 +1446,24 @@ class NewsletterSubscription extends NewsletterModule {
1495
  // Extra profile fields
1496
  for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
1497
  // Not for subscription form
1498
- if ($this->options_profile['profile_' . $i . '_status'] != 2) {
1499
  continue;
1500
  }
1501
 
1502
 
1503
  $buffer .= '<div class="tnp-field tnp-field-profile"><label>' .
1504
- esc_html($this->options_profile['profile_' . $i]) . '</label>';
1505
 
1506
  // Text field
1507
- if ($this->options_profile['profile_' . $i . '_type'] == 'text') {
1508
- $buffer .= '<input class="tnp-profile tnp-profile-' . $i . '" type="text"' . ($this->options_profile['profile_' . $i . '_rules'] == 1 ? ' required' : '') . ' name="np' . $i . '">';
1509
  }
1510
 
1511
  // Select field
1512
- if ($this->options_profile['profile_' . $i . '_type'] == 'select') {
1513
  $buffer .= '<select class="tnp-profile tnp-profile-' . $i . '" name="np' . $i . '" required>' . "\n";
1514
  $buffer .= "<option></option>\n";
1515
- $opts = explode(',', $this->options_profile['profile_' . $i . '_options']);
1516
  for ($j = 0; $j < count($opts); $j++) {
1517
  $buffer .= "<option>" . esc_html(trim($opts[$j])) . "</option>\n";
1518
  }
@@ -1535,7 +1486,7 @@ class NewsletterSubscription extends NewsletterModule {
1535
  $buffer .= $x['field'] . "</div>\n";
1536
  }
1537
 
1538
- $privacy_status = (int) $this->options_profile['privacy_status'];
1539
 
1540
  if ($privacy_status === 1 || $privacy_status === 2) {
1541
  $buffer .= '<div class="tnp-field tnp-field-privacy">';
@@ -1546,9 +1497,9 @@ class NewsletterSubscription extends NewsletterModule {
1546
  $url = $this->get_privacy_url();
1547
  if (!empty($url)) {
1548
  $buffer .= '<a target="_blank" href="' . esc_attr($url) . '">';
1549
- $buffer .= esc_attr($this->options_profile['privacy']) . '</a>';
1550
  } else {
1551
- $buffer .= esc_html($this->options_profile['privacy']);
1552
  }
1553
 
1554
  $buffer .= "</label></div>\n";
@@ -1556,10 +1507,10 @@ class NewsletterSubscription extends NewsletterModule {
1556
 
1557
  $buffer .= '<div class="tnp-field tnp-field-button">';
1558
 
1559
- if (strpos($this->options_profile['subscribe'], 'http') === 0) {
1560
- $buffer .= '<input class="tnp-submit-image" type="image" src="' . esc_attr($this->options_profile['subscribe']) . '">' . "\n";
1561
  } else {
1562
- $buffer .= '<input class="tnp-submit" type="submit" value="' . esc_attr($this->options_profile['subscribe']) . '">' . "\n";
1563
  }
1564
 
1565
  $buffer .= "</div>\n</form>\n";
@@ -1703,30 +1654,27 @@ class NewsletterSubscription extends NewsletterModule {
1703
 
1704
  /**
1705
  *
1706
- * @global type $wpdb
1707
- * @global boolean $cache_stop
1708
- * @global Newsletter $newsletter
1709
- * @param type $attrs
1710
- * @param type $content
1711
  * @return string
1712
  */
1713
  function shortcode_newsletter($attrs, $content) {
1714
- global $wpdb, $cache_stop, $newsletter;
1715
-
1716
- $cache_stop = true;
1717
 
1718
- $module = NewsletterSubscription::instance();
1719
- $user = $module->get_user_from_request();
1720
- $message_key = $module->get_message_key_from_request();
1721
 
1722
  $message = apply_filters('newsletter_page_text', '', $message_key);
1723
 
 
 
1724
  if (empty($message)) {
1725
- $message = $module->options[$message_key . '_text'];
1726
 
1727
  // TODO: the if can be removed
1728
  if ($message_key == 'confirmed') {
1729
- $message .= $module->options[$message_key . '_tracking'];
1730
  }
1731
  }
1732
 
@@ -1736,7 +1684,7 @@ class NewsletterSubscription extends NewsletterModule {
1736
 
1737
  // Compatibility check
1738
  if (stripos($message, '<form') !== false) {
1739
- $message .= $module->get_form_javascript();
1740
  $message = str_ireplace('<form', '<form method="post" action="' . esc_attr(home_url('/')) . '?na=s" onsubmit="return newsletter_check(this)"', $message);
1741
  } else {
1742
 
@@ -1745,20 +1693,16 @@ class NewsletterSubscription extends NewsletterModule {
1745
  }
1746
 
1747
  if (isset($attrs['form'])) {
1748
- $message = str_replace('{subscription_form}', $module->get_form($attrs['form']), $message);
1749
  } else {
1750
- if (isset($attrs['layout']) && $attrs['layout'] == 'table') {
1751
- $message = str_replace('{subscription_form}', $module->get_subscription_form('page'), $message);
1752
- } else {
1753
- $message = str_replace('{subscription_form}', $module->get_subscription_form_html5('page'), $message);
1754
- }
1755
  }
1756
  }
1757
  }
1758
 
1759
  $email = NewsletterSubscription::instance()->get_email_from_request();
1760
 
1761
- $message = $newsletter->replace($message, $user, $email, 'page');
1762
 
1763
  $message = do_shortcode($message);
1764
 
326
  $user = $this->subscribe();
327
 
328
  if ($user->status == 'E')
329
+ $this->show_message('error', $user);
330
  if ($user->status == 'C')
331
+ $this->show_message('confirmed', $user);
332
  if ($user->status == 'A')
333
+ $this->show_message('already_confirmed', $user);
334
  if ($user->status == 'S')
335
+ $this->show_message('confirmation', $user);
336
  }
337
  } else {
338
  // Temporary store data
362
  echo $message;
363
  die();
364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  case 'c':
366
  case 'confirm':
367
  if ($this->antibot_form_check()) {
480
  $this->add_admin_page('lists', 'Lists');
481
  $this->add_admin_page('lists-edit', 'List edit');
482
  $this->add_admin_page('template', 'Template');
 
483
  }
484
 
485
  /**
493
  * @param array $options
494
  * @param string $sub
495
  */
496
+ function save_options($options, $sub = '', $autoload = null, $language = '') {
497
+ if (empty($sub) && empty($language)) {
498
  // For compatibility the options are wrongly named
499
  return update_option('newsletter', $options, $autoload);
500
  }
501
 
502
+ if (empty($sub) && !empty($language)) {
503
+ return update_option('newsletter_' . $language, $options, $autoload);
504
+ }
505
+
506
  if ($sub == 'profile') {
507
+ if (empty($language)) {
508
+ $this->options_profile = $options;
509
+ return update_option('newsletter_profile', $options, $autoload);
510
+ } else {
511
+ return update_option('newsletter_profile_' . $language, $options, $autoload);
512
+ }
513
  // For compatibility the options are wrongly named
 
 
514
  }
515
 
516
  if ($sub == 'forms') {
521
  if ($sub == 'lists') {
522
  $this->options_lists = $options;
523
  }
524
+ return parent::save_options($options, $sub, $autoload, $language);
525
  }
526
 
527
+ function get_options($sub = '', $language = '') {
528
  if ($sub == '') {
529
  // For compatibility the options are wrongly named
530
+ if ($language) {
531
+ $options = get_option('newsletter_' . $language, array());
532
+ $options = array_merge(get_option('newsletter', array()), $options);
533
+ } else {
534
+ $options = get_option('newsletter', array());
535
+ }
536
  if (!is_array($options)) {
537
  $options = array();
538
  }
539
+
540
  return $options;
541
  }
542
  if ($sub == 'profile') {
543
+ if ($language) {
544
+
545
+ $options = get_option('newsletter_profile_' . $language, array());
546
+ $options = array_merge(get_option('newsletter_profile', array()), $options);
547
+ } else {
548
+ $options = get_option('newsletter_profile', array());
549
+ }
550
  // For compatibility the options are wrongly named
551
+ return $options;
552
  }
553
  if ($sub == 'forms') {
554
  // For compatibility the options are wrongly named
555
  return get_option('newsletter_forms', array());
556
  }
557
+ return parent::get_options($sub, $language);
558
  }
559
 
560
  function set_updated($user, $time = 0, $ip = '') {
746
  $user['referrer'] = strip_tags(trim($_REQUEST['nr']));
747
  }
748
 
749
+ if (!empty($_REQUEST['nlang'])) {
750
+ $user['language'] = strtolower(strip_tags($_REQUEST['nlang']));
751
+ }
752
+
753
  // From the antibot form
754
  if (isset($_REQUEST['nhr'])) {
755
  $user['http_referer'] = strip_tags(trim($_REQUEST['nhr']));
757
  $user['http_referer'] = strip_tags(trim($_SERVER['HTTP_REFERER']));
758
  }
759
 
760
+ if (strlen($user['http_referer']) > 200) {
761
+ $user['http_referer'] = mb_substr($user['http_referer'], 0, 200);
762
+ }
763
 
764
  // New profiles
765
  for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
824
  return Newsletter::instance()->mail($to, $subject, $message, $headers);
825
  }
826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
827
  /**
828
  * Confirms a subscription changing the user status and, possibly, merging the
829
  * temporary data if present.
884
  * and checking if the message itself is disabled
885
  *
886
  * @param string $type
887
+ * @param TNP_User $user
888
  */
889
  function send_message($type, $user, $force = false) {
890
  if (!$force && !empty($this->options[$type . '_disabled'])) {
 
891
  return true;
892
  }
893
+
894
+ $options = $this->get_options('', $this->get_user_language($user));
895
+ $message = $options[$type . '_message'];
896
  if ($user->status == Newsletter::STATUS_NOT_CONFIRMED) {
897
  $message = $this->add_microdata($message);
898
  }
899
+ $subject = $options[$type . '_subject'];
900
 
901
  return $this->mail($user->email, $this->replace($subject, $user), $this->replace($message, $user));
902
  }
903
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
904
  /**
905
  * Saves the subscriber data.
906
  *
932
  $url = '';
933
 
934
  if (isset($_REQUEST['ncu'])) {
935
+ // Custom URL from the form
936
  $url = $_REQUEST['ncu'];
937
  } else {
938
+ // Per message custom URL from configuration (language variants could not be supported)
939
+ $options = $this->get_options('', $this->get_user_language($user));
940
+ if (!empty($options[$key . '_url'])) {
941
+ $url = $options[$key . '_url'];
942
  }
943
  }
944
 
1028
 
1029
  $attrs = array_merge(array('class' => 'newsletter', 'style' => ''), $attrs);
1030
 
1031
+ $action = esc_attr($this->build_action_url('s'));
1032
  $class = esc_attr($attrs['class']);
1033
  $style = esc_attr($attrs['style']);
1034
  $buffer = '<form method="post" action="' . $action . '" class="' . $class . '" style="' . $style . '">' . "\n";
1319
  * @return string
1320
  */
1321
  function get_subscription_form($referrer = null, $action = null, $attrs = array()) {
1322
+ $language = $this->get_current_language();
1323
+ $options_profile = $this->get_options('profile', $language);
1324
+
1325
+
1326
  if (isset($attrs['action'])) {
1327
  $action = $attrs['action'];
1328
  }
1332
 
1333
  $buffer = '';
1334
 
1335
+
1336
+
1337
  if (empty($action)) {
1338
+ $action = $this->build_action_url('s');
1339
  }
1340
 
1341
  if ($referrer != 'widget') {
1347
  }
1348
  $buffer .= '<form method="post" action="' . esc_attr($action) . '" onsubmit="return newsletter_check(this)">' . "\n\n";
1349
 
1350
+ $buffer .= '<input type="hidden" name="nlang" value="' . esc_attr($language) . '">' . "\n";
1351
+
1352
  if (!empty($referrer)) {
1353
  $buffer .= '<input type="hidden" name="nr" value="' . esc_attr($referrer) . '">' . "\n";
1354
  }
1369
  }
1370
  }
1371
 
1372
+ if ($options_profile['name_status'] == 2) {
1373
+ $buffer .= '<div class="tnp-field tnp-field-firstname"><label>' . esc_html($options_profile['name']) . '</label>';
1374
+ $buffer .= '<input class="tnp-firstname" type="text" name="nn" ' . ($options_profile['name_rules'] == 1 ? 'required' : '') . '></div>';
1375
  $buffer .= "\n";
1376
  }
1377
 
1378
+ if ($options_profile['surname_status'] == 2) {
1379
+ $buffer .= '<div class="tnp-field tnp-field-lastname"><label>' . esc_html($options_profile['surname']) . '</label>';
1380
+ $buffer .= '<input class="tnp-lastname" type="text" name="ns" ' . ($options_profile['surname_rules'] == 1 ? 'required' : '') . '></div>';
1381
  $buffer .= "\n";
1382
  }
1383
 
1384
+ $buffer .= '<div class="tnp-field tnp-field-email"><label>' . esc_html($options_profile['email']) . '</label>';
1385
  $buffer .= '<input class="tnp-email" type="email" name="ne" required></div>';
1386
  $buffer .= "\n";
1387
 
1388
+ if (isset($options_profile['sex_status']) && $options_profile['sex_status'] == 2) {
1389
+ $buffer .= '<div class="tnp-field tnp-field-gender"><label>' . esc_html($options_profile['sex']) . '</label>';
1390
  $buffer .= '<select name="nx" class="tnp-gender"';
1391
+ if ($options_profile['sex_rules'] == 1) {
1392
  $buffer .= ' required><option value=""></option>';
1393
  } else {
1394
+ $buffer .= '><option value="n">' . esc_html($options_profile['sex_none']) . '</option>';
1395
  }
1396
+ $buffer .= '<option value="m">' . esc_html($options_profile['sex_male']) . '</option>';
1397
+ $buffer .= '<option value="f">' . esc_html($options_profile['sex_female']) . '</option>';
1398
  $buffer .= '</select></div>';
1399
  $buffer .= "\n";
1400
  }
1401
 
1402
  $tmp = '';
1403
+ $lists = $this->get_lists_for_subscription($language);
1404
  if (!empty($attrs['lists_field_layout']) && $attrs['lists_field_layout'] == 'dropdown') {
1405
  foreach ($lists as $list) {
1406
 
1446
  // Extra profile fields
1447
  for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
1448
  // Not for subscription form
1449
+ if ($options_profile['profile_' . $i . '_status'] != 2) {
1450
  continue;
1451
  }
1452
 
1453
 
1454
  $buffer .= '<div class="tnp-field tnp-field-profile"><label>' .
1455
+ esc_html($options_profile['profile_' . $i]) . '</label>';
1456
 
1457
  // Text field
1458
+ if ($options_profile['profile_' . $i . '_type'] == 'text') {
1459
+ $buffer .= '<input class="tnp-profile tnp-profile-' . $i . '" type="text"' . ($options_profile['profile_' . $i . '_rules'] == 1 ? ' required' : '') . ' name="np' . $i . '">';
1460
  }
1461
 
1462
  // Select field
1463
+ if ($options_profile['profile_' . $i . '_type'] == 'select') {
1464
  $buffer .= '<select class="tnp-profile tnp-profile-' . $i . '" name="np' . $i . '" required>' . "\n";
1465
  $buffer .= "<option></option>\n";
1466
+ $opts = explode(',', $options_profile['profile_' . $i . '_options']);
1467
  for ($j = 0; $j < count($opts); $j++) {
1468
  $buffer .= "<option>" . esc_html(trim($opts[$j])) . "</option>\n";
1469
  }
1486
  $buffer .= $x['field'] . "</div>\n";
1487
  }
1488
 
1489
+ $privacy_status = (int) $options_profile['privacy_status'];
1490
 
1491
  if ($privacy_status === 1 || $privacy_status === 2) {
1492
  $buffer .= '<div class="tnp-field tnp-field-privacy">';
1497
  $url = $this->get_privacy_url();
1498
  if (!empty($url)) {
1499
  $buffer .= '<a target="_blank" href="' . esc_attr($url) . '">';
1500
+ $buffer .= esc_attr($options_profile['privacy']) . '</a>';
1501
  } else {
1502
+ $buffer .= esc_html($options_profile['privacy']);
1503
  }
1504
 
1505
  $buffer .= "</label></div>\n";
1507
 
1508
  $buffer .= '<div class="tnp-field tnp-field-button">';
1509
 
1510
+ if (strpos($options_profile['subscribe'], 'http') === 0) {
1511
+ $buffer .= '<input class="tnp-submit-image" type="image" src="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1512
  } else {
1513
+ $buffer .= '<input class="tnp-submit" type="submit" value="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1514
  }
1515
 
1516
  $buffer .= "</div>\n</form>\n";
1654
 
1655
  /**
1656
  *
1657
+ * @global wpdb $wpdb
1658
+ * @param array $attrs
1659
+ * @param string $content
 
 
1660
  * @return string
1661
  */
1662
  function shortcode_newsletter($attrs, $content) {
1663
+ global $wpdb;
 
 
1664
 
1665
+ $user = $this->get_user_from_request();
1666
+ $message_key = $this->get_message_key_from_request();
 
1667
 
1668
  $message = apply_filters('newsletter_page_text', '', $message_key);
1669
 
1670
+ $options = $this->get_options('', $this->get_user_language($user));
1671
+
1672
  if (empty($message)) {
1673
+ $message = $options[$message_key . '_text'];
1674
 
1675
  // TODO: the if can be removed
1676
  if ($message_key == 'confirmed') {
1677
+ $message .= $options[$message_key . '_tracking'];
1678
  }
1679
  }
1680
 
1684
 
1685
  // Compatibility check
1686
  if (stripos($message, '<form') !== false) {
1687
+ $message .= $this->get_form_javascript();
1688
  $message = str_ireplace('<form', '<form method="post" action="' . esc_attr(home_url('/')) . '?na=s" onsubmit="return newsletter_check(this)"', $message);
1689
  } else {
1690
 
1693
  }
1694
 
1695
  if (isset($attrs['form'])) {
1696
+ $message = str_replace('{subscription_form}', $this->get_form($attrs['form']), $message);
1697
  } else {
1698
+ $message = str_replace('{subscription_form}', $this->get_subscription_form('page'), $message);
 
 
 
 
1699
  }
1700
  }
1701
  }
1702
 
1703
  $email = NewsletterSubscription::instance()->get_email_from_request();
1704
 
1705
+ $message = $this->replace($message, $user, $email, 'page');
1706
 
1707
  $message = do_shortcode($message);
1708
 
subscription/template.php CHANGED
@@ -5,11 +5,19 @@ defined('ABSPATH') || exit;
5
  $controls = new NewsletterControls();
6
  $module = NewsletterSubscription::instance();
7
 
 
 
 
 
 
 
 
 
8
  if (!$controls->is_action()) {
9
- $controls->data = $module->get_options('template');
10
  } else {
11
  if ($controls->is_action('save')) {
12
- $module->save_options($controls->data, 'template');
13
 
14
  if (strpos($controls->data['template'], '{message}') === false) {
15
  $controls->errors = __('The tag {message} is missing in your template', 'newsletter');
@@ -19,8 +27,9 @@ if (!$controls->is_action()) {
19
  }
20
 
21
  if ($controls->is_action('reset')) {
22
- $controls->data['template'] = file_get_contents(dirname(__FILE__) . '/email.html');
23
- $module->save_options($controls->data, 'template');
 
24
  $controls->add_message_done();
25
  }
26
 
5
  $controls = new NewsletterControls();
6
  $module = NewsletterSubscription::instance();
7
 
8
+ $current_language = $module->get_current_language();
9
+
10
+ $is_all_languages = $module->is_all_languages();
11
+
12
+ if (!$is_all_languages) {
13
+ $controls->warnings[] = 'You are configuring the language <strong>' . $current_language . '</strong>.';
14
+ }
15
+
16
  if (!$controls->is_action()) {
17
+ $controls->data = $module->get_options('template', $current_language);
18
  } else {
19
  if ($controls->is_action('save')) {
20
+ $module->save_options($controls->data, 'template', null, $current_language);
21
 
22
  if (strpos($controls->data['template'], '{message}') === false) {
23
  $controls->errors = __('The tag {message} is missing in your template', 'newsletter');
27
  }
28
 
29
  if ($controls->is_action('reset')) {
30
+ // TODO: Reset by language?
31
+ $module->reset_options('template');
32
+ $controls->data = $module->get_options('template', $current_language);
33
  $controls->add_message_done();
34
  }
35
 
tnp-header.php CHANGED
@@ -72,7 +72,7 @@ $warning |= empty($status_options['mail']);
72
  <small><?php _e('Profile the subscribers for a better targeting', 'newsletter') ?></small></a>
73
  </li>
74
  <li>
75
- <a href="?page=newsletter_subscription_unsubscription"><i class="fa fa-sign-out"></i> <?php _e('Unsubscription', 'newsletter') ?>
76
  <small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
77
  </li>
78
 
72
  <small><?php _e('Profile the subscribers for a better targeting', 'newsletter') ?></small></a>
73
  </li>
74
  <li>
75
+ <a href="?page=newsletter_unsubscription_index"><i class="fa fa-sign-out"></i> <?php _e('Unsubscription', 'newsletter') ?>
76
  <small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
77
  </li>
78
 
unsubscription/defaults.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Those default options are used ONLY on FIRST setup and on plugin updates but limited to
3
+ // new options that may have been added between your and new version.
4
+ //
5
+ // This is the main language file, too, which is always loaded by Newsletter. Other language
6
+ // files are loaded according the WPLANG constant defined in wp-config.php file. Those language
7
+ // specific files are "merged" with this one and the language specific configuration
8
+ // keys override the ones in this file.
9
+ //
10
+ // Language specific files only need to override configurations containing texts
11
+ // langiage dependant.
12
+
13
+ $options = array();
14
+
15
+ $options['unsubscribe_text'] = '<p>' . __('Please confirm you want to unsubscribe <a href="{unsubscription_confirm_url}">clicking here</a>.', 'newsletter') . '</p>';
16
+ $options['error_text'] = '<p>' . __("Subscriber not found, it probably has already been removed. No further actions are required.", 'newsletter') . '</p>';
17
+
18
+ // When you finally loosed your subscriber
19
+ $options['unsubscribed_text'] = "<p>" . __('Your subscription has been deleted. If that was an error you can <a href="{reactivate_url}">subscribe again here</a>.', 'newsletter') . "</p>";
20
+
21
+ $options['unsubscribed_subject'] = __("Goodbye", 'newsletter');
22
+
23
+ $options['unsubscribed_message'] = '<p>' . __('This message confirms that you have unsubscribed from our newsletter. Thank you.') . '</p>';
24
+
25
+ $options['reactivated_text'] = '<p>' . __('Your subscription has been reactivated.') . '</p>';
subscription/unsubscription.php → unsubscription/index.php RENAMED
@@ -1,49 +1,34 @@
1
  <?php
2
- if (!defined('ABSPATH'))
3
- exit;
4
 
5
  @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
  $controls = new NewsletterControls();
7
- $module = NewsletterSubscription::instance();
8
- $defaults = $module->get_default_options();
 
 
 
 
 
 
 
9
 
10
  if (!$controls->is_action()) {
11
- $controls->data = $module->get_options();
12
  } else {
13
  if ($controls->is_action('save')) {
14
- $controls->data['unsubscription_text'] = NewsletterModule::clean_url_tags($controls->data['unsubscription_text']);
15
- $controls->data['unsubscribed_text'] = NewsletterModule::clean_url_tags($controls->data['unsubscribed_text']);
16
- $controls->data['unsubscribed_message'] = NewsletterModule::clean_url_tags($controls->data['unsubscribed_message']);
17
-
18
- if (empty($controls->data['unsubscription_text'])) {
19
- $controls->data['unsubscription_text'] = $defaults['unsubscription_text'];
20
- }
21
- if (empty($controls->data['unsubscribed_text'])) {
22
- $controls->data['unsubscribed_text'] = $defaults['unsubscribed_text'];
23
- }
24
- if (empty($controls->data['unsubscribed_message'])) {
25
- $controls->data['unsubscribed_message'] = $defaults['unsubscribed_message'];
26
- }
27
- if (empty($controls->data['unsubscribed_subject'])) {
28
- $controls->data['unsubscribed_subject'] = $defaults['unsubscribed_subject'];
29
- }
30
- if (empty($controls->data['unsubscription_error_text'])) {
31
- $controls->data['unsubscription_error_text'] = $defaults['unsubscription_error_text'];
32
- }
33
-
34
- $module->merge_options($controls->data);
35
- $controls->data = $module->get_options();
36
  $controls->add_message_saved();
37
  }
38
 
39
  if ($controls->is_action('reset')) {
40
- $controls->data['unsubscription_text'] = $defaults['unsubscription_text'];
41
- $controls->data['unsubscribed_text'] = $defaults['unsubscribed_text'];
42
- $controls->data['unsubscribed_subject'] = $defaults['unsubscribed_subject'];
43
- $controls->data['unsubscribed_message'] = $defaults['unsubscribed_message'];
44
- $controls->data['unsubscription_error_text'] = $defaults['unsubscription_error_text'];
45
- $module->merge_options($controls->data);
46
- $controls->data = $module->get_options();
47
  }
48
  }
49
  ?>
@@ -78,7 +63,7 @@ if (!$controls->is_action()) {
78
  <tr>
79
  <th><?php _e('Cancellation message', 'newsletter') ?></th>
80
  <td>
81
- <?php $controls->wp_editor('unsubscription_text', array('editor_height'=>250)); ?>
82
  <p class="description">
83
  </p>
84
  </td>
@@ -103,9 +88,9 @@ if (!$controls->is_action()) {
103
  </td>
104
  </tr>
105
  <tr>
106
- <th>Unsubscription error</th>
107
  <td>
108
- <?php $controls->wp_editor('unsubscription_error_text', array('editor_height'=>250)); ?>
109
  <p class="description">
110
 
111
  </p>
1
  <?php
2
+ defined('ABSPATH') || exit;
 
3
 
4
  @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
5
  $controls = new NewsletterControls();
6
+ $module = NewsletterUnsubscription::instance();
7
+
8
+ $current_language = $module->get_current_language();
9
+
10
+ $is_all_languages = $module->is_all_languages();
11
+
12
+ if (!$is_all_languages) {
13
+ $controls->warnings[] = 'You are configuring the language <strong>' . $current_language . '</strong>. Switch to "all languages" to see every options.';
14
+ }
15
 
16
  if (!$controls->is_action()) {
17
+ $controls->data = $module->get_options('', $current_language);
18
  } else {
19
  if ($controls->is_action('save')) {
20
+ //$controls->data['unsubscription_text'] = NewsletterModule::clean_url_tags($controls->data['unsubscription_text']);
21
+ //$controls->data['unsubscribed_text'] = NewsletterModule::clean_url_tags($controls->data['unsubscribed_text']);
22
+ //$controls->data['unsubscribed_message'] = NewsletterModule::clean_url_tags($controls->data['unsubscribed_message']);
23
+
24
+ $module->save_options($controls->data, '', null, $current_language);
25
+ $controls->data = $module->get_options('', $current_language);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  $controls->add_message_saved();
27
  }
28
 
29
  if ($controls->is_action('reset')) {
30
+ // On reset we ignore the current language
31
+ $controls->data = $module->reset_options();
 
 
 
 
 
32
  }
33
  }
34
  ?>
63
  <tr>
64
  <th><?php _e('Cancellation message', 'newsletter') ?></th>
65
  <td>
66
+ <?php $controls->wp_editor('unsubscribe_text', array('editor_height'=>250)); ?>
67
  <p class="description">
68
  </p>
69
  </td>
88
  </td>
89
  </tr>
90
  <tr>
91
+ <th><?php _e('On error', 'newsletter')?></th>
92
  <td>
93
+ <?php $controls->wp_editor('error_text', array('editor_height'=>150)); ?>
94
  <p class="description">
95
 
96
  </p>
unsubscription/unsubscription.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined('ABSPATH') || exit;
4
+
5
+ require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
6
+
7
+ class NewsletterUnsubscription extends NewsletterModule {
8
+
9
+ static $instance;
10
+
11
+ /**
12
+ * @return NewsletterUnsubscription
13
+ */
14
+ static function instance() {
15
+ if (self::$instance == null) {
16
+ self::$instance = new NewsletterUnsubscription();
17
+ }
18
+ return self::$instance;
19
+ }
20
+
21
+ function __construct() {
22
+ parent::__construct('unsubscription', '1.0.0');
23
+ add_action('init', array($this, 'hook_init'));
24
+ add_action('wp_loaded', array($this, 'hook_wp_loaded'));
25
+ }
26
+
27
+ function hook_init() {
28
+ add_filter('newsletter_replace', array($this, 'hook_newsletter_replace'), 10, 3);
29
+ add_filter('newsletter_page_text', array($this, 'hook_newsletter_page_text'), 10, 2);
30
+ }
31
+
32
+ function hook_wp_loaded() {
33
+ global $wpdb;
34
+
35
+ switch (Newsletter::instance()->action) {
36
+ case 'u':
37
+ $user = $this->get_user_from_request();
38
+ $email = $this->get_email_from_request();
39
+ if ($user == null) {
40
+ $url = $this->build_message_url(null, 'error_text', $user);
41
+ wp_redirect($url);
42
+ } else {
43
+ $url = $this->build_message_url(null, 'unsubscribe', $user);
44
+ wp_redirect($url);
45
+ }
46
+ die();
47
+ break;
48
+ case 'uc':
49
+ if ($this->antibot_form_check()) {
50
+ $user = $this->unsubscribe();
51
+ if ($user->status == 'E') {
52
+ $url = $this->build_message_url(null, 'unsubscription_error', $user);
53
+ wp_redirect($url);
54
+ } else {
55
+ $url = $this->build_message_url(null, 'unsubscribed', $user);
56
+ wp_redirect($url);
57
+ }
58
+ return;
59
+ } else {
60
+ $this->request_to_antibot_form('Unsubscribe');
61
+ }
62
+ die();
63
+ break;
64
+
65
+ case 'reactivate':
66
+ if ($this->antibot_form_check()) {
67
+ $user = $this->reactivate();
68
+ $this->show_message('reactivated', $user);
69
+ } else {
70
+ $this->request_to_antibot_form('Unsubscribe');
71
+ }
72
+ die();
73
+
74
+ break;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Unsubscribes the subscriber from the request. Die on subscriber extraction failure.
80
+ *
81
+ * @return TNP_User
82
+ */
83
+ function unsubscribe() {
84
+ $user = $this->get_user_from_request(true);
85
+
86
+ if ($user->status == 'U') {
87
+ return $user;
88
+ }
89
+
90
+ $this->set_user_status($user, TNP_User::STATUS_UNSUBSCRIBED);
91
+
92
+ $user = $this->get_user($user);
93
+
94
+ $this->add_user_log($user, 'unsubscribe');
95
+
96
+ do_action('newsletter_unsubscribed', $user);
97
+
98
+ global $wpdb;
99
+
100
+ $email = $this->get_email_from_request();
101
+ if ($email) {
102
+ $wpdb->update(NEWSLETTER_USERS_TABLE, array('unsub_email_id' => (int) $email_id, 'unsub_time' => time()), array('id' => $user->id));
103
+ }
104
+
105
+ $this->send_message('unsubscribed', $user);
106
+
107
+ $this->notify_admin($user, 'Newsletter unsubscription');
108
+
109
+ return $user;
110
+ }
111
+
112
+ /**
113
+ * Reactivate the subscriber extracted from the request setting his status
114
+ * to confirmed and logging. No email are sent. Dies on subscriber extraction failure.
115
+ *
116
+ * @return TNP_User
117
+ */
118
+ function reactivate() {
119
+ $user = $this->get_user_from_request(true);
120
+
121
+ $user = $this->set_user_status($user, TNP_User::STATUS_CONFIRMED);
122
+ $this->add_user_log($user, 'reactivate');
123
+
124
+ return $user;
125
+ }
126
+
127
+ function hook_newsletter_replace($text, $user, $email) {
128
+
129
+ if (!$user) {
130
+ return $text;
131
+ }
132
+
133
+ $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $this->build_action_url('uc', $user, $email));
134
+ $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $this->build_action_url('u', $user, $email));
135
+ $text = $this->replace_url($text, 'REACTIVATE_URL', $this->build_action_url('reactivate', $user, $email));
136
+
137
+ return $text;
138
+ }
139
+
140
+ function hook_newsletter_page_text($text, $key) {
141
+ if ($key == 'unsubscribe') {
142
+ return $this->options['unsubscribe_text'];
143
+ }
144
+ if ($key == 'unsubscribed') {
145
+ return $this->options['unsubscribed_text'];
146
+ }
147
+ if ($key == 'reactivated') {
148
+ return $this->options['reactivated_text'];
149
+ }
150
+ if ($key == 'unsubscription_error') {
151
+ return $this->options['error_text'];
152
+ }
153
+ return $text;
154
+ }
155
+
156
+ function upgrade() {
157
+ global $wpdb, $charset_collate;
158
+
159
+ parent::upgrade();
160
+
161
+ // Migration code
162
+ if (empty($this->options) || empty($this->options['unsubscribe_text'])) {
163
+ // Options of the subscription module (worng name, I know)
164
+ $options = get_option('newsletter');
165
+ $this->options['unsubscribe_text'] = $options['unsubscription_text'];
166
+
167
+ $this->options['reactivated_text'] = $options['reactivated_text'];
168
+
169
+ $this->options['unsubscribed_text'] = $options['unsubscribed_text'];
170
+ $this->options['unsubscribed_message'] = $options['unsubscribed_message'];
171
+ $this->options['unsubscribed_subject'] = $options['unsubscribed_subject'];
172
+
173
+ $this->save_options($this->options);
174
+ }
175
+ }
176
+
177
+ function admin_menu() {
178
+ $this->add_admin_page('index', 'Unsubscribe');
179
+ }
180
+
181
+ }
182
+
183
+ NewsletterUnsubscription::instance();
users/edit.php CHANGED
@@ -14,9 +14,9 @@ if ($controls->is_action('save')) {
14
  if (empty($email)) {
15
  $controls->errors = __('Wrong email address', 'newsletter');
16
  } else {
17
- $controls->data['email'] = $email;
18
  }
19
-
20
 
21
  if (empty($controls->errors)) {
22
  $u = $module->get_user($controls->data['email']);
@@ -32,7 +32,7 @@ if ($controls->is_action('save')) {
32
  $controls->data['list_' . $i] = 0;
33
  }
34
  }
35
-
36
  if (empty($controls->data['token'])) {
37
  $controls->data['token'] = $module->get_token();
38
  }
@@ -44,7 +44,7 @@ if ($controls->is_action('save')) {
44
  $controls->errors = __('Error. Check the log files.', 'newsletter');
45
  } else {
46
  $controls->add_message_saved();
47
- $controls->data = (array)$user;
48
  }
49
  }
50
  }
@@ -56,7 +56,7 @@ if ($controls->is_action('delete')) {
56
  }
57
 
58
  if (!$controls->is_action()) {
59
- $controls->data = (array)$user;
60
  }
61
 
62
  $options_profile = NewsletterSubscription::instance()->get_options('profile');
@@ -103,12 +103,12 @@ function percentValue($value, $total) {
103
  <div id="tabs">
104
 
105
  <ul>
106
- <li><a href="#tabs-general"><?php _e('General', 'newsletter')?></a></li>
107
- <li><a href="#tabs-preferences"><?php _e('Lists', 'newsletter')?></a></li>
108
- <li><a href="#tabs-profile"><?php _e('Extra fields', 'newsletter')?></a></li>
109
- <li><a href="#tabs-other"><?php _e('Other', 'newsletter')?></a></li>
110
- <li><a href="#tabs-newsletters"><?php _e('Newsletters', 'newsletter')?></a></li>
111
- <li><a href="#tabs-history"><?php _e('Logs', 'newsletter')?></a></li>
112
 
113
  </ul>
114
 
@@ -119,13 +119,13 @@ function percentValue($value, $total) {
119
  <table class="form-table">
120
 
121
  <tr>
122
- <th><?php _e ('Email', 'newsletter'); ?></th>
123
  <td>
124
  <?php $controls->text_email('email', 60); ?>
125
  </td>
126
  </tr>
127
  <tr>
128
- <th><?php _e ('First name', 'newsletter'); ?></th>
129
  <td>
130
  <?php $controls->text('name', 50); ?>
131
  </td>
@@ -137,19 +137,25 @@ function percentValue($value, $total) {
137
  </td>
138
  </tr>
139
  <tr>
140
- <th><?php _e ('Gender', 'newsletter'); ?></th>
141
  <td>
142
  <?php $controls->select('sex', array('n' => 'Not specified', 'f' => 'female', 'm' => 'male')); ?>
143
  </td>
144
  </tr>
145
  <tr>
146
- <th><?php _e ('Status', 'newsletter'); ?></th>
147
  <td>
148
  <?php $controls->select('status', array('C' => 'Confirmed', 'S' => 'Not confirmed', 'U' => 'Unsubscribed', 'B' => 'Bounced')); ?>
149
  </td>
150
  </tr>
151
  <tr>
152
- <th><?php _e ('Test subscriber', 'newsletter'); ?>
 
 
 
 
 
 
153
  <br><?php $controls->help('https://www.thenewsletterplugin.com/documentation/subscribers#test-subscribers') ?></th>
154
  <td>
155
  <?php $controls->yesno('test'); ?>
@@ -183,8 +189,8 @@ function percentValue($value, $total) {
183
  <thead>
184
  <tr>
185
  <th>#</th>
186
- <th><?php _e ('Name', 'newsletter'); ?></th>
187
- <th><?php _e ('Value', 'newsletter'); ?></th>
188
  </tr>
189
  </thead>
190
  <tbody>
@@ -231,21 +237,21 @@ function percentValue($value, $total) {
231
  </td>
232
  </tr>
233
  <tr>
234
- <th><?php _e ('IP address', 'newsletter'); ?></th>
235
  <td>
236
  <?php $controls->value('ip'); ?>
237
  </td>
238
  </tr>
239
  <tr>
240
- <th><?php _e ('Secret token', 'newsletter'); ?></th>
241
  <td>
242
  <?php $controls->text('token', 50); ?>
243
  </td>
244
  </tr>
245
  <tr>
246
- <th><?php _e ('Profile URL', 'newsletter'); ?></th>
247
  <td>
248
- <?php $profile_url = NewsletterProfile::instance()->get_profile_url($user) ?>
249
  <a href='<?php echo $profile_url ?>' target="_blank"><?php echo $profile_url ?></a>
250
  </td>
251
  </tr>
@@ -264,63 +270,64 @@ function percentValue($value, $total) {
264
  }
265
  ?>
266
  </div>
267
-
268
  <div id="tabs-history" class="tnp-tab">
269
  <?php
270
  $logs = $wpdb->get_results($wpdb->prepare("select * from {$wpdb->prefix}newsletter_user_logs where user_id=%d order by id desc", $id));
271
  ?>
272
  <?php if (empty($logs)) { ?>
273
- <p>No logs available</p>
274
  <?php } else { ?>
275
- <p>Only public lists are recorded.</p>
276
- <table class="widefat" style="width: auto">
277
- <thead>
278
- <tr>
279
- <th>Date</th>
280
- <th>Source</th>
281
- <th>IP</th>
282
- <th>Lists</th>
283
- </tr>
284
-
285
- <tbody>
286
- <?php foreach ($logs as $log) { ?>
287
- <?php
288
- $data = json_decode($log->data, ARRAY_A);
289
- if (isset($data['new'])) $data = $data['new'];
290
- ?>
291
- <tr>
292
- <td><?php echo $controls->print_date($log->created)?></td>
293
- <td><?php echo esc_html($log->source)?></td>
294
- <td><?php echo esc_html($log->ip)?></td>
295
- <td>
296
  <?php
297
- if (is_array($data)) {
298
- foreach ($data as $key=>$value) {
299
- echo esc_html(str_replace('_', ' ', $key)), ': ', esc_html($value) . '<br>';
300
- }
301
- }
302
  ?>
303
- </td>
304
- </tr>
305
- <?php } ?>
306
- </tbody>
307
-
308
- </table>
309
- <?php } ?>
310
-
311
-
 
 
 
 
 
 
 
 
 
 
 
 
312
  </div>
313
 
314
  </div>
315
 
316
  <p>
317
  <?php $controls->button_save(); ?>
318
- <?php $controls->button_delete(); ?>
319
  </p>
320
 
321
  </form>
322
  </div>
323
 
324
- <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
325
 
326
  </div>
14
  if (empty($email)) {
15
  $controls->errors = __('Wrong email address', 'newsletter');
16
  } else {
17
+ $controls->data['email'] = $email;
18
  }
19
+
20
 
21
  if (empty($controls->errors)) {
22
  $u = $module->get_user($controls->data['email']);
32
  $controls->data['list_' . $i] = 0;
33
  }
34
  }
35
+
36
  if (empty($controls->data['token'])) {
37
  $controls->data['token'] = $module->get_token();
38
  }
44
  $controls->errors = __('Error. Check the log files.', 'newsletter');
45
  } else {
46
  $controls->add_message_saved();
47
+ $controls->data = (array) $user;
48
  }
49
  }
50
  }
56
  }
57
 
58
  if (!$controls->is_action()) {
59
+ $controls->data = (array) $user;
60
  }
61
 
62
  $options_profile = NewsletterSubscription::instance()->get_options('profile');
103
  <div id="tabs">
104
 
105
  <ul>
106
+ <li><a href="#tabs-general"><?php _e('General', 'newsletter') ?></a></li>
107
+ <li><a href="#tabs-preferences"><?php _e('Lists', 'newsletter') ?></a></li>
108
+ <li><a href="#tabs-profile"><?php _e('Extra fields', 'newsletter') ?></a></li>
109
+ <li><a href="#tabs-other"><?php _e('Other', 'newsletter') ?></a></li>
110
+ <li><a href="#tabs-newsletters"><?php _e('Newsletters', 'newsletter') ?></a></li>
111
+ <li><a href="#tabs-history"><?php _e('Logs', 'newsletter') ?></a></li>
112
 
113
  </ul>
114
 
119
  <table class="form-table">
120
 
121
  <tr>
122
+ <th><?php _e('Email', 'newsletter'); ?></th>
123
  <td>
124
  <?php $controls->text_email('email', 60); ?>
125
  </td>
126
  </tr>
127
  <tr>
128
+ <th><?php _e('First name', 'newsletter'); ?></th>
129
  <td>
130
  <?php $controls->text('name', 50); ?>
131
  </td>
137
  </td>
138
  </tr>
139
  <tr>
140
+ <th><?php _e('Gender', 'newsletter'); ?></th>
141
  <td>
142
  <?php $controls->select('sex', array('n' => 'Not specified', 'f' => 'female', 'm' => 'male')); ?>
143
  </td>
144
  </tr>
145
  <tr>
146
+ <th><?php _e('Status', 'newsletter'); ?></th>
147
  <td>
148
  <?php $controls->select('status', array('C' => 'Confirmed', 'S' => 'Not confirmed', 'U' => 'Unsubscribed', 'B' => 'Bounced')); ?>
149
  </td>
150
  </tr>
151
  <tr>
152
+ <th><?php _e('Language', 'newsletter'); ?></th>
153
+ <td>
154
+ <?php $controls->language(); ?>
155
+ </td>
156
+ </tr>
157
+ <tr>
158
+ <th><?php _e('Test subscriber', 'newsletter'); ?>
159
  <br><?php $controls->help('https://www.thenewsletterplugin.com/documentation/subscribers#test-subscribers') ?></th>
160
  <td>
161
  <?php $controls->yesno('test'); ?>
189
  <thead>
190
  <tr>
191
  <th>#</th>
192
+ <th><?php _e('Name', 'newsletter'); ?></th>
193
+ <th><?php _e('Value', 'newsletter'); ?></th>
194
  </tr>
195
  </thead>
196
  <tbody>
237
  </td>
238
  </tr>
239
  <tr>
240
+ <th><?php _e('IP address', 'newsletter'); ?></th>
241
  <td>
242
  <?php $controls->value('ip'); ?>
243
  </td>
244
  </tr>
245
  <tr>
246
+ <th><?php _e('Secret token', 'newsletter'); ?></th>
247
  <td>
248
  <?php $controls->text('token', 50); ?>
249
  </td>
250
  </tr>
251
  <tr>
252
+ <th><?php _e('Profile URL', 'newsletter'); ?></th>
253
  <td>
254
+ <?php $profile_url = NewsletterProfile::instance()->get_profile_url($user) ?>
255
  <a href='<?php echo $profile_url ?>' target="_blank"><?php echo $profile_url ?></a>
256
  </td>
257
  </tr>
270
  }
271
  ?>
272
  </div>
273
+
274
  <div id="tabs-history" class="tnp-tab">
275
  <?php
276
  $logs = $wpdb->get_results($wpdb->prepare("select * from {$wpdb->prefix}newsletter_user_logs where user_id=%d order by id desc", $id));
277
  ?>
278
  <?php if (empty($logs)) { ?>
279
+ <p>No logs available</p>
280
  <?php } else { ?>
281
+ <p>Only public lists are recorded.</p>
282
+ <table class="widefat" style="width: auto">
283
+ <thead>
284
+ <tr>
285
+ <th>Date</th>
286
+ <th>Source</th>
287
+ <th>IP</th>
288
+ <th>Lists</th>
289
+ </tr>
290
+
291
+ <tbody>
292
+ <?php foreach ($logs as $log) { ?>
 
 
 
 
 
 
 
 
 
293
  <?php
294
+ $data = json_decode($log->data, ARRAY_A);
295
+ if (isset($data['new']))
296
+ $data = $data['new'];
 
 
297
  ?>
298
+ <tr>
299
+ <td><?php echo $controls->print_date($log->created) ?></td>
300
+ <td><?php echo esc_html($log->source) ?></td>
301
+ <td><?php echo esc_html($log->ip) ?></td>
302
+ <td>
303
+ <?php
304
+ if (is_array($data)) {
305
+ foreach ($data as $key => $value) {
306
+ echo esc_html(str_replace('_', ' ', $key)), ': ', esc_html($value) . '<br>';
307
+ }
308
+ }
309
+ ?>
310
+ </td>
311
+ </tr>
312
+ <?php } ?>
313
+ </tbody>
314
+
315
+ </table>
316
+ <?php } ?>
317
+
318
+
319
  </div>
320
 
321
  </div>
322
 
323
  <p>
324
  <?php $controls->button_save(); ?>
325
+ <?php $controls->button_delete(); ?>
326
  </p>
327
 
328
  </form>
329
  </div>
330
 
331
+ <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
332
 
333
  </div>
users/index.php CHANGED
@@ -25,17 +25,15 @@ if ($controls->is_action()) {
25
  }
26
 
27
  if ($controls->is_action('resend')) {
28
- $user = NewsletterUsers::instance()->get_user($controls->button_data);
29
- $opts = get_option('newsletter');
30
- NewsletterSubscription::instance()->mail($user->email, $module->replace($opts['confirmation_subject'], $user), $module->replace($opts['confirmation_message'], $user));
31
- $controls->messages = 'Activation email resent to ' . $user->email;
32
  }
33
 
34
  if ($controls->is_action('resend_welcome')) {
35
- $user = NewsletterUsers::instance()->get_user($controls->button_data);
36
- $opts = get_option('newsletter');
37
- NewsletterSubscription::instance()->mail($user->email, $module->replace($opts['confirmed_subject'], $user), $module->replace($opts['confirmed_message'], $user));
38
- $controls->messages = 'Welcome email resent.';
39
  }
40
 
41
  if ($controls->is_action('remove')) {
25
  }
26
 
27
  if ($controls->is_action('resend')) {
28
+ $user = $module->get_user($controls->button_data);
29
+ NewsletterSubscription::instance()->send_message('confirmation', $user, true);
30
+ $controls->messages = __('Activation email sent.', 'newsletter');
 
31
  }
32
 
33
  if ($controls->is_action('resend_welcome')) {
34
+ $user = $module->get_user($controls->button_data);
35
+ NewsletterSubscription::instance()->send_message('confirmed', $user, true);
36
+ $controls->messages = __('Welcome email sent.', 'newsletter');
 
37
  }
38
 
39
  if ($controls->is_action('remove')) {
users/users.php CHANGED
@@ -19,7 +19,7 @@ class NewsletterUsers extends NewsletterModule {
19
  }
20
 
21
  function __construct() {
22
- parent::__construct('users', '1.2.3');
23
  add_action('init', array($this, 'hook_init'));
24
  }
25
 
@@ -53,6 +53,7 @@ class NewsletterUsers extends NewsletterModule {
53
  `name` varchar(100) NOT NULL DEFAULT '',
54
  `email` varchar(100) NOT NULL DEFAULT '',
55
  `token` varchar(50) NOT NULL DEFAULT '',
 
56
  `status` varchar(1) NOT NULL DEFAULT 'S',
57
  `id` int(11) NOT NULL AUTO_INCREMENT,
58
  `profile` mediumtext,
19
  }
20
 
21
  function __construct() {
22
+ parent::__construct('users', '1.2.4');
23
  add_action('init', array($this, 'hook_init'));
24
  }
25
 
53
  `name` varchar(100) NOT NULL DEFAULT '',
54
  `email` varchar(100) NOT NULL DEFAULT '',
55
  `token` varchar(50) NOT NULL DEFAULT '',
56
+ `language` varchar(10) NOT NULL DEFAULT '',
57
  `status` varchar(1) NOT NULL DEFAULT 'S',
58
  `id` int(11) NOT NULL AUTO_INCREMENT,
59
  `profile` mediumtext,
widget/minimal.php CHANGED
@@ -14,6 +14,7 @@ class NewsletterWidgetMinimal extends WP_Widget {
14
  function widget($args, $instance) {
15
 
16
  $newsletter = Newsletter::instance();
 
17
 
18
  extract($args);
19
 
@@ -32,7 +33,7 @@ class NewsletterWidgetMinimal extends WP_Widget {
32
  $instance['button'] = 'Subscribe';
33
  }
34
 
35
- $options_profile = get_option('newsletter_profile');
36
 
37
 
38
  $form = '<div class="tnp tnp-widget-minimal">';
@@ -63,9 +64,10 @@ class NewsletterWidgetMinimal extends WP_Widget {
63
  if (!is_array($instance)) {
64
  $instance = array();
65
  }
66
- $profile_options = NewsletterSubscription::instance()->get_options('profile');
 
 
67
  $instance = array_merge(array('title' => '', 'text' => '', 'button' => $profile_options['subscribe'], 'nl' => array()), $instance);
68
- $options_profile = get_option('newsletter_profile');
69
  if (!is_array($instance['nl'])) {
70
  $instance['nl'] = array();
71
  }
14
  function widget($args, $instance) {
15
 
16
  $newsletter = Newsletter::instance();
17
+ $current_language = $newsletter->get_current_language();
18
 
19
  extract($args);
20
 
33
  $instance['button'] = 'Subscribe';
34
  }
35
 
36
+ $options_profile = NewsletterSubscription::instance()->get_options('profile', $current_language);
37
 
38
 
39
  $form = '<div class="tnp tnp-widget-minimal">';
64
  if (!is_array($instance)) {
65
  $instance = array();
66
  }
67
+ $newsletter = Newsletter::instance();
68
+ $current_language = $newsletter->get_current_language();
69
+ $profile_options = NewsletterSubscription::instance()->get_options('profile', $current_language);
70
  $instance = array_merge(array('title' => '', 'text' => '', 'button' => $profile_options['subscribe'], 'nl' => array()), $instance);
 
71
  if (!is_array($instance['nl'])) {
72
  $instance['nl'] = array();
73
  }