Newsletter - Version 5.0.9

Version Description

=

  • Removed wp users integration and locked content now available as FREE optional extensions (to make the plugin smaller)
  • Removed obsolete code loading old-style extensions

=

Download this release

Release Info

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

Code changes from version 5.0.8 to 5.0.9

includes/controls.php CHANGED
@@ -663,7 +663,7 @@ class NewsletterControls {
663
  echo htmlspecialchars($this->data[$name]);
664
  }
665
 
666
- function value_date($name, $show_remaining) {
667
  $time = $this->get_value($name);
668
 
669
  echo gmdate(get_option('date_format') . ' ' . get_option('time_format'), $time + get_option('gmt_offset') * 3600);
663
  echo htmlspecialchars($this->data[$name]);
664
  }
665
 
666
+ function value_date($name, $show_remaining = true) {
667
  $time = $this->get_value($name);
668
 
669
  echo gmdate(get_option('date_format') . ' ' . get_option('time_format'), $time + get_option('gmt_offset') * 3600);
includes/module.php CHANGED
@@ -424,6 +424,9 @@ class NewsletterModule {
424
  }
425
 
426
  $result = array(array(), array());
 
 
 
427
  foreach ($posts as &$post) {
428
  if (self::is_post_old($post, $time))
429
  $result[1][] = $post;
424
  }
425
 
426
  $result = array(array(), array());
427
+
428
+ if (empty($posts)) return $result;
429
+
430
  foreach ($posts as &$post) {
431
  if (self::is_post_old($post, $time))
432
  $result[1][] = $post;
lock/index.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- if (!defined('ABSPATH')) exit;
3
-
4
- @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
5
- $controls = new NewsletterControls();
6
- $module = NewsletterLock::instance();
7
-
8
- if (!$controls->is_action()) {
9
- $controls->data = $module->get_options();
10
- } else {
11
- if ($controls->is_action('save')) {
12
- $module->save_options($controls->data);
13
- $controls->data = $module->get_options();
14
- }
15
- if ($controls->is_action('reset')) {
16
- $module->reset_options();
17
- $controls->data = $module->get_options();
18
- }
19
- }
20
- ?>
21
-
22
- <div class="wrap" id="tnp-wrap">
23
-
24
- <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
25
-
26
- <div id="tnp-heading">
27
-
28
- <h2><?php _e('Locked Content', 'newsletter') ?></h2>
29
- <p>
30
- Please, <a href="https://www.thenewsletterplugin.com/plugins/newsletter/newsletter-locked-content" target="_blank">read more here how to use and configure</a>,
31
- since it can incredibly increase your subscription rate.
32
- </p>
33
-
34
- </div>
35
-
36
- <div id="tnp-body">
37
-
38
- <form method="post" action="">
39
- <?php $controls->init(); ?>
40
- <table class="form-table">
41
- <tr valign="top">
42
- <th><?php _e('Enabled', 'newsletter') ?></th>
43
- <td>
44
- <?php $controls->yesno('enabled'); ?>
45
- <p class="description">
46
- If you don't plan to use this feature, keep it disable save blog resources!
47
- </p>
48
- </td>
49
- </tr>
50
- <tr valign="top">
51
- <th><?php _e('Tags or categories to block', 'newsletter') ?></th>
52
- <td>
53
- <?php $controls->text('ids', 70); ?> (<?php _e('comma separated', 'newsletter') ?>)
54
- <p class="description">
55
- <?php _e('Use tag or category slugs or id for which lock the posts content', 'newsletter') ?>
56
- </p>
57
- </td>
58
- </tr>
59
-
60
- <tr valign="top">
61
- <th><?php _e('Unlock destination URL', 'newsletter') ?></th>
62
- <td>
63
- <?php $controls->text('url', 70); ?>
64
- <p class="description">
65
- <?php _e('URL where redirect subscribers when they click on unlocking URL ({unlock_url}) inserted in newsletters and welcome message.', 'newsletter') ?>
66
- <br>
67
- Newsletters with tracking active can link directly the pages with locked content since the URLs will
68
- unlock the content as well.
69
- </p>
70
- </td>
71
- </tr>
72
- <tr valign="top">
73
- <th><?php _e('Denied content message', 'newsletter') ?></th>
74
- <td>
75
- <?php $controls->wp_editor('message'); ?>
76
-
77
- <p class="description">
78
- This message is shown in place of protected post or page content which is surrounded with
79
- [newsletter_lock] and [/newsletter_lock] shortcodes or in place of the full content if they are
80
- in categories or have tags as specified above.<br>
81
- You can use shortcodes like [newsletter_form] to display a subscription form or any other Newsletter shortcode.
82
- <strong>Remember to add the {unlock_url} on the welcome email so the user can unlock the content.</strong>
83
- </p>
84
- </td>
85
- </tr>
86
- </table>
87
- <p>
88
- <?php $controls->button_save(); ?>
89
- <?php $controls->button_reset(); ?>
90
- </p>
91
- </form>
92
- </div>
93
-
94
- <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
95
-
96
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lock/languages/en_US.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- // This file is used only on first installation!
4
-
5
- $options = array();
6
- $options['ids'] = '';
7
- $options['url'] = '';
8
- $options['message'] = '<p>Subscribe to our newsletter and get access to the full article.</p>[subscription_form]';
9
- $options['enabled'] = 0;
 
 
 
 
 
 
 
 
 
lock/lock.php DELETED
@@ -1,154 +0,0 @@
1
- <?php
2
- if (!defined('ABSPATH')) exit;
3
-
4
- require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
5
-
6
- class NewsletterLock extends NewsletterModule {
7
-
8
- static $instance;
9
- var $found = false;
10
-
11
- /**
12
- * @return NewsletterLock
13
- */
14
- static function instance() {
15
- if (self::$instance == null) {
16
- self::$instance = new NewsletterLock();
17
- }
18
- return self::$instance;
19
- }
20
-
21
- function __construct() {
22
- parent::__construct('lock', '1.0.3');
23
- add_action('init', array($this, 'hook_init'), 90);
24
- }
25
-
26
- function hook_init() {
27
- if (empty($this->options['enabled'])) {
28
- add_shortcode('newsletter_lock', array($this, 'shortcode_newsletter_lock_dummy'));
29
- return;
30
- }
31
-
32
- add_shortcode('newsletter_lock', array($this, 'shortcode_newsletter_lock'));
33
- add_filter('the_content', array($this, 'hook_the_content'));
34
- add_action('wp_loaded', array($this, 'hook_wp_loaded'));
35
- }
36
-
37
- function hook_wp_loaded() {
38
-
39
- switch (Newsletter::instance()->action) {
40
-
41
- case 'ul':
42
- $user = $this->check_user();
43
-
44
- if ($user == null || $user->status != 'C') {
45
- echo 'Subscriber not found, sorry.';
46
- die();
47
- }
48
-
49
- setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
50
- if (empty($this->options['url'])) {
51
- header('Location: ' . home_url());
52
- } else {
53
- header('Location: ' . $this->options['url']);
54
- }
55
-
56
- die();
57
- }
58
- }
59
-
60
- function upgrade() {
61
- parent::upgrade();
62
-
63
- if ($this->old_version < '1.0.2') {
64
- // Locked content configuration migration
65
-
66
- $old_options = Newsletter::instance()->get_options();
67
- if (isset($old_options['lock_message']) || isset($old_options['lock_ids']) || isset($old_options['lock_url'])) {
68
- $this->options['ids'] = $old_options['lock_ids'];
69
- $this->options['url'] = $old_options['lock_url'];
70
- $this->options['message'] = $old_options['lock_message'];
71
- $this->options['enabled'] = 1;
72
- $this->save_options($this->options);
73
-
74
- unset($old_options['lock_ids']);
75
- unset($old_options['lock_url']);
76
- unset($old_options['lock_message']);
77
- Newsletter::instance()->save_options($old_options);
78
- }
79
-
80
- $old_options = NewsletterSubscription::instance()->get_options('lock');
81
- if (!empty($old_options)) {
82
- $this->options['ids'] = $old_options['ids'];
83
- $this->options['url'] = $old_options['url'];
84
- $this->options['message'] = $old_options['message'];
85
- $this->options['enabled'] = 1;
86
- $this->save_options($this->options);
87
- NewsletterSubscription::instance()->delete_options('lock');
88
- }
89
- }
90
- }
91
-
92
- function admin_menu() {
93
- $this->add_admin_page('index', 'Locked content');
94
- }
95
-
96
- function hook_the_content($content) {
97
- global $post, $cache_stop;
98
-
99
- if (empty($this->options['ids'])) {
100
- return $content;
101
- }
102
-
103
- if (current_user_can('manage_options')) {
104
- return $content;
105
- }
106
-
107
- $ids = explode(',', str_replace(' ', '', $this->options['ids']));
108
-
109
- if (has_tag($ids) || in_category($ids) || in_array($post->post_name, $ids)) {
110
- $cache_stop = true;
111
- $user = $this->check_user();
112
- if ($user == null || $user->status != 'C') {
113
- $buffer = Newsletter::instance()->replace($this->options['message']);
114
- return '<div class="newsletter-lock">' . do_shortcode($buffer) . '</div>';
115
- }
116
- }
117
-
118
- return $content;
119
- }
120
-
121
- function shortcode_newsletter_lock_dummy($attrs, $content = null) {
122
- return $content;
123
- }
124
-
125
- function shortcode_newsletter_lock($attrs, $content = null) {
126
- global $hyper_cache_stop, $cache_stop;
127
-
128
- $hyper_cache_stop = true;
129
- $cache_stop = true;
130
-
131
- $this->found = true;
132
-
133
- if (current_user_can('publish_posts')) {
134
- return do_shortcode($content);
135
- }
136
-
137
- $user = $this->check_user();
138
- if ($user != null && $user->status == 'C') {
139
- return do_shortcode($content);
140
- }
141
-
142
- $buffer = $this->options['message'];
143
-
144
- $buffer = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '"', $buffer);
145
- $buffer = Newsletter::instance()->replace($buffer, null, null, 'lock');
146
-
147
- $buffer = do_shortcode($buffer);
148
-
149
- return '<div class="newsletter-lock">' . $buffer . '</div>';
150
- }
151
-
152
- }
153
-
154
- NewsletterLock::instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
- Version: 5.0.8
8
  Author: Stefano Lissa & The Newsletter Team
9
  Author URI: https://www.thenewsletterplugin.com
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -14,7 +14,7 @@
14
  */
15
 
16
  // Used as dummy parameter on css and js links
17
- define('NEWSLETTER_VERSION', '5.0.8');
18
 
19
  global $wpdb, $newsletter;
20
 
@@ -183,7 +183,7 @@ class Newsletter extends NewsletterModule {
183
 
184
  // TODO: Meditation on how to use those ones...
185
  register_activation_hook(__FILE__, array($this, 'hook_activate'));
186
- //register_deactivation_hook(__FILE__, array(&$this, 'hook_deactivate'));
187
 
188
  add_action('admin_init', array($this, 'hook_admin_init'));
189
 
@@ -192,9 +192,6 @@ class Newsletter extends NewsletterModule {
192
  add_filter('the_content', array($this, 'hook_the_content'), 99);
193
 
194
  if (is_admin()) {
195
- if ($this->is_admin_page()) {
196
- add_action('in_admin_header', array($this, 'hook_in_admin_header'), 999);
197
- }
198
  add_action('admin_head', array($this, 'hook_admin_head'));
199
 
200
  // Protection against strange schedule removal on some installations
@@ -208,10 +205,6 @@ class Newsletter extends NewsletterModule {
208
  }
209
  }
210
 
211
- function hook_in_admin_header() {
212
- //remove_all_filters('admin_notices');
213
- }
214
-
215
  function hook_activate() {
216
  // Ok, why? When the plugin is not active WordPress may remove the scheduled "newsletter" action because
217
  // the every-five-minutes schedule named "newsletter" is not present.
@@ -225,6 +218,12 @@ class Newsletter extends NewsletterModule {
225
  if (!$install_time) {
226
  update_option('newsletter_install_time', time(), false);
227
  }
 
 
 
 
 
 
228
  }
229
 
230
  function first_install() {
@@ -981,7 +980,6 @@ class Newsletter extends NewsletterModule {
981
 
982
  function hook_deactivate() {
983
  wp_clear_scheduled_hook('newsletter');
984
- wp_clear_scheduled_hook('newsletter_feed');
985
  }
986
 
987
  function hook_cron_schedules($schedules) {
@@ -989,10 +987,6 @@ class Newsletter extends NewsletterModule {
989
  'interval' => NEWSLETTER_CRON_INTERVAL, // seconds
990
  'display' => 'Newsletter'
991
  );
992
- // $schedules['newsletter_weekly'] = array(
993
- // 'interval' => 86400 * 7, // seconds
994
- // 'display' => 'Newsletter Weekly'
995
- // );
996
  return $schedules;
997
  }
998
 
@@ -1510,79 +1504,5 @@ require_once NEWSLETTER_DIR . '/subscription/subscription.php';
1510
  require_once NEWSLETTER_DIR . '/emails/emails.php';
1511
  require_once NEWSLETTER_DIR . '/users/users.php';
1512
  require_once NEWSLETTER_DIR . '/statistics/statistics.php';
1513
- if (!file_exists(WP_PLUGIN_DIR . '/newsletter-lock')) {
1514
- require_once NEWSLETTER_DIR . '/lock/lock.php';
1515
- }
1516
-
1517
- if (!file_exists(WP_PLUGIN_DIR . '/newsletter-wpusers')) {
1518
- require_once NEWSLETTER_DIR . '/wp/wp.php';
1519
- }
1520
-
1521
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-feed')) {
1522
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php')) {
1523
- require_once WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php';
1524
- }
1525
- }
1526
-
1527
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-followup')) {
1528
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php')) {
1529
- require_once WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php';
1530
- }
1531
- }
1532
-
1533
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-reports')) {
1534
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/reports/reports.php')) {
1535
- require_once WP_CONTENT_DIR . '/extensions/newsletter/reports/reports.php';
1536
- }
1537
- }
1538
-
1539
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-mailjet')) {
1540
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mailjet/mailjet.php')) {
1541
- require_once WP_CONTENT_DIR . '/extensions/newsletter/mailjet/mailjet.php';
1542
- }
1543
- }
1544
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-sendgrid')) {
1545
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/sendgrid/sendgrid.php')) {
1546
- require_once WP_CONTENT_DIR . '/extensions/newsletter/sendgrid/sendgrid.php';
1547
- }
1548
- }
1549
-
1550
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-facebook')) {
1551
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php')) {
1552
- require_once WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php';
1553
- }
1554
- }
1555
-
1556
-
1557
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-popup')) {
1558
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php')) {
1559
- require_once WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php';
1560
- }
1561
- }
1562
-
1563
- if (!is_dir(WP_PLUGIN_DIR . '/newsletter-mandrill')) {
1564
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php')) {
1565
- require_once WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php';
1566
- }
1567
- }
1568
-
1569
-
1570
- require_once(dirname(__FILE__) . '/widget/standard.php');
1571
- require_once(dirname(__FILE__) . '/widget/minimal.php');
1572
-
1573
- register_activation_hook(__FILE__, 'newsletter_activate');
1574
-
1575
- function newsletter_activate() {
1576
- Newsletter::instance()->upgrade();
1577
-
1578
- NewsletterUsers::instance()->upgrade();
1579
- NewsletterEmails::instance()->upgrade();
1580
- NewsletterSubscription::instance()->upgrade();
1581
- NewsletterStatistics::instance()->upgrade();
1582
- }
1583
-
1584
- register_activation_hook(__FILE__, 'newsletter_deactivate');
1585
-
1586
- function newsletter_deactivate() {
1587
-
1588
- }
4
  Plugin Name: Newsletter
