Version Description
=
- "ncu" parameter can be used for alternative welcome page as well, not only confirmation, when single opt in is selected
- Removed the old "email alternative" to create custom subscription messages templates (has no effects)
- Added the antiflood system
=
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 5.1.0 |
Comparing to | |
See all releases |
Code changes from version 5.0.9 to 5.1.0
- includes/controls.php +4 -0
- includes/module.php +20 -15
- plugin.php +2 -2
- readme.txt +9 -2
- statistics/statistics.php +1 -1
- subscription/languages/en_US.php +3 -6
- subscription/options.php +16 -0
- subscription/subscription.php +49 -15
- tnp-header.php +1 -4
- users/users.php +2 -1
includes/controls.php
CHANGED
@@ -1367,5 +1367,9 @@ class NewsletterControls {
|
|
1367 |
}
|
1368 |
return $buffer;
|
1369 |
}
|
|
|
|
|
|
|
|
|
1370 |
|
1371 |
}
|
1367 |
}
|
1368 |
return $buffer;
|
1369 |
}
|
1370 |
+
|
1371 |
+
static function help($url, $label='') {
|
1372 |
+
echo '<a href="', $url, '" target="_blank" title="', esc_attr($label), '"><i class="fa fa-question-circle"></i></a>';
|
1373 |
+
}
|
1374 |
|
1375 |
}
|
includes/module.php
CHANGED
@@ -302,8 +302,10 @@ class NewsletterModule {
|
|
302 |
*/
|
303 |
static function normalize_email($email) {
|
304 |
$email = strtolower(trim($email));
|
305 |
-
if (!is_email($email))
|
306 |
return null;
|
|
|
|
|
307 |
return $email;
|
308 |
}
|
309 |
|
@@ -315,26 +317,33 @@ class NewsletterModule {
|
|
315 |
|
316 |
static function normalize_sex($sex) {
|
317 |
$sex = trim(strtolower($sex));
|
318 |
-
if ($sex != 'f' && $sex != 'm')
|
319 |
$sex = 'n';
|
|
|
320 |
return $sex;
|
321 |
}
|
322 |
|
323 |
static function is_email($email, $empty_ok = false) {
|
324 |
$email = strtolower(trim($email));
|
325 |
-
|
326 |
-
|
|
|
|
|
327 |
|
328 |
-
if (!is_email($email))
|
329 |
return false;
|
|
|
330 |
|
331 |
// TODO: To be moved on the subscription module and make configurable
|
332 |
-
if (strpos($email, 'mailinator.com') !== false)
|
333 |
return false;
|
334 |
-
|
|
|
335 |
return false;
|
336 |
-
|
|
|
337 |
return false;
|
|
|
338 |
return true;
|
339 |
}
|
340 |
|
@@ -466,11 +475,6 @@ class NewsletterModule {
|
|
466 |
}
|
467 |
}
|
468 |
|
469 |
-
/** Returns true if the named extension is installed. */
|
470 |
-
static function extension_exists($name) {
|
471 |
-
return is_file(WP_CONTENT_DIR . "/extensions/newsletter/$name/$name.php");
|
472 |
-
}
|
473 |
-
|
474 |
/**
|
475 |
* Cleans up a text containing url tags with appended the absolute URL (due to
|
476 |
* the editor behavior) moving back them to the simple form.
|
@@ -688,10 +692,11 @@ class NewsletterModule {
|
|
688 |
global $wpdb;
|
689 |
|
690 |
// To simplify the reaload of a user passing the user it self.
|
691 |
-
if (is_object($id_or_email))
|
692 |
$id_or_email = $id_or_email->id;
|
693 |
-
else if (is_array($id_or_email))
|
694 |
$id_or_email = $id_or_email['id'];
|
|
|
695 |
|
696 |
$id_or_email = strtolower(trim($id_or_email));
|
697 |
|
302 |
*/
|
303 |
static function normalize_email($email) {
|
304 |
$email = strtolower(trim($email));
|
305 |
+
if (!is_email($email)) {
|
306 |
return null;
|
307 |
+
}
|
308 |
+
$email = apply_filters('newsletter_normalize_email', $email);
|
309 |
return $email;
|
310 |
}
|
311 |
|
317 |
|
318 |
static function normalize_sex($sex) {
|
319 |
$sex = trim(strtolower($sex));
|
320 |
+
if ($sex != 'f' && $sex != 'm') {
|
321 |
$sex = 'n';
|
322 |
+
}
|
323 |
return $sex;
|
324 |
}
|
325 |
|
326 |
static function is_email($email, $empty_ok = false) {
|
327 |
$email = strtolower(trim($email));
|
328 |
+
|
329 |
+
if ($email = '') {
|
330 |
+
return $empty_ok;
|
331 |
+
}
|
332 |
|
333 |
+
if (!is_email($email)) {
|
334 |
return false;
|
335 |
+
}
|
336 |
|
337 |
// TODO: To be moved on the subscription module and make configurable
|
338 |
+
if (strpos($email, 'mailinator.com') !== false) {
|
339 |
return false;
|
340 |
+
}
|
341 |
+
if (strpos($email, 'guerrillamailblock.com') !== false) {
|
342 |
return false;
|
343 |
+
}
|
344 |
+
if (strpos($email, 'emailtemporanea.net') !== false) {
|
345 |
return false;
|
346 |
+
}
|
347 |
return true;
|
348 |
}
|
349 |
|
475 |
}
|
476 |
}
|
477 |
|
|
|
|
|
|
|
|
|
|
|
478 |
/**
|
479 |
* Cleans up a text containing url tags with appended the absolute URL (due to
|
480 |
* the editor behavior) moving back them to the simple form.
|
692 |
global $wpdb;
|
693 |
|
694 |
// To simplify the reaload of a user passing the user it self.
|
695 |
+
if (is_object($id_or_email)) {
|
696 |
$id_or_email = $id_or_email->id;
|
697 |
+
} else if (is_array($id_or_email)) {
|
698 |
$id_or_email = $id_or_email['id'];
|
699 |
+
}
|
700 |
|
701 |
$id_or_email = strtolower(trim($id_or_email));
|
702 |
|
plugin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
-
Version: 5.0
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -14,7 +14,7 @@
|
|
14 |
*/
|
15 |
|
16 |
// Used as dummy parameter on css and js links
|
17 |
-
define('NEWSLETTER_VERSION', '5.0
|
18 |
|
19 |
global $wpdb, $newsletter;
|
20 |
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
+
Version: 5.1.0
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
14 |
*/
|
15 |
|
16 |
// Used as dummy parameter on css and js links
|
17 |
+
define('NEWSLETTER_VERSION', '5.1.0');
|
18 |
|
19 |
global $wpdb, $newsletter;
|
20 |
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 4.8.2
|
5 |
-
Stable tag: 5.0
|
6 |
Contributors: satollo,webagile,michael-travan
|
7 |
|
8 |
Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
|
@@ -85,6 +85,12 @@ Thank you, The Newsletter Team
|
|
85 |
|
86 |
== Changelog ==
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
== 5.0.9 ==
|
89 |
|
90 |
* Removed wp users integration and locked content now available as FREE optional extensions (to make the plugin smaller)
|
@@ -443,6 +449,7 @@ Thank you, The Newsletter Team
|
|
443 |
= 4.1.2 =
|
444 |
|
445 |
* Minor security fix (on admin side with admin access)
|
|
|
446 |
= 4.2.0 =
|
447 |
|
448 |
* Added support for Reports Extension 4
|
@@ -622,7 +629,7 @@ Thank you, The Newsletter Team
|
|
622 |
* Added import subscribers from CSV file
|
623 |
* Updated the WP compatibility version number
|
624 |
* Fixed the save button on sent emails
|
625 |
-
* Fixed the List
|
626 |
|
627 |
= 3.7.8 =
|
628 |
|
2 |
Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 4.8.2
|
5 |
+
Stable tag: 5.1.0
|
6 |
Contributors: satollo,webagile,michael-travan
|
7 |
|
8 |
Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
== 5.1.0 ==
|
89 |
+
|
90 |
+
* "ncu" parameter can be used for alternative welcome page as well, not only confirmation, when single opt in is selected
|
91 |
+
* Removed the old "email alternative" to create custom subscription messages templates (has no effects)
|
92 |
+
* Added the antiflood system
|
93 |
+
|
94 |
== 5.0.9 ==
|
95 |
|
96 |
* Removed wp users integration and locked content now available as FREE optional extensions (to make the plugin smaller)
|
449 |
= 4.1.2 =
|
450 |
|
451 |
* Minor security fix (on admin side with admin access)
|
452 |
+
|
453 |
= 4.2.0 =
|
454 |
|
455 |
* Added support for Reports Extension 4
|
629 |
* Added import subscribers from CSV file
|
630 |
* Updated the WP compatibility version number
|
631 |
* Fixed the save button on sent emails
|
632 |
+
* Fixed the List-Unsubscribe header with new URL schema
|
633 |
|
634 |
= 3.7.8 =
|
635 |
|
statistics/statistics.php
CHANGED
@@ -144,7 +144,7 @@ class NewsletterStatistics extends NewsletterModule {
|
|
144 |
$this->logger->info('Open already registered');
|
145 |
// MAybe an update for some fields?
|
146 |
} else {
|
147 |
-
|
148 |
$res = $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
|
149 |
'email_id' => (int) $email_id,
|
150 |
'user_id' => (int) $user_id,
|
144 |
$this->logger->info('Open already registered');
|
145 |
// MAybe an update for some fields?
|
146 |
} else {
|
147 |
+
$wpdb->query($wpdb->prepare("update " . NEWSLETTER_SENT_TABLE . " set open=1, ip=%s where email_id=%d and user_id=%d limit 1", $ip, $email_id, $user_id));
|
148 |
$res = $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
|
149 |
'email_id' => (int) $email_id,
|
150 |
'user_id' => (int) $user_id,
|
subscription/languages/en_US.php
CHANGED
@@ -13,13 +13,12 @@
|
|
13 |
$options = array();
|
14 |
|
15 |
$options['noconfirmation'] = 0;
|
|
|
16 |
|
17 |
// Profile page
|
18 |
-
$options['profile_text'] = "
|
19 |
<p>If you change your email address, a confirmation email will be sent to activate it.</p>
|
20 |
-
</p>
|
21 |
-
{profile_form}
|
22 |
-
<p>To cancel your subscription, <a href='{unsubscription_confirm_url}'>click here</a>.</p>";
|
23 |
|
24 |
// Profile page messages
|
25 |
$options['profile_email_changed'] = "Your email has been changed, an activation email has been sent. Please follow the instructions to activate the new address.";
|
@@ -29,8 +28,6 @@ $options['error_text'] = '<p>This subscription can\'t be completed, sorry. The e
|
|
29 |
|
30 |
//$options['already_confirmed_text'] = '<p>This email address is already subscribed, anyway a welcome email has been resent. Thank you.</p>';
|
31 |
|
32 |
-
$options['subscribe_wp_users'] = 0;
|
33 |
-
|
34 |
// Subscription page introductory text (befor the subscription form)
|
35 |
$options['subscription_text'] =
|
36 |
"{subscription_form}";
|
13 |
$options = array();
|
14 |
|
15 |
$options['noconfirmation'] = 0;
|
16 |
+
$options['antiflood'] = 10;
|
17 |
|
18 |
// Profile page
|
19 |
+
$options['profile_text'] = __("{profile_form}
|
20 |
<p>If you change your email address, a confirmation email will be sent to activate it.</p>
|
21 |
+
<p><a href=\"{unsubscription_confirm_url}\">Cancel your subscription</a></p>", 'newsletter');
|
|
|
|
|
22 |
|
23 |
// Profile page messages
|
24 |
$options['profile_email_changed'] = "Your email has been changed, an activation email has been sent. Please follow the instructions to activate the new address.";
|
28 |
|
29 |
//$options['already_confirmed_text'] = '<p>This email address is already subscribed, anyway a welcome email has been resent. Thank you.</p>';
|
30 |
|
|
|
|
|
31 |
// Subscription page introductory text (befor the subscription form)
|
32 |
$options['subscription_text'] =
|
33 |
"{subscription_form}";
|
subscription/options.php
CHANGED
@@ -283,6 +283,22 @@ if (empty($controls->data['page'])) {
|
|
283 |
</p>
|
284 |
</td>
|
285 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
</table>
|
287 |
|
288 |
<h3>Special cases</h3>
|
283 |
</p>
|
284 |
</td>
|
285 |
</tr>
|
286 |
+
<tr valign="top">
|
287 |
+
<th>Antiflood</th>
|
288 |
+
<td>
|
289 |
+
<?php $controls->select('antiflood', array(
|
290 |
+
0=>__('Disabled', 'newsletter'),
|
291 |
+
5=>'5 ' . __('seconds', 'newsletter'),
|
292 |
+
10=>'10 ' . __('seconds', 'newsletter'),
|
293 |
+
15=>'15 ' . __('seconds', 'newsletter'),
|
294 |
+
30=>'30 ' . __('seconds', 'newsletter'),
|
295 |
+
60=>'1 ' . __('minute', 'newsletter'),
|
296 |
+
120=>'2 ' . __('minutes', 'newsletter'),
|
297 |
+
300=>'5 ' . __('minutes', 'newsletter')
|
298 |
+
)); ?>
|
299 |
+
<?php $controls->help('https://www.thenewsletterplugin.com/documentation/antiflood') ?>
|
300 |
+
</td>
|
301 |
+
</tr>
|
302 |
</table>
|
303 |
|
304 |
<h3>Special cases</h3>
|
subscription/subscription.php
CHANGED
@@ -42,7 +42,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
42 |
add_shortcode('newsletter_field', array($this, 'shortcode_newsletter_field'));
|
43 |
}
|
44 |
}
|
45 |
-
|
46 |
function hook_admin_init() {
|
47 |
if (isset($_GET['page']) && $_GET['page'] === 'newsletter_subscription_forms') {
|
48 |
header('X-XSS-Protection: 0');
|
@@ -91,6 +91,17 @@ class NewsletterSubscription extends NewsletterModule {
|
|
91 |
// normal subscription
|
92 |
case 's':
|
93 |
case 'subscribe':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
if (!empty($this->options['antibot_disable']) || $this->antibot_form_check()) {
|
95 |
$user = $this->subscribe();
|
96 |
|
@@ -283,9 +294,9 @@ class NewsletterSubscription extends NewsletterModule {
|
|
283 |
if ($sub == '') {
|
284 |
// For compatibility the options are wrongly named
|
285 |
$options = get_option('newsletter', array());
|
286 |
-
if (!is_array($options))
|
|
|
287 |
return $options;
|
288 |
-
|
289 |
}
|
290 |
if ($sub == 'profile') {
|
291 |
// For compatibility the options are wrongly named
|
@@ -294,6 +305,24 @@ class NewsletterSubscription extends NewsletterModule {
|
|
294 |
return parent::get_options($sub);
|
295 |
}
|
296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
/**
|
298 |
* Return the subscribed user.
|
299 |
*
|
@@ -346,6 +375,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
346 |
if ($user->status == 'C') {
|
347 |
|
348 |
set_transient($user->id . '-' . $user->token, $_REQUEST, 3600 * 48);
|
|
|
349 |
|
350 |
// A second subscription always require confirmation otherwise anywan can change other users' data
|
351 |
$user->status = 'S';
|
@@ -385,6 +415,8 @@ class NewsletterSubscription extends NewsletterModule {
|
|
385 |
$user['status'] = $opt_in == 1 ? 'C' : 'S';
|
386 |
}
|
387 |
|
|
|
|
|
388 |
$user = apply_filters('newsletter_user_subscribe', $user);
|
389 |
// TODO: should be removed!!!
|
390 |
if (defined('NEWSLETTER_FEED_VERSION')) {
|
@@ -411,10 +443,10 @@ class NewsletterSubscription extends NewsletterModule {
|
|
411 |
|
412 |
if (empty($options[$prefix . 'disabled'])) {
|
413 |
$message = $options[$prefix . 'message'];
|
414 |
-
|
415 |
if ($user->status == 'S') {
|
416 |
$message = $this->add_microdata($message);
|
417 |
-
|
418 |
|
419 |
// TODO: This is always empty!
|
420 |
//$message_text = $options[$prefix . 'message_text'];
|
@@ -424,7 +456,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
424 |
}
|
425 |
return $user;
|
426 |
}
|
427 |
-
|
428 |
function add_microdata($message) {
|
429 |
return $message . '<span itemscope itemtype="http://schema.org/EmailMessage"><span itemprop="description" content="Email address confirmation"></span><span itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction"><meta itemprop="name" content="Confirm Subscription"><span itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler"><meta itemprop="url" content="{subscription_confirm_url}"><link itemprop="method" href="http://schema.org/HttpRequestMethod/POST"></span></span></span>';
|
430 |
}
|
@@ -459,8 +491,9 @@ class NewsletterSubscription extends NewsletterModule {
|
|
459 |
} else if (isset($_SERVER['HTTP_REFERER'])) {
|
460 |
$user['http_referer'] = strip_tags(trim($_SERVER['HTTP_REFERER']));
|
461 |
}
|
462 |
-
|
463 |
-
if (strlen($user['http_referer']) > 200)
|
|
|
464 |
|
465 |
// New profiles
|
466 |
for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
|
@@ -526,8 +559,8 @@ class NewsletterSubscription extends NewsletterModule {
|
|
526 |
include NEWSLETTER_DIR . '/subscription/email.php';
|
527 |
$message = ob_get_clean();
|
528 |
}
|
529 |
-
|
530 |
-
$headers = array('Auto-Submitted'=>'auto-generated');
|
531 |
|
532 |
$message = Newsletter::instance()->replace($message);
|
533 |
return Newsletter::instance()->mail($to, $subject, $message, $headers);
|
@@ -764,6 +797,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
764 |
|
765 |
if (isset($_REQUEST['ncu'])) {
|
766 |
$this->options['confirmation_url'] = esc_url($_REQUEST['ncu']);
|
|
|
767 |
}
|
768 |
|
769 |
if ($email) {
|
@@ -1474,7 +1508,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1474 |
|
1475 |
if (empty($user)) {
|
1476 |
if (empty($content)) {
|
1477 |
-
return __('Subscriber profile not found.','newsletter');
|
1478 |
} else {
|
1479 |
return $content;
|
1480 |
}
|
@@ -1492,7 +1526,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1492 |
*/
|
1493 |
function get_profile_form($user) {
|
1494 |
$options = get_option('newsletter_profile');
|
1495 |
-
|
1496 |
$buffer = '';
|
1497 |
|
1498 |
$buffer .= '<div class="tnp-profile">';
|
@@ -1580,9 +1614,9 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1580 |
|
1581 |
function get_profile_form_html5($user) {
|
1582 |
$options = get_option('newsletter_profile');
|
1583 |
-
|
1584 |
$buffer = '';
|
1585 |
-
|
1586 |
$buffer .= '<div class="tnp tnp-profile">';
|
1587 |
$buffer .= '<form action="' . esc_attr(home_url('/') . '?na=ps') . '" method="post" onsubmit="return newsletter_check(this)">';
|
1588 |
$buffer .= '<input type="hidden" name="nk" value="' . esc_attr($user->id . '-' . $user->token) . '">';
|
@@ -1635,7 +1669,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1635 |
}
|
1636 |
|
1637 |
if ($options['profile_' . $i . '_type'] == 'select') {
|
1638 |
-
$buffer .= '<select class="tnp-profile tnp-profile-' . $i . '" name="np' . $i . '"' .
|
1639 |
($options['profile_' . $i . '_rules'] == 1 ? ' required' : '') . '>';
|
1640 |
$opts = explode(',', $options['profile_' . $i . '_options']);
|
1641 |
for ($j = 0; $j < count($opts); $j++) {
|
42 |
add_shortcode('newsletter_field', array($this, 'shortcode_newsletter_field'));
|
43 |
}
|
44 |
}
|
45 |
+
|
46 |
function hook_admin_init() {
|
47 |
if (isset($_GET['page']) && $_GET['page'] === 'newsletter_subscription_forms') {
|
48 |
header('X-XSS-Protection: 0');
|
91 |
// normal subscription
|
92 |
case 's':
|
93 |
case 'subscribe':
|
94 |
+
// Flood check
|
95 |
+
if (!empty($this->options['antiflood'])) {
|
96 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
97 |
+
$email = $this->is_email($_REQUEST['ne']);
|
98 |
+
$updated = $wpdb->get_var($wpdb->prepare("select updated from " . NEWSLETTER_USERS_TABLE . " where ip=%s or email=%s order by updated desc limit 1", $ip, $email));
|
99 |
+
|
100 |
+
if ($updated && time() - $updated < $this->options['antiflood']) {
|
101 |
+
die('Too quick');
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
if (!empty($this->options['antibot_disable']) || $this->antibot_form_check()) {
|
106 |
$user = $this->subscribe();
|
107 |
|
294 |
if ($sub == '') {
|
295 |
// For compatibility the options are wrongly named
|
296 |
$options = get_option('newsletter', array());
|
297 |
+
if (!is_array($options))
|
298 |
+
$options = array();
|
299 |
return $options;
|
|
|
300 |
}
|
301 |
if ($sub == 'profile') {
|
302 |
// For compatibility the options are wrongly named
|
305 |
return parent::get_options($sub);
|
306 |
}
|
307 |
|
308 |
+
function set_updated($user, $time = 0, $ip = '') {
|
309 |
+
global $wpdb;
|
310 |
+
if (!$time)
|
311 |
+
$time = time();
|
312 |
+
|
313 |
+
if (!$ip)
|
314 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
315 |
+
|
316 |
+
if (is_object($user))
|
317 |
+
$id = $user->id;
|
318 |
+
else if (is_array($user))
|
319 |
+
$id = $user['id'];
|
320 |
+
|
321 |
+
$id = (int) $id;
|
322 |
+
|
323 |
+
$wpdb->update(NEWSLETTER_USERS_TABLE, array('updated' => $time, 'ip' => $ip), array('id' => $id));
|
324 |
+
}
|
325 |
+
|
326 |
/**
|
327 |
* Return the subscribed user.
|
328 |
*
|
375 |
if ($user->status == 'C') {
|
376 |
|
377 |
set_transient($user->id . '-' . $user->token, $_REQUEST, 3600 * 48);
|
378 |
+
$this->set_updated($user);
|
379 |
|
380 |
// A second subscription always require confirmation otherwise anywan can change other users' data
|
381 |
$user->status = 'S';
|
415 |
$user['status'] = $opt_in == 1 ? 'C' : 'S';
|
416 |
}
|
417 |
|
418 |
+
$user['updated'] = time();
|
419 |
+
|
420 |
$user = apply_filters('newsletter_user_subscribe', $user);
|
421 |
// TODO: should be removed!!!
|
422 |
if (defined('NEWSLETTER_FEED_VERSION')) {
|
443 |
|
444 |
if (empty($options[$prefix . 'disabled'])) {
|
445 |
$message = $options[$prefix . 'message'];
|
446 |
+
|
447 |
if ($user->status == 'S') {
|
448 |
$message = $this->add_microdata($message);
|
449 |
+
}
|
450 |
|
451 |
// TODO: This is always empty!
|
452 |
//$message_text = $options[$prefix . 'message_text'];
|
456 |
}
|
457 |
return $user;
|
458 |
}
|
459 |
+
|
460 |
function add_microdata($message) {
|
461 |
return $message . '<span itemscope itemtype="http://schema.org/EmailMessage"><span itemprop="description" content="Email address confirmation"></span><span itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction"><meta itemprop="name" content="Confirm Subscription"><span itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler"><meta itemprop="url" content="{subscription_confirm_url}"><link itemprop="method" href="http://schema.org/HttpRequestMethod/POST"></span></span></span>';
|
462 |
}
|
491 |
} else if (isset($_SERVER['HTTP_REFERER'])) {
|
492 |
$user['http_referer'] = strip_tags(trim($_SERVER['HTTP_REFERER']));
|
493 |
}
|
494 |
+
|
495 |
+
if (strlen($user['http_referer']) > 200)
|
496 |
+
$user['http_referer'] = substr($user['http_referer'], 0, 200);
|
497 |
|
498 |
// New profiles
|
499 |
for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
|
559 |
include NEWSLETTER_DIR . '/subscription/email.php';
|
560 |
$message = ob_get_clean();
|
561 |
}
|
562 |
+
|
563 |
+
$headers = array('Auto-Submitted' => 'auto-generated');
|
564 |
|
565 |
$message = Newsletter::instance()->replace($message);
|
566 |
return Newsletter::instance()->mail($to, $subject, $message, $headers);
|
797 |
|
798 |
if (isset($_REQUEST['ncu'])) {
|
799 |
$this->options['confirmation_url'] = esc_url($_REQUEST['ncu']);
|
800 |
+
$this->options['confirmed_url'] = esc_url($_REQUEST['ncu']);
|
801 |
}
|
802 |
|
803 |
if ($email) {
|
1508 |
|
1509 |
if (empty($user)) {
|
1510 |
if (empty($content)) {
|
1511 |
+
return __('Subscriber profile not found.', 'newsletter');
|
1512 |
} else {
|
1513 |
return $content;
|
1514 |
}
|
1526 |
*/
|
1527 |
function get_profile_form($user) {
|
1528 |
$options = get_option('newsletter_profile');
|
1529 |
+
|
1530 |
$buffer = '';
|
1531 |
|
1532 |
$buffer .= '<div class="tnp-profile">';
|
1614 |
|
1615 |
function get_profile_form_html5($user) {
|
1616 |
$options = get_option('newsletter_profile');
|
1617 |
+
|
1618 |
$buffer = '';
|
1619 |
+
|
1620 |
$buffer .= '<div class="tnp tnp-profile">';
|
1621 |
$buffer .= '<form action="' . esc_attr(home_url('/') . '?na=ps') . '" method="post" onsubmit="return newsletter_check(this)">';
|
1622 |
$buffer .= '<input type="hidden" name="nk" value="' . esc_attr($user->id . '-' . $user->token) . '">';
|
1669 |
}
|
1670 |
|
1671 |
if ($options['profile_' . $i . '_type'] == 'select') {
|
1672 |
+
$buffer .= '<select class="tnp-profile tnp-profile-' . $i . '" name="np' . $i . '"' .
|
1673 |
($options['profile_' . $i . '_rules'] == 1 ? ' required' : '') . '>';
|
1674 |
$opts = explode(',', $options['profile_' . $i . '_options']);
|
1675 |
for ($j = 0; $j < count($opts); $j++) {
|
tnp-header.php
CHANGED
@@ -52,10 +52,7 @@ function newsletter_print_entries($group) {
|
|
52 |
<li><a href="?page=newsletter_subscription_options"><i class="fa fa-sign-in"></i> <?php _e('Subscription', 'newsletter') ?>
|
53 |
<small><?php _e('The subscription process in detail', 'newsletter') ?></small></a></li>
|
54 |
|
55 |
-
|
56 |
-
<li><a href="?page=newsletter_wp_index"><i class="fa fa-wordpress"></i> <?php _e('WP Registration', 'newsletter') ?>
|
57 |
-
<small><?php _e('Subscribe on WP registration', 'newsletter') ?></small></a></li>
|
58 |
-
<?php } ?>
|
59 |
<li><a href="?page=newsletter_subscription_profile"><i class="fa fa-check-square-o"></i> <?php _e('Subscription Form Fields, Buttons, Labels', 'newsletter') ?>
|
60 |
<small><?php _e('When and what data to collect', 'newsletter') ?></small></a></li>
|
61 |
<li><a href="?page=newsletter_subscription_lists"><i class="fa fa-th-list"></i> <?php _e('Lists', 'newsletter') ?>
|
52 |
<li><a href="?page=newsletter_subscription_options"><i class="fa fa-sign-in"></i> <?php _e('Subscription', 'newsletter') ?>
|
53 |
<small><?php _e('The subscription process in detail', 'newsletter') ?></small></a></li>
|
54 |
|
55 |
+
|
|
|
|
|
|
|
56 |
<li><a href="?page=newsletter_subscription_profile"><i class="fa fa-check-square-o"></i> <?php _e('Subscription Form Fields, Buttons, Labels', 'newsletter') ?>
|
57 |
<small><?php _e('When and what data to collect', 'newsletter') ?></small></a></li>
|
58 |
<li><a href="?page=newsletter_subscription_lists"><i class="fa fa-th-list"></i> <?php _e('Lists', 'newsletter') ?>
|
users/users.php
CHANGED
@@ -20,7 +20,7 @@ class NewsletterUsers extends NewsletterModule {
|
|
20 |
}
|
21 |
|
22 |
function __construct() {
|
23 |
-
parent::__construct('users', '1.1.
|
24 |
add_action('init', array($this, 'hook_init'));
|
25 |
}
|
26 |
|
@@ -58,6 +58,7 @@ class NewsletterUsers extends NewsletterModule {
|
|
58 |
`list` int(11) NOT NULL DEFAULT '0',
|
59 |
`profile` mediumtext,
|
60 |
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
61 |
`followup_step` tinyint(4) NOT NULL DEFAULT '0',
|
62 |
`followup_time` bigint(20) NOT NULL DEFAULT '0',
|
63 |
`followup` tinyint(4) NOT NULL DEFAULT '0',
|
20 |
}
|
21 |
|
22 |
function __construct() {
|
23 |
+
parent::__construct('users', '1.1.4');
|
24 |
add_action('init', array($this, 'hook_init'));
|
25 |
}
|
26 |
|
58 |
`list` int(11) NOT NULL DEFAULT '0',
|
59 |
`profile` mediumtext,
|
60 |
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
61 |
+
`updated` int(11) NOT NULL DEFAULT '0',
|
62 |
`followup_step` tinyint(4) NOT NULL DEFAULT '0',
|
63 |
`followup_time` bigint(20) NOT NULL DEFAULT '0',
|
64 |
`followup` tinyint(4) NOT NULL DEFAULT '0',
|