Newsletter - Version 7.3.3

Version Description

  • Added "complained" status to subscriber filters
  • Fixed some links bringing to a "not allowed" page
  • Fixed a notice on delivery diagnostic page
  • Fixed logo width notice on header block
Download this release

Release Info

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

Code changes from version 7.3.2 to 7.3.3

Files changed (7) hide show
  1. emails/blocks/header/block.php +50 -49
  2. includes/mailer.php +469 -475
  3. plugin.php +2 -2
  4. readme.txt +8 -1
  5. system/delivery.php +199 -199
  6. tnp-header.php +335 -324
  7. users/index.php +251 -251
emails/blocks/header/block.php CHANGED
@@ -1,49 +1,50 @@
1
- <?php
2
-
3
- /*
4
- * Name: Header
5
- * Section: header
6
- * Description: Default header with company info
7
- */
8
-
9
- $default_options = array(
10
- 'font_family' => '',
11
- 'font_size' => '',
12
- 'font_color' => '',
13
- 'font_weight' => '',
14
- 'logo_height' => 100,
15
- 'block_padding_top' => 15,
16
- 'block_padding_bottom' => 15,
17
- 'block_padding_left' => 15,
18
- 'block_padding_right' => 15,
19
- 'block_background' => '',
20
- 'layout' => ''
21
- );
22
- $options = array_merge($default_options, $options);
23
-
24
- if (empty($info['header_logo']['id'])) {
25
- $media = false;
26
- } else {
27
- $media = tnp_get_media($info['header_logo']['id'], 'large');
28
- if ($media) {
29
- $media->alt = $info['header_title'];
30
- $media->link = home_url();
31
- }
32
- }
33
-
34
- $empty = !$media && empty($info['header_sub']) && empty($info['header_title']);
35
-
36
- if ($empty) {
37
- echo '<p>Please, set your company info.</p>';
38
- } elseif ($options['layout'] === 'logo') {
39
- include __DIR__ . '/layout-logo.php';
40
- return;
41
- } elseif ($options['layout'] === 'titlemotto') {
42
- include __DIR__ . '/layout-titlemotto.php';
43
- return;
44
- } else {
45
- include __DIR__ . '/layout-default.php';
46
- return;
47
- }
48
- ?>
49
-
 
