Newsletter - Version 3.4.2

Version Description

  • Refined the subscription for already subscribed emails
Download this release

Release Info

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

Code changes from version 3.4.0 to 3.4.2

do/subscribe.php CHANGED
@@ -9,4 +9,5 @@ require_once '../../../../wp-load.php';
9
  $user = NewsletterSubscription::instance()->subscribe();
10
  if ($user->status == 'E') NewsletterSubscription::instance()->show_message('error', $user->id);
11
  if ($user->status == 'C') NewsletterSubscription::instance()->show_message('confirmed', $user->id);
 
12
  if ($user->status == 'S') NewsletterSubscription::instance()->show_message('confirmation', $user->id);
9
  $user = NewsletterSubscription::instance()->subscribe();
10
  if ($user->status == 'E') NewsletterSubscription::instance()->show_message('error', $user->id);
11
  if ($user->status == 'C') NewsletterSubscription::instance()->show_message('confirmed', $user->id);
12
+ if ($user->status == 'A') NewsletterSubscription::instance()->show_message('already_confirmed', $user->id);
13
  if ($user->status == 'S') NewsletterSubscription::instance()->show_message('confirmation', $user->id);
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/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="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
- Version: 3.4.0
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -13,7 +13,7 @@
13
  */
14
 
15
  // Useed as dummy parameter on css and js links
16
- define('NEWSLETTER_VERSION', '3.4.0');
17
 
18
  global $wpdb, $newsletter;
19
 
@@ -236,10 +236,13 @@ class Newsletter extends NewsletterModule {
236
 
237
  wp_clear_scheduled_hook('newsletter_update');
238
  wp_clear_scheduled_hook('newsletter_check_versions');
239
- wp_schedule_event(time() + 30, 'weekly', 'newsletter_check_versions');
240
 
241
  wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
242
  wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
 
 
 
243
 
244
  return true;
245
  }
@@ -261,7 +264,7 @@ class Newsletter extends NewsletterModule {
261
  $warnings = '';
262
  $x = wp_next_scheduled('newsletter');
263
  if ($x === false) {
264
- $warnings .= 'The delivery engine is off (it should never be off). See the System Check below to reactivate it.<br>';
265
  } else if (time() - $x > 900) {
266
  $warnings .= 'The cron system seems not running correctly. See <a href="http://www.satollo.net/how-to-make-the-wordpress-cron-work" target="_blank">this page</a> for more information.<br>';
267
  }
@@ -642,6 +645,10 @@ class Newsletter extends NewsletterModule {
642
  'interval' => NEWSLETTER_CRON_INTERVAL, // seconds
643
  'display' => 'Newsletter'
644
  );
 
 
 
 
645
  return $schedules;
646
  }
647
 
@@ -1086,9 +1093,9 @@ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php')) {
1086
  }
1087
  }
1088
 
1089
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/updates/updates.php')) {
1090
- require_once WP_CONTENT_DIR . '/extensions/newsletter/updates/updates.php';
1091
- }
1092
 
1093
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php')) {
1094
  require_once WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php';
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/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="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
+ Version: 3.4.2
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
13
  */
14
 
15
  // Useed as dummy parameter on css and js links
16
+ define('NEWSLETTER_VERSION', '3.4.2');
17
 
18
  global $wpdb, $newsletter;
19
 
236
 
237
  wp_clear_scheduled_hook('newsletter_update');
238
  wp_clear_scheduled_hook('newsletter_check_versions');
239
+ wp_schedule_event(time() + 30, 'newsletter_weekly', 'newsletter_check_versions');
240
 
241
  wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
242
  wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
243
+
244
+ wp_clear_scheduled_hook('newsletter_updates_run');
245
+ wp_clear_scheduled_hook('newsletter_statistics_version_check');
246
 
247
  return true;
248
  }
264
  $warnings = '';
265
  $x = wp_next_scheduled('newsletter');
