Newsletter - Version 5.6.8

Version Description

Download this release

Release Info

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

Code changes from version 5.6.7 to 5.6.8

emails/blocks/cta/block.php CHANGED
@@ -15,7 +15,8 @@ $default_options = array(
15
  'url' => home_url(),
16
  'font_family' => $font_family,
17
  'font_size' => 16,
18
- 'block_background'=>'#ffffff'
 
19
  );
20
 
21
  $options = array_merge($default_options, $options);
@@ -23,7 +24,7 @@ $options['block_padding_top'] = '15px';
23
  $options['block_padding_bottom'] = '15px';
24
  ?>
25
 
26
- <a href="<?php echo $options['url'] ?>" target="_blank" rel="noopener" style="line-height: normal; font-size: <?php echo $options['font_size'] ?>px; font-family: <?php echo $options['font_family'] ?>; font-weight: normal; color: <?php echo $options['color'] ?>; text-decoration: none; background-color: <?php echo $options['background'] ?>; border-top: 15px solid <?php echo $options['background'] ?>; border-bottom: 15px solid <?php echo $options['background'] ?>; border-left: 25px solid <?php echo $options['background'] ?>; border-right: 25px solid <?php echo $options['background'] ?>; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;"><?php echo $options['text'] ?></a>
27
 
28
  <div itemscope="" itemtype="http://schema.org/EmailMessage">
29
  <div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
15
  'url' => home_url(),
16
  'font_family' => $font_family,
17
  'font_size' => 16,
18
+ 'block_background'=>'#ffffff',
19
+ 'width'=>'200'
20
  );
21
 
22
  $options = array_merge($default_options, $options);
24
  $options['block_padding_bottom'] = '15px';
25
  ?>
26
 
27
+ <a href="<?php echo $options['url'] ?>" target="_blank" rel="noopener" style="line-height: normal; font-size: <?php echo $options['font_size'] ?>px; font-family: <?php echo $options['font_family'] ?>; font-weight: normal; color: <?php echo $options['color'] ?>; text-decoration: none; background-color: <?php echo $options['background'] ?>; border-top: 15px solid <?php echo $options['background'] ?>; border-bottom: 15px solid <?php echo $options['background'] ?>; border-left: 25px solid <?php echo $options['background'] ?>; border-right: 25px solid <?php echo $options['background'] ?>; width: <?php echo $options['width'] ?>px; max-width: 100%; box-sizing: border-box; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;"><?php echo $options['text'] ?></a>
28
 
29
  <div itemscope="" itemtype="http://schema.org/EmailMessage">
30
  <div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
emails/blocks/cta/options.php CHANGED
@@ -42,6 +42,13 @@
42
  <?php $controls->css_font_family('font_family') ?>
43
  </td>
44
  </tr>
 
 
 
 
 
 
 
45
 
46
  <tr>
47
  <th><?php _e('Background', 'newsletter') ?></th>
42
  <?php $controls->css_font_family('font_family') ?>
43
  </td>
44
  </tr>
45
+
46
+ <tr>
47
+ <th>Width</th>
48
+ <td>
49
+ <?php $controls->text('width') ?>px
50
+ </td>
51
+ </tr>
52
 
53
  <tr>
54
  <th><?php _e('Background', 'newsletter') ?></th>
emails/blocks/giphy/block.php CHANGED
@@ -16,8 +16,8 @@ $default_options = array(
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
  );
16
  'font_family'=>$font_family,
17
  'font_size'=>13,
18
  'color'=>'#999999',
19
+ 'block_padding_top'=>'15px',
20
+ 'block_padding_bottom'=>'15px',
21
  'block_padding_left'=>0,
22
  'block_padding_right'=>0
23
  );
emails/blocks/separator/block.php CHANGED
@@ -11,7 +11,10 @@
11
 
12
  $default_options = array(
13
  'color'=>'#dddddd',
14
- 'height'=>1
 
 
 
15
  );
16
 
17
  $options = array_merge($default_options, $options);
@@ -21,8 +24,6 @@ $options = array_merge($default_options, $options);
21
 
22
  <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%">
23
  <tr>