5
  Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
+ Version: 5.0.9
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.0.9');
18
 
19
  global $wpdb, $newsletter;
20
 
183
 
184
  // TODO: Meditation on how to use those ones...
185
  register_activation_hook(__FILE__, array($this, 'hook_activate'));
186
+ register_deactivation_hook(__FILE__, array($this, 'hook_deactivate'));
187
 
188
  add_action('admin_init', array($this, 'hook_admin_init'));
189
 
192
  add_filter('the_content', array($this, 'hook_the_content'), 99);
193
 
194
  if (is_admin()) {
 
 
 
195
  add_action('admin_head', array($this, 'hook_admin_head'));
196
 
197
  // Protection against strange schedule removal on some installations
205
  }
206
  }
207
 
 
 
 
 
208
  function hook_activate() {
209
  // Ok, why? When the plugin is not active WordPress may remove the scheduled "newsletter" action because
210
  // the every-five-minutes schedule named "newsletter" is not present.
218
  if (!$install_time) {
219
  update_option('newsletter_install_time', time(), false);
220
  }
221
+
222
+ Newsletter::instance()->upgrade();
223
+ NewsletterUsers::instance()->upgrade();
224
+ NewsletterEmails::instance()->upgrade();
225
+ NewsletterSubscription::instance()->upgrade();
226
+ NewsletterStatistics::instance()->upgrade();
227
  }