266
  if ($x === false) {
267
+ $warnings .= 'The delivery engine is off (it should never be off). Deactivate and reactivate the plugin. Thank you.<br>';
268
  } else if (time() - $x > 900) {
269
  $warnings .= 'The cron system seems not running correctly. See <a href="http://www.satollo.net/how-to-make-the-wordpress-cron-work" target="_blank">this page</a> for more information.<br>';
270
  }
645
  'interval' => NEWSLETTER_CRON_INTERVAL, // seconds
646
  'display' => 'Newsletter'
647
  );
648
+ $schedules['newsletter_weekly'] = array(
649
+ 'interval' => 86400*7, // seconds
650
+ 'display' => 'Newsletter Weekly'
651
+ );
652
  return $schedules;
653
  }
654
 
1093
  }
1094
  }
1095
 
1096
+ //if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/updates/updates.php')) {
1097
+ // require_once WP_CONTENT_DIR . '/extensions/newsletter/updates/updates.php';
1098
+ //}
1099
 
1100
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php')) {
1101
  require_once WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php';
readme.txt CHANGED
@@ -55,6 +55,15 @@ No screen shots are available at this time.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
 
 
58
  = 3.4.0 =
59
 
60
  * Changed newsletter copy to copy even the editor and traking status
55
 
56
  == Changelog ==
57
 
58
+ = 3.4.2 =
59
+
60
+ * Refined the subscription for already subscribed emails
61
+
62
+ = 3.4.1 =
63
+
64
+ * Fixed the delivery engine warning message
65
+ * Fixed the version check
66
+
67
  = 3.4.0 =
68
 
69
  * Changed newsletter copy to copy even the editor and traking status
subscription/languages/en_US.php CHANGED
@@ -15,6 +15,8 @@ $options['profile_text'] = "{profile_form}<p>To cancel your subscription, <a hre
15
 
16
  $options['error_text'] = '<p>This subscription can\'t be completed, sorry. The email address is blocked or already subscribed. You should contact the owner to unlock that email address. Thank you.</p>';
17
 
 
 
18
  // Subscription page introductory text (befor the subscription form)
19
  $options['subscription_text'] =
20
  "{subscription_form}";
15
 
16
  $options['error_text'] = '<p>This subscription can\'t be completed, sorry. The email address is blocked or already subscribed. You should contact the owner to unlock that email address. Thank you.</p>';
17
 
18
+ $options['already_confirmed_text'] = '<p>This email address is already subscribed, anyway a welcome email has been resent. Thank you.</p>';
19
+
20
  // Subscription page introductory text (befor the subscription form)
21
  $options['subscription_text'] =
22
  "{subscription_form}";