24
- <td style="padding: 20px;">
25
- <div style="height: <?php echo $options['height'] ?>px!important; background-color: <?php echo $options['color'] ?>; border: 0; margin:0; padding: 0; line-height: 0; width: 100%!important; display: block;"></div>
26
- </td>
27
  </tr>
28
  </table>
11
 
12
  $default_options = array(
13
  'color'=>'#dddddd',
14
+ 'height'=>1,
15
+ 'block_padding_top'=>'20px',
16
+ 'block_padding_bottom'=>'20px'
17
+
18
  );
19
 
20
  $options = array_merge($default_options, $options);
24
 
25
  <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%">
26
  <tr>
27
+ <td style="border-bottom: <?php echo $options['height'] ?>px solid <?php echo $options['color'] ?>;"></td>
 
 
28
  </tr>
29
  </table>
emails/emails.php CHANGED
@@ -111,10 +111,10 @@ class NewsletterEmails extends NewsletterModule {
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) {
111
  $options['block_background'] = '';
112
  }
113
  $style = '';
114
+ if (isset($options['block_padding_top'])) $style .= 'padding-top: ' . $options['block_padding_top'] . '; ';
115
+ if (isset($options['block_padding_left'])) $style .= 'padding-left: ' . $options['block_padding_left'] . '; ';
116
+ if (isset($options['block_padding_right'])) $style .= 'padding-right: ' . $options['block_padding_right'] . '; ';
117
+ if (isset($options['block_padding_bottom'])) $style .= 'padding-bottom: ' . $options['block_padding_bottom'] . '; ';
118
 
119
  // Old block type