228
 
229
  function first_install() {
980
 
981
  function hook_deactivate() {
982
  wp_clear_scheduled_hook('newsletter');
 
983
  }
984
 
985
  function hook_cron_schedules($schedules) {
987
  'interval' => NEWSLETTER_CRON_INTERVAL, // seconds
988
  'display' => 'Newsletter'
989
  );
 
 
 
 
990
  return $schedules;
991
  }
992
 
1504
  require_once NEWSLETTER_DIR . '/emails/emails.php';
1505
  require_once NEWSLETTER_DIR . '/users/users.php';
1506
  require_once NEWSLETTER_DIR . '/statistics/statistics.php';
1507
+ require_once NEWSLETTER_DIR . '/widget/standard.php';
1508
+ require_once NEWSLETTER_DIR . '/widget/minimal.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
3
  Requires at least: 3.4.0
4
  Tested up to: 4.8.2
5
- Stable tag: 5.0.8
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -85,6 +85,11 @@ Thank you, The Newsletter Team
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
88
  == 5.0.8 ==
89
 
90
  * Improved select 2 layout
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing,automation,automated
3
  Requires at least: 3.4.0
4
  Tested up to: 4.8.2
5
+ Stable tag: 5.0.9
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
85
 
86
  == Changelog ==
87
 