1
+ <?php
2
+
3
+ /*
4
+ * Name: Header
5
+ * Section: header
6
+ * Description: Default header with company info
7
+ */
8
+
9
+ $default_options = array(
10
+ 'font_family' => '',
11
+ 'font_size' => '',
12
+ 'font_color' => '',
13
+ 'font_weight' => '',
14
+ 'logo_height' => 100,
15
+ 'logo_width' => '',
16
+ 'block_padding_top' => 15,
17
+ 'block_padding_bottom' => 15,
18
+ 'block_padding_left' => 15,
19
+ 'block_padding_right' => 15,
20
+ 'block_background' => '',
21
+ 'layout' => ''
22
+ );
23
+ $options = array_merge($default_options, $options);
24
+
25
+ if (empty($info['header_logo']['id'])) {
26
+ $media = false;
27
+ } else {
28
+ $media = tnp_get_media($info['header_logo']['id'], 'large');
29
+ if ($media) {
30
+ $media->alt = $info['header_title'];
31
+ $media->link = home_url();
32
+ }
33
+ }
34
+
35
+ $empty = !$media && empty($info['header_sub']) && empty($info['header_title']);
36
+
37
+ if ($empty) {
38
+ echo '<p>Please, set your company info.</p>';
39
+ } elseif ($options['layout'] === 'logo') {
40
+ include __DIR__ . '/layout-logo.php';
41
+ return;
42
+ } elseif ($options['layout'] === 'titlemotto') {
43
+ include __DIR__ . '/layout-titlemotto.php';
44
+ return;
45
+ } else {
46
+ include __DIR__ . '/layout-default.php';
47
+ return;
48
+ }
49
+ ?>
50
+
includes/mailer.php CHANGED
@@ -1,475 +1,469 @@
1
- <?php
2
-
3
- use TNP\Mailer\PHPMailerLoader;
4
-
5
- /**
6
- * @property string $to
7
- * @property string $to_name
8
- * @property string $subject
9
- * @property string $body
10
- * @property array $headers
11
- * @property string $from
12
- * @property string $from_name
13
- */
14
- class TNP_Mailer_Message {
15
-
16
- var $to_name = '';
17
- var $headers = array();
18
- var $user_id = 0;
19
- var $email_id = 0;
20
- var $error = '';
21
- var $subject = '';
22
- var $body = '';
23
- var $body_text = '';
24
- var $from = '';
25
- var $from_name = '';
26
-
27
- }
28
-
29
- /**
30
- * A basic class able to send one or more TNP_Mailer_Message objects using a
31
- * delivery method (wp-mail(), SMTP, API, ...).
32
- */
33
- class NewsletterMailer {
34
-
35
- const ERROR_GENERIC = '1';
36
- const ERROR_FATAL = '2';
37
-
38
- /* @var NewsletterLogger */
39
-
40
- var $logger;
41
- var $name;
42
- var $options;
43
- private $delta;
44
- protected $batch_size = 1;
45
- protected $speed = 0;
46
-
47
- public function __construct($name, $options = []) {
48
- $this->name = $name;
49
- $this->options = $options;
50
- if (!empty($this->options['speed'])) {
51
- $this->speed = max(0, (int)$this->options['speed']);
52
- }
53
- if (!empty($this->options['turbo'])) {
54
- $this->batch_size = max(1, (int)$this->options['turbo']);
55
- }
56
- $this->get_logger()->debug($options);
57
- }
58
-
59
- public function get_name() {
60
- return $this->name;
61
- }
62
-
63
- public function get_description() {
64
- return ucfirst($this->name) . ' Addon';
65
- }
66
-
67
- public function get_batch_size() {
68
- return $this->batch_size;
69
- }
70
-
71
- public function get_speed() {
72
- return $this->speed;
73
- }
74
-
75
- function send_with_stats($message) {
76
- $this->delta = microtime(true);
77
- $r = $this->send($message);
78
- $this->delta = microtime(true) - $this->delta;
79
- return $r;
80
- }
81
-
82
- /**
83
- *
84
- * @param TNP_Mailer_Message $message
85
- * @return bool|WP_Error
86
- */
87
- public function send($message) {
88
- $message->error = 'No mailing system available';
89
- return new WP_Error(self::ERROR_FATAL, 'No mailing system available');
90
- }
91
-
92
- public function send_batch_with_stats($messages) {
93
- $this->delta = microtime(true);
94
- $r = $this->send_batch($messages);
95
- $this->delta = microtime(true) - $this->delta;
96
- return $r;
97
- }
98
-
99
- function get_capability() {
100
- return (int) (3600 * $this->batch_size / $this->delta);
101
- }
102
-
103
- /**
104
- *
105
- * @param TNP_Mailer_Message[] $messages
106
- * @return bool|WP_Error
107
- */
108
- public function send_batch($messages) {
109
-
110
- // We should not get there is the batch size is one, the caller should use "send()". We can get
111
- // there if the array of messages counts to one, since could be the last of a series of chunks.
112
- if ($this->batch_size == 1 || count($messages) == 1) {
113
- $last_result = true;
114
- foreach ($messages as $message) {
115
- $r = $this->send($message);
116
- if (is_wp_error($r)) {
117
- $last_result = $r;
118
- }
119
- }
120
- return $last_result;
121
- }
122
-
123
- // We should always get there
124
- if (count($messages) <= $this->batch_size) {
125
- return $this->send_chunk($messages);
126
- }
127
-
128
- // We should not get here, since it is not optimized
129
- $chunks = array_chunk($message, $this->batch_size);
130
- $last_result = true;
131
- foreach ($chunks as $chunk) {
132
- $r = $this->send_chunk($chunk);
133
- if (is_wp_error($r)) {
134
- $last_result = $r;
135
- }
136
- }
137
- return $last_result;
138
- }
139
-
140
- /**
141
- * This one should be implemented by specilized classes.
142
- *
143
- * @param TNP_Mailer_Message[] $messages
144
- * @return bool|WP_Error
145
- */
146
- protected function send_chunk($messages) {
147
- $last_result = true;
148
- foreach ($messages as $message) {
149
- $r = $this->send($message);
150
- if (is_wp_error($r)) {
151
- $last_result = $r;
152
- }
153
- }
154
- return $last_result;
155
- }
156
-
157
- /**
158
- * @return NewsletterLogger
159
- */
160
- function get_logger() {
161
- if ($this->logger) {
162
- return $this->logger;
163
- }
164
- $this->logger = new NewsletterLogger($this->name . '-mailer');
165
- return $this->logger;
166
- }
167
-
168
- /**
169
- * Original mail function simulation for compatibility.
170
- * @deprecated
171
- *
172
- * @param string $to
173
- * @param string $subject
174
- * @param array $message
175
- * @param array $headers
176
- * @param bool $enqueue
177
- * @param type $from Actually ignored
178
- * @return type
179
- */
180
- public function mail($to, $subject, $message, $headers = null, $enqueue = false, $from = false) {
181
- $mailer_message = new TNP_Mailer_Message();
182
- $mailer_message->to = $to;
183
- $mailer_message->subject = $subject;
184
- $mailer_message->headers = $headers;
185
- $mailer_message->body = $message['html'];
186
- $mailer_message->body_text = $message['text'];
187
-
188
- return !is_wp_error($this->send($mailer_message));
189
- }
190
-
191
- /**
192
- * Used by bounce detection.
193
- *
194
- * @param int $time
195
- */
196
- function save_last_run($time) {
197
- update_option($this->prefix . '_last_run', $time);
198
- }
199
-
200
- /**
201
- * Used by bounce detection.
202
- *
203
- * @param int $time
204
- */
205
- function get_last_run() {
206
- return (int) get_option($this->prefix . '_last_run', 0);
207
- }
208
-
209
- }
210
-
211
- /**
212
- * Standard Mailer which uses the wp_mail() function of WP.
213
- */
214
- class NewsletterDefaultMailer extends NewsletterMailer {
215
-
216
- var $filter_active = false;
217
-
218
- /**
219
- * Static to be accessed in the hook: on some installation the object $this is not working, we're still trying to understand why
220
- * @var TNP_Mailer_Message
221
- */
222
- var $current_message = null;
223
-
224
- function __construct() {
225
- parent::__construct('default', Newsletter::instance()->get_options('smtp'));
226
- }
227
-
228
- function get_description() {
229
- // TODO: check if overloaded
230
- return 'wp_mail() WordPress function (could be extended by a SMTP plugin)';
231
- }
232
-
233
- function get_speed() {
234
- return (int)Newsletter::instance()->options['scheduler_max'];
235
- }
236
-
237
- function fix_mailer($mailer) {
238
- // If there is not a current message, wp_mail() was not called by us
239
- if (is_null($this->current_message)) {
240
- return;
241
- }
242
-
243
- $newsletter = Newsletter::instance();
244
- if (isset($this->current_message->encoding)) {
245
- $mailer->Encoding = $this->current_message->encoding;
246
- } else {
247
- if (!empty($newsletter->options['content_transfer_encoding'])) {
248
- $mailer->Encoding = $newsletter->options['content_transfer_encoding'];
249
- } else {
250
- // Setting and encoding sometimes conflict with SMTP plugins
251
- //$mailer->Encoding = 'base64';
252
- }
253
- }
254
-
255
- /* @var $mailer PHPMailer */
256
- $mailer->Sender = $newsletter->options['return_path'];
257
-
258
- // If there is an HTML body AND a text body, add the text part.
259
- if (!empty($this->current_message->body) && !empty($this->current_message->body_text)) {
260
- $mailer->AltBody = $this->current_message->body_text;
261
- }
262
- }
263
-
264
- /**
265
- *
266
- * @param TNP_Mailer_Message $message
267
- * @return \WP_Error|boolean
268
- */
269
- function send($message) {
270
-
271
- if (!$this->filter_active) {
272
- add_action('phpmailer_init', array($this, 'fix_mailer'), 100);
273
- $this->filter_active = true;
274
- }
275
-
276
- $newsletter = Newsletter::instance();
277
- $wp_mail_headers = [];
278
- if (empty($message->from)) {
279
- $message->from = $newsletter->options['sender_email'];
280
- }
281
-
282
- if (empty($message->from_name)) {
283
- $message->from_name = $newsletter->options['sender_name'];
284
- }
285
-
286
- $wp_mail_headers[] = 'From: "' . $message->from_name . '" <' . $message->from . '>';
287
-
288
- if (!empty($newsletter->options['reply_to'])) {
289
- $wp_mail_headers[] = 'Reply-To: ' . $newsletter->options['reply_to'];
290
- }
291
-
292
- // Manage from and from name
293
-
294
- if (!empty($message->headers)) {
295
- foreach ($message->headers as $key => $value) {
296
- $wp_mail_headers[] = $key . ': ' . $value;
297
- }
298
- }
299
-
300
- if (!empty($message->body)) {
301
- $wp_mail_headers[] = 'Content-Type: text/html;charset=UTF-8';
302
- $body = $message->body;
303
- } else if (!empty($message->body_text)) {
304
- $wp_mail_headers[] = 'Content-Type: text/plain;charset=UTF-8';
305
- $body = $message->body_text;
306
- } else {
307
- $message->error = 'Empty body';
308
- return new WP_Error(self::ERROR_GENERIC, 'Message format');
309
- }
310
-
311
- $this->current_message = $message;
312
- $r = wp_mail($message->to, $message->subject, $body, $wp_mail_headers);
313
- $this->current_message = null;
314
-
315
- if (!$r) {
316
- $last_error = error_get_last();
317
- if (is_array($last_error)) {
318
- $message->error = $last_error['message'];
319
- if (stripos($message->error, 'Could not instantiate mail function') || stripos($message->error, 'Failed to connect to mailserver')) {
320
- return new WP_Error(self::ERROR_FATAL, $last_error['message']);
321
- } else {
322
- return new WP_Error(self::ERROR_GENERIC, $last_error['message']);
323
- }
324
- } else {
325
- $message->error = 'No error explanation reported';
326
- return new WP_Error(self::ERROR_GENERIC, 'No error message reported');
327
- }
328
- }
329
- return true;
330
- }
331
-
332
- }
333
-
334
- /**
335
- * @deprecated since version 6.2.0
336
- * Internal SMTP mailer implementation (move to an SMTP plugin or use the
337
- * SMTP Addon).
338
- */
339
- class NewsletterDefaultSMTPMailer extends NewsletterMailer {
340
-
341
- var $mailer = null;
342
-
343
- function __construct($options) {
344
- parent::__construct('internal-smtp', $options);
345
- }
346
-
347
- function get_description() {
348
- return 'Internal SMTP (deprecated)';
349
- }
350
-
351
- /**
352
- *
353
- * @param TNP_Mailer_Message $message
354
- * @return \WP_Error|boolean
355
- */
356
- public function send($message) {
357
- $logger = $this->get_logger();
358
- $logger->debug('Start sending to ' . $message->to);
359
- $mailer = $this->get_mailer();
360
-
361
- if (!empty($message->body)) {
362
- $mailer->IsHTML(true);
363
- $mailer->Body = $message->body;
364
- $mailer->AltBody = $message->body_text;
365
- } else {
366
- $mailer->IsHTML(false);
367
- $mailer->Body = $message->body_text;
368
- $mailer->AltBody = '';
369
- }
370
-
371
- $mailer->Subject = $message->subject;
372
-
373
- $mailer->ClearCustomHeaders();
374
- if (!empty($message->headers)) {
375
- foreach ($message->headers as $key => $value) {
376
- $mailer->AddCustomHeader($key . ': ' . $value);
377
- }
378
- }
379
-
380
- if ($message->from) {
381
- $logger->debug('Alternative from available');
382
- $mailer->setFrom($message->from, $message->from_name);
383
- } else {
384
- $newsletter = Newsletter::instance();
385
- $mailer->setFrom($newsletter->options['sender_email'], $newsletter->options['sender_name']);
386
- }
387
-
388
- $mailer->ClearAddresses();
389
- $mailer->AddAddress($message->to);
390
- $mailer->Send();
391
-
392
- if ($mailer->IsError()) {
393
-
394
- $logger->error($mailer->ErrorInfo);
395
- // If the error is due to SMTP connection, the mailer cannot be reused since it does not clean up the connection
396
- // on error.
397
- //$this->mailer = null;
398
- $message->error = $mailer->ErrorInfo;
399
- return new WP_Error(self::ERROR_GENERIC, $mailer->ErrorInfo);
400
- }
401
-
402
- $logger->debug('Sent ' . $message->to);
403
- //$logger->error('Time: ' . (microtime(true) - $start) . ' seconds');
404
- return true;
405
- }
406
-
407
- /**
408
- *
409
- * @return PHPMailer
410
- */
411
- function get_mailer() {
412
- global $wp_version;
413
-
414
- if ($this->mailer) {
415
- return $this->mailer;
416
- }
417
-
418
- $logger = $this->get_logger();
419
- $logger->debug('Setting up PHP mailer');
420
-
421
- require_once 'PHPMailerLoader.php';
422
- $this->mailer = PHPMailerLoader::make_instance();
423
-
424
- $this->mailer->XMailer = ' '; // A space!
425
-
426
- $this->mailer->IsSMTP();
427
- $this->mailer->Host = $this->options['host'];
428
- if (!empty($this->options['port'])) {
429
- $this->mailer->Port = (int) $this->options['port'];
430
- }
431
-
432
- if (!empty($this->options['user'])) {
433
- $this->mailer->SMTPAuth = true;
434
- $this->mailer->Username = $this->options['user'];
435
- $this->mailer->Password = $this->options['pass'];
436
- }
437
-
438
- $this->mailer->SMTPSecure = $this->options['secure'];
439
- $this->mailer->SMTPAutoTLS = false;
440
-
441
- if ($this->options['ssl_insecure'] == 1) {
442
- $this->mailer->SMTPOptions = array(
443
- 'ssl' => array(
444
- 'verify_peer' => false,
445
- 'verify_peer_name' => false,
446
- 'allow_self_signed' => true
447
- )
448
- );
449
- }
450
-
451
- $newsletter = Newsletter::instance();
452
-
453
- // if (!empty($newsletter->options['content_transfer_encoding'])) {
454
- // $this->mailer->Encoding = $newsletter->options['content_transfer_encoding'];
455
- // } else {
456
- // $this->mailer->Encoding = 'base64';
457
- // }
458
-
459
- $this->mailer->CharSet = 'UTF-8';
460
- $this->mailer->From = $newsletter->options['sender_email'];
461
-
462
- if (!empty($newsletter->options['return_path'])) {
463
- $this->mailer->Sender = $newsletter->options['return_path'];
464
- }
465
- if (!empty($newsletter->options['reply_to'])) {
466
- $this->mailer->AddReplyTo($newsletter->options['reply_to']);
467
- }
468
-
469
- $this->mailer->FromName = $newsletter->options['sender_name'];
470
-
471
-
472
- return $this->mailer;
473
- }
474
-
475
- }
1
+ <?php
2
+
3
+ use TNP\Mailer\PHPMailerLoader;
4
+
5
+ /**
6
+ * @property string $to
7
+ * @property string $to_name
8
+ * @property string $subject
9
+ * @property string $body
10
+ * @property array $headers
11
+ * @property string $from
12
+ * @property string $from_name
13
+ */
14
+ class TNP_Mailer_Message {
15
+
16
+ var $to_name = '';
17
+ var $headers = array();
18
+ var $user_id = 0;
19
+ var $email_id = 0;
20
+ var $error = '';
21
+ var $subject = '';
22
+ var $body = '';
23
+ var $body_text = '';
24
+ var $from = '';
25
+ var $from_name = '';
26
+
27
+ }
28
+
29
+ /**
30
+ * A basic class able to send one or more TNP_Mailer_Message objects using a
31
+ * delivery method (wp-mail(), SMTP, API, ...).
32
+ */
33
+ class NewsletterMailer {
34
+
35
+ const ERROR_GENERIC = '1';
36
+ const ERROR_FATAL = '2';
37
+
38
+ /* @var NewsletterLogger */
39
+
40
+ var $logger;
41
+ var $name;
42
+ var $options;
43
+ private $delta;
44
+ protected $batch_size = 1;
45
+ protected $speed = 0;
46
+
47
+ public function __construct($name, $options = []) {
48
+ $this->name = $name;
49
+ $this->options = $options;
50
+ if (!empty($this->options['speed'])) {
51
+ $this->speed = max(0, (int)$this->options['speed']);
52
+ }
53
+ if (!empty($this->options['turbo'])) {
54
+ $this->batch_size = max(1, (int)$this->options['turbo']);
55
+ }
56
+ $this->get_logger()->debug($options);
57
+ }
58
+
59
+ public function get_name() {
60
+ return $this->name;
61
+ }
62
+
63
+ public function get_description() {
64
+ return ucfirst($this->name) . ' Addon';
65
+ }
66
+
67
+ public function get_batch_size() {
68
+ return $this->batch_size;
69
+ }
70
+
71
+ public function get_speed() {
72
+ return $this->speed;
73
+ }
74
+
75
+ function send_with_stats($message) {
76
+ $this->delta = microtime(true);
77
+ $r = $this->send($message);
78
+ $this->delta = microtime(true) - $this->delta;
79
+ return $r;
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @param TNP_Mailer_Message $message
85
+ * @return bool|WP_Error
86
+ */
87
+ public function send($message) {
88
+ $message->error = 'No mailing system available';
89
+ return new WP_Error(self::ERROR_FATAL, 'No mailing system available');
90
+ }
91
+
92
+ public function send_batch_with_stats($messages) {
93
+ $this->delta = microtime(true);
94
+ $r = $this->send_batch($messages);
95
+ $this->delta = microtime(true) - $this->delta;
96
+ return $r;
97
+ }
98
+
99
+ function get_capability() {
100
+ return (int) (3600 * $this->batch_size / $this->delta);
101
+ }
102
+
103
+ /**
104
+ *
105
+ * @param TNP_Mailer_Message[] $messages
106
+ * @return bool|WP_Error
107
+ */
108
+ public function send_batch($messages) {
109
+
110
+ // We should not get there is the batch size is one, the caller should use "send()". We can get
111
+ // there if the array of messages counts to one, since could be the last of a series of chunks.
112
+ if ($this->batch_size == 1 || count($messages) == 1) {
113
+ $last_result = true;
114
+ foreach ($messages as $message) {
115
+ $r = $this->send($message);
116
+ if (is_wp_error($r)) {
117
+ $last_result = $r;
118
+ }
119
+ }
120
+ return $last_result;
121
+ }
122
+
123
+ // We should always get there
124
+ if (count($messages) <= $this->batch_size) {
125
+ return $this->send_chunk($messages);
126
+ }
127
+
128
+ // We should not get here, since it is not optimized
129
+ $chunks = array_chunk($message, $this->batch_size);
130
+ $last_result = true;
131
+ foreach ($chunks as $chunk) {
132
+ $r = $this->send_chunk($chunk);
133
+ if (is_wp_error($r)) {
134
+ $last_result = $r;
135
+ }
136
+ }
137
+ return $last_result;
138
+ }
139
+
140
+ /**
141
+ * This one should be implemented by specilized classes.
142
+ *
143
+ * @param TNP_Mailer_Message[] $messages
144
+ * @return bool|WP_Error
145
+ */
146
+ protected function send_chunk($messages) {
147
+ $last_result = true;
148
+ foreach ($messages as $message) {
149
+ $r = $this->send($message);
150
+ if (is_wp_error($r)) {
151
+ $last_result = $r;
152
+ }
153
+ }
154
+ return $last_result;
155
+ }
156
+
157
+ /**
158
+ * @return NewsletterLogger
159
+ */
160
+ function get_logger() {
161
+ if ($this->logger) {
162
+ return $this->logger;
163
+ }
164
+ $this->logger = new NewsletterLogger($this->name . '-mailer');
165
+ return $this->logger;
166
+ }
167
+
168
+ /**
169
+ * Original mail function simulation for compatibility.
170
+ * @deprecated
171
+ *
172
+ * @param string $to
173
+ * @param string $subject
174
+ * @param array $message
175
+ * @param array $headers
176
+ * @param bool $enqueue
177
+ * @param type $from Actually ignored
178
+ * @return type
179
+ */
180
+ public function mail($to, $subject, $message, $headers = null, $enqueue = false, $from = false) {
181
+ $mailer_message = new TNP_Mailer_Message();
182
+ $mailer_message->to = $to;
183
+ $mailer_message->subject = $subject;
184
+ $mailer_message->headers = $headers;
185
+ $mailer_message->body = $message['html'];
186
+ $mailer_message->body_text = $message['text'];
187
+
188
+ return !is_wp_error($this->send($mailer_message));
189
+ }
190
+
191
+ /**
192
+ * Used by bounce detection.
193
+ *
194
+ * @param int $time
195
+ */
196
+ function save_last_run($time) {
197
+ update_option($this->prefix . '_last_run', $time);
198
+ }
199
+
200
+ /**
201
+ * Used by bounce detection.
202
+ *
203
+ * @param int $time
204
+ */
205
+ function get_last_run() {
206
+ return (int) get_option($this->prefix . '_last_run', 0);
207
+ }
208
+
209
+ }
210
+
211
+ /**
212
+ * Standard Mailer which uses the wp_mail() function of WP.
213
+ */
214
+ class NewsletterDefaultMailer extends NewsletterMailer {
215
+
216
+ var $filter_active = false;
217
+
218
+ /**
219
+ * Static to be accessed in the hook: on some installation the object $this is not working, we're still trying to understand why
220
+ * @var TNP_Mailer_Message
221
+ */
222
+ var $current_message = null;
223
+
224
+ function __construct() {
225
+ parent::__construct('default', Newsletter::instance()->get_options('smtp'));
226
+ }
227
+
228
+ function get_description() {
229
+ // TODO: check if overloaded
230
+ return 'wp_mail() WordPress function (could be extended by a SMTP plugin)';
231
+ }
232
+
233
+ function get_speed() {
234
+ return (int)Newsletter::instance()->options['scheduler_max'];
235
+ }
236
+
237
+ function fix_mailer($mailer) {
238
+ // If there is not a current message, wp_mail() was not called by us
239
+ if (is_null($this->current_message)) {
240
+ return;
241
+ }
242
+
243
+ $newsletter = Newsletter::instance();
244
+ if (isset($this->current_message->encoding)) {
245
+ $mailer->Encoding = $this->current_message->encoding;
246
+ } else {
247
+ if (!empty($newsletter->options['content_transfer_encoding'])) {
248
+ $mailer->Encoding = $newsletter->options['content_transfer_encoding'];
249
+ } else {
250
+ // Setting and encoding sometimes conflict with SMTP plugins
251
+ //$mailer->Encoding = 'base64';
252
+ }
253
+ }
254
+
255
+ /* @var $mailer PHPMailer */
256
+ $mailer->Sender = $newsletter->options['return_path'];
257
+
258
+ // If there is an HTML body AND a text body, add the text part.
259
+ if (!empty($this->current_message->body) && !empty($this->current_message->body_text)) {
260
+ $mailer->AltBody = $this->current_message->body_text;
261
+ }
262
+ }
263
+
264
+ /**
265
+ *
266
+ * @param TNP_Mailer_Message $message
267
+ * @return \WP_Error|boolean
268
+ */
269
+ function send($message) {
270
+
271
+ if (!$this->filter_active) {
272
+ add_action('phpmailer_init', array($this, 'fix_mailer'), 100);
273
+ $this->filter_active = true;
274
+ }
275
+
276
+ $newsletter = Newsletter::instance();
277
+ $wp_mail_headers = [];
278
+ if (empty($message->from)) {
279
+ $message->from = $newsletter->options['sender_email'];
280
+ }
281
+
282
+ if (empty($message->from_name)) {
283
+ $message->from_name = $newsletter->options['sender_name'];
284
+ }
285
+
286
+ $wp_mail_headers[] = 'From: "' . $message->from_name . '" <' . $message->from . '>';
287
+
288
+ if (!empty($newsletter->options['reply_to'])) {
289
+ $wp_mail_headers[] = 'Reply-To: ' . $newsletter->options['reply_to'];
290
+ }
291
+
292
+ // Manage from and from name
293
+
294
+ if (!empty($message->headers)) {
295
+ foreach ($message->headers as $key => $value) {
296
+ $wp_mail_headers[] = $key . ': ' . $value;
297
+ }
298
+ }
299
+
300
+ if (!empty($message->body)) {
301
+ $wp_mail_headers[] = 'Content-Type: text/html;charset=UTF-8';
302
+ $body = $message->body;
303
+ } else if (!empty($message->body_text)) {
304
+ $wp_mail_headers[] = 'Content-Type: text/plain;charset=UTF-8';
305
+ $body = $message->body_text;
306
+ } else {
307
+ $message->error = 'Empty body';
308
+ return new WP_Error(self::ERROR_GENERIC, 'Message format');
309
+ }
310
+
311
+ $this->current_message = $message;
312
+ $r = wp_mail($message->to, $message->subject, $body, $wp_mail_headers);
313
+ $this->current_message = null;
314
+
315
+ if (!$r) {
316
+ $last_error = error_get_last();
317
+ if (is_array($last_error)) {
318
+ $message->error = $last_error['message'];
319
+ if (stripos($message->error, 'Could not instantiate mail function') || stripos($message->error, 'Failed to connect to mailserver')) {
320
+ return new WP_Error(self::ERROR_FATAL, $last_error['message']);
321
+ } else {
322
+ return new WP_Error(self::ERROR_GENERIC, $last_error['message']);
323
+ }
324
+ } else {
325
+ $message->error = 'No error explanation reported';
326
+ return new WP_Error(self::ERROR_GENERIC, 'No error message reported');
327
+ }
328
+ }
329
+ return true;
330
+ }
331
+
332
+ }
333
+
334
+ /**
335
+ * @deprecated since version 6.2.0
336
+ * Internal SMTP mailer implementation (move to an SMTP plugin or use the
337
+ * SMTP Addon).
338
+ */
339
+ class NewsletterDefaultSMTPMailer extends NewsletterMailer {
340
+
341
+ var $mailer = null;
342
+
343
+ function __construct($options) {
344
+ parent::__construct('internal-smtp', $options);
345
+ }
346
+
347
+ function get_description() {
348
+ return 'Internal SMTP (deprecated)';
349
+ }
350
+
351
+ /**
352
+ *
353
+ * @param TNP_Mailer_Message $message
354
+ * @return \WP_Error|boolean
355
+ */
356
+ public function send($message) {
357
+ $logger = $this->get_logger();
358
+ $logger->debug('Start sending to ' . $message->to);
359
+ $mailer = $this->get_mailer();
360
+
361
+ if (!empty($message->body)) {
362
+ $mailer->IsHTML(true);
363
+ $mailer->Body = $message->body;
364
+ $mailer->AltBody = $message->body_text;
365
+ } else {
366
+ $mailer->IsHTML(false);
367
+ $mailer->Body = $message->body_text;
368
+ $mailer->AltBody = '';
369
+ }
370
+
371
+ $mailer->Subject = $message->subject;
372
+
373
+ $mailer->ClearCustomHeaders();
374
+ if (!empty($message->headers)) {
375
+ foreach ($message->headers as $key => $value) {
376
+ $mailer->AddCustomHeader($key . ': ' . $value);
377
+ }
378
+ }
379
+
380
+ if ($message->from) {
381
+ $logger->debug('Alternative from available');
382
+ $mailer->setFrom($message->from, $message->from_name);
383
+ } else {
384
+ $newsletter = Newsletter::instance();
385
+ $mailer->setFrom($newsletter->options['sender_email'], $newsletter->options['sender_name']);
386
+ }
387
+
388
+ $mailer->ClearAddresses();
389
+ $mailer->AddAddress($message->to);
390
+ $mailer->Send();
391
+
392
+ if ($mailer->IsError()) {
393
+
394
+ $logger->error($mailer->ErrorInfo);
395
+ // If the error is due to SMTP connection, the mailer cannot be reused since it does not clean up the connection
396
+ // on error.
397
+ //$this->mailer = null;
398
+ $message->error = $mailer->ErrorInfo;
399
+ return new WP_Error(self::ERROR_GENERIC, $mailer->ErrorInfo);
400
+ }
401
+
402
+ $logger->debug('Sent ' . $message->to);
403
+ //$logger->error('Time: ' . (microtime(true) - $start) . ' seconds');
404
+ return true;
405
+ }
406
+
407
+ /**
408
+ *
409
+ * @return PHPMailer
410
+ */
411
+ function get_mailer() {
412
+ global $wp_version;
413
+
414
+ if ($this->mailer) {
415
+ return $this->mailer;
416
+ }
417
+
418
+ $logger = $this->get_logger();
419
+ $logger->debug('Setting up PHP mailer');
420
+
421
+ require_once 'PHPMailerLoader.php';
422
+ $this->mailer = PHPMailerLoader::make_instance();
423
+
424
+ $this->mailer->XMailer = ' '; // A space!
425
+
426
+ $this->mailer->IsSMTP();
427
+ $this->mailer->Host = $this->options['host'];
428
+ if (!empty($this->options['port'])) {
429
+ $this->mailer->Port = (int) $this->options['port'];
430
+ }
431
+
432
+ if (!empty($this->options['user'])) {
433
+ $this->mailer->SMTPAuth = true;
434
+ $this->mailer->Username = $this->options['user'];
435
+ $this->mailer->Password = $this->options['pass'];
436
+ }
437
+
438
+ $this->mailer->SMTPSecure = $this->options['secure'];
439
+ $this->mailer->SMTPAutoTLS = false;
440
+
441
+ if ($this->options['ssl_insecure'] == 1) {
442
+ $this->mailer->SMTPOptions = array(
443
+ 'ssl' => array(
444
+ 'verify_peer' => false,
445
+ 'verify_peer_name' => false,
446
+ 'allow_self_signed' => true
447
+ )
448
+ );
449
+ }
450
+
451
+ $newsletter = Newsletter::instance();
452
+
453
+ $this->mailer->CharSet = 'UTF-8';
454
+ $this->mailer->From = $newsletter->options['sender_email'];
455
+
456
+ if (!empty($newsletter->options['return_path'])) {
457
+ $this->mailer->Sender = $newsletter->options['return_path'];
458
+ }
459
+ if (!empty($newsletter->options['reply_to'])) {
460
+ $this->mailer->AddReplyTo($newsletter->options['reply_to']);
461
+ }
462
+
463
+ $this->mailer->FromName = $newsletter->options['sender_name'];
464
+
465
+
466
+ return $this->mailer;
467
+ }
468
+
469
+ }
 
 
 
 
 
 
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
- Version: 7.3.2
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.
@@ -37,7 +37,7 @@ if (version_compare(phpversion(), '5.6', '<')) {
37
  return;
38
  }
39
 
40
- define('NEWSLETTER_VERSION', '7.3.2');
41
 
42
  global $newsletter, $wpdb;
43
 
4
  Plugin Name: Newsletter
5
  Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
+ Version: 7.3.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.
37
  return;
38
  }