120
  if ($is_old_block) {
emails/tnp-composer/css/newsletter.css CHANGED
@@ -8,7 +8,7 @@ img{-ms-interpolation-mode:bicubic;} /* Allow smoother rendering of resized imag
8
 
9
  /* RESET STYLES */
10
  body{margin:0; padding:0; height:100% !important; margin:0; padding:0; width:100% !important;}
11
- img{border:0; height:auto; line-height:100%; outline:none; text-decoration:none;}
12
  table{border-collapse:collapse !important;}
13
 
14
 
8
 
9
  /* RESET STYLES */
10
  body{margin:0; padding:0; height:100% !important; margin:0; padding:0; width:100% !important;}
11
+ img{border:0; height:auto; line-height:100%; outline:none; text-decoration:none; max-width: 100%!important}
12
  table{border-collapse:collapse !important;}
13
 
14
 
includes/controls.php CHANGED
@@ -1420,7 +1420,7 @@ class NewsletterControls {
1420
  * @param string $name
1421
  */
1422
  function media($name) {
1423
- if (isset($this->data[$name])) {
1424
  $media_id = (int) $this->data[$name]['id'];
1425
  $media = wp_get_attachment_image_src($media_id, 'medium');
1426
  $media_full = wp_get_attachment_image_src($media_id, 'full');
1420
  * @param string $name
1421
  */
1422
  function media($name) {
1423
+ if (isset($this->data[$name]['id'])) {
1424
  $media_id = (int) $this->data[$name]['id'];
1425
  $media = wp_get_attachment_image_src($media_id, 'medium');
1426
  $media_full = wp_get_attachment_image_src($media_id, 'full');
includes/module.php CHANGED
@@ -1439,8 +1439,7 @@ class NewsletterModule {
1439
 
1440
  if ($user) {
1441
  $nk = $this->get_user_key($user);
1442
- $options_profile = get_option('newsletter_profile');
1443
-
1444
  $text = str_replace('{email}', $user->email, $text);
1445
  $name = apply_filters('newsletter_replace_name', $user->name, $user);
1446
  if (empty($name)) {
@@ -1490,10 +1489,6 @@ class NewsletterModule {
1490
  $id_token = '&amp;ni=' . $user->id . '&amp;nt=' . $user->token;
1491
 
1492
 
1493
- $options_subscription = NewsletterSubscription::instance()->options;
1494
-
1495
-
1496
-
1497
  $nek = false;
1498
  if ($email) {
1499
  $nek = $email->id . '-' . $email->token;
@@ -1503,18 +1498,12 @@ class NewsletterModule {
1503
  $text = $this->replace_url($text, 'EMAIL_URL', $this->build_action_url('v', $user) . '&id=' . $email->id);
1504
  }
1505
 
1506
-
1507
- //$text = str_replace('{activation_link}', '<a href="{activation_url}">' . $options_subscription['confirmation_label'] . '</a>', $text);
1508
-
1509
-
1510
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $this->build_action_url('c', $user));
1511
  $text = $this->replace_url($text, 'ACTIVATION_URL', $this->build_action_url('v', $user));
1512
 
1513
  // Obsolete.
1514
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
1515
  $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
1516
- $text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
1517
- $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
1518
 
1519
  $text = $this->replace_url($text, 'UNLOCK_URL', $this->build_action_url('ul', $user));
1520
  } else {
1439
 
1440
  if ($user) {
1441
  $nk = $this->get_user_key($user);
1442
+ $options_profile = NewsletterSubscription::instance()->get_options('profile', $this->get_user_language($user));
 
1443
  $text = str_replace('{email}', $user->email, $text);
1444
  $name = apply_filters('newsletter_replace_name', $user->name, $user);
1445
  if (empty($name)) {
1489
  $id_token = '&amp;ni=' . $user->id . '&amp;nt=' . $user->token;
1490
 
1491
 
 
 
 
 
1492
  $nek = false;
1493
  if ($email) {
1494
  $nek = $email->id . '-' . $email->token;
1498
  $text = $this->replace_url($text, 'EMAIL_URL', $this->build_action_url('v', $user) . '&id=' . $email->id);
1499
  }
1500
 
 
 
 
 
1501
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $this->build_action_url('c', $user));
1502
  $text = $this->replace_url($text, 'ACTIVATION_URL', $this->build_action_url('v', $user));
1503
 
1504
  // Obsolete.
1505
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
1506
  $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
 
 
1507
 
1508
  $text = $this->replace_url($text, 'UNLOCK_URL', $this->build_action_url('ul', $user));
1509
  } else {
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.6.7
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.6.7');
18
 
19
  global $newsletter, $wpdb;
20
 
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.6.8
8
  Author: Stefano Lissa & The Newsletter Team
9
  Author URI: https://www.thenewsletterplugin.com
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
14
  */
15
 
16
  // Used as dummy parameter on css and js links
17
+ define('NEWSLETTER_VERSION', '5.6.8');
18
 
19
  global $newsletter, $wpdb;
20
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated,mailing list
3
  Requires at least: 3.4.0
4
  Tested up to: 4.9.8
5
- Stable tag: 5.6.7
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -108,6 +108,10 @@ Thank you, The Newsletter Team
108
 
109
  == Changelog ==
110
 
 
 
 
 
111
  = 5.6.7 =
112
 
113
  * Fixed multilanguage support for service messages template
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated,mailing list
3
  Requires at least: 3.4.0
4
  Tested up to: 4.9.8
5
+ Stable tag: 5.6.8
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
108
 
109
  == Changelog ==
110
 
111
+ = next =
112
+
113
+ * Removed debug notices
114
+
115
  = 5.6.7 =
116
 
117
  * Fixed multilanguage support for service messages template
subscription/subscription.php CHANGED
@@ -1305,6 +1305,8 @@ class NewsletterSubscription extends NewsletterModule {
1305
  function get_privacy_field() {
1306
  $options_profile = $this->get_options('profile', $this->get_current_language());
1307
  $privacy_status = (int) $options_profile['privacy_status'];
 
 
1308
  $buffer = '<label>';
1309
  if ($privacy_status === 1) {
1310
  $buffer .= '<input type="checkbox" name="ny" required class="tnp-privacy">&nbsp;';
@@ -1564,14 +1566,13 @@ class NewsletterSubscription extends NewsletterModule {
1564
  * @return string
1565
  */
1566
  function replace_lists($buffer) {
1567
- $lists = '';
1568
- for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
1569
- if ($this->options_profile['list_' . $i . '_status'] != 2)
1570
- continue;
1571
- $lists .= '<input type="checkbox" name="nl[]" value="' . $i . '"/>&nbsp;' . $this->options_profile['list_' . $i] . '<br />';
1572
  }
1573
- $buffer = str_replace('{lists}', $lists, $buffer);
1574
- $buffer = str_replace('{preferences}', $lists, $buffer);
1575
  return $buffer;
1576
  }
1577
 
@@ -1636,9 +1637,12 @@ class NewsletterSubscription extends NewsletterModule {
1636
  $form .= '<input type="hidden" name="nlang" value="' . esc_attr($language) . '">' . "\n";
1637
  $form .= '<input class="tnp-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
1638
  $form .= '<input class="tnp-submit" type="submit" value="' . esc_attr($attrs['button']) . '">';
1639
- if (!empty($this->options_profile['privacy_status'])) {
1640
- $form .= '<div class="tnp-privacy-field">' . $this->get_privacy_field() . '</div>';
 
 
1641
  }
 
1642
  $form .= "</form></div>\n";
1643
 
1644
  return $form;
1305
  function get_privacy_field() {
1306
  $options_profile = $this->get_options('profile', $this->get_current_language());
1307
  $privacy_status = (int) $options_profile['privacy_status'];
1308
+ if (empty($privacy_status)) return false;
1309
+
1310
  $buffer = '<label>';
1311
  if ($privacy_status === 1) {
1312
  $buffer .= '<input type="checkbox" name="ny" required class="tnp-privacy">&nbsp;';
1566
  * @return string
1567
  */
1568
  function replace_lists($buffer) {
1569
+ $checkboxes = '';
1570
+ $lists = $this->get_lists_for_subscription($this->get_current_language());
1571
+ foreach ($lists as $list) {
1572
+ $checkboxes .= '<input type="checkbox" name="nl[]" value="' . $list->id . '"/>&nbsp;' . $list->name . '<br />';
 
1573
  }
1574
+ $buffer = str_replace('{lists}', $checkboxes, $buffer);
1575
+ $buffer = str_replace('{preferences}', $checkboxes, $buffer);
1576
  return $buffer;
1577
  }
1578
 
1637
  $form .= '<input type="hidden" name="nlang" value="' . esc_attr($language) . '">' . "\n";
1638
  $form .= '<input class="tnp-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
1639
  $form .= '<input class="tnp-submit" type="submit" value="' . esc_attr($attrs['button']) . '">';
1640
+
1641
+ $privacy_field = $this->get_privacy_field();
1642
+ if (!empty($privacy_field)) {
1643
+ $form .= '<div class="tnp-privacy-field">' . $privacy_field . '</div>';
1644
  }
1645
+
1646
  $form .= "</form></div>\n";
1647
 
1648
  return $form;
users/import.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
- if (!defined('ABSPATH')) exit;
 
3
 
4
  require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
5
  $controls = new NewsletterControls();
@@ -15,7 +16,7 @@ if ($controls->is_action('import')) {
15
  @set_time_limit(0);
16
 
17
  $results = '';
18
-
19
  if (is_uploaded_file($_FILES['csv_file']['tmp_name'])) {
20
  $lines = file($_FILES['csv_file']['tmp_name']);
21
  } else {
@@ -35,7 +36,7 @@ if ($controls->is_action('import')) {
35
  $added_count = 0;
36
  $updated_count = 0;
37
  $skipped_count = 0;
38
-
39
  foreach ($lines as &$line) {
40
  // Parse the CSV line
41
  $line = trim($line);
@@ -56,7 +57,7 @@ if ($controls->is_action('import')) {
56
  if (empty($email)) {
57
  continue;
58
  }
59
-
60
  if (!$newsletter->is_email($email)) {
61
  $results .= '[INVALID EMAIL] ' . $line . "\n";
62
  $error_count++;
@@ -91,8 +92,12 @@ if ($controls->is_action('import')) {
91
  }
92
 
93
  if ($mode == 'overwrite') {
94
- $subscriber['name'] = $module->normalize_name($data[1]);
95
- $subscriber['surname'] = $module->normalize_name($data[2]);
 
 
 
 
96
  if (isset($data[3])) {
97
  $subscriber['sex'] = $module->normalize_sex($data[3]);
98
  }
@@ -138,134 +143,134 @@ if ($controls->is_action('import')) {
138
  ?>
139
 
140
  <div class="wrap" id="tnp-wrap">
141
-
142
- <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
143
 
144
  <div id="tnp-heading">
145
-
146
  <h2><?php _e('Import', 'newsletter') ?></h2>
147
  <p>
148
  The import and export functions <strong>ARE NOT for backup</strong>. If you want to backup you should consider to backup the
149
  wp_newsletter* tables. Please, read on bottom of this page the data format to use and other important notes.</p>
150
-
151
  </div>
152
-
153
  <div id="tnp-body" class="tnp-users tnp-users-import">
154
 
155
- <?php if (!empty($results)) { ?>
156
 
157
- <h3>Results</h3>
158
 
159
- <textarea wrap="off" style="width: 100%; height: 150px; font-size: 11px; font-family: monospace"><?php echo esc_html($results) ?></textarea>
160
 
161
- <?php } ?>
162
 
163
  <form method="post" enctype="multipart/form-data">
164
 
165
- <?php $controls->init(); ?>
166
-
167
- <table class="form-table">
168
-
169
- <tr>
170
- <th><?php _e('Import Subscribers As', 'newsletter') ?></th>
171
- <td>
172
- <?php $controls->select('import_as', array('C' => __('Confirmed', 'newsletter'), 'S' => __('Not confirmed', 'newsletter'))); ?>
173
- <br>
174
- <?php $controls->checkbox('override_status', __('Override status of existing users', 'newsletter')) ?>
175
- </td>
176
- </tr>
177
-
178
- <tr>
179
- <th><?php _e('Import mode', 'newsletter') ?></th>
180
- <td>
181
- <?php $controls->select('mode', array('update' => 'Update', 'overwrite' => 'Overwrite', 'skip' => 'Skip')); ?>
182
- if email is already present
183
- <p class="description">
184
- <strong>Update</strong>: <?php _e('user data will be updated, existing preferences will be left untouched and new ones will be added.', 'newsletter') ?><br />
185
- <strong>Overwrite</strong>: <?php _e('user data will be overwritten with new informations (like name and preferences).', 'newsletter') ?><br />
186
- <strong>Skip</strong>: <?php _e('user data will be left untouched if already present.', 'newsletter') ?>
187
- </p>
188
- </td>
189
- </tr>
190
-
191
- <tr>
192
- <th><?php _e('Lists', 'newsletter') ?></th>
193
- <td>
194
- <?php $controls->preferences_group('preferences', true); ?>
195
- <div class="hints">
196
- Every new imported or updated subscriber will be associate with selected preferences above.
197
- </div>
198
- </td>
199
- </tr>
200
-
201
- <tr>
202
- <th><?php _e('Field separator', 'newsletter') ?></th>
203
- <td>
204
- <?php $controls->select('separator', array(';' => 'Semicolon', ',' => 'Comma', 'tab' => 'Tabulation')); ?>
205
- </td>
206
- </tr>
207
-
208
- <tr>
209
- <th>
210
- <?php _e('CSV file', 'newsletter') ?>
211
- <div class="tnp-tip">
212
- <span class="tip-button">Tip</span>
213
- <span class="tip-content">
214
- Upload a CSV file, see format description <a href="#import_format">here</a>.
215
- </span>
216
- </div>
217
- </th>
218
- <td>
219
- <input type="file" name="csv_file" />
220
- </td>
221
- </tr>
222
- <tr>
223
- <th>CSV text
224
- <div class="tnp-tip">
225
- <span class="tip-button">Tip</span>
226
- <span class="tip-content">
227
- Simply paste CVS text here.
228
- </span>
229
- </div>
230
- </th>
231
- <td>
232
- <textarea name="options[csv]" wrap="off" style="width: 100%; height: 200px; font-size: 11px; font-family: monospace"><?php echo $controls->data['csv']; ?></textarea>
233
- </td>
234
- </tr>
235
- <tr>
236
- <th>&nbsp;</th><td><?php $controls->button('import', 'Import'); ?></td>
237
- </tr>
238
- <tr>
239
- <th>
240
- <a name="import_format"></a>
241
- Data format<br>and other notes
242
- <div class="tnp-tip">
243
- <span class="tip-button">Tip</span>
244
- <span class="tip-content">Consider to split up your input list if you get errors, blank pages or partially imported lists: it can be a time/resource limit
245
- of your provider. It's safe to import the same list a second time, no duplications will occur.</span>
246
- </th>
247
- <td>
248
- <p>
249
- Import list format is:
250
- <p><strong>email</strong><i>[separator]</i><strong>first name</strong><i>[separator]</i><strong>last name</strong><i>[separator]</i><strong>gender</strong><i>[new line]</i></p>
251
- Example:
252
- <p style="border: 1px solid #bfbfbf">
253
- email1@example.com;first name 1;last name 1;m<br />
254
- email2@example.com;first name 2;last name 2;f
255
- </p>
256
- <p>
257
- where [separator] must be selected from the available ones. Empty lines and lines starting with "#" will be skipped. There is
258
- no separator escaping mechanism, so be sure that field values do not contain the selected separator. The only required field is the email
259
- all other fields are options. Gender must be "m" or "f".
260
- </p>
261
- </td>
262
- </tr>
263
- </table>
264
-
265
- </form>
266
 
267
- </div>
268
-
269
- <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
270
 
271
  </div>
1
  <?php
2
+ if (!defined('ABSPATH'))
3
+ exit;
4
 
5
  require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
  $controls = new NewsletterControls();
16
  @set_time_limit(0);
17
 
18
  $results = '';
19
+
20
  if (is_uploaded_file($_FILES['csv_file']['tmp_name'])) {
21
  $lines = file($_FILES['csv_file']['tmp_name']);
22
  } else {
36
  $added_count = 0;
37
  $updated_count = 0;
38
  $skipped_count = 0;
39
+
40
  foreach ($lines as &$line) {
41
  // Parse the CSV line
42
  $line = trim($line);
57
  if (empty($email)) {
58
  continue;
59
  }
60
+
61
  if (!$newsletter->is_email($email)) {
62
  $results .= '[INVALID EMAIL] ' . $line . "\n";
63
  $error_count++;
92
  }
93
 
94
  if ($mode == 'overwrite') {
95
+ if (isset($data[1])) {
96
+ $subscriber['name'] = $module->normalize_name($data[1]);
97
+ }
98
+ if (isset($data[2])) {
99
+ $subscriber['surname'] = $module->normalize_name($data[2]);
100
+ }
101
  if (isset($data[3])) {
102
  $subscriber['sex'] = $module->normalize_sex($data[3]);
103
  }
143
  ?>
144
 
145
  <div class="wrap" id="tnp-wrap">
146
+
147
+ <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
148
 
149
  <div id="tnp-heading">
150
+
151
  <h2><?php _e('Import', 'newsletter') ?></h2>
152
  <p>
153
  The import and export functions <strong>ARE NOT for backup</strong>. If you want to backup you should consider to backup the
154
  wp_newsletter* tables. Please, read on bottom of this page the data format to use and other important notes.</p>
155
+
156
  </div>
157
+
158
  <div id="tnp-body" class="tnp-users tnp-users-import">
159
 
160
+ <?php if (!empty($results)) { ?>
161
 
162
+ <h3>Results</h3>
163
 
164
+ <textarea wrap="off" style="width: 100%; height: 150px; font-size: 11px; font-family: monospace"><?php echo esc_html($results) ?></textarea>
165
 
166
+ <?php } ?>
167
 
168
  <form method="post" enctype="multipart/form-data">
169
 
170
+ <?php $controls->init(); ?>
171
+
172
+ <table class="form-table">
173
+
174
+ <tr>
175
+ <th><?php _e('Import Subscribers As', 'newsletter') ?></th>
176
+ <td>
177
+ <?php $controls->select('import_as', array('C' => __('Confirmed', 'newsletter'), 'S' => __('Not confirmed', 'newsletter'))); ?>
178
+ <br>
179
+ <?php $controls->checkbox('override_status', __('Override status of existing users', 'newsletter')) ?>
180
+ </td>
181
+ </tr>
182
+
183
+ <tr>
184
+ <th><?php _e('Import mode', 'newsletter') ?></th>
185
+ <td>
186
+ <?php $controls->select('mode', array('update' => 'Update', 'overwrite' => 'Overwrite', 'skip' => 'Skip')); ?>
187
+ if email is already present
188
+ <p class="description">
189
+ <strong>Update</strong>: <?php _e('user data will be updated, existing preferences will be left untouched and new ones will be added.', 'newsletter') ?><br />
190
+ <strong>Overwrite</strong>: <?php _e('user data will be overwritten with new informations (like name and preferences).', 'newsletter') ?><br />
191
+ <strong>Skip</strong>: <?php _e('user data will be left untouched if already present.', 'newsletter') ?>
192
+ </p>
193
+ </td>
194
+ </tr>
195
+
196
+ <tr>
197
+ <th><?php _e('Lists', 'newsletter') ?></th>
198
+ <td>
199
+ <?php $controls->preferences_group('preferences', true); ?>
200
+ <div class="hints">
201
+ Every new imported or updated subscriber will be associate with selected preferences above.
202
+ </div>
203
+ </td>
204
+ </tr>
205
+
206
+ <tr>
207
+ <th><?php _e('Field separator', 'newsletter') ?></th>
208
+ <td>
209
+ <?php $controls->select('separator', array(';' => 'Semicolon', ',' => 'Comma', 'tab' => 'Tabulation')); ?>
210
+ </td>
211
+ </tr>
212
+
213
+ <tr>
214
+ <th>
215
+ <?php _e('CSV file', 'newsletter') ?>
216
+ <div class="tnp-tip">
217
+ <span class="tip-button">Tip</span>
218
+ <span class="tip-content">
219
+ Upload a CSV file, see format description <a href="#import_format">here</a>.
220
+ </span>
221
+ </div>
222
+ </th>
223
+ <td>
224
+ <input type="file" name="csv_file" />
225
+ </td>
226
+ </tr>
227
+ <tr>
228
+ <th>CSV text
229
+ <div class="tnp-tip">
230
+ <span class="tip-button">Tip</span>
231
+ <span class="tip-content">
232
+ Simply paste CVS text here.
233
+ </span>
234
+ </div>
235
+ </th>
236
+ <td>
237
+ <textarea name="options[csv]" wrap="off" style="width: 100%; height: 200px; font-size: 11px; font-family: monospace"><?php echo $controls->data['csv']; ?></textarea>
238
+ </td>
239
+ </tr>
240
+ <tr>
241
+ <th>&nbsp;</th><td><?php $controls->button('import', 'Import'); ?></td>
242
+ </tr>
243
+ <tr>
244
+ <th>
245
+ <a name="import_format"></a>
246
+ Data format<br>and other notes
247
+ <div class="tnp-tip">
248
+ <span class="tip-button">Tip</span>
249
+ <span class="tip-content">Consider to split up your input list if you get errors, blank pages or partially imported lists: it can be a time/resource limit
250
+ of your provider. It's safe to import the same list a second time, no duplications will occur.</span>
251
+ </th>
252
+ <td>
253
+ <p>
254
+ Import list format is:
255
+ <p><strong>email</strong><i>[separator]</i><strong>first name</strong><i>[separator]</i><strong>last name</strong><i>[separator]</i><strong>gender</strong><i>[new line]</i></p>
256
+ Example:
257
+ <p style="border: 1px solid #bfbfbf">
258
+ email1@example.com;first name 1;last name 1;m<br />
259
+ email2@example.com;first name 2;last name 2;f
260
+ </p>
261
+ <p>
262
+ where [separator] must be selected from the available ones. Empty lines and lines starting with "#" will be skipped. There is
263
+ no separator escaping mechanism, so be sure that field values do not contain the selected separator. The only required field is the email
264
+ all other fields are options. Gender must be "m" or "f".
265
+ </p>
266
+ </td>
267
+ </tr>
268
+ </table>
269
+
270
+ </form>
271
 
272
+ </div>
273
+
274
+ <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
275
 
276
  </div>