88
+ == 5.0.9 ==
89
+
90
+ * Removed wp users integration and locked content now available as FREE optional extensions (to make the plugin smaller)
91
+ * Removed obsolete code loading old-style extensions
92
+
93
  == 5.0.8 ==
94
 
95
  * Improved select 2 layout
subscription/subscription.php CHANGED
@@ -36,8 +36,6 @@ class NewsletterSubscription extends NewsletterModule {
36
  add_action('admin_init', array($this, 'hook_admin_init'));
37
  } else {
38
  add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
39
- add_action('wp_head', array($this, 'hook_wp_head'), 100);
40
- add_action('wp_footer', array($this, 'hook_wp_footer'));
41
  add_shortcode('newsletter', array($this, 'shortcode_newsletter'));
42
  add_shortcode('newsletter_form', array($this, 'shortcode_newsletter_form'));
43
  add_shortcode('newsletter_profile', array($this, 'shortcode_newsletter_profile'));
@@ -191,14 +189,6 @@ class NewsletterSubscription extends NewsletterModule {
191
  }
192
  }
193
 
194
- function hook_wp_head() {
195
-
196
- }
197
-
198
- function hook_wp_footer() {
199
- // Consider this: http://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript
200
- }
201
-
202
  function upgrade() {
203
  global $wpdb, $charset_collate, $newsletter;
204
 
@@ -374,17 +364,6 @@ class NewsletterSubscription extends NewsletterModule {
374
 
375
  return $user;
376
  }
377
-
378
- // Resend the welcome email, if enabled
379
- // if ($emails && !isset($options['resend_welcome_email_disabled']) && !isset($options['confirmed_disabled'])) {
380
- // $message = $options[$prefix . 'confirmed_message'];
381
- // $subject = $options[$prefix . 'confirmed_subject'];
382
- // $this->mail($user->email, $newsletter->replace($subject, $user), $newsletter->replace($message, $user));
383
- // }
384
- //
385
- // // Non persistent status to decide which message to show (already subscribed)
386
- // $user->status = 'A';
387
- // return $user;
388
  }