subscription/options.php CHANGED
@@ -144,7 +144,7 @@ if ($controls->is_action('create')) {
144
  <?php $controls->init(); ?>
145
  <div id="tabs">
146
  <ul>
147
- <li><a href="#tabs-1">General</a></li>
148
  <li><a href="#tabs-2">Subscription</a></li>
149
  <li><a href="#tabs-3">Confirmation</a></li>
150
  <li><a href="#tabs-4">Welcome</a></li>
@@ -154,7 +154,7 @@ if ($controls->is_action('create')) {
154
  <li><a href="#tabs-7">Docs</a></li>
155
  </ul>
156
 
157
- <div id="tabs-1">
158
  <p>Choose how the subscription process to your newsletter works.</p>
159
  <table class="form-table">
160
  <tr valign="top">
@@ -178,8 +178,8 @@ if ($controls->is_action('create')) {
178
  ?>
179
 
180
  <div class="hints">
181
- Optionally (but recommended) and address of a WordPress page (eg. <?php echo get_option('home') . '/newsletter'; ?>)
182
- you set up for subscription and messages.
183
  <br>
184
  The page must have in its body <strong>only</strong> the short code <strong>[newsletter]</strong> (as is).
185
 
@@ -197,6 +197,20 @@ if ($controls->is_action('create')) {
197
  <?php $controls->yesno('novisual'); ?>
198
  </td>
199
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  <tr valign="top">
201
  <th>Subscription on registration</th>
202
  <td>
@@ -224,16 +238,7 @@ if ($controls->is_action('create')) {
224
  <?php $controls->yesno('wp_welcome'); ?>
225
  </td>
226
  </tr>
227
- <tr valign="top">
228
- <th>Notifications</th>
229
- <td>
230
- <?php $controls->yesno('notify'); ?>
231
- to: <?php $controls->text_email('notify_email'); ?> (email address, leave empty for the WordPress administration email <?php echo get_option('admin_email'); ?>)
232
- <div class="hints">
233
- Notifies when a user confirm his subscription or unsubscribe.
234
- </div>
235
- </td>
236
- </tr>
237
  </table>
238
  </div>
239
 
@@ -260,13 +265,24 @@ if ($controls->is_action('create')) {
260
  </div>
261
  </td>
262
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
263
  <tr valign="top">
264
  <th>Error page content</th>
265
  <td>
266
  <?php $controls->editor('error_text'); ?>
267
  <div class="hints">
268
- This message is shown whenever a subscription is attempted with an address bounced, already registered but not confirmed or
269
- already subscribed. Consider all those three options while writing this message.
270
  </div>
271
  </td>
272
  </tr>
144
  <?php $controls->init(); ?>
145
  <div id="tabs">
146
  <ul>
147
+ <li><a href="#tabs-general">General</a></li>
148
  <li><a href="#tabs-2">Subscription</a></li>
149
  <li><a href="#tabs-3">Confirmation</a></li>
150
  <li><a href="#tabs-4">Welcome</a></li>
154
  <li><a href="#tabs-7">Docs</a></li>
155
  </ul>
156
 
157
+ <div id="tabs-general">
158
  <p>Choose how the subscription process to your newsletter works.</p>
159
  <table class="form-table">
160
  <tr valign="top">
178
  ?>
179
 
180
  <div class="hints">
181
+ Optional (but recommended) an address of a WordPress page (eg. <?php echo get_option('home') . '/newsletter'; ?>)
182
+ you <strong>manually created</strong> for subscription and messages.
183
  <br>
184
  The page must have in its body <strong>only</strong> the short code <strong>[newsletter]</strong> (as is).
185
 
197
  <?php $controls->yesno('novisual'); ?>
198
  </td>
199
  </tr>
200
+ <tr valign="top">
201
+ <th>Notifications</th>
202
+ <td>
203
+ <?php $controls->yesno('notify'); ?>
204
+ to: <?php $controls->text_email('notify_email'); ?> (email address, leave empty for the WordPress administration email <?php echo get_option('admin_email'); ?>)
205
+ <div class="hints">
206
+ Notifies when a user confirm his subscription or unsubscribe.
207
+ </div>
208
+ </td>
209
+ </tr>
210
+ </table>
211
+
212
+ <h3><?php _e('Integration with WordPress user registration', 'newsletter'); ?></h3>
213
+ <table class="form-table">
214
  <tr valign="top">
215
  <th>Subscription on registration</th>
216
  <td>
238
  <?php $controls->yesno('wp_welcome'); ?>
239
  </td>
240
  </tr>
241
+
 
 
 
 
 
 
 
 
 
242
  </table>
243
  </div>
244
 
265
  </div>
266
  </td>
267
  </tr>
268
+ </table>
269
+
270
+ <h3>Special cases</h3>
271
+ <p>
272
+ <table class="form-table">
273
+ <tr valign="top">
274
+ <th>Already subscribed page content</th>
275
+ <td>
276
+ <?php $controls->editor('already_confirmed_text'); ?><br>
277
+ <?php $controls->checkbox('resend_welcome_email_disabled', 'Do not resend the welcome email'); ?>
278
+ </td>
279
+ </tr>
280
  <tr valign="top">
281
  <th>Error page content</th>
282
  <td>
283
  <?php $controls->editor('error_text'); ?>
284
  <div class="hints">
285
+ Message shown when the email is bounced.
 
286
  </div>
287
  </td>
288
  </tr>
subscription/subscription.php CHANGED
@@ -19,10 +19,10 @@ class NewsletterSubscription extends NewsletterModule {
19
  }
20
 
21
  function __construct() {
22
- parent::__construct('subscription', '1.0.9');
23
 
24
  add_action('wp_login', array($this, 'hook_wp_login'));
25
-
26
  // Must be called after the Newsletter::hook_init, since some constants are defined
27
  // there.
28
  add_action('init', array($this, 'hook_init'), 90);
@@ -30,8 +30,9 @@ class NewsletterSubscription extends NewsletterModule {
30
 
31
  function hook_init() {
32
  $action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
33
- if (empty($action) || is_admin()) return;
34
-
 
35
  if ($action == 's') {
36
  $user = $this->subscribe();
37
  if ($user->status == 'E')
@@ -73,10 +74,10 @@ class NewsletterSubscription extends NewsletterModule {
73
  // Migrate the profile_text from profile to subscription options
74
  $options_profile = $this->get_options('profile');
75
  $default_options_profile = $this->get_default_options('profile');
76
-
77
  if (empty($options_profile)) {
78
  update_option('newsletter_profile', $this->get_default_options('profile'));
79
- } else {
80
  update_option('newsletter_profile', array_merge($default_options_profile, $options_profile));
81
  }
82
 
@@ -197,11 +198,23 @@ class NewsletterSubscription extends NewsletterModule {
197
  $user = $newsletter->get_user($email);
198
 
199
  if ($user != null) {
200
- if ($user->status == 'B' || $user->status == 'C') {
201
- $this->logger->error('Subscription of an address with status ' . $user->status);
202
  $user->status = 'E';
203
  return $user;
204
  }
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
 
207
  if ($user != null) {
@@ -244,12 +257,13 @@ class NewsletterSubscription extends NewsletterModule {
244
  $user['list_' . $i] = 1;
245
  }
246
  }
247
-
248
  // Forced preferences as set on subscription configuration
249
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
250
- if (empty($options['preferences_' . $i])) continue;
 
251
  $user['list_' . $i] = 1;
252
- }
253
 
254
  $user['token'] = $newsletter->get_token();
255
  $user['ip'] = $_SERVER['REMOTE_ADDR'];
@@ -286,7 +300,7 @@ class NewsletterSubscription extends NewsletterModule {
286
 
287
 
288
  $prefix = ($user->status == 'C') ? 'confirmed_' : 'confirmation_';
289
-
290
  if (empty($options[$prefix . 'disabled'])) {
291
  $message = $options[$prefix . 'message'];
292
 
@@ -340,7 +354,7 @@ class NewsletterSubscription extends NewsletterModule {
340
 
341
  if (!$emails)
342
  return $user;
343
-
344
  if (empty($this->options['confirmed_disabled'])) {
345
  $message = $this->options['confirmed_message'];
346
  // TODO: This is always empty!
@@ -613,7 +627,7 @@ class NewsletterSubscription extends NewsletterModule {
613
  *
614
  * @return string The html code of the subscription form
615
  */
616
- function get_subscription_form($referrer = null, $action=null) {
617
  $options_profile = get_option('newsletter_profile');
618
  $options = get_option('newsletter');
619
 
@@ -657,7 +671,8 @@ class NewsletterSubscription extends NewsletterModule {
657
  if ($options_profile['list_' . $i . '_status'] != 2)
658
  continue;
659
  $lists .= "\t\t" . '<input type="checkbox" name="nl[]" value="' . $i . '"';
660
- if ($options_profile['list_' . $i . '_checked'] == 1) $lists .= ' checked';
 
661
  $lists .= '/>&nbsp;' . $options_profile['list_' . $i] . '<br />' . "\n";
662
  }
663
  if (!empty($lists))
@@ -687,7 +702,10 @@ class NewsletterSubscription extends NewsletterModule {
687
 
688
  $extra = apply_filters('newsletter_subscription_extra', array());
689
  foreach ($extra as &$x) {
690
- $buffer .= "<tr>\n\t<th>" . $x['label'] . "</th>\n\t<td>\n\t\t";
 
 
 
691
  $buffer .= $x['field'] . "\n\t</td>\n</tr>\n\n";
692
  }
693
 
19
  }
20
 
21
  function __construct() {
22
+ parent::__construct('subscription', '1.1.1');
23
 
24
  add_action('wp_login', array($this, 'hook_wp_login'));
25
+
26
  // Must be called after the Newsletter::hook_init, since some constants are defined
27
  // there.
28
  add_action('init', array($this, 'hook_init'), 90);
30
 
31
  function hook_init() {
32
  $action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
33
+ if (empty($action) || is_admin())
34
+ return;
35
+
36
  if ($action == 's') {
37
  $user = $this->subscribe();
38
  if ($user->status == 'E')
74
  // Migrate the profile_text from profile to subscription options
75
  $options_profile = $this->get_options('profile');
76
  $default_options_profile = $this->get_default_options('profile');
77
+
78
  if (empty($options_profile)) {
79
  update_option('newsletter_profile', $this->get_default_options('profile'));
80
+ } else {
81
  update_option('newsletter_profile', array_merge($default_options_profile, $options_profile));
82
  }
83
 
198
  $user = $newsletter->get_user($email);
199
 
200
  if ($user != null) {
201
+ $this->logger->info('Subscription of an address with status ' . $user->status);
202
+ if ($user->status == 'B') {
203
  $user->status = 'E';
204
  return $user;
205
  }
206
+
207
+ // Already confirmed
208
+ if ($user->status == 'C') {
209
+ if ($emails && !isset($options['resend_welcome_email_disabled']) && !isset($options['confirmed_disabled'])) {
210
+ $message = $options[$prefix . 'confirmed_message'];
211
+ $subject = $options[$prefix . 'confirmed_subject'];
212
+ $this->mail($user->email, $newsletter->replace($subject, $user), $newsletter->replace($message, $user));
213
+ }
214
+
215
+ $user->status = 'A';
216
+ return $user;
217
+ }
218
  }
219
 
220
  if ($user != null) {
257
  $user['list_' . $i] = 1;
258
  }
259
  }
260
+
261
  // Forced preferences as set on subscription configuration
262
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
263
+ if (empty($options['preferences_' . $i]))
264
+ continue;
265
  $user['list_' . $i] = 1;
266
+ }
267
 
268
  $user['token'] = $newsletter->get_token();
269
  $user['ip'] = $_SERVER['REMOTE_ADDR'];
300
 
301
 
302
  $prefix = ($user->status == 'C') ? 'confirmed_' : 'confirmation_';
303
+
304
  if (empty($options[$prefix . 'disabled'])) {
305
  $message = $options[$prefix . 'message'];
306
 
354
 
355
  if (!$emails)
356
  return $user;
357
+
358
  if (empty($this->options['confirmed_disabled'])) {
359
  $message = $this->options['confirmed_message'];
360
  // TODO: This is always empty!
627
  *
628
  * @return string The html code of the subscription form
629
  */
630
+ function get_subscription_form($referrer = null, $action = null) {
631
  $options_profile = get_option('newsletter_profile');
632
  $options = get_option('newsletter');
633
 
671
  if ($options_profile['list_' . $i . '_status'] != 2)
672
  continue;
673
  $lists .= "\t\t" . '<input type="checkbox" name="nl[]" value="' . $i . '"';
674
+ if ($options_profile['list_' . $i . '_checked'] == 1)
675
+ $lists .= ' checked';
676
  $lists .= '/>&nbsp;' . $options_profile['list_' . $i] . '<br />' . "\n";
677
  }
678
  if (!empty($lists))
702
 
703
  $extra = apply_filters('newsletter_subscription_extra', array());
704
  foreach ($extra as &$x) {
705
+ $label = $x['label'];
706
+ if (empty($label))
707
+ $label = '&nbsp;';
708
+ $buffer .= "<tr>\n\t<th>" . $label . "</th>\n\t<td>\n\t\t";
709
  $buffer .= $x['field'] . "\n\t</td>\n</tr>\n\n";
710
  }
711