39
 
40
+ define('NEWSLETTER_VERSION', '7.3.3');
41
 
42
  global $newsletter, $wpdb;
43
 
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Newsletter ===
2
  Tags: newsletter, email marketing, welcome email, signup forms, contact, lead generation, marketing automation
3
  Tested up to: 5.8.2
4
- Stable tag: 7.3.2
5
  Contributors: satollo,webagile,michael-travan
6
  License: GPLv2 or later
7
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -118,6 +118,13 @@ Thank you, The Newsletter Team
118
 
119
  == Changelog ==
120
 
 
 
 
 
 
 
 
121
  = 7.3.2 =
122
 
123
  * Fixed the remote ip retrieval and clean up
1
  === Newsletter ===
2
  Tags: newsletter, email marketing, welcome email, signup forms, contact, lead generation, marketing automation
3
  Tested up to: 5.8.2
4
+ Stable tag: 7.3.3
5
  Contributors: satollo,webagile,michael-travan
6
  License: GPLv2 or later
7
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
118
 
119
  == Changelog ==
120
 
121
+ = 7.3.3 =
122
+
123
+ * Added "complained" status to subscriber filters
124
+ * Fixed some links bringing to a "not allowed" page
125
+ * Fixed a notice on delivery diagnostic page
126
+ * Fixed logo width notice on header block
127
+
128
  = 7.3.2 =
129
 
130
  * Fixed the remote ip retrieval and clean up
