Version Description
- Improved license checking (only for who set a license code - it is not required)
- Imporved extra field configuration with multilanguage blogs
- Improved subscription form with extra fields for multilanguage blogs
- Minor code improvements
- Improved HTTP responses for invalid profile links (good for users and acceptance tests)
- Fixed newsletter page url generation with Polylang
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 6.8.0 |
Comparing to | |
See all releases |
Code changes from version 6.7.9 to 6.8.0
- emails/blocks/header/block.php +59 -54
- emails/blocks/header/layout-logo.php +7 -0
- emails/blocks/header/options.php +6 -1
- emails/blocks/hero/block-full.php +2 -0
- emails/blocks/hero/block-left.php +2 -0
- emails/blocks/hero/block-right.php +2 -0
- emails/blocks/hero/block.php +11 -3
- emails/blocks/image/block.php +0 -1
- emails/blocks/posts/layout-one.php +0 -1
- emails/emails.php +4 -6
- includes/TNP.php +1 -1
- includes/controls.php +14 -1
- includes/module.php +94 -24
- plugin.php +90 -79
- profile/profile.php +20 -20
- readme.txt +10 -1
- subscription/antibot.php +10 -12
- subscription/options.php +4 -6
- subscription/profile.php +21 -7
- subscription/subscription.php +40 -24
- tnp-header.php +2 -2
- unsubscription/unsubscription.php +1 -1
emails/blocks/header/block.php
CHANGED
@@ -22,62 +22,67 @@ if (empty($info['header_logo']['id'])) {
|
|
22 |
$media = false;
|
23 |
} else {
|
24 |
$media = tnp_resize($info['header_logo']['id'], array(200, 80));
|
25 |
-
$media
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
-
$empty =
|
29 |
-
?>
|
30 |
|
31 |
-
|
32 |
-
<p>Please, set your company info.</p>
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
font-family: <?php echo $options['font_family'] ?>;
|
39 |
-
font-weight: <?php echo $options['font_weight'] ?>;
|
40 |
-
color: <?php echo $options['font_color'] ?>;
|
41 |
-
text-decoration: none;
|
42 |
-
line-height: normal;
|
43 |
-
}
|
44 |
-
.header-title {
|
45 |
-
font-size: <?php echo $options['font_size'] * 1.2 ?>px;
|
46 |
-
font-family: <?php echo $options['font_family'] ?>;
|
47 |
-
font-weight: <?php echo $options['font_weight'] ?>;
|
48 |
-
color: <?php echo $options['font_color'] ?>;
|
49 |
-
text-decoration: none;
|
50 |
-
line-height: normal;
|
51 |
-
}
|
52 |
-
.header-logo {
|
53 |
-
font-family: <?php echo $options['font_family'] ?>;
|
54 |
-
line-height: normal;
|
55 |
-
font-weight: <?php echo $options['font_weight'] ?>;
|
56 |
-
color: <?php echo $options['font_color'] ?>;
|
57 |
-
}
|
58 |
-
.header-logo-img {
|
59 |
-
display: inline-block;
|
60 |
-
max-width: 100%!important;
|
61 |
-
}
|
62 |
-
</style>
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
$media = false;
|
23 |
} else {
|
24 |
$media = tnp_resize($info['header_logo']['id'], array(200, 80));
|
25 |
+
if ($media) {
|
26 |
+
$media->alt = $info['header_title'];
|
27 |
+
$media->link = home_url();
|
28 |
+
}
|
29 |
}
|
30 |
|
31 |
+
$empty = !$media && empty($info['header_sub']) && empty($info['header_title']);
|
|
|
32 |
|
33 |
+
if ($empty) {
|
34 |
+
echo '<p>Please, set your company info.</p>';
|
35 |
+
} elseif ($options['layout'] === 'logo') {
|
36 |
+
include __DIR__ . '/layout-logo.php';
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
<style>
|
42 |
+
.header-text {
|
43 |
+
padding: 10px;
|
44 |
+
font-size: <?php echo $options['font_size'] ?>px;
|
45 |
+
font-family: <?php echo $options['font_family'] ?>;
|
46 |
+
font-weight: <?php echo $options['font_weight'] ?>;
|
47 |
+
color: <?php echo $options['font_color'] ?>;
|
48 |
+
text-decoration: none;
|
49 |
+
line-height: normal;
|
50 |
+
}
|
51 |
+
.header-title {
|
52 |
+
font-size: <?php echo $options['font_size'] * 1.2 ?>px;
|
53 |
+
font-family: <?php echo $options['font_family'] ?>;
|
54 |
+
font-weight: <?php echo $options['font_weight'] ?>;
|
55 |
+
color: <?php echo $options['font_color'] ?>;
|
56 |
+
text-decoration: none;
|
57 |
+
line-height: normal;
|
58 |
+
}
|
59 |
+
.header-logo {
|
60 |
+
font-family: <?php echo $options['font_family'] ?>;
|
61 |
+
line-height: normal;
|
62 |
+
font-weight: <?php echo $options['font_weight'] ?>;
|
63 |
+
color: <?php echo $options['font_color'] ?>;
|
64 |
+
}
|
65 |
+
.header-logo-img {
|
66 |
+
display: inline-block;
|
67 |
+
max-width: 100%!important;
|
68 |
+
}
|
69 |
+
</style>
|
70 |
|
71 |
+
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="header-table">
|
72 |
+
<tr>
|
73 |
+
<td align="left" width="50%" inline-class="header-logo" class="header-logo-global">
|
74 |
+
<?php if ($media) { ?>
|
75 |
+
<a href="<?php echo home_url() ?>" target="_blank">
|
76 |
+
<img alt="<?php echo esc_attr($media->alt) ?>" src="<?php echo $media->url ?>" width="<?php echo $media->width ?>" height="<?php echo $media->height ?>" inline-class="header-logo-img" border="0">
|
77 |
+
</a>
|
78 |
+
<?php } else { ?>
|
79 |
+
<a href="<?php echo home_url() ?>" target="_blank" inline-class="header-title">
|
80 |
+
<?php echo esc_attr($info['header_title']) ?>
|
81 |
+
</a>
|
82 |
+
<?php } ?>
|
83 |
+
</td>
|
84 |
+
<td width="50%" align="right" class="mobile-hide" inline-class="header-text">
|
85 |
+
<?php echo esc_html($info['header_sub']) ?>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
</table>
|
emails/blocks/header/layout-logo.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!$media) {
|
3 |
+
echo '<p>Set your logo on company info page, thank you.</p>';
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
?>
|
7 |
+
<a href="<?php echo esc_url($media->link) ?>" target="_blank"><img src="<?php echo $media->url ?>" width="<?php echo $media->width ?>" height="<?php echo $media->height ?>" border="0" alt="<?php echo esc_attr($media->alt) ?>" inline-class="image"></a>
|
emails/blocks/header/options.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/* @var $options array contains all the options the current block we're ediging contains */
|
3 |
/* @var $controls NewsletterControls */
|
4 |
/* @var $controls NewsletterFields */
|
@@ -6,6 +7,10 @@
|
|
6 |
|
7 |
<p>This block uses the <a href="?page=newsletter_main_info" target="_blank">global company info</a>.</p>
|
8 |
|
9 |
-
<?php
|
|
|
|
|
|
|
|
|
10 |
|
11 |
<?php $fields->block_commons() ?>
|
1 |
<?php
|
2 |
+
|
3 |
/* @var $options array contains all the options the current block we're ediging contains */
|
4 |
/* @var $controls NewsletterControls */
|
5 |
/* @var $controls NewsletterFields */
|
7 |
|
8 |
<p>This block uses the <a href="?page=newsletter_main_info" target="_blank">global company info</a>.</p>
|
9 |
|
10 |
+
<?php
|
11 |
+
$fields->select('layout', __('Layout', 'newsletter'), ['' => __('Default', 'newsletter'), 'logo' => __('Only the logo', 'newsletter')])
|
12 |
+
?>
|
13 |
+
|
14 |
+
<?php $fields->font() ?>
|
15 |
|
16 |
<?php $fields->block_commons() ?>
|
emails/blocks/hero/block-full.php
CHANGED
@@ -27,6 +27,8 @@
|
|
27 |
}
|
28 |
</style>
|
29 |
|
|
|
|
|
30 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
31 |
<?php if ($media) { ?>
|
32 |
<tr>
|
27 |
}
|
28 |
</style>
|
29 |
|
30 |
+
<!-- layout: full -->
|
31 |
+
|
32 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
33 |
<?php if ($media) { ?>
|
34 |
<tr>
|
emails/blocks/hero/block-left.php
CHANGED
@@ -32,6 +32,8 @@
|
|
32 |
}
|
33 |
</style>
|
34 |
|
|
|
|
|
35 |
<table width="50%" align="left" class="hero-table" border="0" cellspacing="0" cellpadding="0">
|
36 |
<tr>
|
37 |
<td align="center" valign="top">
|
32 |
}
|
33 |
</style>
|
34 |
|
35 |
+
<!-- layout: left -->
|
36 |
+
|
37 |
<table width="50%" align="left" class="hero-table" border="0" cellspacing="0" cellpadding="0">
|
38 |
<tr>
|
39 |
<td align="center" valign="top">
|
emails/blocks/hero/block-right.php
CHANGED
@@ -32,6 +32,8 @@
|
|
32 |
}
|
33 |
</style>
|
34 |
|
|
|
|
|
35 |
<div dir="rtl">
|
36 |
|
37 |
<table width="50%" align="right" class="hero-table" border="0" cellspacing="0" cellpadding="0">
|
32 |
}
|
33 |
</style>
|
34 |
|
35 |
+
<!-- layout: right -->
|
36 |
+
|
37 |
<div dir="rtl">
|
38 |
|
39 |
<table width="50%" align="right" class="hero-table" border="0" cellspacing="0" cellpadding="0">
|
emails/blocks/hero/block.php
CHANGED
@@ -79,12 +79,20 @@ $layout = $options['layout'];
|
|
79 |
if (!empty($options['image']['id'])) {
|
80 |
if ($layout == 'full') {
|
81 |
$media = tnp_resize($options['image']['id'], array(600, 0));
|
82 |
-
$media
|
|
|
|
|
83 |
} else {
|
|
|
84 |
$media = tnp_resize($options['image']['id'], array(600, 0));
|
85 |
-
$media
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
-
$media->alt = $options['title'];
|
88 |
} else {
|
89 |
$media = false;
|
90 |
}
|
79 |
if (!empty($options['image']['id'])) {
|
80 |
if ($layout == 'full') {
|
81 |
$media = tnp_resize($options['image']['id'], array(600, 0));
|
82 |
+
if ($media) {
|
83 |
+
$media->set_width(600 - $options['block_padding_left'] - $options['block_padding_right']);
|
84 |
+
}
|
85 |
} else {
|
86 |
+
|
87 |
$media = tnp_resize($options['image']['id'], array(600, 0));
|
88 |
+
if ($media) {
|
89 |
+
$media->set_width(300 - $options['block_padding_left']);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
if ($media) {
|
93 |
+
$media->alt = $options['title'];
|
94 |
+
$media->link = $options['button_url'];
|
95 |
}
|
|
|
96 |
} else {
|
97 |
$media = false;
|
98 |
}
|
emails/blocks/image/block.php
CHANGED
@@ -47,7 +47,6 @@ if (empty($options['image']['id'])) {
|
|
47 |
if (!empty($options['width'])) {
|
48 |
$media->set_width($options['width']);
|
49 |
}
|
50 |
-
|
51 |
$url = $options['url'];
|
52 |
?>
|
53 |
<style>
|
47 |
if (!empty($options['width'])) {
|
48 |
$media->set_width($options['width']);
|
49 |
}
|
|
|
50 |
$url = $options['url'];
|
51 |
?>
|
52 |
<style>
|
emails/blocks/posts/layout-one.php
CHANGED
@@ -37,7 +37,6 @@ $size = ['width' => 300, 'height' => 0];
|
|
37 |
$media = null;
|
38 |
if ($show_image) {
|
39 |
$media = tnp_composer_block_posts_get_media($post, $size);
|
40 |
-
//var_dump($media);
|
41 |
if ($media) {
|
42 |
$media->link = $url;
|
43 |
$media->set_width(105);
|
37 |
$media = null;
|
38 |
if ($show_image) {
|
39 |
$media = tnp_composer_block_posts_get_media($post, $size);
|
|
|
40 |
if ($media) {
|
41 |
$media->link = $url;
|
42 |
$media->set_width(105);
|
emails/emails.php
CHANGED
@@ -221,7 +221,6 @@ class NewsletterEmails extends NewsletterModule {
|
|
221 |
|
222 |
ob_start();
|
223 |
$out = $this->render_block($options['block_id'], true, $options, $context);
|
224 |
-
//var_dump($out);
|
225 |
if ($out['return_empty_message'] || $out['stop']) {
|
226 |
if (is_object($email)) {
|
227 |
return false;
|
@@ -765,8 +764,9 @@ class NewsletterEmails extends NewsletterModule {
|
|
765 |
*/
|
766 |
function get_blocks() {
|
767 |
|
768 |
-
if (!is_null($this->blocks))
|
769 |
return $this->blocks;
|
|
|
770 |
|
771 |
$this->blocks = $this->scan_blocks_dir(__DIR__ . '/blocks');
|
772 |
|
@@ -776,10 +776,8 @@ class NewsletterEmails extends NewsletterModule {
|
|
776 |
|
777 |
$dirs = apply_filters('newsletter_blocks_dir', array());
|
778 |
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
$this->logger->debug('Block dirs: ' . print_r($dirs, true));
|
783 |
|
784 |
foreach ($dirs as $dir) {
|
785 |
$dir = str_replace('\\', '/', $dir);
|
221 |
|
222 |
ob_start();
|
223 |
$out = $this->render_block($options['block_id'], true, $options, $context);
|
|
|
224 |
if ($out['return_empty_message'] || $out['stop']) {
|
225 |
if (is_object($email)) {
|
226 |
return false;
|
764 |
*/
|
765 |
function get_blocks() {
|
766 |
|
767 |
+
if (!is_null($this->blocks)) {
|
768 |
return $this->blocks;
|
769 |
+
}
|
770 |
|
771 |
$this->blocks = $this->scan_blocks_dir(__DIR__ . '/blocks');
|
772 |
|
776 |
|
777 |
$dirs = apply_filters('newsletter_blocks_dir', array());
|
778 |
|
779 |
+
$this->logger->debug('Block dirs:');
|
780 |
+
$this->logger->debug($dirs);
|
|
|
|
|
781 |
|
782 |
foreach ($dirs as $dir) {
|
783 |
$dir = str_replace('\\', '/', $dir);
|
includes/TNP.php
CHANGED
@@ -238,7 +238,7 @@ class TNP {
|
|
238 |
}
|
239 |
|
240 |
// Lists (an array under the key "lists")
|
241 |
-
//
|
242 |
if (isset($params['lists']) && is_array($params['lists'])) {
|
243 |
foreach ($params['lists'] as $list_id) {
|
244 |
$user['list_' . ( (int) $list_id )] = 1;
|
238 |
}
|
239 |
|
240 |
// Lists (an array under the key "lists")
|
241 |
+
//(field names are nl[] and values the list number so special forms with radio button can work)
|
242 |
if (isset($params['lists']) && is_array($params['lists'])) {
|
243 |
foreach ($params['lists'] as $list_id) {
|
244 |
$user['list_' . ( (int) $list_id )] = 1;
|
includes/controls.php
CHANGED
@@ -1700,7 +1700,20 @@ class NewsletterControls {
|
|
1700 |
}
|
1701 |
|
1702 |
static function field_help($url, $text = '') {
|
1703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1704 |
}
|
1705 |
|
1706 |
/**
|
1700 |
}
|
1701 |
|
1702 |
static function field_help($url, $text = '') {
|
1703 |
+
if (strpos($url, 'http') !== 0) {
|
1704 |
+
$url = 'https://www.thenewsletterplugin.com' . $url;
|
1705 |
+
}
|
1706 |
+
echo '<a href="', $url, '" target="_blank" style="text-decoration: none" title="' . esc_attr(__('Read more', 'newsletter')) . '"><i class="fas fa-question-circle"></i>';
|
1707 |
+
if ($text) echo ' ', $text;
|
1708 |
+
echo '</a>';
|
1709 |
+
}
|
1710 |
+
|
1711 |
+
static function field_label($label, $help_url = false) {
|
1712 |
+
echo $label;
|
1713 |
+
if ($help_url) {
|
1714 |
+
echo ' ';
|
1715 |
+
self::field_help($help_url);
|
1716 |
+
}
|
1717 |
}
|
1718 |
|
1719 |
/**
|
includes/module.php
CHANGED
@@ -74,13 +74,17 @@ class TNP_Profile {
|
|
74 |
public $status;
|
75 |
public $type;
|
76 |
public $options;
|
|
|
|
|
77 |
|
78 |
-
public function __construct($id, $name, $status, $type, $options) {
|
79 |
$this->id = $id;
|
80 |
$this->name = $name;
|
81 |
$this->status = $status;
|
82 |
$this->type = $type;
|
83 |
$this->options = $options;
|
|
|
|
|
84 |
}
|
85 |
|
86 |
function is_select() {
|
@@ -91,35 +95,75 @@ class TNP_Profile {
|
|
91 |
return $this->type == self::TYPE_TEXT;
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
class TNP_Profile_Service {
|
97 |
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
static $profiles =
|
101 |
-
|
102 |
-
|
|
|
|
|
103 |
}
|
104 |
|
105 |
-
$profiles[$
|
106 |
-
$
|
107 |
-
for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i
|
108 |
-
if (empty($
|
109 |
continue;
|
110 |
}
|
111 |
-
$profile =
|
112 |
-
$i, $data['profile_' . $i], (int) $data['profile_' . $i . '_status'], $data['profile_' . $i . '_type'], self::string_db_options_to_array($data['profile_' . $i . '_options'])
|
113 |
-
);
|
114 |
|
115 |
if (is_null($type) ||
|
116 |
( $type == TNP_Profile::TYPE_SELECT && $profile->is_select() ) ||
|
117 |
( $type == TNP_Profile::TYPE_TEXT && $profile->is_text() )) {
|
118 |
-
$profiles[$
|
119 |
}
|
120 |
}
|
121 |
|
122 |
-
return $profiles[$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
/**
|
@@ -700,7 +744,7 @@ class NewsletterModule {
|
|
700 |
}
|
701 |
|
702 |
function admin_menu() {
|
703 |
-
|
704 |
}
|
705 |
|
706 |
function add_menu_page($page, $title, $capability = '') {
|
@@ -1141,6 +1185,17 @@ class NewsletterModule {
|
|
1141 |
if (is_user_logged_in()) {
|
1142 |
return $this->get_user_by_wp_user_id(get_current_user_id());
|
1143 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1144 |
}
|
1145 |
|
1146 |
/**
|
@@ -1328,15 +1383,13 @@ class NewsletterModule {
|
|
1328 |
* @return string
|
1329 |
*/
|
1330 |
function inline_css($content, $strip_style_blocks = false) {
|
1331 |
-
// CSS
|
1332 |
$matches = array();
|
1333 |
-
// "s" skips line breaks
|
1334 |
$styles = preg_match('|<style>(.*?)</style>|s', $content, $matches);
|
1335 |
if (isset($matches[1])) {
|
1336 |
$style = str_replace(array("\n", "\r"), '', $matches[1]);
|
1337 |
$rules = array();
|
1338 |
preg_match_all('|\s*\.(.*?)\{(.*?)\}\s*|s', $style, $rules);
|
1339 |
-
//print_r($rules);
|
1340 |
for ($i = 0; $i < count($rules[1]); $i++) {
|
1341 |
$class = trim($rules[1][$i]);
|
1342 |
$value = trim($rules[2][$i]);
|
@@ -1665,11 +1718,11 @@ class NewsletterModule {
|
|
1665 |
$email = null;
|
1666 |
}
|
1667 |
}
|
1668 |
-
|
1669 |
$initial_language = $this->get_current_language();
|
1670 |
-
|
1671 |
if ($user && $user->language) {
|
1672 |
-
$this->switch_language($user->language);
|
1673 |
}
|
1674 |
|
1675 |
|
@@ -1823,6 +1876,10 @@ class NewsletterModule {
|
|
1823 |
}
|
1824 |
|
1825 |
public static function antibot_form_check($captcha = false) {
|
|
|
|
|
|
|
|
|
1826 |
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post') {
|
1827 |
return false;
|
1828 |
}
|
@@ -2146,7 +2203,7 @@ class NewsletterModule {
|
|
2146 |
$message .= $list->name . ': ' . ( empty($user->$field) ? "NO" : "YES" ) . "\n";
|
2147 |
}
|
2148 |
|
2149 |
-
for ($i = 0; $i < NEWSLETTER_PROFILE_MAX; $i
|
2150 |
if (empty($this->options_profile['profile_' . $i])) {
|
2151 |
continue;
|
2152 |
}
|
@@ -2166,12 +2223,25 @@ class NewsletterModule {
|
|
2166 |
return '[' . $blogname . '] ' . $subject;
|
2167 |
}
|
2168 |
|
2169 |
-
function dienow($message, $admin_message = null) {
|
2170 |
if ($admin_message && current_user_can('administrator')) {
|
2171 |
$message .= '<br><br><strong>Text below only visibile to administrarors</strong><br>';
|
2172 |
$message .= $admin_message;
|
2173 |
}
|
2174 |
-
wp_die($message,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2175 |
}
|
2176 |
|
2177 |
}
|
74 |
public $status;
|
75 |
public $type;
|
76 |
public $options;
|
77 |
+
public $placeholder;
|
78 |
+
public $rule;
|
79 |
|
80 |
+
public function __construct($id, $name, $status, $type, $options, $placeholder, $rule) {
|
81 |
$this->id = $id;
|
82 |
$this->name = $name;
|
83 |
$this->status = $status;
|
84 |
$this->type = $type;
|
85 |
$this->options = $options;
|
86 |
+
$this->placeholder = $placeholder;
|
87 |
+
$this->rule = $rule;
|
88 |
}
|
89 |
|
90 |
function is_select() {
|
95 |
return $this->type == self::TYPE_TEXT;
|
96 |
}
|
97 |
|
98 |
+
function is_required() {
|
99 |
+
return $this->rule == 1;
|
100 |
+
}
|
101 |
+
|
102 |
}
|
103 |
|
104 |
class TNP_Profile_Service {
|
105 |
|
106 |
+
/**
|
107 |
+
*
|
108 |
+
* @param string $language
|
109 |
+
* @param string $type
|
110 |
+
* @return TNP_Profile[]
|
111 |
+
*/
|
112 |
+
static function get_profiles($language = '', $type = '') {
|
113 |
|
114 |
+
static $profiles = [];
|
115 |
+
$k = $language . $type;
|
116 |
+
|
117 |
+
if (isset($profiles[$k])) {
|
118 |
+
return $profiles[$k];
|
119 |
}
|
120 |
|
121 |
+
$profiles[$k] = [];
|
122 |
+
$profile_options = NewsletterSubscription::instance()->get_options('profile', $language);
|
123 |
+
for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
|
124 |
+
if (empty($profile_options['profile_' . $i])) {
|
125 |
continue;
|
126 |
}
|
127 |
+
$profile = self::create_profile_from_options($profile_options, $i);
|
|
|
|
|
128 |
|
129 |
if (is_null($type) ||
|
130 |
( $type == TNP_Profile::TYPE_SELECT && $profile->is_select() ) ||
|
131 |
( $type == TNP_Profile::TYPE_TEXT && $profile->is_text() )) {
|
132 |
+
$profiles[$k]['' . $i] = $profile;
|
133 |
}
|
134 |
}
|
135 |
|
136 |
+
return $profiles[$k];
|
137 |
+
}
|
138 |
+
|
139 |
+
static function get_profile_by_id($id, $language = '') {
|
140 |
+
|
141 |
+
$profiles = self::get_profiles($language);
|
142 |
+
return $profiles[$id];
|
143 |
+
/*
|
144 |
+
$profile_options = NewsletterSubscription::instance()->get_options( 'profile', $language );
|
145 |
+
|
146 |
+
if ( empty( $profile_options[ 'profile_' . $id ] ) ) {
|
147 |
+
return null;
|
148 |
+
}
|
149 |
+
|
150 |
+
return self::create_profile_from_options( $profile_options, $id );
|
151 |
+
*/
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @return TNP_Profile
|
156 |
+
*/
|
157 |
+
private static function create_profile_from_options($options, $id) {
|
158 |
+
return new TNP_Profile(
|
159 |
+
$id,
|
160 |
+
$options['profile_' . $id],
|
161 |
+
(int) $options['profile_' . $id . '_status'],
|
162 |
+
$options['profile_' . $id . '_type'],
|
163 |
+
self::string_db_options_to_array($options['profile_' . $id . '_options']),
|
164 |
+
$options['profile_' . $id . '_placeholder'],
|
165 |
+
$options['profile_' . $id . '_rules']
|
166 |
+
);
|
167 |
}
|
168 |
|
169 |
/**
|
744 |
}
|
745 |
|
746 |
function admin_menu() {
|
747 |
+
|
748 |
}
|
749 |
|
750 |
function add_menu_page($page, $title, $capability = '') {
|
1185 |
if (is_user_logged_in()) {
|
1186 |
return $this->get_user_by_wp_user_id(get_current_user_id());
|
1187 |
}
|
1188 |
+
return null;
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
function get_user_count($refresh = false) {
|
1192 |
+
global $wpdb;
|
1193 |
+
$user_count = get_transient('newsletter_user_count');
|
1194 |
+
if ($user_count === false || $refresh) {
|
1195 |
+
$user_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C'");
|
1196 |
+
set_transient('newsletter_user_count', $user_count, DAY_IN_SECONDS);
|
1197 |
+
}
|
1198 |
+
return $user_count;
|
1199 |
}
|
1200 |
|
1201 |
/**
|
1383 |
* @return string
|
1384 |
*/
|
1385 |
function inline_css($content, $strip_style_blocks = false) {
|
|
|
1386 |
$matches = array();
|
1387 |
+
// "s" skips line breaks
|
1388 |
$styles = preg_match('|<style>(.*?)</style>|s', $content, $matches);
|
1389 |
if (isset($matches[1])) {
|
1390 |
$style = str_replace(array("\n", "\r"), '', $matches[1]);
|
1391 |
$rules = array();
|
1392 |
preg_match_all('|\s*\.(.*?)\{(.*?)\}\s*|s', $style, $rules);
|
|
|
1393 |
for ($i = 0; $i < count($rules[1]); $i++) {
|
1394 |
$class = trim($rules[1][$i]);
|
1395 |
$value = trim($rules[2][$i]);
|
1718 |
$email = null;
|
1719 |
}
|
1720 |
}
|
1721 |
+
|
1722 |
$initial_language = $this->get_current_language();
|
1723 |
+
|
1724 |
if ($user && $user->language) {
|
1725 |
+
$this->switch_language($user->language);
|
1726 |
}
|
1727 |
|
1728 |
|
1876 |
}
|
1877 |
|
1878 |
public static function antibot_form_check($captcha = false) {
|
1879 |
+
|
1880 |
+
if (!NEWSLETTER_ANTIBOT)
|
1881 |
+
return true;
|
1882 |
+
|
1883 |
if (strtolower($_SERVER['REQUEST_METHOD']) != 'post') {
|
1884 |
return false;
|
1885 |
}
|
2203 |
$message .= $list->name . ': ' . ( empty($user->$field) ? "NO" : "YES" ) . "\n";
|
2204 |
}
|
2205 |
|
2206 |
+
for ($i = 0; $i < NEWSLETTER_PROFILE_MAX; $i++) {
|
2207 |
if (empty($this->options_profile['profile_' . $i])) {
|
2208 |
continue;
|
2209 |
}
|
2223 |
return '[' . $blogname . '] ' . $subject;
|
2224 |
}
|
2225 |
|
2226 |
+
function dienow($message, $admin_message = null, $http_code = 200) {
|
2227 |
if ($admin_message && current_user_can('administrator')) {
|
2228 |
$message .= '<br><br><strong>Text below only visibile to administrarors</strong><br>';
|
2229 |
$message .= $admin_message;
|
2230 |
}
|
2231 |
+
wp_die($message, $http_code);
|
2232 |
+
}
|
2233 |
+
|
2234 |
+
function dump($var) {
|
2235 |
+
if (NEWSLETTER_DEBUG) {
|
2236 |
+
var_dump($var);
|
2237 |
+
}
|
2238 |
+
}
|
2239 |
+
|
2240 |
+
function dump_die($var) {
|
2241 |
+
if (NEWSLETTER_DEBUG) {
|
2242 |
+
var_dump($var);
|
2243 |
+
die();
|
2244 |
+
}
|
2245 |
}
|
2246 |
|
2247 |
}
|
plugin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
-
Version: 6.
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -35,13 +35,18 @@ if (version_compare(phpversion(), '5.6', '<')) {
|
|
35 |
return;
|
36 |
}
|
37 |
|
38 |
-
define('NEWSLETTER_VERSION', '6.
|
39 |
|
40 |
global $newsletter, $wpdb;
|
41 |
|
42 |
if (!defined('NEWSLETTER_BETA'))
|
43 |
define('NEWSLETTER_BETA', false);
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
if (!defined('NEWSLETTER_DEBUG'))
|
46 |
define('NEWSLETTER_DEBUG', false);
|
47 |
|
@@ -180,19 +185,17 @@ class Newsletter extends NewsletterModule {
|
|
180 |
|
181 |
add_action('admin_menu', array($this, 'add_extensions_menu'), 90);
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
if ( $this->is_admin_page() ) {
|
186 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'hook_wp_admin_enqueue_scripts' ) );
|
187 |
-
}
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
});
|
193 |
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
-
|
196 |
}
|
197 |
|
198 |
function hook_init() {
|
@@ -335,9 +338,6 @@ class Newsletter extends NewsletterModule {
|
|
335 |
`language` varchar(10) NOT NULL DEFAULT '',
|
336 |
`subject` varchar(255) NOT NULL DEFAULT '',
|
337 |
`message` longtext,
|
338 |
-
`subject2` varchar(255) NOT NULL DEFAULT '',
|
339 |
-
`message2` longtext,
|
340 |
-
`name2` varchar(255) NOT NULL DEFAULT '',
|
341 |
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
342 |
`status` enum('new','sending','sent','paused') NOT NULL DEFAULT 'new',
|
343 |
`total` int(11) NOT NULL DEFAULT '0',
|
@@ -503,48 +503,47 @@ class Newsletter extends NewsletterModule {
|
|
503 |
}
|
504 |
}
|
505 |
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
}
|
548 |
|
549 |
function shortcode_newsletter_replace($attrs, $content) {
|
550 |
$content = do_shortcode($content);
|
@@ -1263,12 +1262,12 @@ class Newsletter extends NewsletterModule {
|
|
1263 |
if (class_exists('SitePress')) {
|
1264 |
$newsletter_page_url = apply_filters('wpml_permalink', $newsletter_page_url, $language, true);
|
1265 |
}
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
}
|
1273 |
|
1274 |
return $newsletter_page_url;
|
@@ -1287,22 +1286,24 @@ class Newsletter extends NewsletterModule {
|
|
1287 |
|
1288 |
function get_license_data($refresh = false) {
|
1289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1290 |
if (!$refresh) {
|
1291 |
$license_data = get_transient('newsletter_license_data');
|
1292 |
-
if (
|
|
|
1293 |
return $license_data;
|
1294 |
}
|
1295 |
}
|
1296 |
|
1297 |
$this->logger->debug('Refreshing the license data');
|
1298 |
|
1299 |
-
delete_transient('newsletter_license_data');
|
1300 |
-
|
1301 |
-
$license_key = $this->get_license_key();
|
1302 |
-
if (empty($license_key)) {
|
1303 |
-
$this->logger->debug('License was empty');
|
1304 |
-
return false;
|
1305 |
-
}
|
1306 |
$license_data_url = 'https://www.thenewsletterplugin.com/wp-content/plugins/file-commerce-pro/get-license-data.php';
|
1307 |
|
1308 |
$response = wp_remote_post($license_data_url, array(
|
@@ -1311,13 +1312,15 @@ class Newsletter extends NewsletterModule {
|
|
1311 |
|
1312 |
// Fall back to http...
|
1313 |
if (is_wp_error($response)) {
|
1314 |
-
$this->logger->error('Falling back to http');
|
1315 |
$this->logger->error($response);
|
|
|
|
|
1316 |
$response = wp_remote_post($license_data_url, array(
|
1317 |
'body' => array('k' => $license_key)
|
1318 |
));
|
1319 |
if (is_wp_error($response)) {
|
1320 |
$this->logger->error($response);
|
|
|
1321 |
return $response;
|
1322 |
}
|
1323 |
}
|
@@ -1326,7 +1329,9 @@ class Newsletter extends NewsletterModule {
|
|
1326 |
|
1327 |
if (wp_remote_retrieve_response_code($response) != '200') {
|
1328 |
$this->logger->error('license data error: ' . wp_remote_retrieve_response_code($response));
|
1329 |
-
|
|
|
|
|
1330 |
}
|
1331 |
|
1332 |
$json = wp_remote_retrieve_body($response);
|
@@ -1334,17 +1339,23 @@ class Newsletter extends NewsletterModule {
|
|
1334 |
|
1335 |
if (!is_object($data)) {
|
1336 |
$this->logger->error($json);
|
1337 |
-
|
|
|
|
|
1338 |
}
|
1339 |
|
1340 |
if (isset($data->message)) {
|
1341 |
-
|
|
|
|
|
1342 |
}
|
1343 |
|
1344 |
-
$
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
|
|
|
|
1348 |
|
1349 |
return $data;
|
1350 |
}
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
+
Version: 6.8.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.
|
35 |
return;
|
36 |
}
|
37 |
|
38 |
+
define('NEWSLETTER_VERSION', '6.8.0');
|
39 |
|
40 |
global $newsletter, $wpdb;
|
41 |
|
42 |
if (!defined('NEWSLETTER_BETA'))
|
43 |
define('NEWSLETTER_BETA', false);
|
44 |
|
45 |
+
// For acceptance tests, DO NOT CHANGE
|
46 |
+
if (!defined('NEWSLETTER_ANTIBOT'))
|
47 |
+
define('NEWSLETTER_ANTIBOT', true);
|
48 |
+
|
49 |
+
// For acceptance tests, DO NOT CHANGE
|
50 |
if (!defined('NEWSLETTER_DEBUG'))
|
51 |
define('NEWSLETTER_DEBUG', false);
|
52 |
|
185 |
|
186 |
add_action('admin_menu', array($this, 'add_extensions_menu'), 90);
|
187 |
|
188 |
+
add_filter('display_post_states', array($this, 'add_notice_to_chosen_profile_page_hook'), 10, 2);
|
|
|
|
|
|
|
|
|
189 |
|
190 |
+
if ($this->is_admin_page()) {
|
191 |
+
add_action('admin_enqueue_scripts', array($this, 'hook_wp_admin_enqueue_scripts'));
|
192 |
+
}
|
|
|
193 |
|
194 |
+
add_action('wp_ajax_tnp_hide_promotion', function () {
|
195 |
+
update_option('newsletter_promotion', $_POST['id']);
|
196 |
+
die();
|
197 |
+
});
|
198 |
}
|
|
|
199 |
}
|
200 |
|
201 |
function hook_init() {
|
338 |
`language` varchar(10) NOT NULL DEFAULT '',
|
339 |
`subject` varchar(255) NOT NULL DEFAULT '',
|
340 |
`message` longtext,
|
|
|
|
|
|
|
341 |
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
342 |
`status` enum('new','sending','sent','paused') NOT NULL DEFAULT 'new',
|
343 |
`total` int(11) NOT NULL DEFAULT '0',
|
503 |
}
|
504 |
}
|
505 |
|
506 |
+
function hook_wp_admin_enqueue_scripts() {
|
507 |
+
|
508 |
+
$newsletter_url = plugins_url('newsletter');
|
509 |
+
wp_enqueue_script('jquery-ui-tabs');
|
510 |
+
wp_enqueue_script('jquery-ui-tooltip');
|
511 |
+
wp_enqueue_media();
|
512 |
+
|
513 |
+
wp_enqueue_style('tnp-admin-font', 'https://use.typekit.net/jlj2wjy.css');
|
514 |
+
wp_enqueue_style('tnp-admin-fontawesome', $newsletter_url . '/vendor/fa/css/all.min.css', [], '6.6.0');
|
515 |
+
wp_enqueue_style('tnp-admin-jquery-ui', $newsletter_url . '/vendor/jquery-ui/jquery-ui.min.css', [], '6.6.0');
|
516 |
+
wp_enqueue_style('tnp-admin-dropdown', $newsletter_url . '/css/dropdown.css', [], '6.6.0');
|
517 |
+
wp_enqueue_style('tnp-admin-fields', $newsletter_url . '/css/fields.css', [], '6.6.0');
|
518 |
+
wp_enqueue_style('tnp-admin-widgets', $newsletter_url . '/css/widgets.css', [], '6.6.0');
|
519 |
+
wp_enqueue_style('tnp-admin', $newsletter_url . '/admin.css',
|
520 |
+
array(
|
521 |
+
'tnp-admin-font',
|
522 |
+
'tnp-admin-fontawesome',
|
523 |
+
'tnp-admin-jquery-ui',
|
524 |
+
'tnp-admin-dropdown',
|
525 |
+
'tnp-admin-fields',
|
526 |
+
'tnp-admin-widgets'
|
527 |
+
), filemtime(NEWSLETTER_DIR . '/admin.css'));
|
528 |
+
|
529 |
+
wp_enqueue_script('tnp-admin', $newsletter_url . '/admin.js', array('jquery'), time());
|
530 |
+
|
531 |
+
$translations_array = array(
|
532 |
+
'save_to_update_counter' => __('Save the newsletter to update the counter!', 'newsletter')
|
533 |
+
);
|
534 |
+
wp_localize_script('tnp-admin', 'tnp_translations', $translations_array);
|
535 |
+
|
536 |
+
wp_enqueue_style('wp-color-picker');
|
537 |
+
wp_enqueue_script('wp-color-picker');
|
538 |
+
|
539 |
+
wp_enqueue_style('tnp-select2', $newsletter_url . '/vendor/select2/select2.css');
|
540 |
+
wp_enqueue_script('tnp-select2', $newsletter_url . '/vendor/select2/select2.min.js');
|
541 |
+
wp_enqueue_script('tnp-jquery-vmap', $newsletter_url . '/vendor/jqvmap/jquery.vmap.min.js', array('jquery'));
|
542 |
+
wp_enqueue_script('tnp-jquery-vmap-world', $newsletter_url . '/vendor/jqvmap/jquery.vmap.world.js', array('tnp-jquery-vmap'));
|
543 |
+
wp_enqueue_style('tnp-jquery-vmap', $newsletter_url . '/vendor/jqvmap/jqvmap.min.css');
|
544 |
+
|
545 |
+
wp_register_script('tnp-chart', $newsletter_url . '/vendor/chartjs/Chart.min.js', array('jquery'));
|
546 |
+
}
|
|
|
547 |
|
548 |
function shortcode_newsletter_replace($attrs, $content) {
|
549 |
$content = do_shortcode($content);
|
1262 |
if (class_exists('SitePress')) {
|
1263 |
$newsletter_page_url = apply_filters('wpml_permalink', $newsletter_page_url, $language, true);
|
1264 |
}
|
1265 |
+
if (function_exists('pll_get_post')) {
|
1266 |
+
$translated_page = get_permalink( pll_get_post( $page->ID, $language ) );
|
1267 |
+
if ($translated_page) {
|
1268 |
+
$newsletter_page_url = $translated_page;
|
1269 |
+
}
|
1270 |
+
}
|
1271 |
}
|
1272 |
|
1273 |
return $newsletter_page_url;
|
1286 |
|
1287 |
function get_license_data($refresh = false) {
|
1288 |
|
1289 |
+
$this->logger->debug('Getting license data');
|
1290 |
+
|
1291 |
+
$license_key = $this->get_license_key();
|
1292 |
+
if (empty($license_key)) {
|
1293 |
+
$this->logger->debug('License was empty');
|
1294 |
+
return false;
|
1295 |
+
}
|
1296 |
+
|
1297 |
if (!$refresh) {
|
1298 |
$license_data = get_transient('newsletter_license_data');
|
1299 |
+
if ($license_data !== false && is_object($license_data)) {
|
1300 |
+
$this->logger->debug('License data found on cache');
|
1301 |
return $license_data;
|
1302 |
}
|
1303 |
}
|
1304 |
|
1305 |
$this->logger->debug('Refreshing the license data');
|
1306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1307 |
$license_data_url = 'https://www.thenewsletterplugin.com/wp-content/plugins/file-commerce-pro/get-license-data.php';
|
1308 |
|
1309 |
$response = wp_remote_post($license_data_url, array(
|
1312 |
|
1313 |
// Fall back to http...
|
1314 |
if (is_wp_error($response)) {
|
|
|
1315 |
$this->logger->error($response);
|
1316 |
+
$this->logger->error('Falling back to http');
|
1317 |
+
$license_data_url = str_replace('https', 'http', $license_data_url);
|
1318 |
$response = wp_remote_post($license_data_url, array(
|
1319 |
'body' => array('k' => $license_key)
|
1320 |
));
|
1321 |
if (is_wp_error($response)) {
|
1322 |
$this->logger->error($response);
|
1323 |
+
set_transient('newsletter_license_data', $response, DAY_IN_SECONDS);
|
1324 |
return $response;
|
1325 |
}
|
1326 |
}
|
1329 |
|
1330 |
if (wp_remote_retrieve_response_code($response) != '200') {
|
1331 |
$this->logger->error('license data error: ' . wp_remote_retrieve_response_code($response));
|
1332 |
+
$data = new WP_Error(wp_remote_retrieve_response_code($response), 'License validation service error. <br>' . $download_message);
|
1333 |
+
set_transient('newsletter_license_data', $data, DAY_IN_SECONDS);
|
1334 |
+
return $data;
|
1335 |
}
|
1336 |
|
1337 |
$json = wp_remote_retrieve_body($response);
|
1339 |
|
1340 |
if (!is_object($data)) {
|
1341 |
$this->logger->error($json);
|
1342 |
+
$data = new WP_Error(1, 'License validation service error. <br>' . $download_message);
|
1343 |
+
set_transient('newsletter_license_data', $data, DAY_IN_SECONDS);
|
1344 |
+
return $data;
|
1345 |
}
|
1346 |
|
1347 |
if (isset($data->message)) {
|
1348 |
+
$data = new WP_Error(1, $data->message . ' (check the license on Newsletter main settings)');
|
1349 |
+
set_transient('newsletter_license_data', $data, DAY_IN_SECONDS);
|
1350 |
+
return $data;
|
1351 |
}
|
1352 |
|
1353 |
+
$expiration = WEEK_IN_SECONDS;
|
1354 |
+
// If the license expires in few days, make the transient live only few days, so it will be refreshed
|
1355 |
+
if ($data->expire > time() && $data->expire - time() < WEEK_IN_SECONDS) {
|
1356 |
+
$expiration = $data->expire - time();
|
1357 |
+
}
|
1358 |
+
set_transient('newsletter_license_data', $data, $expiration);
|
1359 |
|
1360 |
return $data;
|
1361 |
}
|
profile/profile.php
CHANGED
@@ -28,7 +28,8 @@ class NewsletterProfile extends NewsletterModule {
|
|
28 |
|
29 |
if (in_array($action, ['p', 'profile', 'pe', 'profile-save', 'profile_export', 'ps'])) {
|
30 |
if (!$user || $user->status != TNP_User::STATUS_CONFIRMED) {
|
31 |
-
|
|
|
32 |
}
|
33 |
}
|
34 |
|
@@ -244,23 +245,22 @@ class NewsletterProfile extends NewsletterModule {
|
|
244 |
$buffer .= "</div>\n";
|
245 |
}
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
$languages = $this->get_languages();
|
250 |
|
251 |
-
|
252 |
-
$buffer .= '<label>' . __( 'Language', 'Newsletter' ) . '</label>';
|
253 |
-
$buffer .= '<select name="nlng" class="tnp-language">';
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
}
|
259 |
|
260 |
-
|
261 |
-
|
|
|
|
|
262 |
|
263 |
-
|
|
|
|
|
264 |
|
265 |
// Profile
|
266 |
for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
|
@@ -409,12 +409,12 @@ class NewsletterProfile extends NewsletterModule {
|
|
409 |
die('Wrong sex field');
|
410 |
}
|
411 |
}
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
|
419 |
// Lists. If not list is present or there is no list to choose or all are unchecked.
|
420 |
$nl = array();
|
28 |
|
29 |
if (in_array($action, ['p', 'profile', 'pe', 'profile-save', 'profile_export', 'ps'])) {
|
30 |
if (!$user || $user->status != TNP_User::STATUS_CONFIRMED) {
|
31 |
+
|
32 |
+
$this->dienow(__('The subscriber was not found or is not confirmed.', 'newsletter'), '', 404);
|
33 |
}
|
34 |
}
|
35 |
|
245 |
$buffer .= "</div>\n";
|
246 |
}
|
247 |
|
248 |
+
if ($this->is_multilanguage()) {
|
|
|
|
|
249 |
|
250 |
+
$languages = $this->get_languages();
|
|
|
|
|
251 |
|
252 |
+
$buffer .= '<div class="tnp-field tnp-field-language">';
|
253 |
+
$buffer .= '<label>' . __('Language', 'Newsletter') . '</label>';
|
254 |
+
$buffer .= '<select name="nlng" class="tnp-language">';
|
|
|
255 |
|
256 |
+
$buffer .= '<option value="" disabled ' . ( empty($user->language) ? ' selected' : '' ) . '>' . __('Select language', 'newsletter') . '</option>';
|
257 |
+
foreach ($languages as $key => $language) {
|
258 |
+
$buffer .= '<option value="' . $key . '"' . ( $user->language == $key ? ' selected' : '' ) . '>' . $language . '</option>';
|
259 |
+
}
|
260 |
|
261 |
+
$buffer .= '</select>';
|
262 |
+
$buffer .= "</div>\n";
|
263 |
+
}
|
264 |
|
265 |
// Profile
|
266 |
for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
|
409 |
die('Wrong sex field');
|
410 |
}
|
411 |
}
|
412 |
+
if (isset($_REQUEST['nlng'])) {
|
413 |
+
$languages = $this->get_languages();
|
414 |
+
if (isset($languages[$_REQUEST['nlng']])) {
|
415 |
+
$data['language'] = $_REQUEST['nlng'];
|
416 |
+
}
|
417 |
+
}
|
418 |
|
419 |
// Lists. If not list is present or there is no list to choose or all are unchecked.
|
420 |
$nl = array();
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Tags: email, email marketing, newsletter, newsletter subscribers, welcome email, signup forms, contact, lead generation, popup, marketing automation
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 5.4.2
|
5 |
-
Stable tag: 6.
|
6 |
Requires PHP: 5.6
|
7 |
Contributors: satollo,webagile,michael-travan
|
8 |
|
@@ -113,6 +113,15 @@ Thank you, The Newsletter Team
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
= 6.7.9 =
|
117 |
|
118 |
* Fixed posts block
|
2 |
Tags: email, email marketing, newsletter, newsletter subscribers, welcome email, signup forms, contact, lead generation, popup, marketing automation
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 5.4.2
|
5 |
+
Stable tag: 6.8.0
|
6 |
Requires PHP: 5.6
|
7 |
Contributors: satollo,webagile,michael-travan
|
8 |
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
= 6.8.0 =
|
117 |
+
|
118 |
+
* Improved license checking (only for who set a license code - it is not required)
|
119 |
+
* Imporved extra field configuration with multilanguage blogs
|
120 |
+
* Improved subscription form with extra fields for multilanguage blogs
|
121 |
+
* Minor code improvements
|
122 |
+
* Improved HTTP responses for invalid profile links (good for users and acceptance tests)
|
123 |
+
* Fixed newsletter page url generation with Polylang
|
124 |
+
|
125 |
= 6.7.9 =
|
126 |
|
127 |
* Fixed posts block
|
subscription/antibot.php
CHANGED
@@ -37,9 +37,9 @@ if ($controls->is_action()) {
|
|
37 |
<?php $controls->init(); ?>
|
38 |
|
39 |
|
40 |
-
<
|
41 |
<?php $controls->button_save() ?>
|
42 |
-
</
|
43 |
|
44 |
<div id="tabs">
|
45 |
<ul>
|
@@ -63,7 +63,7 @@ if ($controls->is_action()) {
|
|
63 |
</tr>
|
64 |
|
65 |
<tr>
|
66 |
-
<th
|
67 |
<td>
|
68 |
<?php
|
69 |
$controls->select('akismet', array(
|
@@ -71,12 +71,11 @@ if ($controls->is_action()) {
|
|
71 |
1 => __('Enabled', 'newsletter')
|
72 |
));
|
73 |
?>
|
74 |
-
<?php $controls->help('https://www.thenewsletterplugin.com/documentation/subscription/antiflood') ?>
|
75 |
</td>
|
76 |
</tr>
|
77 |
|
78 |
<tr>
|
79 |
-
<th><?php
|
80 |
<td>
|
81 |
<?php
|
82 |
$controls->select('antiflood', array(
|
@@ -94,13 +93,14 @@ if ($controls->is_action()) {
|
|
94 |
360 => '60 ' . __('minutes', 'newsletter')
|
95 |
));
|
96 |
?>
|
97 |
-
<?php $controls->help('https://www.thenewsletterplugin.com/documentation/subscription/antiflood') ?>
|
98 |
</td>
|
99 |
</tr>
|
100 |
<tr>
|
101 |
-
<th
|
|
|
|
|
102 |
<td>
|
103 |
-
<?php $controls->enabled('captcha'); ?>
|
104 |
</td>
|
105 |
</tr>
|
106 |
<?php /*
|
@@ -123,8 +123,7 @@ if ($controls->is_action()) {
|
|
123 |
<table class="form-table">
|
124 |
<tr>
|
125 |
<th>
|
126 |
-
<?php
|
127 |
-
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/subscription/antiflood/#ip') ?>
|
128 |
</th>
|
129 |
<td>
|
130 |
<?php $controls->textarea('ip_blacklist'); ?>
|
@@ -133,8 +132,7 @@ if ($controls->is_action()) {
|
|
133 |
</tr>
|
134 |
<tr>
|
135 |
<th>
|
136 |
-
<?php
|
137 |
-
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/subscription/antiflood/#domains') ?>
|
138 |
</th>
|
139 |
<td>
|
140 |
<?php $controls->textarea('address_blacklist'); ?>
|
37 |
<?php $controls->init(); ?>
|
38 |
|
39 |
|
40 |
+
<p>
|
41 |
<?php $controls->button_save() ?>
|
42 |
+
</p>
|
43 |
|
44 |
<div id="tabs">
|
45 |
<ul>
|
63 |
</tr>
|
64 |
|
65 |
<tr>
|
66 |
+
<th><?php $controls->field_label('Akismet', '/documentation/subscription/antiflood#akismet')?></th>
|
67 |
<td>
|
68 |
<?php
|
69 |
$controls->select('akismet', array(
|
71 |
1 => __('Enabled', 'newsletter')
|
72 |
));
|
73 |
?>
|
|
|
74 |
</td>
|
75 |
</tr>
|
76 |
|
77 |
<tr>
|
78 |
+
<th><?php $controls->field_label(__('Antiflood', 'newsletter'), '/documentation/subscription/antiflood#antiflood') ?></th>
|
79 |
<td>
|
80 |
<?php
|
81 |
$controls->select('antiflood', array(
|
93 |
360 => '60 ' . __('minutes', 'newsletter')
|
94 |
));
|
95 |
?>
|
|
|
96 |
</td>
|
97 |
</tr>
|
98 |
<tr>
|
99 |
+
<th>
|
100 |
+
<?php $controls->field_label(__('Captcha', 'newsletter'), '/documentation/subscription/antiflood/#captcha') ?>
|
101 |
+
</th>
|
102 |
<td>
|
103 |
+
<?php $controls->enabled('captcha'); ?>
|
104 |
</td>
|
105 |
</tr>
|
106 |
<?php /*
|
123 |
<table class="form-table">
|
124 |
<tr>
|
125 |
<th>
|
126 |
+
<?php $controls->field_label(__('IP black list', 'newsletter'), '/documentation/subscription/antiflood/#ip-blacklist') ?>
|
|
|
127 |
</th>
|
128 |
<td>
|
129 |
<?php $controls->textarea('ip_blacklist'); ?>
|
132 |
</tr>
|
133 |
<tr>
|
134 |
<th>
|
135 |
+
<?php $controls->field_label(__('Address black list', 'newsletter'), '/documentation/subscription/antiflood/#email-blacklist') ?>
|
|
|
136 |
</th>
|
137 |
<td>
|
138 |
<?php $controls->textarea('address_blacklist'); ?>
|
subscription/options.php
CHANGED
@@ -117,7 +117,7 @@ if ($controls->is_action()) {
|
|
117 |
<div id="tnp-heading">
|
118 |
|
119 |
<h2><?php _e('Subscription Configuration', 'newsletter') ?></h2>
|
120 |
-
<?php $controls->page_help('https://www.thenewsletterplugin.com/documentation/subscription') ?>
|
121 |
|
122 |
</div>
|
123 |
|
@@ -139,24 +139,22 @@ if ($controls->is_action()) {
|
|
139 |
<table class="form-table">
|
140 |
|
141 |
<tr>
|
142 |
-
<th><?php
|
143 |
<td>
|
144 |
<?php $controls->select('noconfirmation', array(0 => __('Double Opt In', 'newsletter'), 1 => __('Single Opt In', 'newsletter'))); ?>
|
145 |
-
<?php $controls->help('https://www.thenewsletterplugin.com/documentation/subscription#opt-in') ?>
|
146 |
</td>
|
147 |
</tr>
|
148 |
<tr>
|
149 |
-
<th><?php
|
150 |
<td>
|
151 |
<?php $controls->yesno('optin_override'); ?>
|
152 |
</td>
|
153 |
</tr>
|
154 |
<tr>
|
155 |
-
<th><?php
|
156 |
<td>
|
157 |
<?php //$controls->select('multiple', array('0'=>__('No', 'newsletter'), '1'=>__('Yes', 'newsletter'), '2'=>__('On new lists added', 'newsletter'))); ?>
|
158 |
<?php $controls->select('multiple', array('0'=>__('No', 'newsletter'), '1'=>__('Yes', 'newsletter'))); ?>
|
159 |
-
<?php $controls->help('https://www.thenewsletterplugin.com/documentation/subscription#repeated')?>
|
160 |
</td>
|
161 |
</tr>
|
162 |
|
117 |
<div id="tnp-heading">
|
118 |
|
119 |
<h2><?php _e('Subscription Configuration', 'newsletter') ?></h2>
|
120 |
+
<?php $controls->page_help('https://www.thenewsletterplugin.com/documentation/subscription/subscription/') ?>
|
121 |
|
122 |
</div>
|
123 |
|
139 |
<table class="form-table">
|
140 |
|
141 |
<tr>
|
142 |
+
<th><?php $controls->field_label(__('Opt In', 'newsletter'), '/documentation/subscription/subscription/') ?></th>
|
143 |
<td>
|
144 |
<?php $controls->select('noconfirmation', array(0 => __('Double Opt In', 'newsletter'), 1 => __('Single Opt In', 'newsletter'))); ?>
|
|
|
145 |
</td>
|
146 |
</tr>
|
147 |
<tr>
|
148 |
+
<th><?php $controls->field_label(__('Override Opt In', 'newsletter'), '/documentation/subscription/subscription/#advanced') ?></th>
|
149 |
<td>
|
150 |
<?php $controls->yesno('optin_override'); ?>
|
151 |
</td>
|
152 |
</tr>
|
153 |
<tr>
|
154 |
+
<th><?php $controls->field_label(__('Repeated subscriptions', 'newsletter'), '/documentation/subscription/subscription/') ?></th>
|
155 |
<td>
|
156 |
<?php //$controls->select('multiple', array('0'=>__('No', 'newsletter'), '1'=>__('Yes', 'newsletter'), '2'=>__('On new lists added', 'newsletter'))); ?>
|
157 |
<?php $controls->select('multiple', array('0'=>__('No', 'newsletter'), '1'=>__('Yes', 'newsletter'))); ?>
|
|
|
158 |
</td>
|
159 |
</tr>
|
160 |
|
subscription/profile.php
CHANGED
@@ -18,6 +18,7 @@ if (!$controls->is_action()) {
|
|
18 |
} else {
|
19 |
if ($controls->is_action('save')) {
|
20 |
$this->save_options($controls->data, 'profile', null, $current_language);
|
|
|
21 |
$controls->add_message_saved();
|
22 |
}
|
23 |
|
@@ -29,6 +30,7 @@ if (!$controls->is_action()) {
|
|
29 |
|
30 |
$status = array(0 => __('Private', 'newsletter'), 1 => __('Show on profile page', 'newsletter'), 2 => __('Show on subscription form', 'newsletter'));
|
31 |
$rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newsletter'));
|
|
|
32 |
?>
|
33 |
|
34 |
<div class="wrap" id="tnp-wrap">
|
@@ -45,7 +47,7 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
45 |
|
46 |
</div>
|
47 |
|
48 |
-
<div id="tnp-body">
|
49 |
|
50 |
<form action="" method="post">
|
51 |
<?php $controls->init(); ?>
|
@@ -115,7 +117,7 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
115 |
male: <?php $controls->text('sex_male'); ?>
|
116 |
not specified: <?php $controls->text('sex_none'); ?>
|
117 |
</td></tr>
|
118 |
-
|
119 |
|
120 |
<tr><th>Salutation titles</th><td>
|
121 |
|
@@ -206,9 +208,17 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
206 |
|
207 |
<table class="widefat">
|
208 |
<thead>
|
209 |
-
|
210 |
-
|
211 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
</thead>
|
213 |
<?php for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) { ?>
|
214 |
<tr>
|
@@ -217,8 +227,12 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
217 |
<td><?php $controls->text('profile_' . $i . '_placeholder'); ?></td>
|
218 |
<?php if ($is_all_languages) { ?>
|
219 |
<td><?php $controls->select('profile_' . $i . '_status', $status); ?></td>
|
220 |
-
<td><?php $controls->select('profile_' . $i . '_type',
|
221 |
<td><?php $controls->select('profile_' . $i . '_rules', $rules); ?></td>
|
|
|
|
|
|
|
|
|
222 |
<?php } ?>
|
223 |
<td>
|
224 |
<?php $controls->textarea_fixed('profile_' . $i . '_options', '200px', '50px'); ?>
|
@@ -229,7 +243,7 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
229 |
|
230 |
</div>
|
231 |
|
232 |
-
|
233 |
|
234 |
</div>
|
235 |
|
18 |
} else {
|
19 |
if ($controls->is_action('save')) {
|
20 |
$this->save_options($controls->data, 'profile', null, $current_language);
|
21 |
+
$controls->data = $this->get_options('profile', $current_language);
|
22 |
$controls->add_message_saved();
|
23 |
}
|
24 |
|
30 |
|
31 |
$status = array(0 => __('Private', 'newsletter'), 1 => __('Show on profile page', 'newsletter'), 2 => __('Show on subscription form', 'newsletter'));
|
32 |
$rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newsletter'));
|
33 |
+
$extra_type = array('text' => __('Text', 'newsletter'), 'select' => __('List', 'newsletter'));
|
34 |
?>
|
35 |
|
36 |
<div class="wrap" id="tnp-wrap">
|
47 |
|
48 |
</div>
|
49 |
|
50 |
+
<div id="tnp-body">
|
51 |
|
52 |
<form action="" method="post">
|
53 |
<?php $controls->init(); ?>
|
117 |
male: <?php $controls->text('sex_male'); ?>
|
118 |
not specified: <?php $controls->text('sex_none'); ?>
|
119 |
</td></tr>
|
120 |
+
|
121 |
|
122 |
<tr><th>Salutation titles</th><td>
|
123 |
|
208 |
|
209 |
<table class="widefat">
|
210 |
<thead>
|
211 |
+
<tr>
|
212 |
+
<th>Field</th>
|
213 |
+
<th>Name/Label</th>
|
214 |
+
<th>Placeholder</th>
|
215 |
+
|
216 |
+
<th>When/Where</th>
|
217 |
+
<th>Type</th>
|
218 |
+
<th>Rule</th>
|
219 |
+
|
220 |
+
<th>List values comma separated</th>
|
221 |
+
</tr>
|
222 |
</thead>
|
223 |
<?php for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) { ?>
|
224 |
<tr>
|
227 |
<td><?php $controls->text('profile_' . $i . '_placeholder'); ?></td>
|
228 |
<?php if ($is_all_languages) { ?>
|
229 |
<td><?php $controls->select('profile_' . $i . '_status', $status); ?></td>
|
230 |
+
<td><?php $controls->select('profile_' . $i . '_type', $extra_type); ?></td>
|
231 |
<td><?php $controls->select('profile_' . $i . '_rules', $rules); ?></td>
|
232 |
+
<?php } else { ?>
|
233 |
+
<td><?php echo esc_html($status[$controls->get_value('profile_' . $i . '_status')]) ?></td>
|
234 |
+
<td><?php echo esc_html($extra_type[$controls->get_value('profile_' . $i . '_type')]) ?></td>
|
235 |
+
<td><?php echo esc_html($rules[$controls->get_value('profile_' . $i . '_rules')]) ?></td>
|
236 |
<?php } ?>
|
237 |
<td>
|
238 |
<?php $controls->textarea_fixed('profile_' . $i . '_options', '200px', '50px'); ?>
|
243 |
|
244 |
</div>
|
245 |
|
246 |
+
|
247 |
|
248 |
</div>
|
249 |
|
subscription/subscription.php
CHANGED
@@ -287,7 +287,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
287 |
switch ($action) {
|
288 |
case 'profile-change':
|
289 |
if ($this->antibot_form_check()) {
|
290 |
-
|
291 |
if (!$user || $user->status != TNP_user::STATUS_CONFIRMED) {
|
292 |
$this->dienow('Subscriber not found or not confirmed.');
|
293 |
}
|
@@ -549,7 +549,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
549 |
if (!is_array($i18n_options)) $i18n_options = array();
|
550 |
$options = get_option('newsletter_profile', array());
|
551 |
if (!is_array($options)) $options = array();
|
552 |
-
$options = array_merge($options, $i18n_options);
|
553 |
} else {
|
554 |
$options = get_option('newsletter_profile', array());
|
555 |
}
|
@@ -645,7 +645,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
645 |
}
|
646 |
|
647 |
$user = $this->get_user($email);
|
648 |
-
|
649 |
|
650 |
if ($user != null) {
|
651 |
// Email already registered in our database
|
@@ -719,7 +719,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
719 |
if ($emails) {
|
720 |
$this->send_message(($user->status == Newsletter::STATUS_CONFIRMED) ? 'confirmed' : 'confirmation', $user);
|
721 |
}
|
722 |
-
|
723 |
$user = apply_filters('newsletter_user_post_subscribe', $user);
|
724 |
|
725 |
return $user;
|
@@ -788,7 +788,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
788 |
$user['profile_' . $i] = trim(stripslashes($_REQUEST['np' . $i]));
|
789 |
}
|
790 |
}
|
791 |
-
|
792 |
// Extra validation to explain the administrator while the submitted data could
|
793 |
// be interpreted only partially
|
794 |
if (current_user_can('administrator')) {
|
@@ -856,9 +856,9 @@ class NewsletterSubscription extends NewsletterModule {
|
|
856 |
$message = str_replace('{message}', $message, $template);
|
857 |
|
858 |
//$headers = array('Auto-Submitted' => 'auto-generated');
|
859 |
-
|
860 |
$headers = array();
|
861 |
-
|
862 |
// Replaces tags from the template
|
863 |
$message = $this->replace($message, $user);
|
864 |
$subject = $this->replace($subject, $user);
|
@@ -1075,7 +1075,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1075 |
if (isset($attrs['referrer'])) {
|
1076 |
$buffer .= '<input type="hidden" name="nr" value="' . esc_attr($attrs['referrer']) . '">' . "\n";
|
1077 |
}
|
1078 |
-
|
1079 |
if (isset($attrs['optin'])) {
|
1080 |
$buffer .= '<input type="hidden" name="optin" value="' . esc_attr($attrs['optin']) . '">' . "\n";
|
1081 |
}
|
@@ -1120,7 +1120,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1120 |
|
1121 |
/**
|
1122 |
* Internal use only
|
1123 |
-
*
|
1124 |
* @param type $name
|
1125 |
* @param type $attrs
|
1126 |
* @param type $suffix
|
@@ -1265,7 +1265,24 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1265 |
|
1266 |
if ($name == 'profile' && isset($attrs['number'])) {
|
1267 |
$number = (int) $attrs['number'];
|
1268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1269 |
$size = isset($attrs['size']) ? $attrs['size'] : '';
|
1270 |
$buffer .= '<div class="tnp-field tnp-field-profile">';
|
1271 |
if (isset($attrs['label'])) {
|
@@ -1273,35 +1290,33 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1273 |
$buffer .= '<label>' . esc_html($attrs['label']) . '</label>';
|
1274 |
}
|
1275 |
} else {
|
1276 |
-
$buffer .= '<label>' . esc_html($
|
1277 |
}
|
1278 |
-
$placeholder = isset($attrs['placeholder']) ? $attrs['placeholder'] : $this->options_profile['profile_' . $number . '_placeholder'];
|
1279 |
|
1280 |
-
$
|
1281 |
|
1282 |
// Text field
|
1283 |
-
if ($type ==
|
1284 |
$buffer .= '<input class="tnp-profile tnp-profile-' . $number . '" type="text" size="' . esc_attr($size) . '" name="np' . $number . '" placeholder="' . esc_attr($placeholder) . '"';
|
1285 |
-
if ($
|
1286 |
$buffer .= ' required';
|
1287 |
}
|
1288 |
$buffer .= '>';
|
1289 |
}
|
1290 |
|
1291 |
// Select field
|
1292 |
-
if ($type ==
|
1293 |
$buffer .= '<select class="tnp-profile tnp-profile-' . $number . '" name="np' . $number . '"';
|
1294 |
-
if ($
|
1295 |
$buffer .= ' required';
|
1296 |
}
|
1297 |
$buffer .= '>';
|
1298 |
if (!empty($placeholder)) {
|
1299 |
-
$buffer .= '<option value="">' . esc_html($placeholder) . '</option>';
|
1300 |
-
}
|
1301 |
-
$opts = explode(',', $this->options_profile['profile_' . $number . '_options']);
|
1302 |
-
for ($j = 0; $j < count($opts); $j++) {
|
1303 |
-
$buffer .= '<option>' . esc_html(trim($opts[$j])) . '</option>';
|
1304 |
}
|
|
|
|
|
|
|
1305 |
$buffer .= "</select>\n";
|
1306 |
}
|
1307 |
|
@@ -1387,7 +1402,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1387 |
if (isset($attrs['action'])) {
|
1388 |
$action = $attrs['action'];
|
1389 |
}
|
1390 |
-
|
1391 |
if (isset($attrs['referrer'])) {
|
1392 |
$referrer = $attrs['referrer'];
|
1393 |
}
|
@@ -1414,7 +1429,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1414 |
if (!empty($attrs['optin'])) {
|
1415 |
$buffer .= '<input type="hidden" name="optin" value="' . esc_attr($attrs['optin']) . '">' . "\n";
|
1416 |
}
|
1417 |
-
|
1418 |
if (!empty($referrer)) {
|
1419 |
$buffer .= '<input type="hidden" name="nr" value="' . esc_attr($referrer) . '">' . "\n";
|
1420 |
}
|
@@ -1723,6 +1738,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
1723 |
}
|
1724 |
|
1725 |
$message = apply_filters('newsletter_page_text', '', $message_key, $user);
|
|
|
1726 |
|
1727 |
$options = $this->get_options('', $this->get_current_language($user));
|
1728 |
|
287 |
switch ($action) {
|
288 |
case 'profile-change':
|
289 |
if ($this->antibot_form_check()) {
|
290 |
+
|
291 |
if (!$user || $user->status != TNP_user::STATUS_CONFIRMED) {
|
292 |
$this->dienow('Subscriber not found or not confirmed.');
|
293 |
}
|
549 |
if (!is_array($i18n_options)) $i18n_options = array();
|
550 |
$options = get_option('newsletter_profile', array());
|
551 |
if (!is_array($options)) $options = array();
|
552 |
+
$options = array_merge($options, array_filter($i18n_options));
|
553 |
} else {
|
554 |
$options = get_option('newsletter_profile', array());
|
555 |
}
|
645 |
}
|
646 |
|
647 |
$user = $this->get_user($email);
|
648 |
+
|
649 |
|
650 |
if ($user != null) {
|
651 |
// Email already registered in our database
|
719 |
if ($emails) {
|
720 |
$this->send_message(($user->status == Newsletter::STATUS_CONFIRMED) ? 'confirmed' : 'confirmation', $user);
|
721 |
}
|
722 |
+
|
723 |
$user = apply_filters('newsletter_user_post_subscribe', $user);
|
724 |
|
725 |
return $user;
|
788 |
$user['profile_' . $i] = trim(stripslashes($_REQUEST['np' . $i]));
|
789 |
}
|
790 |
}
|
791 |
+
|
792 |
// Extra validation to explain the administrator while the submitted data could
|
793 |
// be interpreted only partially
|
794 |
if (current_user_can('administrator')) {
|
856 |
$message = str_replace('{message}', $message, $template);
|
857 |
|
858 |
//$headers = array('Auto-Submitted' => 'auto-generated');
|
859 |
+
|
860 |
$headers = array();
|
861 |
+
|
862 |
// Replaces tags from the template
|
863 |
$message = $this->replace($message, $user);
|
864 |
$subject = $this->replace($subject, $user);
|
1075 |
if (isset($attrs['referrer'])) {
|
1076 |
$buffer .= '<input type="hidden" name="nr" value="' . esc_attr($attrs['referrer']) . '">' . "\n";
|
1077 |
}
|
1078 |
+
|
1079 |
if (isset($attrs['optin'])) {
|
1080 |
$buffer .= '<input type="hidden" name="optin" value="' . esc_attr($attrs['optin']) . '">' . "\n";
|
1081 |
}
|
1120 |
|
1121 |
/**
|
1122 |
* Internal use only
|
1123 |
+
*
|
1124 |
* @param type $name
|
1125 |
* @param type $attrs
|
1126 |
* @param type $suffix
|
1265 |
|
1266 |
if ($name == 'profile' && isset($attrs['number'])) {
|
1267 |
$number = (int) $attrs['number'];
|
1268 |
+
|
1269 |
+
$profile = TNP_Profile_Service::get_profile_by_id($number);
|
1270 |
+
|
1271 |
+
if ( $profile->status == 0 ) {
|
1272 |
+
if ( current_user_can( 'administrator' ) ) {
|
1273 |
+
$buffer .= '<div class="tnp-field tnp-field-profile">';
|
1274 |
+
$buffer .= sprintf( __( 'Extra profile field \'%s\' is set on private status. Please change extra profile status to show it on registration form. This message is visible only for administrator.', 'newsletter' ),
|
1275 |
+
esc_html( $profile->name ) );
|
1276 |
+
$buffer .= "</div>";
|
1277 |
+
|
1278 |
+
return $buffer;
|
1279 |
+
}
|
1280 |
+
|
1281 |
+
return '';
|
1282 |
+
|
1283 |
+
}
|
1284 |
+
|
1285 |
+
|
1286 |
$size = isset($attrs['size']) ? $attrs['size'] : '';
|
1287 |
$buffer .= '<div class="tnp-field tnp-field-profile">';
|
1288 |
if (isset($attrs['label'])) {
|
1290 |
$buffer .= '<label>' . esc_html($attrs['label']) . '</label>';
|
1291 |
}
|
1292 |
} else {
|
1293 |
+
$buffer .= '<label>' . esc_html($profile->name) . '</label>';
|
1294 |
}
|
|
|
1295 |
|
1296 |
+
$placeholder = isset($attrs['placeholder']) ? $attrs['placeholder'] : $profile->placeholder;
|
1297 |
|
1298 |
// Text field
|
1299 |
+
if ($profile->type == TNP_Profile::TYPE_TEXT) {
|
1300 |
$buffer .= '<input class="tnp-profile tnp-profile-' . $number . '" type="text" size="' . esc_attr($size) . '" name="np' . $number . '" placeholder="' . esc_attr($placeholder) . '"';
|
1301 |
+
if ($profile->is_required()) {
|
1302 |
$buffer .= ' required';
|
1303 |
}
|
1304 |
$buffer .= '>';
|
1305 |
}
|
1306 |
|
1307 |
// Select field
|
1308 |
+
if ($profile->type == TNP_Profile::TYPE_SELECT) {
|
1309 |
$buffer .= '<select class="tnp-profile tnp-profile-' . $number . '" name="np' . $number . '"';
|
1310 |
+
if ($profile->is_required()) {
|
1311 |
$buffer .= ' required';
|
1312 |
}
|
1313 |
$buffer .= '>';
|
1314 |
if (!empty($placeholder)) {
|
1315 |
+
$buffer .= '<option value="" selected disabled>' . esc_html($placeholder) . '</option>';
|
|
|
|
|
|
|
|
|
1316 |
}
|
1317 |
+
foreach ( $profile->options as $option ) {
|
1318 |
+
$buffer .= '<option>' . esc_html( trim( $option ) ) . '</option>';
|
1319 |
+
}
|
1320 |
$buffer .= "</select>\n";
|
1321 |
}
|
1322 |
|
1402 |
if (isset($attrs['action'])) {
|
1403 |
$action = $attrs['action'];
|
1404 |
}
|
1405 |
+
|
1406 |
if (isset($attrs['referrer'])) {
|
1407 |
$referrer = $attrs['referrer'];
|
1408 |
}
|
1429 |
if (!empty($attrs['optin'])) {
|
1430 |
$buffer .= '<input type="hidden" name="optin" value="' . esc_attr($attrs['optin']) . '">' . "\n";
|
1431 |
}
|
1432 |
+
|
1433 |
if (!empty($referrer)) {
|
1434 |
$buffer .= '<input type="hidden" name="nr" value="' . esc_attr($referrer) . '">' . "\n";
|
1435 |
}
|
1738 |
}
|
1739 |
|
1740 |
$message = apply_filters('newsletter_page_text', '', $message_key, $user);
|
1741 |
+
$message .= '<!-- ' . $message_key . ' -->';
|
1742 |
|
1743 |
$options = $this->get_options('', $this->get_current_language($user));
|
1744 |
|
tnp-header.php
CHANGED
@@ -5,7 +5,7 @@ defined('ABSPATH') || exit;
|
|
5 |
|
6 |
$dismissed = get_option('newsletter_dismissed', array());
|
7 |
|
8 |
-
$user_count =
|
9 |
|
10 |
$is_administrator = current_user_can('administrator');
|
11 |
|
@@ -166,7 +166,7 @@ $warning |= empty($status_options['mail']);
|
|
166 |
</li>
|
167 |
<?php } elseif (is_wp_error($license_data)) { ?>
|
168 |
<li class="tnp-professional-extensions-button-red">
|
169 |
-
<a href="?page=newsletter_main_main"><i class="fas fa-hand-paper" style="color: white"></i> <?php _e('
|
170 |
</li>
|
171 |
|
172 |
<?php } elseif ($license_data->expire == 0) { ?>
|
5 |
|
6 |
$dismissed = get_option('newsletter_dismissed', array());
|
7 |
|
8 |
+
$user_count = Newsletter::instance()->get_user_count();
|
9 |
|
10 |
$is_administrator = current_user_can('administrator');
|
11 |
|
166 |
</li>
|
167 |
<?php } elseif (is_wp_error($license_data)) { ?>
|
168 |
<li class="tnp-professional-extensions-button-red">
|
169 |
+
<a href="?page=newsletter_main_main"><i class="fas fa-hand-paper" style="color: white"></i> <?php _e('Unable to check', 'newsletter') ?></a>
|
170 |
</li>
|
171 |
|
172 |
<?php } elseif ($license_data->expire == 0) { ?>
|
unsubscription/unsubscription.php
CHANGED
@@ -30,7 +30,7 @@ class NewsletterUnsubscription extends NewsletterModule {
|
|
30 |
|
31 |
if (in_array($action, ['u', 'uc', 'lu', 'reactivate'])) {
|
32 |
if (!$user) {
|
33 |
-
$this->dienow('The subscriber was not found.');
|
34 |
}
|
35 |
}
|
36 |
|
30 |
|
31 |
if (in_array($action, ['u', 'uc', 'lu', 'reactivate'])) {
|
32 |
if (!$user) {
|
33 |
+
$this->dienow('The subscriber was not found.', '', 404);
|
34 |
}
|
35 |
}
|
36 |
|