Newsletter - Version 5.1.9

Version Description

=

  • Fixed debug notice on test email from Automated Extension

=

Download this release

Release Info

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

Code changes from version 5.1.8 to 5.1.9

Files changed (3) hide show
  1. includes/module.php +58 -38
  2. plugin.php +4 -3
  3. readme.txt +6 -2
includes/module.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
- if (!defined('ABSPATH'))
4
- exit;
5
 
6
  class NewsletterModule {
7
 
@@ -80,7 +79,7 @@ class NewsletterModule {
80
  $this->available_version = get_option($this->prefix . '_available_version');
81
  }
82
  }
83
-
84
  /**
85
  * Exceutes a query and log it.
86
  */
@@ -89,7 +88,7 @@ class NewsletterModule {
89
 
90
  $this->log($query, 3);
91
  return $wpdb->query($query);
92
- }
93
 
94
  function first_install() {
95
 
@@ -313,7 +312,8 @@ class NewsletterModule {
313
  * returns false.
314
  */
315
  static function normalize_email($email) {
316
- if (!is_string($email)) return false;
 
317
  $email = strtolower(trim($email));
318
  if (!is_email($email)) {
319
  return false;
@@ -338,7 +338,8 @@ class NewsletterModule {
338
 
339
  static function is_email($email, $empty_ok = false) {
340
 
341
- if (!is_string($email)) return false;
 
342
  $email = strtolower(trim($email));
343
 
344
  if ($email == '') {
@@ -602,7 +603,7 @@ class NewsletterModule {
602
  if ($type == null) {
603
  $list = $wpdb->get_results("select * from " . NEWSLETTER_EMAILS_TABLE . " order by id desc", $format);
604
  } else {
605
- $type = (string)$type;
606
  $list = $wpdb->get_results($wpdb->prepare("select * from " . NEWSLETTER_EMAILS_TABLE . " where type=%s order by id desc", $type), $format);
607
  }
608
  if ($wpdb->last_error) {
@@ -623,17 +624,21 @@ class NewsletterModule {
623
  */
624
  function get_email($id, $format = OBJECT) {
625
  $email = $this->store->get_single(NEWSLETTER_EMAILS_TABLE, $id, $format);
 
 
626
  if ($format == OBJECT) {
627
  $email->options = maybe_unserialize($email->options);
628
- if (!is_array($email->options)) $email->options = array();
 
629
  } else if ($format == ARRAY_A) {
630
  $email['options'] = maybe_unserialize($email['options']);
631
- if (!is_array($email['options'])) $email['options'] = array();
 
632
  }
633
  return $email;
634
  }
635
-
636
- /**
637
  * Save an email and provide serialization, if needed, of $email['options'].
638
  */
639
  function save_email($email, $return_format = OBJECT) {
@@ -652,10 +657,12 @@ class NewsletterModule {
652
  $email = $this->store->save(NEWSLETTER_EMAILS_TABLE, $email, $return_format);
653
  if ($return_format == OBJECT) {
654
  $email->options = maybe_unserialize($email->options);
655
- if (!is_array($email->options)) $email->options = array();
 
656
  } else if ($return_format == ARRAY_A) {
657
  $email['options'] = maybe_unserialize($email['options']);
658
- if (!is_array($email['options'])) $email['options'] = array();
 
659
  }
660
  return $email;
661
  }
@@ -666,7 +673,7 @@ class NewsletterModule {
666
 
667
  function get_email_field($id, $field_name) {
668
  return $this->store->get_field(NEWSLETTER_EMAILS_TABLE, $id, $field_name);
669
- }
670
 
671
  function get_email_status_label($email) {
672
  switch ($email->status) {
@@ -778,7 +785,7 @@ class NewsletterModule {
778
  }
779
  return $r;
780
  }
781
-
782
  /**
783
  * Return the user identified by the "nk" parameter (POST or GET).
784
  * If no user can be found, returns null.
@@ -802,7 +809,7 @@ class NewsletterModule {
802
  }
803
  }
804
  return $user;
805
- }
806
 
807
  function get_list($id) {
808
  global $wpdb;
@@ -866,14 +873,14 @@ class NewsletterModule {
866
  return $content;
867
  }
868
  }
869
-
870
  /**
871
  * Returns a list of users marked as "test user".
872
  * @return array
873
  */
874
  function get_test_users() {
875
  return $this->store->get_all(NEWSLETTER_USERS_TABLE, "where test=1");
876
- }
877
 
878
  function delete_user($id) {
879
  global $wpdb;
@@ -892,7 +899,7 @@ class NewsletterModule {
892
  */
893
  function set_user_status($id_or_email, $status) {
894
  global $wpdb;
895
- $status = (string)$status;
896
  $this->logger->debug('Status change to ' . $status . ' of subscriber ' . $id_or_email . ' from ' . $_SERVER['REQUEST_URI']);
897
 
898
  $id_or_email = strtolower(trim($id_or_email));
@@ -920,26 +927,42 @@ class NewsletterModule {
920
  function get_user_by_wp_user_id($wp_user_id, $format = OBJECT) {
921
  return $this->store->get_single_by_field(NEWSLETTER_USERS_TABLE, 'wp_user_id', $wp_user_id, $format);
922
  }
923
-
924
  /**
925
- * Replace any kind of newsletter placeholder in a text.
 
 
 
 
 
 
 
926
  */
927
- function replace($text, $user = null, $email_id = null, $referrer = null) {
928
  global $wpdb;
929
 
930
  //$this->logger->debug('Replace start');
931
- if (is_array($user)) {
932
- $user = $this->get_user($user['id']);
 
 
 
 
 
 
933
  }
934
 
935
- $email = null;
936
- if (is_object($email_id)) {
937
- $email = $email_id;
938
- $email_id = $email->id;
939
- } else if (is_numeric($email_id)) {
940
- $email = $this->get_email($email_id);
 
 
941
  }
942
 
 
943
  $text = apply_filters('newsletter_replace', $text, $user, $email);
944
 
945
  $text = $this->replace_url($text, 'BLOG_URL', home_url('/'));
@@ -950,7 +973,7 @@ class NewsletterModule {
950
 
951
  $text = $this->replace_date($text);
952
 
953
- if ($user != null) {
954
  $options_profile = get_option('newsletter_profile');
955
 
956
  $text = str_replace('{email}', $user->email, $text);
@@ -1015,15 +1038,14 @@ class NewsletterModule {
1015
 
1016
  $home_url = home_url('/');
1017
  //$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
1018
-
1019
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
1020
  $text = $this->replace_url($text, 'ACTIVATION_URL', $home_url . '?na=c&nk=' . $nk);
1021
-
1022
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $home_url . '?na=uc&nk=' . $nk . ($email ? '&nek=' . $email->id : ''));
1023
  //$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
1024
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $home_url . '?na=u&nk=' . $nk . ($email ? '&nek=' . $email->id : ''));
1025
  // $text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
1026
-
1027
  // Obsolete.
1028
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
1029
  $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
@@ -1040,7 +1062,6 @@ class NewsletterModule {
1040
  if (!empty($email_id)) {
1041
  $text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email_id . '&amp;nk=' . $nk);
1042
  }
1043
-
1044
  } else {
1045
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', '#');
1046
  $text = $this->replace_url($text, 'ACTIVATION_URL', '#');
@@ -1062,7 +1083,7 @@ class NewsletterModule {
1062
  //$this->logger->debug('Replace end');
1063
  return $text;
1064
  }
1065
-
1066
  function replace_date($text) {
1067
  $text = str_replace('{date}', date_i18n(get_option('date_format')), $text);
1068
 
@@ -1076,7 +1097,7 @@ class NewsletterModule {
1076
  $text = substr($text, 0, $x) . date($f) . substr($text, $y + 1);
1077
  }
1078
  return $text;
1079
- }
1080
 
1081
  function replace_url($text, $tag, $url) {
1082
  $home = trailingslashit(home_url());
@@ -1094,7 +1115,6 @@ class NewsletterModule {
1094
 
1095
  return $text;
1096
  }
1097
-
1098
 
1099
  public static function antibot_form_check() {
1100
  return strtolower($_SERVER['REQUEST_METHOD']) == 'post' && isset($_POST['ts']) && time() - $_POST['ts'] < 30;
1
  <?php
2
 
3
+ defined('ABSPATH') || exit;
 
4
 
5
  class NewsletterModule {
6
 
79
  $this->available_version = get_option($this->prefix . '_available_version');
80
  }
81
  }
82
+
83
  /**
84
  * Exceutes a query and log it.
85
  */
88
 
89
  $this->log($query, 3);
90
  return $wpdb->query($query);
91
+ }
92
 
93
  function first_install() {
94
 
312
  * returns false.
313
  */
314
  static function normalize_email($email) {
315
+ if (!is_string($email))
316
+ return false;
317
  $email = strtolower(trim($email));
318
  if (!is_email($email)) {
319
  return false;
338
 
339
  static function is_email($email, $empty_ok = false) {
340
 
341
+ if (!is_string($email))
342
+ return false;
343
  $email = strtolower(trim($email));
344
 
345
  if ($email == '') {
603
  if ($type == null) {
604
  $list = $wpdb->get_results("select * from " . NEWSLETTER_EMAILS_TABLE . " order by id desc", $format);
605
  } else {
606
+ $type = (string) $type;
607
  $list = $wpdb->get_results($wpdb->prepare("select * from " . NEWSLETTER_EMAILS_TABLE . " where type=%s order by id desc", $type), $format);
608
  }
609
  if ($wpdb->last_error) {
624
  */
625
  function get_email($id, $format = OBJECT) {
626
  $email = $this->store->get_single(NEWSLETTER_EMAILS_TABLE, $id, $format);
627
+ if (!$email)
628
+ return $email;
629
  if ($format == OBJECT) {
630
  $email->options = maybe_unserialize($email->options);
631
+ if (!is_array($email->options))
632
+ $email->options = array();
633
  } else if ($format == ARRAY_A) {
634
  $email['options'] = maybe_unserialize($email['options']);
635
+ if (!is_array($email['options']))
636
+ $email['options'] = array();
637
  }
638
  return $email;
639
  }
640
+
641
+ /**
642
  * Save an email and provide serialization, if needed, of $email['options'].
643
  */
644
  function save_email($email, $return_format = OBJECT) {
657
  $email = $this->store->save(NEWSLETTER_EMAILS_TABLE, $email, $return_format);
658
  if ($return_format == OBJECT) {
659
  $email->options = maybe_unserialize($email->options);
660
+ if (!is_array($email->options))
661
+ $email->options = array();
662
  } else if ($return_format == ARRAY_A) {
663
  $email['options'] = maybe_unserialize($email['options']);
664
+ if (!is_array($email['options']))
665
+ $email['options'] = array();
666
  }
667
  return $email;
668
  }
673
 
674
  function get_email_field($id, $field_name) {
675
  return $this->store->get_field(NEWSLETTER_EMAILS_TABLE, $id, $field_name);
676
+ }
677
 
678
  function get_email_status_label($email) {
679
  switch ($email->status) {
785
  }
786
  return $r;
787
  }
788
+
789
  /**
790
  * Return the user identified by the "nk" parameter (POST or GET).
791
  * If no user can be found, returns null.
809
  }
810
  }
811
  return $user;
812
+ }
813
 
814
  function get_list($id) {
815
  global $wpdb;
873
  return $content;
874
  }
875
  }
876
+
877
  /**
878
  * Returns a list of users marked as "test user".
879
  * @return array
880
  */
881
  function get_test_users() {
882
  return $this->store->get_all(NEWSLETTER_USERS_TABLE, "where test=1");
883
+ }
884
 
885
  function delete_user($id) {
886
  global $wpdb;
899
  */
900
  function set_user_status($id_or_email, $status) {
901
  global $wpdb;
902
+ $status = (string) $status;
903
  $this->logger->debug('Status change to ' . $status . ' of subscriber ' . $id_or_email . ' from ' . $_SERVER['REQUEST_URI']);
904
 
905
  $id_or_email = strtolower(trim($id_or_email));
927
  function get_user_by_wp_user_id($wp_user_id, $format = OBJECT) {
928
  return $this->store->get_single_by_field(NEWSLETTER_USERS_TABLE, 'wp_user_id', $wp_user_id, $format);
929
  }
930
+
931
  /**
932
+ * Replaces every possible Newsletter tag ({...}) in a piece of text or HTML.
933
+ *
934
+ * @global wpdb $wpdb
935
+ * @param string $text
936
+ * @param mixed $user Can be an object, associative array or id
937
+ * @param mixed $email Can be an object, associative array or id
938
+ * @param type $referrer
939
+ * @return type
940
  */
941
+ function replace($text, $user = null, $email = null, $referrer = null) {
942
  global $wpdb;
943
 
944
  //$this->logger->debug('Replace start');
945
+ if ($user !== null && !is_object($user)) {
946
+ if (is_array($user)) {
947
+ $user = (object) $user; //$this->get_user($user['id']);
948
+ } else if (is_numeric($user)) {
949
+ $user = $this->get_user($user);
950
+ } else {
951
+ $user = null;
952
+ }
953
  }
954
 
955
+ if ($email !== null && !is_object($email)) {
956
+ if (is_array($email)) {
957
+ $email = (object) $email; //$this->get_user($user['id']);
958
+ } else if (is_numeric($email)) {
959
+ $email = $this->get_email($email);
960
+ } else {
961
+ $email = null;
962
+ }
963
  }
964
 
965
+
966
  $text = apply_filters('newsletter_replace', $text, $user, $email);
967
 
968
  $text = $this->replace_url($text, 'BLOG_URL', home_url('/'));
973
 
974
  $text = $this->replace_date($text);
975
 
976
+ if ($user) {
977
  $options_profile = get_option('newsletter_profile');
978
 
979
  $text = str_replace('{email}', $user->email, $text);
1038
 
1039
  $home_url = home_url('/');
1040
  //$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
1041
+
1042
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
1043
  $text = $this->replace_url($text, 'ACTIVATION_URL', $home_url . '?na=c&nk=' . $nk);
1044
+
1045
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $home_url . '?na=uc&nk=' . $nk . ($email ? '&nek=' . $email->id : ''));
1046
  //$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
1047
  $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $home_url . '?na=u&nk=' . $nk . ($email ? '&nek=' . $email->id : ''));
1048
  // $text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
 
1049
  // Obsolete.
1050
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
1051
  $text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
1062
  if (!empty($email_id)) {
1063
  $text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email_id . '&amp;nk=' . $nk);
1064
  }
 
1065
  } else {
1066
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', '#');
1067
  $text = $this->replace_url($text, 'ACTIVATION_URL', '#');
1083
  //$this->logger->debug('Replace end');
1084
  return $text;
1085
  }
1086
+
1087
  function replace_date($text) {
1088
  $text = str_replace('{date}', date_i18n(get_option('date_format')), $text);
1089
 
1097
  $text = substr($text, 0, $x) . date($f) . substr($text, $y + 1);
1098
  }
1099
  return $text;
1100
+ }
1101
 
1102
  function replace_url($text, $tag, $url) {
1103
  $home = trailingslashit(home_url());
1115
 
1116
  return $text;
1117
  }
 
1118
 
1119
  public static function antibot_form_check() {
1120
  return strtolower($_SERVER['REQUEST_METHOD']) == 'post' && isset($_POST['ts']) && time() - $_POST['ts'] < 30;
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.1.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.1.8');
18
 
19
  global $wpdb, $newsletter;
20
 
@@ -590,8 +590,9 @@ class Newsletter extends NewsletterModule {
590
  // Before try to send, check the limits.
591
  if (!$test && $this->limits_exceeded()) {
592
  $result = false;
593
- if ($this->the_mailer != null)
594
  $this->the_mailer->flush();
 
595
  break;
596
  }
597
 
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.1.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.1.9');
18
 
19
  global $wpdb, $newsletter;
20
 
590
  // Before try to send, check the limits.
591
  if (!$test && $this->limits_exceeded()) {
592
  $result = false;
593
+ if ($this->the_mailer != null) {
594
  $this->the_mailer->flush();
595
+ }
596
  break;
597
  }
598
 
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.1
5
- Stable tag: 5.1.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,9 +85,13 @@ Thank you, The Newsletter Team
85
 
86
  == Changelog ==
87
 
 
 
 
 
88
  == 5.1.8 ==
89
 
90
- Newsletter page creation fix
91
 
92
  == 5.1.7 ==
93
 
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.1
5
+ Stable tag: 5.1.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.1.9 ==
89
+
90
+ * Fixed debug notice on test email from Automated Extension
91
+
92
  == 5.1.8 ==
93
 
94
+ * Newsletter page creation fix
95
 
96
  == 5.1.7 ==
97