389
  }
390
 
36
  add_action('admin_init', array($this, 'hook_admin_init'));
37
  } else {
38
  add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
 
 
39
  add_shortcode('newsletter', array($this, 'shortcode_newsletter'));
40
  add_shortcode('newsletter_form', array($this, 'shortcode_newsletter_form'));
41
  add_shortcode('newsletter_profile', array($this, 'shortcode_newsletter_profile'));
189
  }
190
  }
191
 
 
 
 
 
 
 
 
 
192
  function upgrade() {
193
  global $wpdb, $charset_collate, $newsletter;
194
 
364
 
365
  return $user;
366
  }
 
 
 
 
 
 
 
 
 
 
 
367
  }
368
  }
369
 
users/users.php CHANGED
@@ -20,7 +20,7 @@ class NewsletterUsers extends NewsletterModule {
20
  }
21
 
22
  function __construct() {
23
- parent::__construct('users', '1.1.2');
24
  add_action('init', array($this, 'hook_init'));
25
  }
26
 
@@ -72,7 +72,9 @@ class NewsletterUsers extends NewsletterModule {
72
  `country` varchar(4) NOT NULL DEFAULT '',
73
  `region` varchar(100) NOT NULL DEFAULT '',
74
  `city` varchar(100) NOT NULL DEFAULT '',
75
- `unsub_email_id` int(11) NOT NULL DEFAULT '0',
 
 
76
  `unsub_time` int(11) NOT NULL DEFAULT '0',\n";
77
 
78
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
20
  }
