Version Description
- Changed the lists configuration to be more clear
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 6.7.1 |
Comparing to | |
See all releases |
Code changes from version 6.7.0 to 6.7.1
- includes/addon.php +17 -15
- includes/module.php +62 -34
- main/extensions.php +3 -3
- main/index.php +2 -5
- main/info.php +12 -4
- main/main.php +68 -55
- main/status.php +13 -15
- plugin.php +3 -3
- readme.txt +5 -1
- statistics/statistics.php +5 -3
- subscription/antibot.php +1 -1
- subscription/defaults-lists.php +2 -0
- subscription/forms.php +13 -0
- subscription/lists.php +97 -26
- subscription/profile.php +11 -26
- subscription/subscription.php +2 -2
- tnp-header.php +0 -5
includes/addon.php
CHANGED
@@ -22,28 +22,30 @@ class NewsletterAddon {
|
|
22 |
}
|
23 |
}
|
24 |
add_action('newsletter_init', array($this, 'init'));
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
* Method to be overridden and invoked on version change or on first install.
|
29 |
-
*
|
30 |
* @param bool $first_install
|
31 |
*/
|
32 |
function upgrade($first_install = false) {
|
33 |
-
|
34 |
}
|
35 |
-
|
36 |
/**
|
37 |
* Method to be overridden to initialize the add-on. It is invoked when Newsletter
|
38 |
* fires the <code>newsletter_init</code> event.
|
39 |
*/
|
40 |
function init() {
|
41 |
-
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* General logger for this add-on.
|
46 |
-
*
|
47 |
* @return NewsletterLogger
|
48 |
*/
|
49 |
function get_logger() {
|
@@ -55,7 +57,7 @@ class NewsletterAddon {
|
|
55 |
|
56 |
/**
|
57 |
* Specific logger for administrator actions.
|
58 |
-
*
|
59 |
* @return NewsletterLogger
|
60 |
*/
|
61 |
function get_admin_logger() {
|
@@ -65,7 +67,7 @@ class NewsletterAddon {
|
|
65 |
return $this->admin_logger;
|
66 |
}
|
67 |
|
68 |
-
/**
|
69 |
* Loads and prepares the options. It can be used to late initialize the options to save some resources on
|
70 |
* add-ons which do not need to do something on each page load.
|
71 |
* @return array
|
@@ -95,7 +97,7 @@ class NewsletterAddon {
|
|
95 |
|
96 |
/**
|
97 |
* Equivalent to $wpdb->query() but logs the event in case of error.
|
98 |
-
*
|
99 |
* @global wpdb $wpdb
|
100 |
* @param string $query
|
101 |
*/
|
@@ -115,11 +117,11 @@ class NewsletterAddon {
|
|
115 |
/**
|
116 |
* Used by mailers add-ons as base-class. Some specific options collected by the mailer
|
117 |
* are interpreted automatically.
|
118 |
-
*
|
119 |
* They are:
|
120 |
-
*
|
121 |
* `enabled` if not empty it means the mailer is active and should be registered
|
122 |
-
*
|
123 |
* The options are set up in the constructor, there is no need to setup them later.
|
124 |
*/
|
125 |
class NewsletterMailerAddon extends NewsletterAddon {
|
@@ -168,7 +170,7 @@ class NewsletterMailerAddon extends NewsletterAddon {
|
|
168 |
/**
|
169 |
* Returns a TNP_Mailer_Message built to send a test message to the <code>$to</code>
|
170 |
* email address.
|
171 |
-
*
|
172 |
* @param string $to
|
173 |
* @param string $subject
|
174 |
* @return TNP_Mailer_Message
|
@@ -194,9 +196,9 @@ class NewsletterMailerAddon extends NewsletterAddon {
|
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
-
* Returns a set of test messages to be sent to the specified email address. Used for
|
198 |
* turbo mode tests. Each message has a different generated subject.
|
199 |
-
*
|
200 |
* @param string $to The destination mailbox
|
201 |
* @param int $count Number of message objects to create
|
202 |
* @return TNP_Mailer_Message[]
|
22 |
}
|
23 |
}
|
24 |
add_action('newsletter_init', array($this, 'init'));
|
25 |
+
//Load translations from specific addon /languages/ directory
|
26 |
+
load_plugin_textdomain( 'newsletter-' . $this->name, false, 'newsletter-' . $this->name . '/languages/' );
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
* Method to be overridden and invoked on version change or on first install.
|
31 |
+
*
|
32 |
* @param bool $first_install
|
33 |
*/
|
34 |
function upgrade($first_install = false) {
|
35 |
+
|
36 |
}
|
37 |
+
|
38 |
/**
|
39 |
* Method to be overridden to initialize the add-on. It is invoked when Newsletter
|
40 |
* fires the <code>newsletter_init</code> event.
|
41 |
*/
|
42 |
function init() {
|
43 |
+
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* General logger for this add-on.
|
48 |
+
*
|
49 |
* @return NewsletterLogger
|
50 |
*/
|
51 |
function get_logger() {
|
57 |
|
58 |
/**
|
59 |
* Specific logger for administrator actions.
|
60 |
+
*
|
61 |
* @return NewsletterLogger
|
62 |
*/
|
63 |
function get_admin_logger() {
|
67 |
return $this->admin_logger;
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
* Loads and prepares the options. It can be used to late initialize the options to save some resources on
|
72 |
* add-ons which do not need to do something on each page load.
|
73 |
* @return array
|
97 |
|
98 |
/**
|
99 |
* Equivalent to $wpdb->query() but logs the event in case of error.
|
100 |
+
*
|
101 |
* @global wpdb $wpdb
|
102 |
* @param string $query
|
103 |
*/
|
117 |
/**
|
118 |
* Used by mailers add-ons as base-class. Some specific options collected by the mailer
|
119 |
* are interpreted automatically.
|
120 |
+
*
|
121 |
* They are:
|
122 |
+
*
|
123 |
* `enabled` if not empty it means the mailer is active and should be registered
|
124 |
+
*
|
125 |
* The options are set up in the constructor, there is no need to setup them later.
|
126 |
*/
|
127 |
class NewsletterMailerAddon extends NewsletterAddon {
|
170 |
/**
|
171 |
* Returns a TNP_Mailer_Message built to send a test message to the <code>$to</code>
|
172 |
* email address.
|
173 |
+
*
|
174 |
* @param string $to
|
175 |
* @param string $subject
|
176 |
* @return TNP_Mailer_Message
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
+
* Returns a set of test messages to be sent to the specified email address. Used for
|
200 |
* turbo mode tests. Each message has a different generated subject.
|
201 |
+
*
|
202 |
* @param string $to The destination mailbox
|
203 |
* @param int $count Number of message objects to create
|
204 |
* @return TNP_Mailer_Message[]
|
includes/module.php
CHANGED
@@ -32,12 +32,23 @@ class TNP_Media {
|
|
32 |
* @property bool $checked If it must be pre-checked on subscription form
|
33 |
* @property array $languages The list of language used to pre-assign this list
|
34 |
*/
|
35 |
-
|
36 |
|
37 |
const STATUS_PRIVATE = 0;
|
38 |
-
const STATUS_PUBLIC =
|
39 |
-
const
|
40 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
}
|
43 |
|
@@ -684,7 +695,7 @@ class NewsletterModule {
|
|
684 |
}
|
685 |
|
686 |
function admin_menu() {
|
687 |
-
|
688 |
}
|
689 |
|
690 |
function add_menu_page($page, $title, $capability = '') {
|
@@ -973,7 +984,7 @@ class NewsletterModule {
|
|
973 |
/** Searches for a user using the nk parameter or the ni and nt parameters. Tries even with the newsletter cookie.
|
974 |
* If found, the user object is returned or null.
|
975 |
* The user is returned without regards to his status that should be checked by caller.
|
976 |
-
*
|
977 |
* DO NOT REMOVE EVEN IF OLD
|
978 |
*
|
979 |
* @return TNP_User
|
@@ -1151,24 +1162,36 @@ class NewsletterModule {
|
|
1151 |
if (empty($data['list_' . $i])) {
|
1152 |
continue;
|
1153 |
}
|
1154 |
-
$list = new
|
1155 |
$list->name = $data['list_' . $i];
|
1156 |
$list->id = $i;
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1160 |
if (empty($data['list_' . $i . '_languages'])) {
|
1161 |
$list->languages = array();
|
1162 |
} else {
|
1163 |
$list->languages = $data['list_' . $i . '_languages'];
|
1164 |
}
|
1165 |
-
$lists[$language][] = $list;
|
1166 |
}
|
1167 |
return $lists[$language];
|
1168 |
}
|
1169 |
|
1170 |
/**
|
1171 |
-
*
|
1172 |
* @return TNP_List[]
|
1173 |
*/
|
1174 |
function get_lists_public($language = '') {
|
@@ -1183,7 +1206,7 @@ class NewsletterModule {
|
|
1183 |
if ($list->status == TNP_List::STATUS_PRIVATE) {
|
1184 |
continue;
|
1185 |
}
|
1186 |
-
$lists[$language][] = $list;
|
1187 |
}
|
1188 |
return $lists[$language];
|
1189 |
}
|
@@ -1202,16 +1225,17 @@ class NewsletterModule {
|
|
1202 |
$lists[$language] = array();
|
1203 |
$all = $this->get_lists($language);
|
1204 |
foreach ($all as $list) {
|
1205 |
-
if (
|
1206 |
continue;
|
1207 |
}
|
1208 |
-
$lists[$language][] = $list;
|
1209 |
}
|
1210 |
return $lists[$language];
|
1211 |
}
|
1212 |
|
1213 |
/**
|
1214 |
-
* Returns the lists to be shown in the profile page.
|
|
|
1215 |
*
|
1216 |
* @return TNP_List[]
|
1217 |
*/
|
@@ -1224,33 +1248,27 @@ class NewsletterModule {
|
|
1224 |
$lists[$language] = array();
|
1225 |
$all = $this->get_lists($language);
|
1226 |
foreach ($all as $list) {
|
1227 |
-
if (
|
1228 |
continue;
|
1229 |
}
|
1230 |
-
$lists[$language][] = $list;
|
1231 |
}
|
1232 |
return $lists[$language];
|
1233 |
}
|
1234 |
|
1235 |
/**
|
1236 |
-
* Returns
|
1237 |
*
|
1238 |
* @param int $id
|
1239 |
* @return TNP_List
|
1240 |
*/
|
1241 |
function get_list($id, $language = '') {
|
1242 |
-
$
|
1243 |
-
if (
|
1244 |
return null;
|
1245 |
}
|
1246 |
-
|
1247 |
-
$
|
1248 |
-
$list->name = $data['list_' . $id];
|
1249 |
-
$list->id = $id;
|
1250 |
-
$list->forced = !empty($data['list_' . $id . '_forced']);
|
1251 |
-
$list->status = (int) $data['list_' . $id . '_status'];
|
1252 |
-
$list->checked = !empty($data['list_' . $id . '_checked']);
|
1253 |
-
return $list;
|
1254 |
}
|
1255 |
|
1256 |
/**
|
@@ -1934,8 +1952,9 @@ class NewsletterModule {
|
|
1934 |
}
|
1935 |
|
1936 |
static function sanitize_ip($ip) {
|
1937 |
-
if (empty($ip))
|
1938 |
return '';
|
|
|
1939 |
return preg_replace('/[^0-9a-fA-F:., ]/', '', $ip);
|
1940 |
}
|
1941 |
|
@@ -1949,8 +1968,9 @@ class NewsletterModule {
|
|
1949 |
}
|
1950 |
|
1951 |
static function check_signature($text, $signature) {
|
1952 |
-
if (empty($signature))
|
1953 |
return false;
|
|
|
1954 |
$key = NewsletterStatistics::instance()->options['key'];
|
1955 |
return md5($text . $key) === $signature;
|
1956 |
}
|
@@ -1979,7 +1999,6 @@ class NewsletterModule {
|
|
1979 |
* @return string The language code
|
1980 |
*/
|
1981 |
function get_current_language($user = null) {
|
1982 |
-
global $current_user;
|
1983 |
|
1984 |
if ($user && $user->language) {
|
1985 |
return $user->language;
|
@@ -2050,15 +2069,24 @@ class NewsletterModule {
|
|
2050 |
|
2051 |
function get_language_label($language) {
|
2052 |
$languages = $this->get_languages();
|
2053 |
-
if (isset($languages[$language]))
|
2054 |
return $languages[$language];
|
|
|
2055 |
return '';
|
2056 |
}
|
2057 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2058 |
function switch_language($language) {
|
2059 |
if (class_exists('SitePress')) {
|
2060 |
-
if (empty($language))
|
2061 |
$language = 'all';
|
|
|
2062 |
do_action('wpml_switch_language', $language);
|
2063 |
return;
|
2064 |
}
|
32 |
* @property bool $checked If it must be pre-checked on subscription form
|
33 |
* @property array $languages The list of language used to pre-assign this list
|
34 |
*/
|
35 |
+
class TNP_List {
|
36 |
|
37 |
const STATUS_PRIVATE = 0;
|
38 |
+
const STATUS_PUBLIC = 1;
|
39 |
+
const SUBSCRIPTION_HIDE = 0;
|
40 |
+
const SUBSCRIPTION_SHOW = 1;
|
41 |
+
const SUBSCRIPTION_SHOW_CHECKED = 2;
|
42 |
+
const PROFILE_HIDE = 0;
|
43 |
+
const PROFILE_SHOW = 1;
|
44 |
+
|
45 |
+
var $id;
|
46 |
+
var $name;
|
47 |
+
var $status;
|
48 |
+
var $forced;
|
49 |
+
var $checked;
|
50 |
+
var $show_on_subscription;
|
51 |
+
var $show_on_profile;
|
52 |
|
53 |
}
|
54 |
|
695 |
}
|
696 |
|
697 |
function admin_menu() {
|
698 |
+
|
699 |
}
|
700 |
|
701 |
function add_menu_page($page, $title, $capability = '') {
|
984 |
/** Searches for a user using the nk parameter or the ni and nt parameters. Tries even with the newsletter cookie.
|
985 |
* If found, the user object is returned or null.
|
986 |
* The user is returned without regards to his status that should be checked by caller.
|
987 |
+
*
|
988 |
* DO NOT REMOVE EVEN IF OLD
|
989 |
*
|
990 |
* @return TNP_User
|
1162 |
if (empty($data['list_' . $i])) {
|
1163 |
continue;
|
1164 |
}
|
1165 |
+
$list = new TNP_List();
|
1166 |
$list->name = $data['list_' . $i];
|
1167 |
$list->id = $i;
|
1168 |
+
|
1169 |
+
// New format
|
1170 |
+
if (isset($data['list_' . $i . '_subscription'])) {
|
1171 |
+
$list->forced = !empty($data['list_' . $i . '_forced']);
|
1172 |
+
$list->status = empty($data['list_' . $i . '_status']) ? TNP_List::STATUS_PRIVATE : TNP_List::STATUS_PUBLIC;
|
1173 |
+
$list->checked = $data['list_' . $i . '_subscription'] == 2;
|
1174 |
+
$list->show_on_subscription = $list->status != TNP_List::STATUS_PRIVATE && !empty($data['list_' . $i . '_subscription']) && !$list->forced;
|
1175 |
+
$list->show_on_profile = $list->status != TNP_List::STATUS_PRIVATE && !empty($data['list_' . $i . '_profile']);
|
1176 |
+
} else {
|
1177 |
+
$list->forced = !empty($data['list_' . $i . '_forced']);
|
1178 |
+
$list->status = empty($data['list_' . $i . '_status']) ? TNP_List::STATUS_PRIVATE : TNP_List::STATUS_PUBLIC;
|
1179 |
+
$list->checked = !empty($data['list_' . $i . '_checked']);
|
1180 |
+
$list->show_on_subscription = $data['list_' . $i . '_status'] == 2 && !$list->forced;
|
1181 |
+
$list->show_on_profile = $data['list_' . $i . '_status'] == 1 || $data['list_' . $i . '_status'] == 2;
|
1182 |
+
}
|
1183 |
if (empty($data['list_' . $i . '_languages'])) {
|
1184 |
$list->languages = array();
|
1185 |
} else {
|
1186 |
$list->languages = $data['list_' . $i . '_languages'];
|
1187 |
}
|
1188 |
+
$lists[$language]['' . $list->id] = $list;
|
1189 |
}
|
1190 |
return $lists[$language];
|
1191 |
}
|
1192 |
|
1193 |
/**
|
1194 |
+
* Returns an array of TNP_List objects of lists that are public.
|
1195 |
* @return TNP_List[]
|
1196 |
*/
|
1197 |
function get_lists_public($language = '') {
|
1206 |
if ($list->status == TNP_List::STATUS_PRIVATE) {
|
1207 |
continue;
|
1208 |
}
|
1209 |
+
$lists[$language]['' . $list->id] = $list;
|
1210 |
}
|
1211 |
return $lists[$language];
|
1212 |
}
|
1225 |
$lists[$language] = array();
|
1226 |
$all = $this->get_lists($language);
|
1227 |
foreach ($all as $list) {
|
1228 |
+
if (!$list->show_on_subscription) {
|
1229 |
continue;
|
1230 |
}
|
1231 |
+
$lists[$language]['' . $list->id] = $list;
|
1232 |
}
|
1233 |
return $lists[$language];
|
1234 |
}
|
1235 |
|
1236 |
/**
|
1237 |
+
* Returns the lists to be shown in the profile page. The list is associative with
|
1238 |
+
* the list ID as key.
|
1239 |
*
|
1240 |
* @return TNP_List[]
|
1241 |
*/
|
1248 |
$lists[$language] = array();
|
1249 |
$all = $this->get_lists($language);
|
1250 |
foreach ($all as $list) {
|
1251 |
+
if (!$list->show_on_profile) {
|
1252 |
continue;
|
1253 |
}
|
1254 |
+
$lists[$language]['' . $list->id] = $list;
|
1255 |
}
|
1256 |
return $lists[$language];
|
1257 |
}
|
1258 |
|
1259 |
/**
|
1260 |
+
* Returns the list object or null if not found.
|
1261 |
*
|
1262 |
* @param int $id
|
1263 |
* @return TNP_List
|
1264 |
*/
|
1265 |
function get_list($id, $language = '') {
|
1266 |
+
$lists = $this->get_lists($language);
|
1267 |
+
if (!isset($lists['' . $id])) {
|
1268 |
return null;
|
1269 |
}
|
1270 |
+
|
1271 |
+
return $lists['' . $id];
|
|
|
|
|
|
|
|
|
|
|
|
|
1272 |
}
|
1273 |
|
1274 |
/**
|
1952 |
}
|
1953 |
|
1954 |
static function sanitize_ip($ip) {
|
1955 |
+
if (empty($ip)) {
|
1956 |
return '';
|
1957 |
+
}
|
1958 |
return preg_replace('/[^0-9a-fA-F:., ]/', '', $ip);
|
1959 |
}
|
1960 |
|
1968 |
}
|
1969 |
|
1970 |
static function check_signature($text, $signature) {
|
1971 |
+
if (empty($signature)) {
|
1972 |
return false;
|
1973 |
+
}
|
1974 |
$key = NewsletterStatistics::instance()->options['key'];
|
1975 |
return md5($text . $key) === $signature;
|
1976 |
}
|
1999 |
* @return string The language code
|
2000 |
*/
|
2001 |
function get_current_language($user = null) {
|
|
|
2002 |
|
2003 |
if ($user && $user->language) {
|
2004 |
return $user->language;
|
2069 |
|
2070 |
function get_language_label($language) {
|
2071 |
$languages = $this->get_languages();
|
2072 |
+
if (isset($languages[$language])) {
|
2073 |
return $languages[$language];
|
2074 |
+
}
|
2075 |
return '';
|
2076 |
}
|
2077 |
|
2078 |
+
/**
|
2079 |
+
* Changes the current language usually before extracting the posts since WPML
|
2080 |
+
* does not support the language filter in the post query (or at least we didn't
|
2081 |
+
* find it).
|
2082 |
+
*
|
2083 |
+
* @param string $language
|
2084 |
+
*/
|
2085 |
function switch_language($language) {
|
2086 |
if (class_exists('SitePress')) {
|
2087 |
+
if (empty($language)) {
|
2088 |
$language = 'all';
|
2089 |
+
}
|
2090 |
do_action('wpml_switch_language', $language);
|
2091 |
return;
|
2092 |
}
|
main/extensions.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
|
|
2 |
defined('ABSPATH') || exit;
|
3 |
|
4 |
-
|
5 |
$controls = new NewsletterControls();
|
6 |
-
$
|
7 |
-
$extensions = $module->getTnpExtensions();
|
8 |
|
9 |
$controls->data = get_option('newsletter_main');
|
10 |
|
1 |
<?php
|
2 |
+
/* @var $this Newsletter */
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
6 |
$controls = new NewsletterControls();
|
7 |
+
$extensions = $this->getTnpExtensions();
|
|
|
8 |
|
9 |
$controls->data = get_option('newsletter_main');
|
10 |
|
main/index.php
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
@include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
7 |
|
|
|
8 |
$controls = new NewsletterControls();
|
9 |
|
10 |
wp_enqueue_script( 'tnp-chart' );
|
1 |
<?php
|
2 |
+
defined('ABSPATH') || exit;
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
5 |
$controls = new NewsletterControls();
|
6 |
|
7 |
wp_enqueue_script( 'tnp-chart' );
|
main/info.php
CHANGED
@@ -1,17 +1,25 @@
|
|
1 |
<?php
|
|
|
2 |
defined('ABSPATH') || exit;
|
3 |
|
4 |
-
|
5 |
-
$module = Newsletter::instance();
|
6 |
$controls = new NewsletterControls();
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
if (!$controls->is_action()) {
|
9 |
$controls->data = get_option('newsletter_main');
|
10 |
} else {
|
11 |
|
12 |
if ($controls->is_action('save')) {
|
13 |
-
$
|
14 |
-
$
|
15 |
$controls->add_message_saved();
|
16 |
}
|
17 |
}
|
1 |
<?php
|
2 |
+
/* @var $this Newsletter */
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
|
|
6 |
$controls = new NewsletterControls();
|
7 |
|
8 |
+
$current_language = $this->get_current_language();
|
9 |
+
|
10 |
+
$is_all_languages = $this->is_all_languages();
|
11 |
+
|
12 |
+
//if (!$is_all_languages) {
|
13 |
+
// $controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
|
14 |
+
//}
|
15 |
+
|
16 |
if (!$controls->is_action()) {
|
17 |
$controls->data = get_option('newsletter_main');
|
18 |
} else {
|
19 |
|
20 |
if ($controls->is_action('save')) {
|
21 |
+
$this->merge_options($controls->data);
|
22 |
+
$this->save_options($controls->data, 'info');
|
23 |
$controls->add_message_saved();
|
24 |
}
|
25 |
}
|
main/main.php
CHANGED
@@ -1,42 +1,44 @@
|
|
1 |
<?php
|
|
|
2 |
defined('ABSPATH') || exit;
|
3 |
|
4 |
-
|
5 |
$controls = new NewsletterControls();
|
6 |
-
$module = Newsletter::instance();
|
7 |
|
8 |
if (!$controls->is_action()) {
|
9 |
$controls->data = get_option('newsletter_main');
|
10 |
if (!isset($controls->data['roles'])) {
|
11 |
$controls->data['roles'] = array();
|
12 |
-
if (!empty($controls->data['editor']))
|
|
|
13 |
}
|
14 |
} else {
|
15 |
|
16 |
if ($controls->is_action('save')) {
|
17 |
$errors = null;
|
18 |
-
|
19 |
-
if (!isset($controls->data['roles']))
|
|
|
20 |
|
21 |
// Validation
|
22 |
-
$controls->data['sender_email'] = $
|
23 |
-
if (!$
|
24 |
$controls->errors .= __('The sender email address is not correct.', 'newsletter') . '<br>';
|
25 |
} else {
|
26 |
-
$controls->data['sender_email'] = $
|
27 |
}
|
28 |
|
29 |
-
if (!$
|
30 |
$controls->errors .= __('Return path email is not correct.', 'newsletter') . '<br>';
|
31 |
} else {
|
32 |
-
$controls->data['return_path'] = $
|
33 |
}
|
34 |
|
35 |
|
36 |
-
if (!$
|
37 |
$controls->errors .= __('Reply to email is not correct.', 'newsletter') . '<br>';
|
38 |
} else {
|
39 |
-
$controls->data['reply_to'] = $
|
40 |
}
|
41 |
|
42 |
if (!empty($controls->data['contract_key'])) {
|
@@ -44,14 +46,14 @@ if (!$controls->is_action()) {
|
|
44 |
}
|
45 |
|
46 |
if (empty($controls->errors)) {
|
47 |
-
$
|
48 |
$controls->add_message_saved();
|
49 |
-
$
|
50 |
}
|
51 |
|
52 |
update_option('newsletter_log_level', $controls->data['log_level']);
|
53 |
|
54 |
-
//$
|
55 |
delete_transient("tnp_extensions_json");
|
56 |
delete_transient('newsletter_license_data');
|
57 |
}
|
@@ -66,23 +68,23 @@ if (!$controls->is_action()) {
|
|
66 |
$page['ping_status'] = 'closed';
|
67 |
$page['post_category'] = array(1);
|
68 |
|
69 |
-
$current_language = $
|
70 |
-
$
|
71 |
// Insert the post into the database
|
72 |
$page_id = wp_insert_post($page);
|
73 |
-
$
|
74 |
|
75 |
$controls->data['page'] = $page_id;
|
76 |
-
$
|
77 |
|
78 |
$controls->messages = 'A new page has been created';
|
79 |
}
|
80 |
}
|
81 |
|
82 |
-
$license_data = $
|
83 |
|
84 |
if (is_wp_error($license_data)) {
|
85 |
-
|
86 |
} else {
|
87 |
if ($license_data !== false) {
|
88 |
if ($license_data->expire == 0) {
|
@@ -95,19 +97,18 @@ if (is_wp_error($license_data)) {
|
|
95 |
}
|
96 |
}
|
97 |
|
98 |
-
$return_path = $
|
99 |
|
100 |
if (!empty($return_path)) {
|
101 |
list($return_path_local, $return_path_domain) = explode('@', $return_path);
|
102 |
|
103 |
-
$sender = $
|
104 |
list($sender_local, $sender_domain) = explode('@', $sender);
|
105 |
|
106 |
if ($sender_domain != $return_path_domain) {
|
107 |
$controls->warnings[] = __('Your Return Path domain is different from your Sender domain. Providers may require them to match.', 'newsletter');
|
108 |
}
|
109 |
}
|
110 |
-
|
111 |
?>
|
112 |
|
113 |
<?php include NEWSLETTER_INCLUDES_DIR . '/codemirror.php'; ?>
|
@@ -137,7 +138,7 @@ if (!empty($return_path)) {
|
|
137 |
|
138 |
</div>
|
139 |
<div id="tnp-body" class="tnp-main-main">
|
140 |
-
|
141 |
|
142 |
<form method="post" action="">
|
143 |
<?php $controls->init(); ?>
|
@@ -160,35 +161,49 @@ if (!empty($return_path)) {
|
|
160 |
<table class="form-table">
|
161 |
|
162 |
<tr>
|
163 |
-
<th
|
|
|
|
|
|
|
164 |
<td>
|
165 |
<?php $controls->text_email('sender_email', 40); ?>
|
166 |
-
|
167 |
</td>
|
168 |
</tr>
|
169 |
<tr>
|
170 |
-
<th
|
|
|
|
|
171 |
<td>
|
172 |
<?php $controls->text('sender_name', 40); ?>
|
173 |
</td>
|
174 |
</tr>
|
175 |
|
176 |
<tr>
|
177 |
-
<th
|
|
|
|
|
|
|
178 |
<td>
|
179 |
<?php $controls->text_email('return_path', 40); ?>
|
180 |
-
|
181 |
</td>
|
182 |
</tr>
|
183 |
<tr>
|
184 |
-
<th
|
|
|
|
|
|
|
185 |
<td>
|
186 |
<?php $controls->text_email('reply_to', 40); ?>
|
187 |
-
|
188 |
</td>
|
189 |
</tr>
|
190 |
<tr>
|
191 |
-
<th
|
|
|
|
|
|
|
192 |
<td>
|
193 |
<?php $controls->page('page', __('Unstyled page', 'newsletter'), '', true); ?>
|
194 |
<?php
|
@@ -196,8 +211,6 @@ if (!empty($return_path)) {
|
|
196 |
$controls->button('create', __('Create the page', 'newsletter'));
|
197 |
}
|
198 |
?>
|
199 |
-
<?php $controls->help('https://www.thenewsletterplugin.com/documentation/newsletter-configuration#dedicated-page') ?>
|
200 |
-
|
201 |
</td>
|
202 |
</tr>
|
203 |
|
@@ -220,20 +233,18 @@ if (!empty($return_path)) {
|
|
220 |
|
221 |
<div id="tabs-speed">
|
222 |
|
223 |
-
<p>
|
224 |
-
<?php $controls->panel_help('https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-delivery-engine') ?>
|
225 |
-
</p>
|
226 |
-
|
227 |
<table class="form-table">
|
228 |
<tr>
|
229 |
-
<th
|
|
|
|
|
|
|
230 |
<td>
|
231 |
<?php $controls->text('scheduler_max', 5); ?>
|
232 |
-
<?php $controls->help('https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-delivery-engine') ?>
|
233 |
</td>
|
234 |
</tr>
|
235 |
</table>
|
236 |
-
|
237 |
<?php do_action('newsletter_panel_main_speed', $controls) ?>
|
238 |
</div>
|
239 |
|
@@ -263,17 +274,19 @@ if (!empty($return_path)) {
|
|
263 |
<tr>
|
264 |
<th><?php _e('Allowed roles', 'newsletter') ?></th>
|
265 |
<td>
|
266 |
-
<?php
|
267 |
$wp_roles = get_editable_roles();
|
268 |
$roles = array();
|
269 |
-
foreach ($wp_roles as $key
|
270 |
-
if ($key == 'administrator')
|
271 |
-
|
|
|
|
|
272 |
$roles[$key] = $wp_role['name'];
|
273 |
}
|
274 |
-
$controls->checkboxes('roles', $roles);
|
275 |
?>
|
276 |
-
|
277 |
</td>
|
278 |
</tr>
|
279 |
|
@@ -288,17 +301,17 @@ if (!empty($return_path)) {
|
|
288 |
<!--
|
289 |
<tr>
|
290 |
<th>
|
291 |
-
|
292 |
</th>
|
293 |
<td>
|
294 |
-
|
295 |
</td>
|
296 |
</tr>
|
297 |
-->
|
298 |
<tr>
|
299 |
-
<th><?php _e('IP addresses', 'newsletter')?></th>
|
300 |
<td>
|
301 |
-
<?php $controls->select('ip', array(''=>__('Store', 'newsletter'), 'anonymize'=> __('Anonymize', 'newsletter'), 'skip'=>__('Do not store', 'newsletter'))); ?>
|
302 |
</td>
|
303 |
</tr>
|
304 |
|
@@ -324,15 +337,15 @@ if (!empty($return_path)) {
|
|
324 |
<?php $controls->help('https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-configuration#encoding') ?>
|
325 |
</td>
|
326 |
</tr>
|
327 |
-
|
328 |
<tr>
|
329 |
<th>
|
330 |
<?php _e('Execute shortcodes on newsletters', 'newsletter') ?>
|
331 |
-
<?php $controls->field_help("https://www.thenewsletterplugin.com/documentation/newsletter-configuration#shortcodes")?>
|
332 |
</th>
|
333 |
<td>
|
334 |
<?php $controls->yesno('do_shortcodes', 40); ?>
|
335 |
-
<?php $controls->field_help("https://www.thenewsletterplugin.com/documentation/newsletter-configuration#shortcodes")?>
|
336 |
</td>
|
337 |
</tr>
|
338 |
</table>
|
1 |
<?php
|
2 |
+
/* @var $this Newsletter */
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
6 |
$controls = new NewsletterControls();
|
|
|
7 |
|
8 |
if (!$controls->is_action()) {
|
9 |
$controls->data = get_option('newsletter_main');
|
10 |
if (!isset($controls->data['roles'])) {
|
11 |
$controls->data['roles'] = array();
|
12 |
+
if (!empty($controls->data['editor']))
|
13 |
+
$controls->data['roles'] = 'editor';
|
14 |
}
|
15 |
} else {
|
16 |
|
17 |
if ($controls->is_action('save')) {
|
18 |
$errors = null;
|
19 |
+
|
20 |
+
if (!isset($controls->data['roles']))
|
21 |
+
$controls->data['roles'] = array();
|
22 |
|
23 |
// Validation
|
24 |
+
$controls->data['sender_email'] = $this->normalize_email($controls->data['sender_email']);
|
25 |
+
if (!$this->is_email($controls->data['sender_email'])) {
|
26 |
$controls->errors .= __('The sender email address is not correct.', 'newsletter') . '<br>';
|
27 |
} else {
|
28 |
+
$controls->data['sender_email'] = $this->normalize_email($controls->data['sender_email']);
|
29 |
}
|
30 |
|
31 |
+
if (!$this->is_email($controls->data['return_path'], true)) {
|
32 |
$controls->errors .= __('Return path email is not correct.', 'newsletter') . '<br>';
|
33 |
} else {
|
34 |
+
$controls->data['return_path'] = $this->normalize_email($controls->data['return_path']);
|
35 |
}
|
36 |
|
37 |
|
38 |
+
if (!$this->is_email($controls->data['reply_to'], true)) {
|
39 |
$controls->errors .= __('Reply to email is not correct.', 'newsletter') . '<br>';
|
40 |
} else {
|
41 |
+
$controls->data['reply_to'] = $this->normalize_email($controls->data['reply_to']);
|
42 |
}
|
43 |
|
44 |
if (!empty($controls->data['contract_key'])) {
|
46 |
}
|
47 |
|
48 |
if (empty($controls->errors)) {
|
49 |
+
$this->merge_options($controls->data);
|
50 |
$controls->add_message_saved();
|
51 |
+
$this->logger->debug('Main options saved');
|
52 |
}
|
53 |
|
54 |
update_option('newsletter_log_level', $controls->data['log_level']);
|
55 |
|
56 |
+
//$this->hook_newsletter_extension_versions(true);
|
57 |
delete_transient("tnp_extensions_json");
|
58 |
delete_transient('newsletter_license_data');
|
59 |
}
|
68 |
$page['ping_status'] = 'closed';
|
69 |
$page['post_category'] = array(1);
|
70 |
|
71 |
+
$current_language = $this->get_current_language();
|
72 |
+
$this->switch_language('');
|
73 |
// Insert the post into the database
|
74 |
$page_id = wp_insert_post($page);
|
75 |
+
$this->switch_language($current_language);
|
76 |
|
77 |
$controls->data['page'] = $page_id;
|
78 |
+
$this->merge_options($controls->data);
|
79 |
|
80 |
$controls->messages = 'A new page has been created';
|
81 |
}
|
82 |
}
|
83 |
|
84 |
+
$license_data = $this->get_license_data(true);
|
85 |
|
86 |
if (is_wp_error($license_data)) {
|
87 |
+
$controls->errors .= esc_html('[' . $license_data->get_error_code()) . '] - ' . esc_html($license_data->get_error_message());
|
88 |
} else {
|
89 |
if ($license_data !== false) {
|
90 |
if ($license_data->expire == 0) {
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
$return_path = $this->options['return_path'];
|
101 |
|
102 |
if (!empty($return_path)) {
|
103 |
list($return_path_local, $return_path_domain) = explode('@', $return_path);
|
104 |
|
105 |
+
$sender = $this->options['sender_email'];
|
106 |
list($sender_local, $sender_domain) = explode('@', $sender);
|
107 |
|
108 |
if ($sender_domain != $return_path_domain) {
|
109 |
$controls->warnings[] = __('Your Return Path domain is different from your Sender domain. Providers may require them to match.', 'newsletter');
|
110 |
}
|
111 |
}
|
|
|
112 |
?>
|
113 |
|
114 |
<?php include NEWSLETTER_INCLUDES_DIR . '/codemirror.php'; ?>
|
138 |
|
139 |
</div>
|
140 |
<div id="tnp-body" class="tnp-main-main">
|
141 |
+
|
142 |
|
143 |
<form method="post" action="">
|
144 |
<?php $controls->init(); ?>
|
161 |
<table class="form-table">
|
162 |
|
163 |
<tr>
|
164 |
+
<th>
|
165 |
+
<?php _e('Sender email address', 'newsletter') ?>
|
166 |
+
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/installation/newsletter-configuration/#sender') ?>
|
167 |
+
</th>
|
168 |
<td>
|
169 |
<?php $controls->text_email('sender_email', 40); ?>
|
170 |
+
|
171 |
</td>
|
172 |
</tr>
|
173 |
<tr>
|
174 |
+
<th>
|
175 |
+
<?php _e('Sender name', 'newsletter') ?>
|
176 |
+
</th>
|
177 |
<td>
|
178 |
<?php $controls->text('sender_name', 40); ?>
|
179 |
</td>
|
180 |
</tr>
|
181 |
|
182 |
<tr>
|
183 |
+
<th>
|
184 |
+
<?php _e('Return path', 'newsletter') ?>
|
185 |
+
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/installation/newsletter-configuration/#return-path') ?>
|
186 |
+
</th>
|
187 |
<td>
|
188 |
<?php $controls->text_email('return_path', 40); ?>
|
189 |
+
|
190 |
</td>
|
191 |
</tr>
|
192 |
<tr>
|
193 |
+
<th>
|
194 |
+
<?php _e('Reply to', 'newsletter') ?>
|
195 |
+
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/installation/newsletter-configuration/#reply-to') ?>
|
196 |
+
</th>
|
197 |
<td>
|
198 |
<?php $controls->text_email('reply_to', 40); ?>
|
199 |
+
|
200 |
</td>
|
201 |
</tr>
|
202 |
<tr>
|
203 |
+
<th>
|
204 |
+
<?php _e('Dedicated page', 'newsletter') ?>
|
205 |
+
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/installation/newsletter-configuration/#dedicated-page') ?>
|
206 |
+
</th>
|
207 |
<td>
|
208 |
<?php $controls->page('page', __('Unstyled page', 'newsletter'), '', true); ?>
|
209 |
<?php
|
211 |
$controls->button('create', __('Create the page', 'newsletter'));
|
212 |
}
|
213 |
?>
|
|
|
|
|
214 |
</td>
|
215 |
</tr>
|
216 |
|
233 |
|
234 |
<div id="tabs-speed">
|
235 |
|
|
|
|
|
|
|
|
|
236 |
<table class="form-table">
|
237 |
<tr>
|
238 |
+
<th>
|
239 |
+
<?php _e('Max emails per hour', 'newsletter') ?>
|
240 |
+
<?php $controls->field_help('https://www.thenewsletterplugin.com/documentation/delivery-and-spam/newsletter-delivery-engine/') ?>
|
241 |
+
</th>
|
242 |
<td>
|
243 |
<?php $controls->text('scheduler_max', 5); ?>
|
|
|
244 |
</td>
|
245 |
</tr>
|
246 |
</table>
|
247 |
+
|
248 |
<?php do_action('newsletter_panel_main_speed', $controls) ?>
|
249 |
</div>
|
250 |
|
274 |
<tr>
|
275 |
<th><?php _e('Allowed roles', 'newsletter') ?></th>
|
276 |
<td>
|
277 |
+
<?php
|
278 |
$wp_roles = get_editable_roles();
|
279 |
$roles = array();
|
280 |
+
foreach ($wp_roles as $key => $wp_role) {
|
281 |
+
if ($key == 'administrator')
|
282 |
+
continue;
|
283 |
+
if ($key == 'subscriber')
|
284 |
+
continue;
|
285 |
$roles[$key] = $wp_role['name'];
|
286 |
}
|
287 |
+
$controls->checkboxes('roles', $roles);
|
288 |
?>
|
289 |
+
|
290 |
</td>
|
291 |
</tr>
|
292 |
|
301 |
<!--
|
302 |
<tr>
|
303 |
<th>
|
304 |
+
<?php _e('Disable the scheduler notice', 'newsletter') ?>
|
305 |
</th>
|
306 |
<td>
|
307 |
+
<?php $controls->yesno('disable_cron_notice'); ?>
|
308 |
</td>
|
309 |
</tr>
|
310 |
-->
|
311 |
<tr>
|
312 |
+
<th><?php _e('IP addresses', 'newsletter') ?></th>
|
313 |
<td>
|
314 |
+
<?php $controls->select('ip', array('' => __('Store', 'newsletter'), 'anonymize' => __('Anonymize', 'newsletter'), 'skip' => __('Do not store', 'newsletter'))); ?>
|
315 |
</td>
|
316 |
</tr>
|
317 |
|
337 |
<?php $controls->help('https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-configuration#encoding') ?>
|
338 |
</td>
|
339 |
</tr>
|
340 |
+
|
341 |
<tr>
|
342 |
<th>
|
343 |
<?php _e('Execute shortcodes on newsletters', 'newsletter') ?>
|
344 |
+
<?php $controls->field_help("https://www.thenewsletterplugin.com/documentation/newsletter-configuration#shortcodes") ?>
|
345 |
</th>
|
346 |
<td>
|
347 |
<?php $controls->yesno('do_shortcodes', 40); ?>
|
348 |
+
<?php $controls->field_help("https://www.thenewsletterplugin.com/documentation/newsletter-configuration#shortcodes") ?>
|
349 |
</td>
|
350 |
</tr>
|
351 |
</table>
|
main/status.php
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
<?php
|
2 |
/* @var $this Newsletter */
|
|
|
3 |
|
4 |
defined('ABSPATH') || exit;
|
5 |
|
6 |
-
|
7 |
-
$module = Newsletter::instance();
|
8 |
$controls = new NewsletterControls();
|
9 |
-
/* @var $wpdb wpdb */
|
10 |
-
|
11 |
|
12 |
$wp_cron_calls = get_option('newsletter_diagnostic_cron_calls', array());
|
13 |
$total = 0;
|
@@ -83,7 +81,7 @@ if ($controls->is_action('test')) {
|
|
83 |
|
84 |
$options = $controls->data;
|
85 |
|
86 |
-
if ($controls->data['test_email'] == $
|
87 |
$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>';
|
88 |
}
|
89 |
|
@@ -92,10 +90,10 @@ if ($controls->is_action('test')) {
|
|
92 |
$message->body_text = 'This is a textual test email part sent using the sender data set on Newsletter main setting.';
|
93 |
$message->to = $controls->data['test_email'];
|
94 |
$message->subject = 'Newsletter test email at ' . date(DATE_ISO8601);
|
95 |
-
$message->from = $
|
96 |
-
$message->from_name = $
|
97 |
|
98 |
-
$r = $
|
99 |
|
100 |
if (!is_wp_error($r)) {
|
101 |
$options['mail'] = 1;
|
@@ -108,26 +106,26 @@ if ($controls->is_action('test')) {
|
|
108 |
|
109 |
$controls->errors .= '<strong>FAILED</strong> (' . $r->get_error_message() . ')<br>';
|
110 |
|
111 |
-
if (!empty($
|
112 |
$controls->errors .= '- Try to remove the return path on main settings.<br>';
|
113 |
}
|
114 |
|
115 |
$controls->errors .= '<a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>' . __('Read more', 'newsletter') . '</strong></a>.';
|
116 |
|
117 |
-
$parts = explode('@', $
|
118 |
$sitename = strtolower($_SERVER['SERVER_NAME']);
|
119 |
if (substr($sitename, 0, 4) == 'www.') {
|
120 |
$sitename = substr($sitename, 4);
|
121 |
}
|
122 |
if (strtolower($sitename) != strtolower($parts[1])) {
|
123 |
-
$controls->errors .= '- Try to set on main setting a sender address with the same domain of your blog: ' . $sitename . ' (you are using ' . $
|
124 |
}
|
125 |
}
|
126 |
-
$
|
127 |
}
|
128 |
}
|
129 |
|
130 |
-
$options = $
|
131 |
|
132 |
// Compute the number of newsletters ongoing and other stats
|
133 |
$emails = $wpdb->get_results("select * from " . NEWSLETTER_EMAILS_TABLE . " where status='sending' and send_on<" . time() . " order by id asc");
|
@@ -369,11 +367,11 @@ function tnp_status_print_flag($condition) {
|
|
369 |
|
370 |
|
371 |
<?php
|
372 |
-
$return_path = $
|
373 |
if (!empty($return_path)) {
|
374 |
list($return_path_local, $return_path_domain) = explode('@', $return_path);
|
375 |
}
|
376 |
-
$sender = $
|
377 |
if (!empty($sender)) {
|
378 |
list($sender_local, $sender_domain) = explode('@', $sender);
|
379 |
}
|
1 |
<?php
|
2 |
/* @var $this Newsletter */
|
3 |
+
/* @var $wpdb wpdb */
|
4 |
|
5 |
defined('ABSPATH') || exit;
|
6 |
|
7 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
|
|
8 |
$controls = new NewsletterControls();
|
|
|
|
|
9 |
|
10 |
$wp_cron_calls = get_option('newsletter_diagnostic_cron_calls', array());
|
11 |
$total = 0;
|
81 |
|
82 |
$options = $controls->data;
|
83 |
|
84 |
+
if ($controls->data['test_email'] == $this->options['sender_email']) {
|
85 |
$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>';
|
86 |
}
|
87 |
|
90 |
$message->body_text = 'This is a textual test email part sent using the sender data set on Newsletter main setting.';
|
91 |
$message->to = $controls->data['test_email'];
|
92 |
$message->subject = 'Newsletter test email at ' . date(DATE_ISO8601);
|
93 |
+
$message->from = $this->options['sender_email'];
|
94 |
+
$message->from_name = $this->options['sender_name'];
|
95 |
|
96 |
+
$r = $this->deliver($message);
|
97 |
|
98 |
if (!is_wp_error($r)) {
|
99 |
$options['mail'] = 1;
|
106 |
|
107 |
$controls->errors .= '<strong>FAILED</strong> (' . $r->get_error_message() . ')<br>';
|
108 |
|
109 |
+
if (!empty($this->options['return_path'])) {
|
110 |
$controls->errors .= '- Try to remove the return path on main settings.<br>';
|
111 |
}
|
112 |
|
113 |
$controls->errors .= '<a href="https://www.thenewsletterplugin.com/documentation/?p=15170" target="_blank"><strong>' . __('Read more', 'newsletter') . '</strong></a>.';
|
114 |
|
115 |
+
$parts = explode('@', $this->options['sender_email']);
|
116 |
$sitename = strtolower($_SERVER['SERVER_NAME']);
|
117 |
if (substr($sitename, 0, 4) == 'www.') {
|
118 |
$sitename = substr($sitename, 4);
|
119 |
}
|
120 |
if (strtolower($sitename) != strtolower($parts[1])) {
|
121 |
+
$controls->errors .= '- Try to set on main setting a sender address with the same domain of your blog: ' . $sitename . ' (you are using ' . $this->options['sender_email'] . ')<br>';
|
122 |
}
|
123 |
}
|
124 |
+
$this->save_options($options, 'status');
|
125 |
}
|
126 |
}
|
127 |
|
128 |
+
$options = $this->get_options('status');
|
129 |
|
130 |
// Compute the number of newsletters ongoing and other stats
|
131 |
$emails = $wpdb->get_results("select * from " . NEWSLETTER_EMAILS_TABLE . " where status='sending' and send_on<" . time() . " order by id asc");
|
367 |
|
368 |
|
369 |
<?php
|
370 |
+
$return_path = $this->options['return_path'];
|
371 |
if (!empty($return_path)) {
|
372 |
list($return_path_local, $return_path_domain) = explode('@', $return_path);
|
373 |
}
|
374 |
+
$sender = $this->options['sender_email'];
|
375 |
if (!empty($sender)) {
|
376 |
list($sender_local, $sender_domain) = explode('@', $sender);
|
377 |
}
|
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.7.
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -35,7 +35,7 @@ if (version_compare(phpversion(), '5.6', '<')) {
|
|
35 |
return;
|
36 |
}
|
37 |
|
38 |
-
define('NEWSLETTER_VERSION', '6.7.
|
39 |
|
40 |
global $newsletter, $wpdb;
|
41 |
|
@@ -1365,7 +1365,7 @@ class Newsletter extends NewsletterModule {
|
|
1365 |
function add_notice_to_chosen_profile_page_hook($post_states, $post) {
|
1366 |
|
1367 |
if ($post->ID == $this->options['page']) {
|
1368 |
-
$post_states[] = __('Newsletter
|
1369 |
}
|
1370 |
|
1371 |
return $post_states;
|
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.7.1
|
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.7.1');
|
39 |
|
40 |
global $newsletter, $wpdb;
|
41 |
|
1365 |
function add_notice_to_chosen_profile_page_hook($post_states, $post) {
|
1366 |
|
1367 |
if ($post->ID == $this->options['page']) {
|
1368 |
+
$post_states[] = __('Newsletter plugin page, do not delete', 'newsletter');
|
1369 |
}
|
1370 |
|
1371 |
return $post_states;
|
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.1
|
5 |
-
Stable tag: 6.7.
|
6 |
Requires PHP: 5.6
|
7 |
Contributors: satollo,webagile,michael-travan
|
8 |
|
@@ -113,6 +113,10 @@ Thank you, The Newsletter Team
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
|
|
116 |
= 6.7.0 =
|
117 |
|
118 |
* Fixed the text part not sent when using the standard mailing function of WP
|
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.1
|
5 |
+
Stable tag: 6.7.1
|
6 |
Requires PHP: 5.6
|
7 |
Contributors: satollo,webagile,michael-travan
|
8 |
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
= 6.7.1 =
|
117 |
+
|
118 |
+
* Changed the lists configuration to be more clear
|
119 |
+
|
120 |
= 6.7.0 =
|
121 |
|
122 |
* Fixed the text part not sent when using the standard mailing function of WP
|
statistics/statistics.php
CHANGED
@@ -385,15 +385,17 @@ class NewsletterStatistics extends NewsletterModule {
|
|
385 |
/**
|
386 |
* Returns an object with statistics values
|
387 |
*
|
388 |
-
* @global
|
389 |
* @param TNP_Email $email
|
390 |
* @return TNP_Report
|
391 |
*/
|
392 |
function get_statistics($email) {
|
393 |
global $wpdb;
|
394 |
|
395 |
-
if (!is_object($email))
|
396 |
-
|
|
|
|
|
397 |
$report = new TNP_Statistics();
|
398 |
|
399 |
$report->email_id = $email->id;
|
385 |
/**
|
386 |
* Returns an object with statistics values
|
387 |
*
|
388 |
+
* @global wpdb $wpdb
|
389 |
* @param TNP_Email $email
|
390 |
* @return TNP_Report
|
391 |
*/
|
392 |
function get_statistics($email) {
|
393 |
global $wpdb;
|
394 |
|
395 |
+
if (!is_object($email)) {
|
396 |
+
$email = $this->get_email($email);
|
397 |
+
}
|
398 |
+
|
399 |
$report = new TNP_Statistics();
|
400 |
|
401 |
$report->email_id = $email->id;
|
subscription/antibot.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/* @var $this NewsletterSubscription */
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
-
|
6 |
$controls = new NewsletterControls();
|
7 |
|
8 |
if ($controls->is_action()) {
|
2 |
/* @var $this NewsletterSubscription */
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
6 |
$controls = new NewsletterControls();
|
7 |
|
8 |
if ($controls->is_action()) {
|
subscription/defaults-lists.php
CHANGED
@@ -7,4 +7,6 @@ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
|
7 |
$options['list_' . $i . '_status'] = 0;
|
8 |
$options['list_' . $i . '_checked'] = 0;
|
9 |
$options['list_' . $i . '_forced'] = 0;
|
|
|
|
|
10 |
}
|
7 |
$options['list_' . $i . '_status'] = 0;
|
8 |
$options['list_' . $i . '_checked'] = 0;
|
9 |
$options['list_' . $i . '_forced'] = 0;
|
10 |
+
$options['list_' . $i . '_subscription'] = 0;
|
11 |
+
$options['list_' . $i . '_profile'] = 0;
|
12 |
}
|
subscription/forms.php
CHANGED
@@ -38,6 +38,7 @@ if ($controls->is_action('save')) {
|
|
38 |
|
39 |
<ul>
|
40 |
<li><a href="#tabs-forms">Forms</a></li>
|
|
|
41 |
</ul>
|
42 |
|
43 |
<div id="tabs-forms">
|
@@ -54,6 +55,18 @@ if ($controls->is_action('save')) {
|
|
54 |
<?php } ?>
|
55 |
</table>
|
56 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
</div>
|
59 |
</form>
|
38 |
|
39 |
<ul>
|
40 |
<li><a href="#tabs-forms">Forms</a></li>
|
41 |
+
<li><a href="#tabs-html">HTML sample</a></li>
|
42 |
</ul>
|
43 |
|
44 |
<div id="tabs-forms">
|
55 |
<?php } ?>
|
56 |
</table>
|
57 |
</div>
|
58 |
+
|
59 |
+
<div id="tabs-html">
|
60 |
+
|
61 |
+
<p>This panel shows the form HTML code generated by Newsletter if you want to copy it as starting point for a custom form.</p>
|
62 |
+
|
63 |
+
<h3>Standard form code</h3>
|
64 |
+
<textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php echo esc_html(NewsletterSubscription::instance()->get_subscription_form()); ?></textarea>
|
65 |
+
|
66 |
+
<h3>Widget form code</h3>
|
67 |
+
<textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form()); ?></textarea>
|
68 |
+
|
69 |
+
</div>
|
70 |
|
71 |
</div>
|
72 |
</form>
|
subscription/lists.php
CHANGED
@@ -1,21 +1,52 @@
|
|
1 |
<?php
|
|
|
2 |
defined('ABSPATH') || exit;
|
3 |
|
4 |
-
|
5 |
$controls = new NewsletterControls();
|
6 |
-
$module = NewsletterSubscription::instance();
|
7 |
|
8 |
-
$current_language = $
|
9 |
-
$is_all_languages = $
|
10 |
-
$is_multilanguage = $
|
11 |
|
12 |
$controls->add_language_warning();
|
13 |
|
14 |
if (!$controls->is_action()) {
|
15 |
-
$controls->data = $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
} else {
|
17 |
if ($controls->is_action('save')) {
|
18 |
-
|
|
|
19 |
$controls->add_message_saved();
|
20 |
}
|
21 |
if ($controls->is_action('unlink')) {
|
@@ -26,14 +57,15 @@ if (!$controls->is_action()) {
|
|
26 |
|
27 |
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
28 |
if (!isset($controls->data['list_' . $i . '_forced'])) {
|
29 |
-
$controls->data['list_' . $i . '_forced'] = empty($
|
30 |
}
|
31 |
}
|
32 |
|
33 |
-
$all_lang_options = $
|
34 |
-
|
35 |
|
36 |
-
|
|
|
|
|
37 |
?>
|
38 |
<script>
|
39 |
jQuery(function () {
|
@@ -43,6 +75,37 @@ $status = array(0 => 'Private', 1 => 'Only on profile page', 2 => 'Even on subsc
|
|
43 |
return this.title;
|
44 |
}
|
45 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
});
|
47 |
</script>
|
48 |
<div class="wrap tnp-lists" id="tnp-wrap">
|
@@ -68,11 +131,12 @@ $status = array(0 => 'Private', 1 => 'Only on profile page', 2 => 'Even on subsc
|
|
68 |
<th>#</th>
|
69 |
<th><?php _e('Name', 'newsletter') ?></th>
|
70 |
<?php if ($is_all_languages) { ?>
|
71 |
-
<th><?php _e('
|
72 |
-
<th><?php _e('
|
73 |
-
<th><?php _e('
|
|
|
74 |
<?php if ($is_multilanguage) { ?>
|
75 |
-
<th><?php _e('
|
76 |
<?php } ?>
|
77 |
<?php } ?>
|
78 |
<th><?php _e('Subscribers', 'newsletter') ?></th>
|
@@ -82,30 +146,36 @@ $status = array(0 => 'Private', 1 => 'Only on profile page', 2 => 'Even on subsc
|
|
82 |
</tr>
|
83 |
</thead>
|
84 |
<?php for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) { ?>
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
<tr>
|
91 |
<td><?php echo $i; ?></td>
|
92 |
<td>
|
93 |
<?php $controls->text('list_' . $i, 50); ?>
|
94 |
<?php if (!$is_all_languages) { ?>
|
95 |
-
|
96 |
<?php } ?>
|
97 |
</td>
|
98 |
<?php if ($is_all_languages) { ?>
|
99 |
<td><?php $controls->select('list_' . $i . '_status', $status); ?></td>
|
100 |
-
<td
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
<?php if ($is_multilanguage) { ?>
|
103 |
<td><?php $controls->languages('list_' . $i . '_languages'); ?></td>
|
104 |
<?php } ?>
|
105 |
<?php } ?>
|
106 |
|
107 |
<td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
|
108 |
-
|
109 |
<td>
|
110 |
<?php if ($is_all_languages) { ?>
|
111 |
<?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?>
|
@@ -116,10 +186,11 @@ $status = array(0 => 'Private', 1 => 'Only on profile page', 2 => 'Even on subsc
|
|
116 |
<?php
|
117 |
$text = '';
|
118 |
foreach ($notes as $note) {
|
119 |
-
$text .= $note . '<br>';
|
120 |
}
|
121 |
if (!empty($text)) {
|
122 |
-
echo
|
|
|
123 |
}
|
124 |
?>
|
125 |
|
1 |
<?php
|
2 |
+
/* @var $this NewsletterSubscription */
|
3 |
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
6 |
$controls = new NewsletterControls();
|
|
|
7 |
|
8 |
+
$current_language = $this->get_current_language();
|
9 |
+
$is_all_languages = $this->is_all_languages();
|
10 |
+
$is_multilanguage = $this->is_multilanguage();
|
11 |
|
12 |
$controls->add_language_warning();
|
13 |
|
14 |
if (!$controls->is_action()) {
|
15 |
+
$controls->data = $this->get_options('lists', $current_language);
|
16 |
+
|
17 |
+
// Migration
|
18 |
+
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
19 |
+
// If we already have the new format options, do nothing
|
20 |
+
if (isset($controls->data['list_' . $i . '_subscription'])) {
|
21 |
+
continue;
|
22 |
+
}
|
23 |
+
if ($controls->data['list_' . $i . '_status'] != 0) {
|
24 |
+
if ($controls->data['list_' . $i . '_status'] == 1) {
|
25 |
+
$controls->data['list_' . $i . '_profile'] = 1;
|
26 |
+
$controls->data['list_' . $i . '_subscription'] = 0;
|
27 |
+
}
|
28 |
+
|
29 |
+
if ($controls->data['list_' . $i . '_status'] == 2) {
|
30 |
+
$controls->data['list_' . $i . '_profile'] = 1;
|
31 |
+
$controls->data['list_' . $i . '_subscription'] = 1; // Show unchecked
|
32 |
+
}
|
33 |
+
|
34 |
+
if ($controls->data['list_' . $i . '_status'] == 3) {
|
35 |
+
$controls->data['list_' . $i . '_profile'] = 0;
|
36 |
+
$controls->data['list_' . $i . '_subscription'] = 0;
|
37 |
+
}
|
38 |
+
|
39 |
+
$controls->data['list_' . $i . '_status'] = 1; // Public
|
40 |
+
}
|
41 |
+
|
42 |
+
if ($controls->data['list_' . $i . '_forced'] == 1) {
|
43 |
+
$controls->data['list_' . $i . '_subscription'] = 3;
|
44 |
+
}
|
45 |
+
}
|
46 |
} else {
|
47 |
if ($controls->is_action('save')) {
|
48 |
+
|
49 |
+
$this->save_options($controls->data, 'lists', null, $current_language);
|
50 |
$controls->add_message_saved();
|
51 |
}
|
52 |
if ($controls->is_action('unlink')) {
|
57 |
|
58 |
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
|
59 |
if (!isset($controls->data['list_' . $i . '_forced'])) {
|
60 |
+
$controls->data['list_' . $i . '_forced'] = empty($this->options['preferences_' . $i]) ? 0 : 1;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
+
$all_lang_options = $this->get_options('lists');
|
|
|
65 |
|
66 |
+
//echo json_encode($controls->data, JSON_PRETTY_PRINT);
|
67 |
+
//$status = array(0 => 'Private', 1 => 'Only on profile page', 2 => 'Even on subscription forms', '3' => 'Hidden');
|
68 |
+
$status = array(0 => __('Private', 'newsletter'), 1 => __('Public', 'newsletter'));
|
69 |
?>
|
70 |
<script>
|
71 |
jQuery(function () {
|
75 |
return this.title;
|
76 |
}
|
77 |
});
|
78 |
+
|
79 |
+
for (i = 1; i <=<?php echo NEWSLETTER_LIST_MAX ?>; i++) {
|
80 |
+
|
81 |
+
jQuery('#options-list_' + i + '_forced').change(function () {
|
82 |
+
let field = '#' + this.id.replace('forced', 'subscription');
|
83 |
+
let fieldStatus = '#' + this.id.replace('forced', 'status');
|
84 |
+
if (jQuery(fieldStatus).val() === '1') {
|
85 |
+
jQuery(field).toggle(!this.checked);
|
86 |
+
}
|
87 |
+
});
|
88 |
+
jQuery('#options-list_' + i + '_status').change(function () {
|
89 |
+
let field = '#' + this.id.replace('status', 'subscription');
|
90 |
+
let fieldProfile = '#' + this.id.replace('status', 'profile');
|
91 |
+
let fieldForced = '#' + this.id.replace('status', 'forced');
|
92 |
+
if (this.value === '0') {
|
93 |
+
jQuery(field).hide();
|
94 |
+
jQuery(fieldProfile).hide();
|
95 |
+
} else {
|
96 |
+
if (!jQuery(fieldForced).attr('checked')) {
|
97 |
+
jQuery(field).show();
|
98 |
+
|
99 |
+
}
|
100 |
+
jQuery(fieldProfile).show();
|
101 |
+
}
|
102 |
+
});
|
103 |
+
}
|
104 |
+
|
105 |
+
for (i = 1; i <=<?php echo NEWSLETTER_LIST_MAX ?>; i++) {
|
106 |
+
jQuery('#options-list_' + i + '_status').change();
|
107 |
+
jQuery('#options-list_' + i + '_forced').change();
|
108 |
+
}
|
109 |
});
|
110 |
</script>
|
111 |
<div class="wrap tnp-lists" id="tnp-wrap">
|
131 |
<th>#</th>
|
132 |
<th><?php _e('Name', 'newsletter') ?></th>
|
133 |
<?php if ($is_all_languages) { ?>
|
134 |
+
<th><?php _e('Type', 'newsletter') ?></th>
|
135 |
+
<th><?php _e('Enforced', 'newsletter') ?> <i class="fas fa-info-circle tnp-notes" title="<?php esc_attr_e('If you check this box, all your new subscribers will be automatically added to this list', 'newsletter')?>"></i></th>
|
136 |
+
<th style="white-space: nowrap"><?php _e('Subscription form', 'newsletter') ?></th>
|
137 |
+
<th><?php _e('Profile form', 'newsletter') ?></th>
|
138 |
<?php if ($is_multilanguage) { ?>
|
139 |
+
<th><?php _e('Enforced by language', 'newsletter') ?></th>
|
140 |
<?php } ?>
|
141 |
<?php } ?>
|
142 |
<th><?php _e('Subscribers', 'newsletter') ?></th>
|
146 |
</tr>
|
147 |
</thead>
|
148 |
<?php for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) { ?>
|
149 |
+
<?php
|
150 |
+
if (!$is_all_languages && empty($controls->data['list_' . $i])) {
|
151 |
+
continue;
|
152 |
+
}
|
153 |
+
?>
|
154 |
<tr>
|
155 |
<td><?php echo $i; ?></td>
|
156 |
<td>
|
157 |
<?php $controls->text('list_' . $i, 50); ?>
|
158 |
<?php if (!$is_all_languages) { ?>
|
159 |
+
<p class="description">Main name: <?php echo esc_html($all_lang_options['list_' . $i]) ?></p>
|
160 |
<?php } ?>
|
161 |
</td>
|
162 |
<?php if ($is_all_languages) { ?>
|
163 |
<td><?php $controls->select('list_' . $i . '_status', $status); ?></td>
|
164 |
+
<td style="text-align: center">
|
165 |
+
<?php $controls->checkbox('list_' . $i . '_forced'); ?>
|
166 |
+
</td>
|
167 |
+
<td>
|
168 |
+
<?php //$controls->select('list_' . $i . '_subscription', array(0 => 'Do not show', 1 => 'Show, unchecked', 2 => 'Show, checked', 3 => 'Assign to everyone')); ?>
|
169 |
+
<?php $controls->select('list_' . $i . '_subscription', array(0 => 'Do not show', 1 => 'Show, unchecked', 2 => 'Show, checked')); ?>
|
170 |
+
</td>
|
171 |
+
<td><?php $controls->select('list_' . $i . '_profile', array(0 => 'Do not show', 1 => 'Show')); ?></td>
|
172 |
<?php if ($is_multilanguage) { ?>
|
173 |
<td><?php $controls->languages('list_' . $i . '_languages'); ?></td>
|
174 |
<?php } ?>
|
175 |
<?php } ?>
|
176 |
|
177 |
<td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
|
178 |
+
|
179 |
<td>
|
180 |
<?php if ($is_all_languages) { ?>
|
181 |
<?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?>
|
186 |
<?php
|
187 |
$text = '';
|
188 |
foreach ($notes as $note) {
|
189 |
+
$text .= esc_html($note) . '<br>';
|
190 |
}
|
191 |
if (!empty($text)) {
|
192 |
+
echo $text;
|
193 |
+
//echo '<i class="fas fa-info-circle tnp-notes" title="', esc_attr($text), '"></i>';
|
194 |
}
|
195 |
?>
|
196 |
|
subscription/profile.php
CHANGED
@@ -1,29 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
|
5 |
-
|
6 |
$controls = new NewsletterControls();
|
7 |
-
$module = NewsletterSubscription::instance();
|
8 |
|
9 |
-
$current_language = $
|
10 |
|
11 |
-
$is_all_languages = $
|
12 |
|
13 |
if (!$is_all_languages) {
|
14 |
$controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
|
15 |
}
|
16 |
|
17 |
if (!$controls->is_action()) {
|
18 |
-
$controls->data = $
|
19 |
} else {
|
20 |
if ($controls->is_action('save')) {
|
21 |
-
$
|
22 |
$controls->add_message_saved();
|
23 |
}
|
24 |
|
25 |
if ($controls->is_action('reset')) {
|
26 |
-
$controls->data = $
|
27 |
$controls->add_message_done();
|
28 |
}
|
29 |
}
|
@@ -34,17 +33,14 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
34 |
|
35 |
<div class="wrap" id="tnp-wrap">
|
36 |
|
37 |
-
<?php $help_url = 'https://www.thenewsletterplugin.com/plugins/newsletter/subscription-module'; ?>
|
38 |
-
|
39 |
<?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
|
40 |
|
41 |
<div id="tnp-heading">
|
42 |
|
43 |
<h2><?php _e('Subscription Form Fields and Layout', 'newsletter') ?></h2>
|
|
|
44 |
<p>
|
45 |
-
|
46 |
-
And let you to <strong>translate</strong> every single button and label.<br>
|
47 |
-
<strong>Preferences</strong> can be an important setting for your newsletter: <a href="https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-preferences" target="_blank">here you can read more about them</a>.
|
48 |
</p>
|
49 |
|
50 |
</div>
|
@@ -59,7 +55,6 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
59 |
<ul>
|
60 |
<li><a href="#tabs-2">Main profile fields</a></li>
|
61 |
<li><a href="#tabs-3">Extra profile fields</a></li>
|
62 |
-
<li><a href="#tabs-5">Form code</a></li>
|
63 |
</ul>
|
64 |
|
65 |
<div id="tabs-2">
|
@@ -234,17 +229,7 @@ $rules = array(0 => __('Optional', 'newsletter'), 1 => __('Required', 'newslette
|
|
234 |
|
235 |
</div>
|
236 |
|
237 |
-
|
238 |
-
|
239 |
-
<p>This panel shows the form HTML code generated by Newsletter if you want to copy it as starting point for a custom form.</p>
|
240 |
-
|
241 |
-
<h3>Standard form code</h3>
|
242 |
-
<textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php echo esc_html(NewsletterSubscription::instance()->get_subscription_form()); ?></textarea>
|
243 |
-
|
244 |
-
<h3>Widget form code</h3>
|
245 |
-
<textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form()); ?></textarea>
|
246 |
-
|
247 |
-
</div>
|
248 |
|
249 |
</div>
|
250 |
|
1 |
<?php
|
2 |
+
/* @var $this NewsletterSubscription */
|
3 |
+
defined('ABSPATH') || exit;
|
4 |
|
5 |
+
include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
|
6 |
$controls = new NewsletterControls();
|
|
|
7 |
|
8 |
+
$current_language = $this->get_current_language();
|
9 |
|
10 |
+
$is_all_languages = $this->is_all_languages();
|
11 |
|
12 |
if (!$is_all_languages) {
|
13 |
$controls->warnings[] = 'You are configuring the language "<strong>' . $current_language . '</strong>". Switch to "all languages" to see every options.';
|
14 |
}
|
15 |
|
16 |
if (!$controls->is_action()) {
|
17 |
+
$controls->data = $this->get_options('profile', $current_language);
|
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 |
|
24 |
if ($controls->is_action('reset')) {
|
25 |
+
$controls->data = $this->reset_options('profile');
|
26 |
$controls->add_message_done();
|
27 |
}
|
28 |
}
|
33 |
|
34 |
<div class="wrap" id="tnp-wrap">
|
35 |
|
|
|
|
|
36 |
<?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
|
37 |
|
38 |
<div id="tnp-heading">
|
39 |
|
40 |
<h2><?php _e('Subscription Form Fields and Layout', 'newsletter') ?></h2>
|
41 |
+
|
42 |
<p>
|
43 |
+
<a href="?page=newsletter_subscription_forms">HTML samples and hand coded forms</a>
|
|
|
|
|
44 |
</p>
|
45 |
|
46 |
</div>
|
55 |
<ul>
|
56 |
<li><a href="#tabs-2">Main profile fields</a></li>
|
57 |
<li><a href="#tabs-3">Extra profile fields</a></li>
|
|
|
58 |
</ul>
|
59 |
|
60 |
<div id="tabs-2">
|
229 |
|
230 |
</div>
|
231 |
|
232 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
</div>
|
235 |
|
subscription/subscription.php
CHANGED
@@ -302,7 +302,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
302 |
// Check if the list is public
|
303 |
$list = $this->get_list($list_id);
|
304 |
if (!$list || $list->status == TNP_List::STATUS_PRIVATE) {
|
305 |
-
$this->dienow('List change not allowed.', 'Please check if the list is marked as "
|
306 |
}
|
307 |
|
308 |
$url = esc_url_raw($_REQUEST['redirect']);
|
@@ -792,7 +792,7 @@ class NewsletterSubscription extends NewsletterModule {
|
|
792 |
if (isset($_REQUEST['nl']) && is_array($_REQUEST['nl'])) {
|
793 |
foreach ($_REQUEST['nl'] as $list_id) {
|
794 |
$list = $this->get_list($list_id);
|
795 |
-
if ($list->status
|
796 |
$this->dienow('Invalid list', 'List ' . $list_id . ' has been submitted but it is set as private. Please fix the subscription form.');
|
797 |
}
|
798 |
}
|
302 |
// Check if the list is public
|
303 |
$list = $this->get_list($list_id);
|
304 |
if (!$list || $list->status == TNP_List::STATUS_PRIVATE) {
|
305 |
+
$this->dienow('List change not allowed.', 'Please check if the list is marked as "private".');
|
306 |
}
|
307 |
|
308 |
$url = esc_url_raw($_REQUEST['redirect']);
|
792 |
if (isset($_REQUEST['nl']) && is_array($_REQUEST['nl'])) {
|
793 |
foreach ($_REQUEST['nl'] as $list_id) {
|
794 |
$list = $this->get_list($list_id);
|
795 |
+
if ($list && $list->status == TNP_List::STATUS_PRIVATE) {
|
796 |
$this->dienow('Invalid list', 'List ' . $list_id . ' has been submitted but it is set as private. Please fix the subscription form.');
|
797 |
}
|
798 |
}
|
tnp-header.php
CHANGED
@@ -77,11 +77,6 @@ $warning |= empty($status_options['mail']);
|
|
77 |
<small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
|
78 |
</li>
|
79 |
|
80 |
-
<li>
|
81 |
-
<a href="?page=newsletter_subscription_forms"><i class="fas fa-edit"></i> <?php _e('Custom Forms', 'newsletter') ?>
|
82 |
-
<small><?php _e('Hand coded form storage', 'newsletter') ?></small></a>
|
83 |
-
</li>
|
84 |
-
|
85 |
<?php
|
86 |
newsletter_print_entries('subscription');
|
87 |
?>
|
77 |
<small><?php _e('How to give the last goodbye (or avoid it!)', 'newsletter') ?></small></a>
|
78 |
</li>
|
79 |
|
|
|
|
|
|
|
|
|
|
|
80 |
<?php
|
81 |
newsletter_print_entries('subscription');
|
82 |
?>
|