Version Description
- Lists pre-assignment by language (no more need to customize the newsletter shortcode or duplicate the widgets)
- Improved Polylang support (still not fully tested)
Download this release
Release Info
Developer | satollo |
Plugin | Newsletter |
Version | 5.6.0 |
Comparing to | |
See all releases |
Code changes from version 5.5.9 to 5.6.0
- includes/controls.php +40 -4
- includes/module.php +35 -1
- plugin.php +2 -2
- profile/profile.php +6 -2
- readme.txt +6 -1
- subscription/lists.php +23 -17
- subscription/options.php +1 -4
- subscription/subscription.php +9 -2
includes/controls.php
CHANGED
@@ -396,6 +396,16 @@ class NewsletterControls {
|
|
396 |
$this->messages .= __('Done.', 'newsletter');
|
397 |
}
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
function hint($text, $url = '') {
|
400 |
echo '<div class="hints">';
|
401 |
// Do not escape that, it can be formatted
|
@@ -541,13 +551,13 @@ class NewsletterControls {
|
|
541 |
|
542 |
function page($name = 'page', $first = null, $language = '') {
|
543 |
$args = array(
|
544 |
-
'post_type'=>'page',
|
545 |
'posts_per_page' => 1000,
|
546 |
'offset' => 0,
|
547 |
'orderby' => 'post_title',
|
548 |
'post_status' => 'any',
|
549 |
'suppress_filters' => true
|
550 |
-
|
551 |
|
552 |
$pages = get_posts($args);
|
553 |
//$pages = get_pages();
|
@@ -556,7 +566,7 @@ class NewsletterControls {
|
|
556 |
/* @var $page WP_Post */
|
557 |
$label = $page->post_title;
|
558 |
if ($page->post_status != 'publish') {
|
559 |
-
$label .= ' (' . $page->post_status . ')';
|
560 |
}
|
561 |
$options[$page->ID] = $label;
|
562 |
}
|
@@ -1458,7 +1468,33 @@ class NewsletterControls {
|
|
1458 |
}
|
1459 |
|
1460 |
|
1461 |
-
$this->select(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1462 |
}
|
1463 |
|
1464 |
/**
|
396 |
$this->messages .= __('Done.', 'newsletter');
|
397 |
}
|
398 |
|
399 |
+
function add_language_warning() {
|
400 |
+
$newsletter = Newsletter::instance();
|
401 |
+
$current_language = $newsletter->get_current_language();
|
402 |
+
|
403 |
+
if (!$current_language) {
|
404 |
+
return;
|
405 |
+
}
|
406 |
+
$this->warnings[] = 'You are configuring the language <strong>' . $newsletter->get_language_label($current_language) . '</strong>. Switch to "all languages" to see every options.';
|
407 |
+
}
|
408 |
+
|
409 |
function hint($text, $url = '') {
|
410 |
echo '<div class="hints">';
|
411 |
// Do not escape that, it can be formatted
|
551 |
|
552 |
function page($name = 'page', $first = null, $language = '') {
|
553 |
$args = array(
|
554 |
+
'post_type' => 'page',
|
555 |
'posts_per_page' => 1000,
|
556 |
'offset' => 0,
|
557 |
'orderby' => 'post_title',
|
558 |
'post_status' => 'any',
|
559 |
'suppress_filters' => true
|
560 |
+
);
|
561 |
|
562 |
$pages = get_posts($args);
|
563 |
//$pages = get_pages();
|
566 |
/* @var $page WP_Post */
|
567 |
$label = $page->post_title;
|
568 |
if ($page->post_status != 'publish') {
|
569 |
+
$label .= ' (' . $page->post_status . ')';
|
570 |
}
|
571 |
$options[$page->ID] = $label;
|
572 |
}
|
1468 |
}
|
1469 |
|
1470 |
|
1471 |
+
$this->select($name, $language_options);
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
function is_multilanguage() {
|
1475 |
+
return Newsletter::instance()->is_multilanguage();
|
1476 |
+
}
|
1477 |
+
|
1478 |
+
/**
|
1479 |
+
* Creates a checkbox group with all active languages. Each checkbox is named
|
1480 |
+
* $name[] and values with the relative language code.
|
1481 |
+
*
|
1482 |
+
* @param string $name
|
1483 |
+
*/
|
1484 |
+
function languages($name = 'languages') {
|
1485 |
+
if (!$this->is_multilanguage()) {
|
1486 |
+
echo __('Install WPML or Polylang for multilangue support', 'newsletter');
|
1487 |
+
return;
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
$language_options = Newsletter::instance()->get_languages();
|
1491 |
+
|
1492 |
+
if (empty($language_options)) {
|
1493 |
+
echo __('Your multilangiage plugin is not supported or there are no languages defined', 'newsletter');
|
1494 |
+
return;
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
$this->checkboxes_group($name, $language_options);
|
1498 |
}
|
1499 |
|
1500 |
/**
|
includes/module.php
CHANGED
@@ -8,6 +8,7 @@ defined('ABSPATH') || exit;
|
|
8 |
* @property bool $forced If the list must be added to every new subscriber
|
9 |
* @property int $status When and how the list is visible to the subscriber - see constants
|
10 |
* @property bool $checked If it must be pre-checked on subscription form
|
|
|
11 |
* */
|
12 |
abstract class TNP_List {
|
13 |
|
@@ -939,7 +940,7 @@ class NewsletterModule {
|
|
939 |
}
|
940 |
|
941 |
/**
|
942 |
-
*
|
943 |
* @return TNP_List[]
|
944 |
*/
|
945 |
function get_lists($language = '') {
|
@@ -960,6 +961,11 @@ class NewsletterModule {
|
|
960 |
$list->forced = !empty($data['list_' . $i . '_forced']);
|
961 |
$list->status = (int) $data['list_' . $i . '_status'];
|
962 |
$list->checked = !empty($data['list_' . $i . '_checked']);
|
|
|
|
|
|
|
|
|
|
|
963 |
$lists[$language][] = $list;
|
964 |
}
|
965 |
return $lists[$language];
|
@@ -1754,6 +1760,34 @@ class NewsletterModule {
|
|
1754 |
function is_default_language() {
|
1755 |
return $this->get_current_language() == $this->get_default_language();
|
1756 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1757 |
|
1758 |
function switch_language($language) {
|
1759 |
if (class_exists('SitePress')) {
|
8 |
* @property bool $forced If the list must be added to every new subscriber
|
9 |
* @property int $status When and how the list is visible to the subscriber - see constants
|
10 |
* @property bool $checked If it must be pre-checked on subscription form
|
11 |
+
* @property array $languages The list of language used to pre-assign this list
|
12 |
* */
|
13 |
abstract class TNP_List {
|
14 |
|
940 |
}
|
941 |
|
942 |
/**
|
943 |
+
* @param string $language The language for the list labels (it does not affect the lists returned)
|
944 |
* @return TNP_List[]
|
945 |
*/
|
946 |
function get_lists($language = '') {
|
961 |
$list->forced = !empty($data['list_' . $i . '_forced']);
|
962 |
$list->status = (int) $data['list_' . $i . '_status'];
|
963 |
$list->checked = !empty($data['list_' . $i . '_checked']);
|
964 |
+
if (empty($data['list_' . $i . '_languages'])) {
|
965 |
+
$list->languages = array();
|
966 |
+
} else {
|
967 |
+
$list->languages = $data['list_' . $i . '_languages'];
|
968 |
+
}
|
969 |
$lists[$language][] = $list;
|
970 |
}
|
971 |
return $lists[$language];
|
1760 |
function is_default_language() {
|
1761 |
return $this->get_current_language() == $this->get_default_language();
|
1762 |
}
|
1763 |
+
|
1764 |
+
/**
|
1765 |
+
* Returns an array od languages with key the language code and value the language name.
|
1766 |
+
* An empty array is returned if no language is available.
|
1767 |
+
*/
|
1768 |
+
function get_languages() {
|
1769 |
+
$language_options = array();
|
1770 |
+
if (class_exists('SitePress')) {
|
1771 |
+
$languages = apply_filters('wpml_active_languages', null);
|
1772 |
+
foreach ($languages as $language) {
|
1773 |
+
$language_options[$language['language_code']] = $language['translated_name'];
|
1774 |
+
}
|
1775 |
+
} else if (function_exists('icl_get_languages')) {
|
1776 |
+
$languages = icl_get_languages();
|
1777 |
+
foreach ($languages as $code=>$language) {
|
1778 |
+
$language_options[$code] = $language['native_name'];
|
1779 |
+
}
|
1780 |
+
}
|
1781 |
+
|
1782 |
+
return $language_options;
|
1783 |
+
}
|
1784 |
+
|
1785 |
+
function get_language_label($language) {
|
1786 |
+
$languages = $this->get_languages();
|
1787 |
+
if (isset($languages[$language])) return $languages[$language];
|
1788 |
+
return '';
|
1789 |
+
|
1790 |
+
}
|
1791 |
|
1792 |
function switch_language($language) {
|
1793 |
if (class_exists('SitePress')) {
|
plugin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
-
Version: 5.
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -14,7 +14,7 @@
|
|
14 |
*/
|
15 |
|
16 |
// Used as dummy parameter on css and js links
|
17 |
-
define('NEWSLETTER_VERSION', '5.
|
18 |
|
19 |
global $newsletter, $wpdb;
|
20 |
|
4 |
Plugin Name: Newsletter
|
5 |
Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
|
6 |
Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
|
7 |
+
Version: 5.6.0
|
8 |
Author: Stefano Lissa & The Newsletter Team
|
9 |
Author URI: https://www.thenewsletterplugin.com
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
14 |
*/
|
15 |
|
16 |
// Used as dummy parameter on css and js links
|
17 |
+
define('NEWSLETTER_VERSION', '5.6.0');
|
18 |
|
19 |
global $newsletter, $wpdb;
|
20 |
|
profile/profile.php
CHANGED
@@ -358,8 +358,12 @@ class NewsletterProfile extends NewsletterModule {
|
|
358 |
|
359 |
// General data
|
360 |
$data['email'] = $email;
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
363 |
if ($options_profile['sex_status'] >= 1) {
|
364 |
$data['sex'] = $_REQUEST['nx'][0];
|
365 |
// Wrong data injection check
|
358 |
|
359 |
// General data
|
360 |
$data['email'] = $email;
|
361 |
+
if (isset($_REQUEST['nn'])) {
|
362 |
+
$data['name'] = $this->normalize_name(stripslashes($_REQUEST['nn']));
|
363 |
+
}
|
364 |
+
if (isset($_REQUEST['ns'])) {
|
365 |
+
$data['surname'] = $this->normalize_name(stripslashes($_REQUEST['ns']));
|
366 |
+
}
|
367 |
if ($options_profile['sex_status'] >= 1) {
|
368 |
$data['sex'] = $_REQUEST['nx'][0];
|
369 |
// Wrong data injection check
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 4.9.7
|
5 |
-
Stable tag: 5.
|
6 |
Contributors: satollo,webagile,michael-travan
|
7 |
|
8 |
Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
|
@@ -107,6 +107,11 @@ Thank you, The Newsletter Team
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
|
|
|
|
|
|
|
|
|
|
110 |
= 5.5.9 =
|
111 |
|
112 |
* Fixed a possible debug notice on subscription without a dedicated page configured
|
2 |
Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
|
3 |
Requires at least: 3.4.0
|
4 |
Tested up to: 4.9.7
|
5 |
+
Stable tag: 5.6.0
|
6 |
Contributors: satollo,webagile,michael-travan
|
7 |
|
8 |
Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 5.6.0 =
|
111 |
+
|
112 |
+
* Lists pre-assignment by language (no more need to customize the newsletter shortcode or duplicate the widgets)
|
113 |
+
* Improved Polylang support (still not fully tested)
|
114 |
+
|
115 |
= 5.5.9 =
|
116 |
|
117 |
* Fixed a possible debug notice on subscription without a dedicated page configured
|
subscription/lists.php
CHANGED
@@ -6,12 +6,10 @@ $controls = new NewsletterControls();
|
|
6 |
$module = NewsletterSubscription::instance();
|
7 |
|
8 |
$current_language = $module->get_current_language();
|
9 |
-
|
10 |
$is_all_languages = $module->is_all_languages();
|
|
|
11 |
|
12 |
-
|
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 = $module->get_options('lists', $current_language);
|
@@ -21,7 +19,7 @@ if (!$controls->is_action()) {
|
|
21 |
$controls->add_message_saved();
|
22 |
}
|
23 |
if ($controls->is_action('unlink')) {
|
24 |
-
$wpdb->query("update " . NEWSLETTER_USERS_TABLE . " set list_" . ((int)$controls->button_data) . "=0");
|
25 |
$controls->add_message_done();
|
26 |
}
|
27 |
}
|
@@ -66,14 +64,18 @@ $status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => '
|
|
66 |
<thead>
|
67 |
<tr>
|
68 |
<th>#</th>
|
69 |
-
<th><?php _e('Name', 'newsletter')?></th>
|
70 |
<?php if ($is_all_languages) { ?>
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
76 |
<?php } ?>
|
|
|
|
|
|
|
77 |
<th><?php _e('Notes', 'newsletter') ?></th>
|
78 |
</tr>
|
79 |
</thead>
|
@@ -82,13 +84,17 @@ $status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => '
|
|
82 |
<td><?php echo $i; ?></td>
|
83 |
<td><?php $controls->text('list_' . $i, 50); ?></td>
|
84 |
<?php if ($is_all_languages) { ?>
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
88 |
<td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
|
89 |
-
|
90 |
<td><?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?></td>
|
91 |
-
|
92 |
<td>
|
93 |
<?php $notes = apply_filters('newsletter_lists_notes', array(), $i); ?>
|
94 |
<?php
|
@@ -97,7 +103,7 @@ $status = array(0 => 'Disabled/Private use', 1 => 'Only on profile page', 2 => '
|
|
97 |
$text .= $note . '<br>';
|
98 |
}
|
99 |
if (!empty($text)) {
|
100 |
-
|
101 |
}
|
102 |
?>
|
103 |
|
6 |
$module = NewsletterSubscription::instance();
|
7 |
|
8 |
$current_language = $module->get_current_language();
|
|
|
9 |
$is_all_languages = $module->is_all_languages();
|
10 |
+
$is_multilanguage = $module->is_multilanguage();
|
11 |
|
12 |
+
$controls->add_language_warning();
|
|
|
|
|
13 |
|
14 |
if (!$controls->is_action()) {
|
15 |
$controls->data = $module->get_options('lists', $current_language);
|
19 |
$controls->add_message_saved();
|
20 |
}
|
21 |
if ($controls->is_action('unlink')) {
|
22 |
+
$wpdb->query("update " . NEWSLETTER_USERS_TABLE . " set list_" . ((int) $controls->button_data) . "=0");
|
23 |
$controls->add_message_done();
|
24 |
}
|
25 |
}
|
64 |
<thead>
|
65 |
<tr>
|
66 |
<th>#</th>
|
67 |
+
<th><?php _e('Name', 'newsletter') ?></th>
|
68 |
<?php if ($is_all_languages) { ?>
|
69 |
+
<th><?php _e('Visibility', 'newsletter') ?></th>
|
70 |
+
<th><?php _e('Pre-checked', 'newsletter') ?></th>
|
71 |
+
<th><?php _e('Pre-assigned', 'newsletter') ?></th>
|
72 |
+
<?php if ($is_multilanguage) { ?>
|
73 |
+
<th><?php _e('Pre-assigned by language', 'newsletter') ?></th>
|
74 |
+
<?php } ?>
|
75 |
<?php } ?>
|
76 |
+
<th><?php _e('Subscribers', 'newsletter') ?></th>
|
77 |
+
<th> </th>
|
78 |
+
|
79 |
<th><?php _e('Notes', 'newsletter') ?></th>
|
80 |
</tr>
|
81 |
</thead>
|
84 |
<td><?php echo $i; ?></td>
|
85 |
<td><?php $controls->text('list_' . $i, 50); ?></td>
|
86 |
<?php if ($is_all_languages) { ?>
|
87 |
+
<td><?php $controls->select('list_' . $i . '_status', $status); ?></td>
|
88 |
+
<td><?php $controls->select('list_' . $i . '_checked', array(0 => 'No', 1 => 'Yes')); ?></td>
|
89 |
+
<td><?php $controls->select('list_' . $i . '_forced', array(0 => 'No', 1 => 'Yes')); ?></td>
|
90 |
+
<?php if ($is_multilanguage) { ?>
|
91 |
+
<td><?php $controls->languages('list_' . $i . '_languages'); ?></td>
|
92 |
+
<?php } ?>
|
93 |
+
<?php } ?>
|
94 |
+
|
95 |
<td><?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?></td>
|
|
|
96 |
<td><?php $controls->button_confirm('unlink', __('Unlink everyone', 'newsletter'), '', $i); ?></td>
|
97 |
+
|
98 |
<td>
|
99 |
<?php $notes = apply_filters('newsletter_lists_notes', array(), $i); ?>
|
100 |
<?php
|
103 |
$text .= $note . '<br>';
|
104 |
}
|
105 |
if (!empty($text)) {
|
106 |
+
echo '<i class="fa fa-info-circle tnp-notes" title="', esc_attr($text), '"></i>';
|
107 |
}
|
108 |
?>
|
109 |
|
subscription/options.php
CHANGED
@@ -9,11 +9,8 @@ $current_language = $module->get_current_language();
|
|
9 |
|
10 |
$is_all_languages = $module->is_all_languages();
|
11 |
|
12 |
-
|
13 |
-
$controls->warnings[] = 'You are configuring the language <strong>' . $current_language . '</strong>. Switch to "all languages" to see every options.';
|
14 |
-
}
|
15 |
|
16 |
-
// TODO: Remove and use the $module->options.
|
17 |
$options = $module->get_options('', $current_language);
|
18 |
|
19 |
if ($controls->is_action()) {
|
9 |
|
10 |
$is_all_languages = $module->is_all_languages();
|
11 |
|
12 |
+
$controls->add_language_warning();
|
|
|
|
|
13 |
|
|
|
14 |
$options = $module->get_options('', $current_language);
|
15 |
|
16 |
if ($controls->is_action()) {
|
subscription/subscription.php
CHANGED
@@ -746,8 +746,11 @@ class NewsletterSubscription extends NewsletterModule {
|
|
746 |
$user['referrer'] = strip_tags(trim($_REQUEST['nr']));
|
747 |
}
|
748 |
|
|
|
749 |
if (!empty($_REQUEST['nlang'])) {
|
750 |
-
$
|
|
|
|
|
751 |
}
|
752 |
|
753 |
// From the antibot form
|
@@ -785,12 +788,16 @@ class NewsletterSubscription extends NewsletterModule {
|
|
785 |
$this->logger->debug('No lists received');
|
786 |
}
|
787 |
|
788 |
-
// Forced lists
|
789 |
$lists = $this->get_lists();
|
790 |
foreach ($lists as $list) {
|
791 |
if ($list->forced) {
|
792 |
$user['list_' . $list->id] = 1;
|
793 |
}
|
|
|
|
|
|
|
|
|
794 |
}
|
795 |
|
796 |
// TODO: should be removed!!!
|
746 |
$user['referrer'] = strip_tags(trim($_REQUEST['nr']));
|
747 |
}
|
748 |
|
749 |
+
$language = '';
|
750 |
if (!empty($_REQUEST['nlang'])) {
|
751 |
+
$language = strtolower(strip_tags($_REQUEST['nlang']));
|
752 |
+
// TODO: Check if it's an allowed language code
|
753 |
+
$user['language'] = $language;
|
754 |
}
|
755 |
|
756 |
// From the antibot form
|
788 |
$this->logger->debug('No lists received');
|
789 |
}
|
790 |
|
791 |
+
// Forced lists (general or by language)
|
792 |
$lists = $this->get_lists();
|
793 |
foreach ($lists as $list) {
|
794 |
if ($list->forced) {
|
795 |
$user['list_' . $list->id] = 1;
|
796 |
}
|
797 |
+
if (in_array($language, $list->languages)) {
|
798 |
+
echo 'assegnato' . $list->id;
|
799 |
+
$user['list_' . $list->id] = 1;
|
800 |
+
}
|
801 |
}
|
802 |
|
803 |
// TODO: should be removed!!!
|