21
 
22
  function __construct() {
23
+ parent::__construct('users', '1.1.3');
24
  add_action('init', array($this, 'hook_init'));
25
  }
26
 
72
  `country` varchar(4) NOT NULL DEFAULT '',
73
  `region` varchar(100) NOT NULL DEFAULT '',
74
  `city` varchar(100) NOT NULL DEFAULT '',
75
+ `bounce_type` varchar(50) NOT NULL DEFAULT '',
76
+ `bounce_time` int(11) NOT NULL DEFAULT '0',
77
+ `unsub_email_id` int(11) NOT NULL DEFAULT '0',
78
  `unsub_time` int(11) NOT NULL DEFAULT '0',\n";
79
 
80
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
wp/index.php DELETED
@@ -1,165 +0,0 @@
1
- <?php
2
- if (!defined('ABSPATH'))
3
- exit;
4
-
5
- @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
- $controls = new NewsletterControls();
7
- $module = NewsletterWp::instance();
8
-
9
- if (!$controls->is_action()) {
10
- $controls->data = $module->options;
11
- } else {
12
- if ($controls->is_action('save')) {
13
- //$module->merge_options($controls->data);
14
- unset($controls->data['align_wp_users_status']);
15
- $module->save_options($controls->data);
16
- $controls->add_message_saved();
17
- }
18
-
19
- if ($controls->is_action('align_wp_users')) {
20
- ignore_user_abort(true);
21
- set_time_limit(0);
22
-
23
- // TODO: check if the user is already there
24
- $wp_users = $wpdb->get_results("select id, user_email, user_login from $wpdb->users");
25
- $count = 0;
26
- foreach ($wp_users as &$wp_user) {
27
-
28
- // A subscriber is already there with the same wp_user_id? Do Nothing.
29
- $nl_user = $module->get_user_by_wp_user_id($wp_user->id);
30
- if (!empty($nl_user)) {
31
- continue;
32
- }
33
-
34
- // A subscriber has the same email? Align them if not already associated to another wordpress user
35
- $nl_user = $module->get_user($module->normalize_email($wp_user->user_email));
36
- if (!empty($nl_user)) {
37
- if (empty($nl_user->wp_user_id)) {
38
- //$module->logger->info('Linked');
39
- $module->set_user_wp_user_id($nl_user->id, $wp_user->id);
40
- continue;
41
- }
42
- }
43
-
44
- // Create a new subscriber
45
- $nl_user = array();
46
- $nl_user['email'] = $module->normalize_email($wp_user->user_email);
47
- $nl_user['name'] = $wp_user->first_name;
48
- if (empty($nl_user['name'])) {
49
- $nl_user['name'] = $wp_user->user_login;
50
- }
51
- $nl_user['surname'] = $wp_user->last_name;
52
- $nl_user['status'] = $controls->data['align_wp_users_status'];
53
- $nl_user['wp_user_id'] = $wp_user->id;
54
- $nl_user['referrer'] = 'wordpress';
55
-
56
- // Adds the force subscription preferences
57
- $preferences = NewsletterSubscription::instance()->options['preferences'];
58
- if (is_array($preferences)) {
59
- foreach ($preferences as $p) {
60
- $nl_user['list_' . $p] = 1;
61
- }
62
- }
63
-
64
- $module->save_user($nl_user);
65
- $count++;
66
- }
67
- $controls->messages = count($wp_users) . ' ' . __('WordPress users processed', 'newsletter') . '. ';
68
- $controls->messages .= $count . ' ' . __('subscriptions added', 'newsletter') . '.';
69
- }
70
- }
71
- ?>
72
- <div class="wrap" id="tnp-wrap">
73
-
74
- <?php include NEWSLETTER_DIR . '/tnp-header.php'; ?>
75
-
76
- <div id="tnp-heading">
77
-
78
- <h2><?php _e('WordPress Registration Integration', 'newsletter') ?></h2>
79
-
80
- <p>Configure if and how a regular WordPress user registration can be connected to a Newsletter subscription.</p>
81
- <p>
82
- Important! This type of subscription does not require confirmation, it's automatic on first login.
83
- <a href="https://www.thenewsletterplugin.com/plugins/newsletter/subscription-module#registration" target="_blank">Read more on documentation page</a>.
84
- </p>
85
-
86
- </div>
87
-
88
- <div id="tnp-body">
89
-
90
- <form method="post" action="">
91
-
92
- <?php $controls->init(); ?>
93
-
94
- <table class="form-table">
95
- <tr valign="top">
96
- <th>Subscription on registration</th>
97
- <td>
98
- <?php $controls->select('subscribe', array(0 => 'No', 1 => 'Yes, force subscription', 2 => 'Yes, show the option', 3 => 'Yes, show the option already checked')); ?>
99
- <p class="description">
100
- Adds a newsletter subscription option on registration.
101
- <a href="https://www.thenewsletterplugin.com/plugins/newsletter/subscription-module#registration" target="_blank">Read more</a>
102
- </p>
103
- </td>
104
- </tr>
105
- <tr valign="top">
106
- <th><?php _e('Check box label', 'newsletter') ?></th>
107
- <td>
108
- <?php $controls->text('subscribe_label', 30); ?>
109
- </td>
110
- </tr>
111
- </table>
112
-
113
- <h3><?php _e('Confirmation', 'newsletter') ?></h3>
114
- <p>
115
- Subscribers will be automatically confirmed on first log-in (because it demonstrates they received the WP email with
116
- their password. Hence no confirmation email is sent. Anyway you can change that behavior here and ask anyway for confirmation.
117
- </p>
118
- <table class="form-table">
119
-
120
- <tr valign="top">
121
- <th>Send the confirmation email</th>
122
- <td>
123
- <?php $controls->yesno('confirmation'); ?>
124
- </td>
125
- </tr>
126
- <tr valign="top">
127
- <th><?php _e('Send welcome email to registered users', 'newsletter') ?></th>
128
- <td>
129
- <?php $controls->yesno('welcome'); ?>
130
- </td>
131
- </tr>
132
- <tr valign="top">
133
- <th><?php _e('Subscription delete', 'newsletter') ?></th>
134
- <td>
135
- <?php $controls->yesno('delete'); ?>
136
- <p class="description">Delete the subscription connected to a WordPress user when that user is deleted</p>
137
- </td>
138
- </tr>
139
- </table>
140
-
141
-
142
- <h3><?php _e('Import already registered users', 'newsletter') ?>
143
- <table class="form-table">
144
- <tr>
145
- <th><?php _e('Import with status', 'newsletter') ?></th>
146
- <td>
147
- <?php $controls->select('align_wp_users_status', array('C' => __('Confirmed', 'newsletter'), 'S' => __('Not confirmed', 'newsletter'))); ?>
148
- <?php $controls->button_confirm('align_wp_users', __('Import', 'newsletter'), __('Proceed?', 'newsletter')); ?>
149
- <p class="description">
150
- <a href="https://www.thenewsletterplugin.com/plugins/newsletter/subscribers-module#import-wp-users" target="_blank">
151
- <?php _e('Please, carefully read the documentation before taking this action!', 'newsletter') ?>
152
- </a>
153
- </p>
154
- </td>
155
- </tr>
156
- </table>
157
- <p>
158
- <?php $controls->button_save(); ?>
159
- </p>
160
- </form>
161
- </div>
162
-
163
- <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
164
-
165
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp/languages/en_US.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- // This file is used only on first installation!
4
-
5
- $options = array();
6
- $options['subscribe_label'] = 'Subscribe our newsletter';
7
- $options['subscribe'] = 0;
8
- $options['confirmation'] = 0;
9
- $options['welcome'] = 0;
10
- $options['delete'] = 0;
11
-
 
 
 
 
 
 
 
 
 
 
 
wp/wp.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- if (!defined('ABSPATH')) exit;
3
-
4
- require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
5
-
6
- class NewsletterWp extends NewsletterModule {
7
-
8
- static $instance;
9
- var $found = false;
10
-
11
- /**
12
- * @return NewsletterWp
13
- */
14
- static function instance() {
15
- if (self::$instance == null) {
16
- self::$instance = new NewsletterWp();
17
- }
18
- return self::$instance;
19
- }
20
-
21
- function __construct() {
22
- parent::__construct('wp', '1.0.1');
23
- add_action('init', array($this, 'hook_init'), 90);
24
- }
25
-
26
- function hook_init() {
27
- add_action('delete_user', array($this, 'hook_delete_user'));
28
- add_action('wp_login', array($this, 'hook_wp_login'));
29
- add_action('register_form', array($this, 'hook_register_form'));
30
- // The hook is always active so the module can be activated only on registration (otherwise we should check that
31
- // option on every page load. The registration code should be moved inside the module...
32
- add_action('user_register', array($this, 'hook_subscription_user_register'));
33
- }
34
-
35
- /**
36
- * See wp-includes/user.php function wp_signon().
37
- */
38
- function hook_wp_login($user_login) {
39
- //$this->logger->info(__METHOD__ . '> Start with ' . $user_login);
40
- $wp_user = get_user_by('login', $user_login);
41
- if (!empty($wp_user)) {
42
- //$this->logger->info($wp_user);
43
- // We have a user able to login, so his subscription can be confirmed if not confirmed
44
- $user = $this->get_user($wp_user->user_email);
45
- if (!empty($user)) {
46
- NewsletterSubscription::instance()->confirm($user->id, $this->options['welcome'] == 1);
47
- }
48
- }
49
- //$this->logger->info(__METHOD__ . '> End');
50
- }
51
-
52
- function hook_delete_user($id) {
53
- global $wpdb;
54
- if ($this->options['delete'] == 1) {
55
- $wpdb->delete(NEWSLETTER_USERS_TABLE, array('wp_user_id' => $id));
56
- }
57
- }
58
-
59
- function upgrade() {
60
- parent::upgrade();
61
-
62
- if ($this->old_version < '1.0.0') {
63
- // Locked content configuration migration
64
-
65
- $old_options = $old_options = NewsletterSubscription::instance()->get_options();
66
-
67
- if (isset($old_options['wp_welcome'])) {
68
- $this->options['welcome'] = $old_options['wp_welcome'];
69
- }
70
- if (isset($old_options['wp_delete'])) {
71
- $this->options['delete'] = $old_options['wp_delete'];
72
- }
73
- if (isset($old_options['subscribe_wp_users_label'])) {
74
- $this->options['subscribe_label'] = $old_options['subscribe_wp_users_label'];
75
- }
76
- if (isset($old_options['subscribe_wp_users'])) {
77
- $this->options['subscribe'] = $old_options['subscribe_wp_users'];
78
- }
79
- if (isset($old_options['wp_send_confirmation'])) {
80
- $this->options['confirmation'] = $old_options['wp_send_confirmation'];
81
- }
82
- $this->save_options($this->options);
83
-
84
- unset($old_options['wp_welcome']);
85
- unset($old_options['wp_delete']);
86
- unset($old_options['subscribe_wp_users_label']);
87
- unset($old_options['subscribe_wp_users']);
88
- unset($old_options['wp_send_confirmation']);
89
- NewsletterSubscription::instance()->save_options($old_options);
90
- }
91
- }
92
-
93
- function admin_menu() {
94
- $this->add_admin_page('index', 'WP Registration');
95
- }
96
-
97
- function hook_register_form() {
98
- if ($this->options['subscribe'] == 2 || $this->options['subscribe'] == 3) {
99
- echo '<p>';
100
- echo '<input type="checkbox" value="1" name="newsletter"';
101
- if ($this->options['subscribe'] == 3) {
102
- echo ' checked';
103
- }
104
- echo '>&nbsp;';
105
- echo $this->options['subscribe_label'];
106
- echo '</p>';
107
- }
108
- }
109
-
110
- function hook_subscription_user_register($wp_user_id) {
111
- global $wpdb;
112
-
113
- // If the integration is disabled...
114
- if ($this->options['subscribe'] == 0) {
115
- return;
116
- }
117
-
118
- // If not forced and the user didn't choose the newsletter...
119
- if ($this->options['subscribe'] != 1) {
120
- if (!isset($_REQUEST['newsletter'])) {
121
- return;
122
- }
123
- }
124
-
125
- $this->logger->info('Adding a registered WordPress user (' . $wp_user_id . ')');
126
- $wp_user = $wpdb->get_row($wpdb->prepare("select * from $wpdb->users where id=%d limit 1", $wp_user_id));
127
- if (empty($wp_user)) {
128
- $this->logger->error('User not found?!');
129
- return;
130
- }
131
-
132
- // Yes, some registration procedures allow empty email
133
- if (!$this->is_email($wp_user->user_email)) {
134
- return;
135
- }
136
-
137
- $_REQUEST['ne'] = $wp_user->user_email;
138
- $_REQUEST['nr'] = 'registration';
139
- // Upon registration there is no last name and first name, sorry.
140
- // $status is determined by the opt in
141
- $user = NewsletterSubscription::instance()->subscribe(null, $this->options['confirmation'] == 1);
142
-
143
- // Now we associate it with wp
144
- $this->set_user_wp_user_id($user->id, $wp_user_id);
145
- }
146
-
147
- }
148
-
149
- NewsletterWp::instance();