system/delivery.php CHANGED
@@ -1,199 +1,199 @@
1
- <?php
2
- /* @var $this NewsletterSystem */
3
- /* @var $wpdb wpdb */
4
-
5
- defined('ABSPATH') || exit;
6
-
7
- include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
8
- $controls = new NewsletterControls();
9
- $newsletter = Newsletter::instance();
10
-
11
- if ($controls->is_action('test')) {
12
-
13
- if (!NewsletterModule::is_email($controls->data['test_email'])) {
14
- $controls->errors = 'The test email address is not set or is not correct.';
15
- }
16
-
17
- if (empty($controls->errors)) {
18
-
19
- $options = $controls->data;
20
-
21
- if ($controls->data['test_email'] == $newsletter->get_sender_email()) {
22
- $controls->messages .= '<strong>Warning:</strong> you are using as test email the same address configured as sender in main configuration. Test can fail because of that.<br>';
23
- }
24
-
25
- $message = NewsletterMailerAddon::get_test_message($controls->data['test_email'], 'Newsletter test email at ' . date(DATE_ISO8601));
26
-
27
- $r = $newsletter->deliver($message);
28
-
29
- if (!is_wp_error($r)) {
30
- $options['mail'] = 1;
31
- $controls->messages .= '<strong>SUCCESS</strong><br>';
32
- $controls->messages .= 'Anyway if the message does not appear the mailbox (check even the spam folder) you can ';
33
- $controls->messages .= '<a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>read more here</strong></a>.';
34
- } else {
35
- $options['mail'] = 0;
36
- $options['mail_error'] = $r->get_error_message();
37
-
38
- $controls->errors .= '<strong>FAILED</strong> (' . esc_html($r->get_error_message()) . ')<br>';
39
-
40
- if (!empty($newsletter->options['return_path'])) {
41
- $controls->errors .= '- Try to remove the return path on main settings.<br>';
42
- }
43
-
44
- $controls->errors .= '<a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>' . __('Read more', 'newsletter') . '</strong></a>.';
45
-
46
- $parts = explode('@', $newsletter->get_sender_email());
47
- $sitename = strtolower($_SERVER['SERVER_NAME']);
48
- if (substr($sitename, 0, 4) == 'www.') {
49
- $sitename = substr($sitename, 4);
50
- }
51
- if (strtolower($sitename) != strtolower($parts[1])) {
52
- $controls->errors .= '- Try to set on main setting a sender address with the same domain of your blog: ' . esc_html($sitename) . ' (you are using ' . esc_html($newsletter->get_sender_email()) . ')<br>';
53
- }
54
- }
55
- $this->save_options($options, 'status');
56
- }
57
- }
58
-
59
- $options = $this->get_options('status');
60
-
61
- $mailer = Newsletter::instance()->get_mailer();
62
- $functions = tnp_get_hook_functions('phpmailer_init');
63
- $icon = 'fas fa-plug';
64
- if ($mailer instanceof NewsletterDefaultMailer) {
65
- $mailer_name = 'Wordpress';
66
- $service_name = 'Hosting Provider';
67
- if (!empty($functions)) {
68
- $mailer_name .= '<br>(see below)';
69
- $service_name .= '<br>(see below)';
70
- }
71
- $icon = 'fab fa-wordpress';
72
- } else if ($mailer instanceof NewsletterDefaultSMTPMailer) {
73
- $mailer_name = 'Internal SMTP';
74
- $service_name = 'SMTP Provider';
75
- } else {
76
- $mailer_name = 'Unknown';
77
- $service_name = 'Unknown';
78
- if (is_object($mailer)) {
79
- if (method_exists($mailer, 'get_description')) {
80
- $mailer_name = esc_html($mailer->get_description());
81
- $service_name = esc_html(ucfirst($mailer->get_name()) . ' Service');
82
- } else {
83
- $mailer_name = esc_html(get_class($mailer));
84
- $service_name = $mailer_name;
85
- }
86
- }
87
- }
88
-
89
- function tnp_get_hook_functions($tag) {
90
- global $wp_filter;
91
- if (isset($wp_filter)) {
92
- $b = '';
93
- foreach ($wp_filter[$tag]->callbacks as $priority => $functions) {
94
-
95
- foreach ($functions as $function) {
96
- $b .= '[' . $priority . '] ';
97
- if (is_array($function['function'])) {
98
- if (is_object($function['function'][0])) {
99
- $b .= get_class($function['function'][0]) . '::' . $function['function'][1];
100
- } else {
101
- $b .= $function['function'][0] . '::' . $function['function'][1];
102
- }
103
- } else {
104
- if (is_object($function['function'])) {
105
- $fn = new ReflectionFunction($function['function']);
106
- $b .= get_class($fn->getClosureThis()) . '(closure)';
107
- } else {
108
- $b .= $function['function'];
109
- }
110
- }
111
- $b .= "<br>";
112
- }
113
- }
114
- }
115
- return $b;
116
- }
117
-
118
- $speed = Newsletter::$instance->get_send_speed();
119
- ?>
120
-
121
- <style>
122
- <?php include __DIR__ . '/css/system.css' ?>
123
- </style>
124
-
125
- <div class="wrap tnp-system tnp-system-delivery" id="tnp-wrap">
126
-
127
- <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
128
-
129
- <div id="tnp-heading">
130
-
131
- <h2><?php _e('Email Delivery', 'newsletter') ?></h2>
132
-
133
- </div>
134
-
135
- <div id="tnp-body">
136
- <form method="post" action="">
137
- <?php $controls->init(); ?>
138
- <h3>Mailing test</h3>
139
-
140
- <p>
141
- <?php $controls->text_email('test_email', ['required' => true]) ?>
142
- <?php $controls->button('test', __('Send a test message')) ?>
143
- <?php if (empty($options['mail'])) { ?>
144
- <span class="tnp-ko">KO</span>
145
- <?php } else { ?>
146
- <span class="tnp-ok">OK</span>
147
- <?php } ?>
148
- </p>
149
-
150
- <p>
151
- <?php if (empty($options['mail'])) { ?>
152
- <?php if (empty($options['mail_error'])) { ?>
153
- <p>A test has never run.</p>
154
- <?php } else { ?>
155
- <p>Last test failed with error "<?php echo esc_html($options['mail_error']) ?>".</p>
156
-
157
- <?php } ?>
158
- <?php } else { ?>
159
- <p>Last test was successful. If you didn't receive the test email:</p>
160
- <ol style="color: #fff">
161
- <li>If you're using an third party SMTP plugin, do a test from that plugin configuration panel</li>
162
- <li>If you're using a Newsletter Delivery Addon, do a test from that addon configuration panel</li>
163
- <li>If previous points do not apply to you, ask for support to your provider reporting the emails from your blog are not delivered</li>
164
- </ol>
165
- <?php } ?>
166
- <p><a href="https://www.thenewsletterplugin.com/documentation/email-sending-issues" target="_blank">Read more to solve your issues, if any</a></p>
167
-
168
-
169
- </form>
170
-
171
- <h3>
172
- How are messages delivered by Newsletter to your subscribers?
173
- </h3>
174
-
175
- <div class="tnp-flow">
176
- <div class="tnp-mail"><i class="fas fa-envelope"></i><br><br>Messages<br>
177
- (max: <?php echo esc_html($speed) ?> emails per hour)
178
- </div>
179
- <div class="tnp-arrow">&rightarrow;</div>
180
- <div class="tnp-addon"><i class="<?php echo $icon ?>"></i><br><br><?php echo $mailer_name ?></div>
181
- <div class="tnp-arrow">&rightarrow;</div>
182
- <div class="tnp-service"><i class="fas fa-cog"></i><br><br>
183
- <?php echo $service_name ?>
184
- </div>
185
- <div class="tnp-arrow">&rightarrow;</div>
186
- <div class="tnp-user"><i class="fas fa-user"></i></div>
187
- </div>
188
-
189
-
190
- <?php if (!empty($functions)) { ?>
191
- <br><br>
192
- <h3>Functions that are changing the default WordPress delivery system</h3>
193
- <p><?php echo $functions ?></p>
194
- <?php } ?>
195
-
196
-
197
- </div>
198
- <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
199
- </div>
1
+ <?php
2
+ /* @var $this NewsletterSystem */
3
+ /* @var $wpdb wpdb */
4
+
5
+ defined('ABSPATH') || exit;
6
+
7
+ include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
8
+ $controls = new NewsletterControls();
9
+ $newsletter = Newsletter::instance();
10
+
11
+ if ($controls->is_action('test')) {
12
+
13
+ if (!NewsletterModule::is_email($controls->data['test_email'])) {
14
+ $controls->errors = 'The test email address is not set or is not correct.';
15
+ }
16
+
17
+ if (empty($controls->errors)) {
18
+
19
+ $options = $controls->data;
20
+
21
+ if ($controls->data['test_email'] == $newsletter->get_sender_email()) {
22
+ $controls->messages .= '<strong>Warning:</strong> you are using as test email the same address configured as sender in main configuration. Test can fail because of that.<br>';
23
+ }
24
+
25
+ $message = NewsletterMailerAddon::get_test_message($controls->data['test_email'], 'Newsletter test email at ' . date(DATE_ISO8601));
26
+
27
+ $r = $newsletter->deliver($message);
28
+
29
+ if (!is_wp_error($r)) {
30
+ $options['mail'] = 1;
31
+ $controls->messages .= '<strong>SUCCESS</strong><br>';
32
+ $controls->messages .= 'Anyway if the message does not appear the mailbox (check even the spam folder) you can ';
33
+ $controls->messages .= '<a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>read more here</strong></a>.';
34
+ } else {
35
+ $options['mail'] = 0;
36
+ $options['mail_error'] = $r->get_error_message();
37
+
38
+ $controls->errors .= '<strong>FAILED</strong> (' . esc_html($r->get_error_message()) . ')<br>';
39
+
40
+ if (!empty($newsletter->options['return_path'])) {
41
+ $controls->errors .= '- Try to remove the return path on main settings.<br>';
42
+ }
43
+
44
+ $controls->errors .= '<a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>' . __('Read more', 'newsletter') . '</strong></a>.';
45
+
46
+ $parts = explode('@', $newsletter->get_sender_email());
47
+ $sitename = strtolower($_SERVER['SERVER_NAME']);
48
+ if (substr($sitename, 0, 4) == 'www.') {
49
+ $sitename = substr($sitename, 4);
50
+ }
51
+ if (strtolower($sitename) != strtolower($parts[1])) {
52
+ $controls->errors .= '- Try to set on main setting a sender address with the same domain of your blog: ' . esc_html($sitename) . ' (you are using ' . esc_html($newsletter->get_sender_email()) . ')<br>';
53
+ }
54
+ }
55
+ $this->save_options($options, 'status');
56
+ }
57
+ }
58
+
59
+ $options = $this->get_options('status');
60
+
61
+ $mailer = Newsletter::instance()->get_mailer();
62
+ $functions = tnp_get_hook_functions('phpmailer_init');
63
+ $icon = 'fas fa-plug';
64
+ if ($mailer instanceof NewsletterDefaultMailer) {
65
+ $mailer_name = 'Wordpress';
66
+ $service_name = 'Hosting Provider';
67
+ if (!empty($functions)) {
68
+ $mailer_name .= '<br>(see below)';
69
+ $service_name .= '<br>(see below)';
70
+ }
71
+ $icon = 'fab fa-wordpress';
72
+ } else if ($mailer instanceof NewsletterDefaultSMTPMailer) {
73
+ $mailer_name = 'Internal SMTP';
74
+ $service_name = 'SMTP Provider';
75
+ } else {
76
+ $mailer_name = 'Unknown';
77
+ $service_name = 'Unknown';
78
+ if (is_object($mailer)) {
79
+ if (method_exists($mailer, 'get_description')) {
80
+ $mailer_name = esc_html($mailer->get_description());
81
+ $service_name = esc_html(ucfirst($mailer->get_name()) . ' Service');
82
+ } else {
83
+ $mailer_name = esc_html(get_class($mailer));
84
+ $service_name = $mailer_name;
85
+ }
86
+ }
87
+ }
88
+
89
+ function tnp_get_hook_functions($tag) {
90
+ global $wp_filter;
91
+ $b = '';
92
+ if (isset($wp_filter[$tag])) {
93
+ foreach ($wp_filter[$tag]->callbacks as $priority => $functions) {
94
+
95
+ foreach ($functions as $function) {
96
+ $b .= '[' . $priority . '] ';
97
+ if (is_array($function['function'])) {
98
+ if (is_object($function['function'][0])) {
99
+ $b .= get_class($function['function'][0]) . '::' . $function['function'][1];
100
+ } else {
101
+ $b .= $function['function'][0] . '::' . $function['function'][1];
102
+ }
103
+ } else {
104
+ if (is_object($function['function'])) {
105
+ $fn = new ReflectionFunction($function['function']);
106
+ $b .= get_class($fn->getClosureThis()) . '(closure)';
107
+ } else {
108
+ $b .= $function['function'];
109
+ }
110
+ }
111
+ $b .= "<br>";
112
+ }
113
+ }
114
+ }
115
+ return $b;
116
+ }
117
+
118
+ $speed = Newsletter::$instance->get_send_speed();
119
+ ?>
120
+
121
+ <style>
122
+ <?php include __DIR__ . '/css/system.css' ?>
123
+ </style>
124
+
125
+ <div class="wrap tnp-system tnp-system-delivery" id="tnp-wrap">
126
+
127
+ <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
128
+
129
+ <div id="tnp-heading">
130
+
131
+ <h2><?php _e('Email Delivery', 'newsletter') ?></h2>
132
+
133
+ </div>
134
+
135
+ <div id="tnp-body">
136
+ <form method="post" action="">
137
+ <?php $controls->init(); ?>
138
+ <h3>Mailing test</h3>
139
+
140
+ <p>
141
+ <?php $controls->text_email('test_email', ['required' => true]) ?>
142
+ <?php $controls->button('test', __('Send a test message')) ?>
143
+ <?php if (empty($options['mail'])) { ?>
144
+ <span class="tnp-ko">KO</span>
145
+ <?php } else { ?>
146
+ <span class="tnp-ok">OK</span>
147
+ <?php } ?>
148
+ </p>
149
+
150
+ <p>
151
+ <?php if (empty($options['mail'])) { ?>
152
+ <?php if (empty($options['mail_error'])) { ?>
153
+ <p>A test has never run.</p>
154
+ <?php } else { ?>
155
+ <p>Last test failed with error "<?php echo esc_html($options['mail_error']) ?>".</p>
156
+
157
+ <?php } ?>
158
+ <?php } else { ?>
159
+ <p>Last test was successful. If you didn't receive the test email:</p>
160
+ <ol style="color: #fff">
161
+ <li>If you're using an third party SMTP plugin, do a test from that plugin configuration panel</li>
162
+ <li>If you're using a Newsletter Delivery Addon, do a test from that addon configuration panel</li>
163
+ <li>If previous points do not apply to you, ask for support to your provider reporting the emails from your blog are not delivered</li>
164
+ </ol>
165
+ <?php } ?>
166
+ <p><a href="https://www.thenewsletterplugin.com/documentation/email-sending-issues" target="_blank">Read more to solve your issues, if any</a></p>
167
+
168
+
169
+ </form>
170
+
171
+ <h3>
172
+ How are messages delivered by Newsletter to your subscribers?
173
+ </h3>
174
+
175
+ <div class="tnp-flow">
176
+ <div class="tnp-mail"><i class="fas fa-envelope"></i><br><br>Messages<br>
177
+ (max: <?php echo esc_html($speed) ?> emails per hour)
178
+ </div>
179
+ <div class="tnp-arrow">&rightarrow;</div>
180
+ <div class="tnp-addon"><i class="<?php echo $icon ?>"></i><br><br><?php echo $mailer_name ?></div>
181
+ <div class="tnp-arrow">&rightarrow;</div>
182
+ <div class="tnp-service"><i class="fas fa-cog"></i><br><br>
183
+ <?php echo $service_name ?>
184
+ </div>
185
+ <div class="tnp-arrow">&rightarrow;</div>
186
+ <div class="tnp-user"><i class="fas fa-user"></i></div>
187
+ </div>
188
+
189
+
190
+ <?php if (!empty($functions)) { ?>
191
+ <br><br>
192
+ <h3>Functions that are changing the default WordPress delivery system</h3>
193
+ <p><?php echo $functions ?></p>
194
+ <?php } ?>
195
+
196
+
197
+ </div>
198
+ <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
199
+ </div>
tnp-header.php CHANGED
@@ -1,324 +1,335 @@
1
- <?php
2
- global $current_user, $wpdb;
3
-
4
- defined('ABSPATH') || exit;
5
-
6
- $dismissed = get_option('newsletter_dismissed', []);
7
-
8
- $user_count = Newsletter::instance()->get_user_count();
9
-
10
- $is_administrator = current_user_can('administrator');
11
-
12
- function newsletter_print_entries($group) {
13
- $entries = apply_filters('newsletter_menu_' . $group, array());
14
- if (!$entries) {
15
- return;
16
- }
17
-
18
- foreach ($entries as &$entry) {
19
- echo '<li><a href="', $entry['url'], '">', $entry['label'];
20
- if (!empty($entry['description'])) {
21
- echo '<small>', $entry['description'], '</small>';
22
- }
23
- echo '</a></li>';
24
- }
25
- }
26
-
27
- // Check the status to show a warning if needed
28
- $status_options = Newsletter::instance()->get_options('status');
29
- $warning = false;
30
-
31
- $warning |= empty($status_options['mail']);
32
- ?>
33
-
34
- <div class="tnp-drowpdown" id="tnp-header">
35
- <a href="?page=newsletter_main_index"><img src="<?php echo plugins_url('newsletter'); ?>/admin/images/logo-red.png" class="tnp-header-logo" style="vertical-align: bottom;"></a>
36
- <ul>
37
- <li><a href="#"><i class="fas fa-users"></i> <?php _e('Subscribers', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
38
- <ul>
39
- <li>
40
- <a href="?page=newsletter_users_index"><i class="fas fa-search"></i> <?php _e('Search And Edit', 'newsletter') ?>
41
- <small><?php _e('Add, edit, search', 'newsletter') ?></small></a>
42
- </li>
43
-
44
- <li>
45
- <a href="?page=newsletter_profile_index"><i class="fas fa-user-circle"></i> <?php _e('Profile page', 'newsletter') ?>
46
- <small><?php _e('The subscriber personal profile editing panel', 'newsletter') ?></small></a>
47
- </li>
48
-
49
- <?php if (!class_exists('NewsletterImport')) { ?>
50
- <li>
51
- <a href="?page=newsletter_users_import"><i class="fas fa-upload"></i> <?php _e('Import', 'newsletter') ?>
52
- <small><?php _e('Import from external sources', 'newsletter') ?></small></a>
53
- </li>
54
- <?php } ?>
55
-
56
- <li>
57
- <a href="?page=newsletter_users_export"><i class="fas fa-download"></i> <?php _e('Export', 'newsletter') ?>
58
- <small><?php _e('Export your subscribers list', 'newsletter') ?></small></a>
59
- </li>
60
-
61
- <li>
62
- <a href="?page=newsletter_users_massive"><i class="fas fa-wrench"></i> <?php _e('Maintenance', 'newsletter') ?>
63
- <small><?php _e('Massive actions: change list, clean up, ...', 'newsletter') ?></small></a>
64
- </li>
65
-
66
- <li>
67
- <a href="?page=newsletter_users_statistics"><i class="fas fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?>
68
- <small><?php _e('All about your subscribers', 'newsletter') ?></small></a>
69
- </li>
70
-
71
- <?php newsletter_print_entries('subscribers') ?>
72
- </ul>
73
- </li>
74
- <li><a href="#"><i class="fas fa-list"></i> <?php _e('List Building', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
75
- <ul>
76
- <li>
77
- <a href="?page=newsletter_subscription_profile"><i class="fas fa-check-square"></i> <?php _e('Subscription Form Fields, Buttons, Labels', 'newsletter') ?>
78
- <small><?php _e('When and what data to collect', 'newsletter') ?></small></a>
79
- </li>
80
-
81
- <li>
82
- <a href="?page=newsletter_subscription_options"><i class="fas fa-sign-in-alt"></i> <?php _e('Subscription', 'newsletter') ?>
83
- <small><?php _e('The subscription process in detail', 'newsletter') ?></small></a>
84
- </li>
85
-
86
- <li>
87
- <a href="?page=newsletter_subscription_lists"><i class="fas fa-th-list"></i> <?php _e('Lists', 'newsletter') ?>
88
- <small><?php _e('Profile the subscribers for a better targeting', 'newsletter') ?></small></a>
89
- </li>
90
-
91
- <li>
92
- <a href="?page=newsletter_subscription_antibot"><i class="fas fa-lock"></i> <?php _e('Security', 'newsletter') ?>
93
- <small><?php _e('Spam subscriptions control', 'newsletter') ?></small></a>
94
- </li>
95
-
96
- <li>
97
- <a href="?page=newsletter_unsubscription_index"><i class="fas fa-sign-out-alt"></i> <?php _e('Unsubscription', 'newsletter') ?>
98
- <small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
99
- </li>
100
-
101
- <?php
102
- newsletter_print_entries('subscription');
103
- ?>
104
- </ul>
105
- </li>
106
-
107
- <li>
108
- <a href="#"><i class="fas fa-newspaper"></i> <?php _e('Newsletters', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
109
- <ul>
110
- <li>
111
- <a href="?page=newsletter_emails_composer"><i class="fas fa-plus"></i> <?php _e('Create newsletter', 'newsletter') ?>
112
- <small><?php _e('Start your new campaign', 'newsletter') ?></small></a>
113
- </li>
114
-
115
- <li>
116
- <a href="?page=newsletter_emails_index"><i class="fas fa-newspaper"></i> <?php _e('Newsletters', 'newsletter') ?>
117
- <small><?php _e('The classic "write & send" newsletters', 'newsletter') ?></small></a>
118
- </li>
119
-
120
- <li>
121
- <a href="<?php echo NewsletterStatistics::instance()->get_index_url() ?>"><i class="fas fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?>
122
- <small><?php _e('Tracking configuration and basic data', 'newsletter') ?></small></a>
123
- </li>
124
- <?php
125
- newsletter_print_entries('newsletters');
126
- ?>
127
- </ul>
128
- </li>
129
-
130
- <li>
131
- <a href="#"><i class="fas fa-cog"></i> <?php _e('Settings', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
132
- <ul>
133
- <?php if ($is_administrator) { ?>
134
- <li>
135
- <a href="?page=newsletter_main_main"><i class="fas fa-cogs"></i> <?php _e('General Settings', 'newsletter') ?>
136
- <small><?php _e('Delivery speed, sender details, ...', 'newsletter') ?></small></a>
137
- </li>
138
- <?php if (!class_exists('NewsletterSmtp')) { ?>
139
- <li>
140
- <a href="?page=newsletter_main_smtp"><i class="fas fa-server"></i> <?php _e('SMTP', 'newsletter') ?>
141
- <small><?php _e('External mail server', 'newsletter') ?></small>
142
- </a>
143
- </li>
144
- <?php } ?>
145
- <?php } ?>
146
-
147
- <li>
148
- <a href="?page=newsletter_main_info"><i class="fas fa-info"></i> <?php _e('Company Info', 'newsletter') ?>
149
- <small><?php _e('Social, address, logo and general info', 'newsletter') ?></small></a>
150
- </li>
151
-
152
- <li>
153
- <a href="?page=newsletter_subscription_template"><i class="fas fa-file-alt"></i> <?php _e('Messages Template', 'newsletter') ?>
154
- <small><?php _e('Change the look of your service emails', 'newsletter') ?></small></a>
155
- </li>
156
-
157
- <?php
158
- newsletter_print_entries('settings');
159
- ?>
160
- </ul>
161
- </li>
162
-
163
- <?php if ($is_administrator) { ?>
164
- <li>
165
- <a href="#"><i class="fas fa-thermometer"></i> <?php _e('System', 'newsletter') ?>
166
- <?php if ($warning) { ?>
167
- <i class="fas fa-exclamation-triangle" style="color: red;"></i>
168
- <?php } ?>
169
- </a>
170
- <ul>
171
- <li>
172
- <a href="<?php echo admin_url('site-health.php') ?> "><i class="fas fa-file"></i> <?php _e('Site health') ?>
173
- <small><?php _e('WP native site health checks', 'newsletter') ?></small></a>
174
- </li>
175
- <li>
176
- <a href="?page=newsletter_system_delivery"><i class="fas fa-file"></i> <?php _e('Delivery Diagnostic', 'newsletter') ?>
177
- <small><?php _e('Delivery analysis and test', 'newsletter') ?></small></a>
178
- </li>
179
- <li>
180
- <a href="?page=newsletter_system_scheduler"><i class="fas fa-robot"></i> <?php _e('Scheduler', 'newsletter') ?>
181
- <small><?php _e('WordPress background jobs', 'newsletter') ?></small></a>
182
- </li>
183
- <li>
184
- <a href="?page=newsletter_system_status"><i class="fas fa-file"></i> <?php _e('Status', 'newsletter') ?>
185
- <small><?php _e('Checks and parameters', 'newsletter') ?></small></a>
186
- </li>
187
-
188
- <li>
189
- <a href="?page=newsletter_system_logs"><i class="fas fa-file"></i> <?php _e('Logs', 'newsletter') ?>
190
- <small><?php _e('Plugin and addons logs', 'newsletter') ?></small></a>
191
- </li>
192
- </ul>
193
- </li>
194
- <?php } ?>
195
-
196
- <?php
197
- $license_data = Newsletter::instance()->get_license_data();
198
- $premium_url = 'https://www.thenewsletterplugin.com/premium?utm_source=header&utm_medium=link&utm_campaign=plugin&utm_content=' . urlencode($_GET['page']);
199
- ?>
200
-
201
- <?php if (empty($license_data)) { ?>
202
- <li class="tnp-professional-extensions-button"><a href="<?php echo $premium_url ?>" target="_blank">
203
- <i class="fas fa-trophy"></i> <?php _e('Get Professional Addons', 'newsletter') ?></a>
204
- </li>
205
- <?php } elseif (is_wp_error($license_data)) { ?>
206
- <li class="tnp-professional-extensions-button-red">
207
- <a href="?page=newsletter_main_main"><i class="fas fa-hand-paper" style="color: white"></i> <?php _e('Unable to check', 'newsletter') ?></a>
208
- </li>
209
-
210
- <?php } elseif ($license_data->expire == 0) { ?>
211
-
212
- <li class="tnp-professional-extensions-button"><a href="<?php echo $premium_url ?>" target="_blank">
213
- <i class="fas fa-trophy"></i> <?php _e('Get Professional Addons', 'newsletter') ?></a>
214
- </li>
215
-
216
- <?php } elseif ($license_data->expire < time()) { ?>
217
-
218
- <li class="tnp-professional-extensions-button-red">
219
- <a href="?page=newsletter_main_main"><i class="fas fa-hand-paper" style="color: white"></i> <?php _e('License expired', 'newsletter') ?></a>
220
- </li>
221
-
222
- <?php } elseif ($license_data->expire >= time()) { ?>
223
-
224
- <?php $p = class_exists('NewsletterExtensions') ? 'newsletter_extensions_index' : 'newsletter_main_extensions'; ?>
225
- <li class="tnp-professional-extensions-button">
226
- <a href="?page=<?php echo $p ?>"><i class="fas fa-check-square"></i> <?php _e('License active', 'newsletter') ?></a>
227
- </li>
228
-
229
- <?php } ?>
230
- </ul>
231
- </div>
232
-
233
- <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-shortcode'])) { ?>
234
- <?php
235
- // Check of Newsletter dedicated page
236
- if (!empty(Newsletter::instance()->options['page'])) {
237
- if (get_post_status(Newsletter::instance()->options['page']) === 'publish') {
238
- $content = get_post_field('post_content', Newsletter::instance()->options['page']);
239
- // With and without attributes
240
- if (strpos($content, '[newsletter]') === false && strpos($content, '[newsletter ') === false) {
241
- ?>
242
- <div class="tnp-notice">
243
- <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-shortcode' ?>" class="tnp-dismiss">&times;</a>
244
- The Newsletter dedicated page does not contain the [newsletter] shortcode. If you're using a visual composer it could be ok.
245
- <a href="<?php echo site_url('/wp-admin/post.php') ?>?post=<?php echo esc_attr(Newsletter::instance()->options['page']) ?>&action=edit"><strong>Edit the page</strong></a>.
246
-
247
- </div>
248
- <?php
249
- }
250
- }
251
- }
252
- ?>
253
- <?php } ?>
254
-
255
- <?php if (isset($_GET['debug']) || !isset($dismissed['rate']) && $user_count > 300) { ?>
256
- <div class="tnp-notice">
257
- <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=rate' ?>" class="tnp-dismiss">&times;</a>
258
-
259
- We never asked before and we're curious: <a href="http://wordpress.org/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
260
- (few seconds required - account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
261
-
262
- </div>
263
- <?php } ?>
264
-
265
- <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-page']) && empty(Newsletter::instance()->options['page'])) { ?>
266
- <div class="tnp-notice">
267
- <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-page' ?>" class="tnp-dismiss">&times;</a>
268
-
269
- You should create a blog page to show the subscription form and the subscription messages. Go to the
270
- <a href="?page=newsletter_main_main">general settings panel</a> to configure it.
271
-
272
- </div>
273
- <?php } ?>
274
-
275
- <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-subscribe']) && get_option('newsletter_install_time') && get_option('newsletter_install_time') < time() - 86400 * 15) { ?>
276
- <div class="tnp-notice">
277
- <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-subscribe' ?>" class="tnp-dismiss">&times;</a>
278
- If you want to be informed of important updates of Newsletter, you may want to subscribe to our newsletter<br>
279
- <form action="https://www.thenewsletterplugin.com/?na=s" target="_blank" method="post">
280
- <input type="hidden" value="plugin-header" name="nr">
281
- <input type="hidden" value="3" name="nl[]">
282
- <input type="hidden" value="single" name="optin">
283
- <input type="email" name="ne" value="<?php echo esc_attr(get_option('admin_email')) ?>">
284
- <input type="submit" value="<?php esc_attr_e('Subscribe', 'newsletter') ?>">
285
- </form>
286
- </div>
287
- <?php } ?>
288
-
289
- <?php
290
- if (!defined('NEWSLETTER_CRON_WARNINGS') || NEWSLETTER_CRON_WARNINGS) {
291
- $x = NewsletterSystem::instance()->get_job_status();
292
- if ($x !== NewsletterSystem::JOB_OK) {
293
- echo '<div class="tnpc-warning">The are issues with the delivery engine. Please <a href="?page=newsletter_main_scheduler">check them here</a>.</div>';
294
- }
295
- }
296
- ?>
297
-
298
- <?php
299
- if ($_GET['page'] !== 'newsletter_emails_edit') {
300
-
301
- $last_failed_newsletters = Newsletter::instance()->get_emails_by_field('status', TNP_Email::STATUS_ERROR);
302
-
303
- foreach ($last_failed_newsletters as $newsletter) {
304
- echo '<div class="tnpc-error">';
305
- printf(__('Newsletter "%s" stopped by fatal error.', 'newsletter'), esc_html($newsletter->subject));
306
- echo '&nbsp;';
307
- $c = new NewsletterControls();
308
- $c->btn_link('?page=newsletter_emails_edit&id=' . $newsletter->id, __('Check', 'newsletter'));
309
- echo '</div>';
310
- }
311
- }
312
- ?>
313
-
314
- <div id="tnp-notification">
315
- <?php
316
- if (isset($controls)) {
317
- $controls->show();
318
- $controls->messages = '';
319
- $controls->errors = '';
320
- }
321
- ?>
322
- </div>
323
-
324
-
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $current_user, $wpdb;
3
+
4
+ defined('ABSPATH') || exit;
5
+
6
+ $dismissed = get_option('newsletter_dismissed', []);
7
+
8
+ $user_count = Newsletter::instance()->get_user_count();
9
+
10
+ $is_administrator = current_user_can('administrator');
11
+
12
+ function newsletter_print_entries($group) {
13
+ $entries = apply_filters('newsletter_menu_' . $group, array());
14
+ if (!$entries) {
15
+ return;
16
+ }
17
+
18
+ foreach ($entries as &$entry) {
19
+ echo '<li><a href="', $entry['url'], '">', $entry['label'];
20
+ if (!empty($entry['description'])) {
21
+ echo '<small>', $entry['description'], '</small>';
22
+ }
23
+ echo '</a></li>';
24
+ }
25
+ }
26
+
27
+ // Check the status to show a warning if needed
28
+ $status_options = Newsletter::instance()->get_options('status');
29
+ $warning = false;
30
+
31
+ $warning |= empty($status_options['mail']);
32
+ ?>
33
+
34
+ <div class="tnp-drowpdown" id="tnp-header">
35
+ <a href="?page=newsletter_main_index"><img src="<?php echo plugins_url('newsletter'); ?>/admin/images/logo-red.png" class="tnp-header-logo" style="vertical-align: bottom;"></a>
36
+ <ul>
37
+ <li><a href="#"><i class="fas fa-users"></i> <?php _e('Subscribers', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
38
+ <ul>
39
+ <li>
40
+ <a href="?page=newsletter_users_index"><i class="fas fa-search"></i> <?php _e('Search And Edit', 'newsletter') ?>
41
+ <small><?php _e('Add, edit, search', 'newsletter') ?></small></a>
42
+ </li>
43
+
44
+ <li>
45
+ <a href="?page=newsletter_profile_index"><i class="fas fa-user-circle"></i> <?php _e('Profile page', 'newsletter') ?>
46
+ <small><?php _e('The subscriber personal profile editing panel', 'newsletter') ?></small></a>
47
+ </li>
48
+
49
+ <?php if (!class_exists('NewsletterImport')) { ?>
50
+ <li>
51
+ <a href="?page=newsletter_users_import"><i class="fas fa-upload"></i> <?php _e('Import', 'newsletter') ?>
52
+ <small><?php _e('Import from external sources', 'newsletter') ?></small></a>
53
+ </li>
54
+ <?php } ?>
55
+
56
+ <li>
57
+ <a href="?page=newsletter_users_export"><i class="fas fa-download"></i> <?php _e('Export', 'newsletter') ?>
58
+ <small><?php _e('Export your subscribers list', 'newsletter') ?></small></a>
59
+ </li>
60
+
61
+ <li>
62
+ <a href="?page=newsletter_users_massive"><i class="fas fa-wrench"></i> <?php _e('Maintenance', 'newsletter') ?>
63
+ <small><?php _e('Massive actions: change list, clean up, ...', 'newsletter') ?></small></a>
64
+ </li>
65
+
66
+ <li>
67
+ <a href="?page=newsletter_users_statistics"><i class="fas fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?>
68
+ <small><?php _e('All about your subscribers', 'newsletter') ?></small></a>
69
+ </li>
70
+
71
+ <?php newsletter_print_entries('subscribers') ?>
72
+ </ul>
73
+ </li>
74
+ <li><a href="#"><i class="fas fa-list"></i> <?php _e('List Building', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
75
+ <ul>
76
+ <li>
77
+ <a href="?page=newsletter_subscription_profile"><i class="fas fa-check-square"></i> <?php _e('Subscription Form Fields, Buttons, Labels', 'newsletter') ?>
78
+ <small><?php _e('When and what data to collect', 'newsletter') ?></small></a>
79
+ </li>
80
+
81
+ <li>
82
+ <a href="?page=newsletter_subscription_options"><i class="fas fa-sign-in-alt"></i> <?php _e('Subscription', 'newsletter') ?>
83
+ <small><?php _e('The subscription process in detail', 'newsletter') ?></small></a>
84
+ </li>
85
+
86
+ <li>
87
+ <a href="?page=newsletter_subscription_lists"><i class="fas fa-th-list"></i> <?php _e('Lists', 'newsletter') ?>
88
+ <small><?php _e('Profile the subscribers for a better targeting', 'newsletter') ?></small></a>
89
+ </li>
90
+
91
+ <li>
92
+ <a href="?page=newsletter_subscription_antibot"><i class="fas fa-lock"></i> <?php _e('Security', 'newsletter') ?>
93
+ <small><?php _e('Spam subscriptions control', 'newsletter') ?></small></a>
94
+ </li>
95
+
96
+ <li>
97
+ <a href="?page=newsletter_unsubscription_index"><i class="fas fa-sign-out-alt"></i> <?php _e('Unsubscription', 'newsletter') ?>
98
+ <small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
99
+ </li>
100
+
101
+ <?php
102
+ newsletter_print_entries('subscription');
103
+ ?>
104
+ </ul>
105
+ </li>
106
+
107
+ <li>
108
+ <a href="#"><i class="fas fa-newspaper"></i> <?php _e('Newsletters', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
109
+ <ul>
110
+ <li>
111
+ <a href="?page=newsletter_emails_composer"><i class="fas fa-plus"></i> <?php _e('Create newsletter', 'newsletter') ?>
112
+ <small><?php _e('Start your new campaign', 'newsletter') ?></small></a>
113
+ </li>
114
+
115
+ <li>
116
+ <a href="?page=newsletter_emails_index"><i class="fas fa-newspaper"></i> <?php _e('Newsletters', 'newsletter') ?>
117
+ <small><?php _e('The classic "write & send" newsletters', 'newsletter') ?></small></a>
118
+ </li>
119
+
120
+ <li>
121
+ <a href="<?php echo NewsletterStatistics::instance()->get_index_url() ?>"><i class="fas fa-chart-bar"></i> <?php _e('Statistics', 'newsletter') ?>
122
+ <small><?php _e('Tracking configuration and basic data', 'newsletter') ?></small></a>
123
+ </li>
124
+ <?php
125
+ newsletter_print_entries('newsletters');
126
+ ?>
127
+ </ul>
128
+ </li>
129
+
130
+ <li>
131
+ <a href="#"><i class="fas fa-cog"></i> <?php _e('Settings', 'newsletter') ?> <i class="fas fa-chevron-down"></i></a>
132
+ <ul>
133
+ <?php if ($is_administrator) { ?>
134
+ <li>
135
+ <a href="?page=newsletter_main_main"><i class="fas fa-cogs"></i> <?php _e('General Settings', 'newsletter') ?>
136
+ <small><?php _e('Delivery speed, sender details, ...', 'newsletter') ?></small></a>
137
+ </li>
138
+ <?php if (!class_exists('NewsletterSmtp')) { ?>
139
+ <li>
140
+ <a href="?page=newsletter_main_smtp"><i class="fas fa-server"></i> <?php _e('SMTP', 'newsletter') ?>
141
+ <small><?php _e('External mail server', 'newsletter') ?></small>
142
+ </a>
143
+ </li>
144
+ <?php } ?>
145
+ <?php } ?>
146
+
147
+ <li>
148
+ <a href="?page=newsletter_main_info"><i class="fas fa-info"></i> <?php _e('Company Info', 'newsletter') ?>
149
+ <small><?php _e('Social, address, logo and general info', 'newsletter') ?></small></a>
150
+ </li>
151
+
152
+ <li>
153
+ <a href="?page=newsletter_subscription_template"><i class="fas fa-file-alt"></i> <?php _e('Messages Template', 'newsletter') ?>
154
+ <small><?php _e('Change the look of your service emails', 'newsletter') ?></small></a>
155
+ </li>
156
+
157
+ <?php
158
+ newsletter_print_entries('settings');
159
+ ?>
160
+ </ul>
161
+ </li>
162
+
163
+ <?php if ($is_administrator) { ?>
164
+ <li>
165
+ <a href="#"><i class="fas fa-thermometer"></i> <?php _e('System', 'newsletter') ?>
166
+ <?php if ($warning) { ?>
167
+ <i class="fas fa-exclamation-triangle" style="color: red;"></i>
168
+ <?php } ?>
169
+ </a>
170
+ <ul>
171
+ <li>
172
+ <a href="<?php echo admin_url('site-health.php') ?> "><i class="fas fa-file"></i> <?php _e('Site health') ?>
173
+ <small><?php _e('WP native site health checks', 'newsletter') ?></small></a>
174
+ </li>
175
+ <li>
176
+ <a href="?page=newsletter_system_delivery"><i class="fas fa-file"></i> <?php _e('Delivery Diagnostic', 'newsletter') ?>
177
+ <small><?php _e('Delivery analysis and test', 'newsletter') ?></small></a>
178
+ </li>
179
+ <li>
180
+ <a href="?page=newsletter_system_scheduler"><i class="fas fa-robot"></i> <?php _e('Scheduler', 'newsletter') ?>
181
+ <small><?php _e('WordPress background jobs', 'newsletter') ?></small></a>
182
+ </li>
183
+ <li>
184
+ <a href="?page=newsletter_system_status"><i class="fas fa-file"></i> <?php _e('Status', 'newsletter') ?>
185
+ <small><?php _e('Checks and parameters', 'newsletter') ?></small></a>
186
+ </li>
187
+
188
+ <li>
189
+ <a href="?page=newsletter_system_logs"><i class="fas fa-file"></i> <?php _e('Logs', 'newsletter') ?>
190
+ <small><?php _e('Plugin and addons logs', 'newsletter') ?></small></a>
191
+ </li>
192
+ </ul>
193
+ </li>
194
+ <?php } ?>
195
+
196
+ <?php
197
+ $license_data = Newsletter::instance()->get_license_data();
198
+ $premium_url = 'https://www.thenewsletterplugin.com/premium?utm_source=header&utm_medium=link&utm_campaign=plugin&utm_content=' . urlencode($_GET['page']);
199
+ ?>
200
+
201
+ <?php if (empty($license_data)) { ?>
202
+ <?php if (time() < 1638226799) { ?>
203
+ <li class="tnp-professional-extensions-button" style="background-color: #000; color: #fff; border-color: #FF5F65!important; border-width: 2px !important;"><a href="https://www.thenewsletterplugin.com/premium?utm_source=header&utm_medium=link&utm_campaign=black-friday" target="_blank">
204
+ <i class="fas fa-trophy"></i> BLACK FRIDAY IS LIVE</a>
205
+ </li>
206
+ <?php } else { ?>
207
+ <li class="tnp-professional-extensions-button"><a href="<?php echo $premium_url ?>" target="_blank">
208
+ <i class="fas fa-trophy"></i> <?php _e('Get Professional Addons', 'newsletter') ?></a>
209
+ </li>
210
+ <?php } ?>
211
+ <?php } elseif (is_wp_error($license_data)) { ?>
212
+ <li class="tnp-professional-extensions-button-red">
213
+ <a href="?page=newsletter_main_main"><i class="fas fa-hand-paper" style="color: white"></i> <?php _e('Unable to check', 'newsletter') ?></a>
214
+ </li>
215
+
216
+ <?php } elseif ($license_data->expire == 0) { ?>
217
+ <?php if (time() < 1638226799) { ?>
218
+ <li class="tnp-professional-extensions-button" style="background-color: #000; color: #fff; border-color: #FF5F65!important; border-width: 2px !important;"><a href="https://www.thenewsletterplugin.com/premium?utm_source=header&utm_medium=link&utm_campaign=black-friday" target="_blank">
219
+ <i class="fas fa-trophy"></i> BLACK FRIDAY IS LIVE</a>
220
+ </li>
221
+ <?php } else { ?>
222
+ <li class="tnp-professional-extensions-button"><a href="<?php echo $premium_url ?>" target="_blank">
223
+ <i class="fas fa-trophy"></i> <?php _e('Get Professional Addons', 'newsletter') ?></a>
224
+ </li>
225
+ <?php } ?>
226
+
227
+ <?php } elseif ($license_data->expire < time()) { ?>
228
+
229
+ <li class="tnp-professional-extensions-button-red">
230
+ <a href="?page=newsletter_main_main"><i class="fas fa-hand-paper" style="color: white"></i> <?php _e('License expired', 'newsletter') ?></a>
231
+ </li>
232
+
233
+ <?php } elseif ($license_data->expire >= time()) { ?>
234
+
235
+ <?php $p = class_exists('NewsletterExtensions') ? 'newsletter_extensions_index' : 'newsletter_main_extensions'; ?>
236
+ <li class="tnp-professional-extensions-button">
237
+ <a href="?page=<?php echo $p ?>"><i class="fas fa-check-square"></i> <?php _e('License active', 'newsletter') ?></a>
238
+ </li>
239
+
240
+ <?php } ?>
241
+ </ul>
242
+ </div>
243
+
244
+ <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-shortcode'])) { ?>
245
+ <?php
246
+ // Check of Newsletter dedicated page
247
+ if (!empty(Newsletter::instance()->options['page'])) {
248
+ if (get_post_status(Newsletter::instance()->options['page']) === 'publish') {
249
+ $content = get_post_field('post_content', Newsletter::instance()->options['page']);
250
+ // With and without attributes
251
+ if (strpos($content, '[newsletter]') === false && strpos($content, '[newsletter ') === false) {
252
+ ?>
253
+ <div class="tnp-notice">
254
+ <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-shortcode' ?>" class="tnp-dismiss">&times;</a>
255
+ The Newsletter dedicated page does not contain the [newsletter] shortcode. If you're using a visual composer it could be ok.
256
+ <a href="<?php echo site_url('/wp-admin/post.php') ?>?post=<?php echo esc_attr(Newsletter::instance()->options['page']) ?>&action=edit"><strong>Edit the page</strong></a>.
257
+
258
+ </div>
259
+ <?php
260
+ }
261
+ }
262
+ }
263
+ ?>
264
+ <?php } ?>
265
+
266
+ <?php if (isset($_GET['debug']) || !isset($dismissed['rate']) && $user_count > 300) { ?>
267
+ <div class="tnp-notice">
268
+ <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=rate' ?>" class="tnp-dismiss">&times;</a>
269
+
270
+ We never asked before and we're curious: <a href="http://wordpress.org/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
271
+ (few seconds required - account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
272
+
273
+ </div>
274
+ <?php } ?>
275
+
276
+ <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-page']) && empty(Newsletter::instance()->options['page'])) { ?>
277
+ <div class="tnp-notice">
278
+ <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-page' ?>" class="tnp-dismiss">&times;</a>
279
+
280
+ You should create a blog page to show the subscription form and the subscription messages. Go to the
281
+ <a href="?page=newsletter_main_main">general settings panel</a> to configure it.
282
+
283
+ </div>
284
+ <?php } ?>
285
+
286
+ <?php if (isset($_GET['debug']) || !isset($dismissed['newsletter-subscribe']) && get_option('newsletter_install_time') && get_option('newsletter_install_time') < time() - 86400 * 15) { ?>
287
+ <div class="tnp-notice">
288
+ <a href="<?php echo $_SERVER['REQUEST_URI'] . '&noheader=1&dismiss=newsletter-subscribe' ?>" class="tnp-dismiss">&times;</a>
289
+ If you want to be informed of important updates of Newsletter, you may want to subscribe to our newsletter<br>
290
+ <form action="https://www.thenewsletterplugin.com/?na=s" target="_blank" method="post">
291
+ <input type="hidden" value="plugin-header" name="nr">
292
+ <input type="hidden" value="3" name="nl[]">
293
+ <input type="hidden" value="single" name="optin">
294
+ <input type="email" name="ne" value="<?php echo esc_attr(get_option('admin_email')) ?>">
295
+ <input type="submit" value="<?php esc_attr_e('Subscribe', 'newsletter') ?>">
296
+ </form>
297
+ </div>
298
+ <?php } ?>
299
+
300
+ <?php
301
+ if (!defined('NEWSLETTER_CRON_WARNINGS') || NEWSLETTER_CRON_WARNINGS) {
302
+ $x = NewsletterSystem::instance()->get_job_status();
303
+ if ($x !== NewsletterSystem::JOB_OK) {
304
+ echo '<div class="tnpc-warning">The are issues with the delivery engine. Please <a href="?page=newsletter_main_scheduler">check them here</a>.</div>';
305
+ }
306
+ }
307
+ ?>
308
+
309
+ <?php
310
+ if ($_GET['page'] !== 'newsletter_emails_edit') {
311
+
312
+ $last_failed_newsletters = Newsletter::instance()->get_emails_by_field('status', TNP_Email::STATUS_ERROR);
313
+
314
+ foreach ($last_failed_newsletters as $newsletter) {
315
+ echo '<div class="tnpc-error">';
316
+ printf(__('Newsletter "%s" stopped by fatal error.', 'newsletter'), esc_html($newsletter->subject));
317
+ echo '&nbsp;';
318
+ $c = new NewsletterControls();
319
+ $c->btn_link('?page=newsletter_emails_edit&id=' . $newsletter->id, __('Check', 'newsletter'));
320
+ echo '</div>';
321
+ }
322
+ }
323
+ ?>
324
+
325
+ <div id="tnp-notification">
326
+ <?php
327
+ if (isset($controls)) {
328
+ $controls->show();
329
+ $controls->messages = '';
330
+ $controls->errors = '';
331
+ }
332
+ ?>
333
+ </div>
334
+
335
+
users/index.php CHANGED
@@ -1,251 +1,251 @@
1
- <?php
2
- /* @var $this NewsletterUsers */
3
- defined('ABSPATH') || exit;
4
-
5
- require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
-
7
- $controls = new NewsletterControls();
8
-
9
- $options = $controls->data;
10
- $options_profile = get_option('newsletter_profile');
11
- $options_main = get_option('newsletter_main');
12
-
13
- // Move to base zero
14
- if ($controls->is_action()) {
15
- if ($controls->is_action('reset')) {
16
- $controls->data = array();
17
- } else {
18
- $controls->data['search_page'] = (int) $controls->data['search_page'] - 1;
19
- }
20
- $this->save_options($controls->data, 'search');
21
- } else {
22
- $controls->data = $this->get_options('search');
23
- if (empty($controls->data['search_page']))
24
- $controls->data['search_page'] = 0;
25
- }
26
-
27
- if ($controls->is_action('resend')) {
28
- $user = $this->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 = $this->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('delete')) {
40
- $this->delete_user($controls->button_data);
41
- unset($controls->data['subscriber_id']);
42
- }
43
-
44
- if ($controls->is_action('delete_selected')) {
45
- $r = Newsletter::instance()->delete_user($_POST['ids']);
46
- $controls->messages .= $r . ' user(s) deleted';
47
- }
48
-
49
- // We build the query condition
50
- $where = 'where 1=1';
51
- $query_args = array();
52
- $text = trim($controls->get_value('search_text'));
53
- if ($text) {
54
- $query_args[] = '%' . $text . '%';
55
- $query_args[] = '%' . $text . '%';
56
- $query_args[] = '%' . $text . '%';
57
- $where .= " and (email like %s or name like %s or surname like %s)";
58
- }
59
-
60
- if (!empty($controls->data['search_status'])) {
61
- if ($controls->data['search_status'] == 'T') {
62
- $where .= " and test=1";
63
- } else {
64
- $query_args[] = $controls->data['search_status'];
65
- $where .= " and status=%s";
66
- }
67
- }
68
-
69
- if (!empty($controls->data['search_list'])) {
70
- $where .= " and list_" . ((int) $controls->data['search_list']) . "=1";
71
- }
72
-
73
- $filtered = $where != 'where 1=1';
74
-
75
- // Total items, total pages
76
- $items_per_page = 20;
77
- if (!empty($query_args)) {
78
- $where = $wpdb->prepare($where, $query_args);
79
- }
80
- $count = Newsletter::instance()->store->get_count(NEWSLETTER_USERS_TABLE, $where);
81
- $last_page = floor($count / $items_per_page) - ($count % $items_per_page == 0 ? 1 : 0);
82
- if ($last_page < 0)
83
- $last_page = 0;
84
-
85
- if ($controls->is_action('last')) {
86
- $controls->data['search_page'] = $last_page;
87
- }
88
- if ($controls->is_action('first')) {
89
- $controls->data['search_page'] = 0;
90
- }
91
- if ($controls->is_action('next')) {
92
- $controls->data['search_page'] = (int) $controls->data['search_page'] + 1;
93
- }
94
- if ($controls->is_action('prev')) {
95
- $controls->data['search_page'] = (int) $controls->data['search_page'] - 1;
96
- }
97
- if ($controls->is_action('search')) {
98
- $controls->data['search_page'] = 0;
99
- }
100
-
101
- // Eventually fix the page
102
- if (!isset($controls->data['search_page']) || $controls->data['search_page'] < 0)
103
- $controls->data['search_page'] = 0;
104
- if ($controls->data['search_page'] > $last_page)
105
- $controls->data['search_page'] = $last_page;
106
-
107
- $query = "select * from " . NEWSLETTER_USERS_TABLE . ' ' . $where . " order by id desc";
108
- $query .= " limit " . ($controls->data['search_page'] * $items_per_page) . "," . $items_per_page;
109
- $list = $wpdb->get_results($query);
110
-
111
- // Move to base 1
112
- $controls->data['search_page'] ++;
113
- ?>
114
-
115
- <div class="wrap tnp-users tnp-users-index" id="tnp-wrap">
116
-
117
- <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
118
-
119
- <div id="tnp-heading">
120
-
121
- <h2><?php _e('Subscribers', 'newsletter') ?>
122
- <a class="tnp-btn-h1" href="?page=newsletter_users_new"><?php _e('Add a subscriber', 'newsletter') ?></a>
123
- </h2>
124
-
125
- <p>
126
- See the <a href="admin.php?page=newsletter_users_massive">maintenance panel</a> to move subscribers between list, massively delete and so on.
127
- </p>
128
-
129
- </div>
130
-
131
- <div id="tnp-body">
132
-
133
- <form id="channel" method="post" action="">
134
- <?php $controls->init(); ?>
135
-
136
- <div class="tnp-subscribers-search">
137
- <?php $controls->text('search_text', 45, __('Search text', 'newsletter')); ?>
138
-
139
- <?php _e('filter by', 'newsletter') ?>:
140
- <?php $controls->select('search_status', array('' => 'Any status', 'T' => 'Test subscribers', 'C' => 'Confirmed', 'S' => 'Not confirmed', 'U' => 'Unsubscribed', 'B' => 'Bounced')); ?>
141
- <?php $controls->lists_select('search_list', '-'); ?>
142
-
143
- <?php $controls->button('search', __('Search', 'newsletter')); ?>
144
- <?php if ($where != "where 1=1") { ?>
145
- <?php $controls->button('reset', __('Reset Filters', 'newsletter')); ?>
146
- <?php } ?>
147
- <br>
148
- <?php $controls->checkbox('show_preferences', __('Show lists', 'newsletter')); ?>
149
- </div>
150
-
151
- <?php if ($filtered) { ?>
152
- <p><?php _e('The list below is filtered.', 'newsletter') ?></p>
153
- <?php } ?>
154
-
155
- <div class="tnp-paginator">
156
-
157
- <?php $controls->button('first', '«'); ?>
158
- <?php $controls->button('prev', '‹'); ?>
159
- <?php $controls->text('search_page', 3); ?> of <?php echo $last_page + 1 ?> <?php $controls->button('go', __('Go', 'newsletter')); ?>
160
- <?php $controls->button('next', '›'); ?>
161
- <?php $controls->button('last', '»'); ?>
162
-
163
- <?php echo $count ?> <?php _e('subscriber(s) found', 'newsletter') ?>
164
-
165
- <?php $controls->button_confirm('delete_selected', __('Delete selected', 'newsletter')); ?>
166
-
167
- </div>
168
-
169
- <table class="widefat">
170
- <thead>
171
- <tr>
172
- <td class="check-column"><input type="checkbox" onchange="jQuery('input.tnp-selector').prop('checked', this.checked)"></th>
173
- <th>Id</th>
174
- <th>Email</th>
175
- <th><?php _e('Name', 'newsletter') ?></th>
176
- <th><?php _e('Status', 'newsletter') ?></th>
177
- <?php if (isset($options['show_preferences']) && $options['show_preferences'] == 1) { ?>
178
- <th><?php _e('Lists', 'newsletter') ?></th>
179
- <?php } ?>
180
- <th>&nbsp;</th>
181
-
182
- <th>&nbsp;</th>
183
- </tr>
184
- </thead>
185
- <?php $i = 0; ?>
186
- <?php foreach ($list as $s) { ?>
187
- <tr>
188
- <th scope="row" class="check-column" style="vertical-align: middle"><input class="tnp-selector" type="checkbox" name="ids[]" value="<?php echo $s->id; ?>"/></td>
189
- <td>
190
- <?php echo $s->id; ?>
191
- </td>
192
-
193
- <td>
194
- <?php echo esc_html($s->email); ?>
195
- </td>
196
-
197
- <td>
198
- <?php echo esc_html($s->name); ?> <?php echo esc_html($s->surname); ?>
199
- </td>
200
-
201
- <td>
202
- <small>
203
- <?php echo $this->get_user_status_label($s, true) ?>
204
- </small>
205
- </td>
206
-
207
- <?php if (isset($options['show_preferences']) && $options['show_preferences'] == 1) { ?>
208
- <td>
209
- <small>
210
- <?php
211
- $lists = $this->get_lists();
212
- foreach ($lists as $item) {
213
- $l = 'list_' . $item->id;
214
- if ($s->$l == 1)
215
- echo esc_html($item->name) . '<br>';
216
- }
217
- ?>
218
- </small>
219
- </td>
220
- <?php } ?>
221
-
222
- <td>
223
- <?php $controls->button_icon_edit($this->get_admin_page_url('edit') . '&amp;id=' . $s->id)?>
224
- </td>
225
-
226
- <td style="white-space: nowrap">
227
- <?php $controls->button_icon_delete($s->id); ?>
228
-
229
- <?php if ($s->status == "C") { ?>
230
- <?php $controls->button_icon('resend_welcome', 'fa-redo', __('Resend welcome', 'newsletter'), $s->id, true); ?>
231
- <?php } else { ?>
232
- <?php $controls->button_icon('resend', 'fa-redo', __('Resend activation', 'newsletter'), $s->id, true); ?>
233
- <?php } ?>
234
- </td>
235
-
236
- </tr>
237
- <?php } ?>
238
- </table>
239
- <div class="tnp-paginator">
240
-
241
- <?php $controls->button('first', '«'); ?>
242
- <?php $controls->button('prev', '‹'); ?>
243
- <?php $controls->button('next', '›'); ?>
244
- <?php $controls->button('last', '»'); ?>
245
- </div>
246
- </form>
247
- </div>
248
-
249
- <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
250
-
251
- </div>
1
+ <?php
2
+ /* @var $this NewsletterUsers */
3
+ defined('ABSPATH') || exit;
4
+
5
+ require_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
+
7
+ $controls = new NewsletterControls();
8
+
9
+ $options = $controls->data;
10
+ $options_profile = get_option('newsletter_profile');
11
+ $options_main = get_option('newsletter_main');
12
+
13
+ // Move to base zero
14
+ if ($controls->is_action()) {
15
+ if ($controls->is_action('reset')) {
16
+ $controls->data = array();
17
+ } else {
18
+ $controls->data['search_page'] = (int) $controls->data['search_page'] - 1;
19
+ }
20
+ $this->save_options($controls->data, 'search');
21
+ } else {
22
+ $controls->data = $this->get_options('search');
23
+ if (empty($controls->data['search_page']))
24
+ $controls->data['search_page'] = 0;
25
+ }
26
+
27
+ if ($controls->is_action('resend')) {
28
+ $user = $this->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 = $this->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('delete')) {
40
+ $this->delete_user($controls->button_data);
41
+ unset($controls->data['subscriber_id']);
42
+ }
43
+
44
+ if ($controls->is_action('delete_selected')) {
45
+ $r = Newsletter::instance()->delete_user($_POST['ids']);
46
+ $controls->messages .= $r . ' user(s) deleted';
47
+ }
48
+
49
+ // We build the query condition
50
+ $where = 'where 1=1';
51
+ $query_args = array();
52
+ $text = trim($controls->get_value('search_text'));
53
+ if ($text) {
54
+ $query_args[] = '%' . $text . '%';
55
+ $query_args[] = '%' . $text . '%';
56
+ $query_args[] = '%' . $text . '%';
57
+ $where .= " and (email like %s or name like %s or surname like %s)";
58
+ }
59
+
60
+ if (!empty($controls->data['search_status'])) {
61
+ if ($controls->data['search_status'] == 'T') {
62
+ $where .= " and test=1";
63
+ } else {
64
+ $query_args[] = $controls->data['search_status'];
65
+ $where .= " and status=%s";
66
+ }
67
+ }
68
+
69
+ if (!empty($controls->data['search_list'])) {
70
+ $where .= " and list_" . ((int) $controls->data['search_list']) . "=1";
71
+ }
72
+
73
+ $filtered = $where != 'where 1=1';
74
+
75
+ // Total items, total pages
76
+ $items_per_page = 20;
77
+ if (!empty($query_args)) {
78
+ $where = $wpdb->prepare($where, $query_args);
79
+ }
80
+ $count = Newsletter::instance()->store->get_count(NEWSLETTER_USERS_TABLE, $where);
81
+ $last_page = floor($count / $items_per_page) - ($count % $items_per_page == 0 ? 1 : 0);
82
+ if ($last_page < 0)
83
+ $last_page = 0;
84
+
85
+ if ($controls->is_action('last')) {
86
+ $controls->data['search_page'] = $last_page;
87
+ }
88
+ if ($controls->is_action('first')) {
89
+ $controls->data['search_page'] = 0;
90
+ }
91
+ if ($controls->is_action('next')) {
92
+ $controls->data['search_page'] = (int) $controls->data['search_page'] + 1;
93
+ }
94
+ if ($controls->is_action('prev')) {
95
+ $controls->data['search_page'] = (int) $controls->data['search_page'] - 1;
96
+ }
97
+ if ($controls->is_action('search')) {
98
+ $controls->data['search_page'] = 0;
99
+ }
100
+
101
+ // Eventually fix the page
102
+ if (!isset($controls->data['search_page']) || $controls->data['search_page'] < 0)
103
+ $controls->data['search_page'] = 0;
104
+ if ($controls->data['search_page'] > $last_page)
105
+ $controls->data['search_page'] = $last_page;
106
+
107
+ $query = "select * from " . NEWSLETTER_USERS_TABLE . ' ' . $where . " order by id desc";
108
+ $query .= " limit " . ($controls->data['search_page'] * $items_per_page) . "," . $items_per_page;
109
+ $list = $wpdb->get_results($query);
110
+
111
+ // Move to base 1
112
+ $controls->data['search_page'] ++;
113
+ ?>
114
+
115
+ <div class="wrap tnp-users tnp-users-index" id="tnp-wrap">
116
+
117
+ <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
118
+
119
+ <div id="tnp-heading">
120
+
121
+ <h2><?php _e('Subscribers', 'newsletter') ?>
122
+ <a class="tnp-btn-h1" href="?page=newsletter_users_new"><?php _e('Add a subscriber', 'newsletter') ?></a>
123
+ </h2>
124
+
125
+ <p>
126
+ See the <a href="admin.php?page=newsletter_users_massive">maintenance panel</a> to move subscribers between list, massively delete and so on.
127
+ </p>
128
+
129
+ </div>
130
+
131
+ <div id="tnp-body">
132
+
133
+ <form id="channel" method="post" action="">
134
+ <?php $controls->init(); ?>
135
+
136
+ <div class="tnp-subscribers-search">
137
+ <?php $controls->text('search_text', 45, __('Search text', 'newsletter')); ?>
138
+
139
+ <?php _e('filter by', 'newsletter') ?>:
140
+ <?php $controls->select('search_status', ['' => 'Any status', 'T' => 'Test subscribers', 'C' => 'Confirmed', 'S' => 'Not confirmed', 'U' => 'Unsubscribed', 'B' => 'Bounced', 'P'=> TNP_User::get_status_label('P')]); ?>
141
+ <?php $controls->lists_select('search_list', '-'); ?>
142
+
143
+ <?php $controls->button('search', __('Search', 'newsletter')); ?>
144
+ <?php if ($where != "where 1=1") { ?>
145
+ <?php $controls->button('reset', __('Reset Filters', 'newsletter')); ?>
146
+ <?php } ?>
147
+ <br>
148
+ <?php $controls->checkbox('show_preferences', __('Show lists', 'newsletter')); ?>
149
+ </div>
150
+
151
+ <?php if ($filtered) { ?>
152
+ <p><?php _e('The list below is filtered.', 'newsletter') ?></p>
153
+ <?php } ?>
154
+
155
+ <div class="tnp-paginator">
156
+
157
+ <?php $controls->button('first', '«'); ?>
158
+ <?php $controls->button('prev', '‹'); ?>
159
+ <?php $controls->text('search_page', 3); ?> of <?php echo $last_page + 1 ?> <?php $controls->button('go', __('Go', 'newsletter')); ?>
160
+ <?php $controls->button('next', '›'); ?>
161
+ <?php $controls->button('last', '»'); ?>
162
+
163
+ <?php echo $count ?> <?php _e('subscriber(s) found', 'newsletter') ?>
164
+
165
+ <?php $controls->button_confirm('delete_selected', __('Delete selected', 'newsletter')); ?>
166
+
167
+ </div>
168
+
169
+ <table class="widefat">
170
+ <thead>
171
+ <tr>
172
+ <td class="check-column"><input type="checkbox" onchange="jQuery('input.tnp-selector').prop('checked', this.checked)"></th>
173
+ <th>Id</th>
174
+ <th>Email</th>
175
+ <th><?php _e('Name', 'newsletter') ?></th>
176
+ <th><?php _e('Status', 'newsletter') ?></th>
177
+ <?php if (isset($options['show_preferences']) && $options['show_preferences'] == 1) { ?>
178
+ <th><?php _e('Lists', 'newsletter') ?></th>
179
+ <?php } ?>
180
+ <th>&nbsp;</th>
181
+
182
+ <th>&nbsp;</th>
183
+ </tr>
184
+ </thead>
185
+ <?php $i = 0; ?>
186
+ <?php foreach ($list as $s) { ?>
187
+ <tr>
188
+ <th scope="row" class="check-column" style="vertical-align: middle"><input class="tnp-selector" type="checkbox" name="ids[]" value="<?php echo $s->id; ?>"/></td>
189
+ <td>
190
+ <?php echo $s->id; ?>
191
+ </td>
192
+
193
+ <td>
194
+ <?php echo esc_html($s->email); ?>
195
+ </td>
196
+
197
+ <td>
198
+ <?php echo esc_html($s->name); ?> <?php echo esc_html($s->surname); ?>
199
+ </td>
200
+
201
+ <td>
202
+ <small>
203
+ <?php echo $this->get_user_status_label($s, true) ?>
204
+ </small>
205
+ </td>
206
+
207
+ <?php if (isset($options['show_preferences']) && $options['show_preferences'] == 1) { ?>
208
+ <td>
209
+ <small>
210
+ <?php
211
+ $lists = $this->get_lists();
212
+ foreach ($lists as $item) {
213
+ $l = 'list_' . $item->id;
214
+ if ($s->$l == 1)
215
+ echo esc_html($item->name) . '<br>';
216
+ }
217
+ ?>
218
+ </small>
219
+ </td>
220
+ <?php } ?>
221
+
222
+ <td>
223
+ <?php $controls->button_icon_edit($this->get_admin_page_url('edit') . '&amp;id=' . $s->id)?>
224
+ </td>
225
+
226
+ <td style="white-space: nowrap">
227
+ <?php $controls->button_icon_delete($s->id); ?>
228
+
229
+ <?php if ($s->status == "C") { ?>
230
+ <?php $controls->button_icon('resend_welcome', 'fa-redo', __('Resend welcome', 'newsletter'), $s->id, true); ?>
231
+ <?php } else { ?>
232
+ <?php $controls->button_icon('resend', 'fa-redo', __('Resend activation', 'newsletter'), $s->id, true); ?>
233
+ <?php } ?>
234
+ </td>
235
+
236
+ </tr>
237
+ <?php } ?>
238
+ </table>
239
+ <div class="tnp-paginator">
240
+
241
+ <?php $controls->button('first', '«'); ?>
242
+ <?php $controls->button('prev', '‹'); ?>
243
+ <?php $controls->button('next', '›'); ?>
244
+ <?php $controls->button('last', '»'); ?>
245
+ </div>
246
+ </form>
247
+ </div>
248
+
249
+ <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
250
+
251
+ </div>