Newsletter - Version 7.4.3

Version Description

  • Removed obsolete note about the newsletter textual part
  • Introduced text part generator right now only for the Composer (with permission of Frank M.)
  • Added check on System>Status for images with relative URL
  • Addec check for Freesoul Deactivate Plugins
  • Minimal for layout now consider the button_label attribute
Download this release

Release Info

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

Code changes from version 7.4.2 to 7.4.3

emails/composer.php CHANGED
@@ -94,6 +94,14 @@ if ($controls->is_action()) {
94
  }
95
  } else {
96
  TNP_Composer::update_email($email, $controls);
 
 
 
 
 
 
 
 
97
  $email->updated = time();
98
  $email = Newsletter::instance()->save_email($email);
99
  TNP_Composer::prepare_controls($controls, $email);
94
  }
95
  } else {
96
  TNP_Composer::update_email($email, $controls);
97
+
98
+ if (empty($email->options['text_message_mode'])) {
99
+ $text = TNP_Composer::convert_to_text($email->message);
100
+ if ($text) {
101
+ $email->message_text = TNP_Composer::convert_to_text($email->message);
102
+ }
103
+ }
104
+
105
  $email->updated = time();
106
  $email = Newsletter::instance()->save_email($email);
107
  TNP_Composer::prepare_controls($controls, $email);
emails/edit.php CHANGED
@@ -536,17 +536,22 @@ if ($email['status'] != 'sent') {
536
  <td><?php echo esc_html($email['token']); ?></td>
537
  </tr>
538
  <tr>
539
- <th>This is the textual version of your newsletter.
540
- If you empty it, only an HTML version will be sent but is an anti-spam best practice to include a text only version.</th>
 
 
541
  <td>
542
- <?php if (Newsletter::instance()->options['phpmailer'] == 0) { ?>
543
- <p class="tnp-tab-warning">
544
- See <a href="https://wordpress.org/plugins/plaintext-newsletter/" target="_blank">this plugin</a> for automatic plaintext generation.
545
- The text part is sent only when Newsletter manages
546
- directly the sending process. <a href="admin.php?page=newsletter_main_main" target="_blank">See the main settings</a>.
547
- </p>
548
  <?php } ?>
 
549
  <?php $controls->textarea_fixed('message_text', '100%', '500'); ?>
 
 
 
 
 
550
  </td>
551
  </tr>
552
  </table>
536
  <td><?php echo esc_html($email['token']); ?></td>
537
  </tr>
538
  <tr>
539
+ <th style="vertical-align: top">
540
+ This is the textual version of your newsletter.
541
+ If you empty it, only an HTML version will be sent but is an anti-spam best practice to include a text only version.
542
+ </th>
543
  <td>
544
+ <?php if ($editor_type == NewsletterEmails::EDITOR_COMPOSER) { ?>
545
+ <?php $controls->select('options_text_message_mode', [''=>__('Autogenerate', 'newsletter'), '1'=>__('Hand edited', 'newsletter')]) ?>
546
+ <p class="description"></p>
 
 
 
547
  <?php } ?>
548
+
549
  <?php $controls->textarea_fixed('message_text', '100%', '500'); ?>
550
+ <!--
551
+ <p class="tnp-tab-warning">
552
+ See <a href="https://wordpress.org/plugins/plaintext-newsletter/" target="_blank">this plugin</a> for automatic plaintext generation.
553
+ </p>
554
+ -->
555
  </td>
556
  </tr>
557
  </table>
includes/composer.php CHANGED
@@ -665,9 +665,77 @@ class TNP_Composer {
665
 
666
  return $button_options;
667
  }
668
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  }
670
 
 
 
671
  class TNP_Style {
672
 
673
  var $font_family;
665
 
666
  return $button_options;
667
  }
668
+
669
+ static function convert_to_text($html) {
670
+ if (!class_exists('DOMDocument')) {
671
+ return '';
672
+ }
673
+ // Replace '&' with '&amp;' in URLs to avoid warnings about inavlid entities from loadHTML()
674
+ // Todo: make this more general using a regular expression
675
+ //$logger = PlaintextNewsletterAddon::$instance->get_logger();
676
+ //$logger->debug('html="' . $html . '"');
677
+ $html = str_replace(
678
+ array('&nk=', '&nek=', '&id='),
679
+ array('&amp;nk=', '&amp;nek=', '&amp;id='),
680
+ $html);
681
+ //$logger->debug('new html="' . $html . '"');
682
+ //
683
+ $output = '';
684
+ $dom = new DOMDocument();
685
+ $r = $dom->loadHTML('<?xml encoding="utf-8" ?>' . $html);
686
+ if (!$r) {
687
+ return '';
688
+ }
689
+ $bodylist = $dom->getElementsByTagName('body');
690
+ // Of course it should be a single element
691
+ foreach ($bodylist as $body) {
692
+ self::process_dom_element($body, $output);
693
+ }
694
+ return $output;
695
+ }
696
+
697
+ static function process_dom_element(DOMElement $parent, &$output) {
698
+ foreach ($parent->childNodes as $node) {
699
+ if (is_a($node, 'DOMElement') && ($node->tagName != 'style')) {
700
+ if ($node->tagName== 'br') {
701
+ $output .= "\n";
702
+ continue;
703
+ }
704
+ self::process_dom_element($node, $output);
705
+
706
+ // If the containing tag was a block level tag, we add a couple of line ending
707
+ if ($node->tagName == 'p' || $node->tagName == 'div' || $node->tagName == 'td') {
708
+ // Avoid more than one blank line between elements
709
+ if ((strlen($output) >= 2) && (substr($output, -2) != "\n\n")) {
710
+ $output .= "\n\n";
711
+ }
712
+ }
713
+
714
+ if ($node->tagName == 'a') {
715
+ $output .= ' (' . $node->getAttribute('href') . ') ';
716
+ continue;
717
+ }
718
+ elseif ($node->tagName == 'img') {
719
+ $output .= $node->getAttribute('alt');
720
+ }
721
+ }
722
+ elseif (is_a($node, 'DOMText')) {
723
+ $decoded = utf8_decode($node->wholeText);
724
+ if (ctype_space($decoded)) {
725
+ // Append blank only if last character output is not blank.
726
+ if ((strlen($output) > 0) && !ctype_space(substr($output, -1))) {
727
+ $output .= ' ';
728
+ }
729
+ } else {
730
+ $output .= trim($node->wholeText);
731
+ }
732
+ }
733
+ }
734
+ }
735
  }
736
 
737
+
738
+
739
  class TNP_Style {
740
 
741
  var $font_family;
includes/store.php CHANGED
@@ -124,6 +124,8 @@ class NewsletterStore {
124
  foreach (array_keys($data) as $key) {
125
  if (substr($key, 0, 1) == '_') unset($data[$key]);
126
  }
 
 
127
 
128
  if (isset($data['id'])) {
129
  $id = (int)$data['id'];
124
  foreach (array_keys($data) as $key) {
125
  if (substr($key, 0, 1) == '_') unset($data[$key]);
126
  }
127
+
128
+ //$this->logger->debug($data);
129
 
130
  if (isset($data['id'])) {
131
  $id = (int)$data['id'];
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: 7.4.2
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.
@@ -37,7 +37,7 @@ if (version_compare(phpversion(), '5.6', '<')) {
37
  return;
38
  }
39
 
40
- define('NEWSLETTER_VERSION', '7.4.2');
41
 
42
  global $newsletter, $wpdb;
43
 
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: 7.4.3
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.
37
  return;
38
  }
39
 
40
+ define('NEWSLETTER_VERSION', '7.4.3');
41
 
42
  global $newsletter, $wpdb;
43
 
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Newsletter ===
2
  Tags: newsletter, email marketing, welcome email, signup forms, contact, lead generation, marketing automation
3
- Tested up to: 5.9.2
4
- Stable tag: 7.4.2
5
  Contributors: satollo,webagile,michael-travan
6
  License: GPLv2 or later
7
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -126,6 +126,14 @@ Thank you, The Newsletter Team
126
 
127
  == Changelog ==
128
 
 
 
 
 
 
 
 
 
129
  = 7.4.2 =
130
 
131
  * Fixed the post date (regression)
1
  === Newsletter ===
2
  Tags: newsletter, email marketing, welcome email, signup forms, contact, lead generation, marketing automation
3
+ Tested up to: 5.9.3
4
+ Stable tag: 7.4.3
5
  Contributors: satollo,webagile,michael-travan
6
  License: GPLv2 or later
7
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
126
 
127
  == Changelog ==
128
 
129
+ = 7.4.3 =
130
+
131
+ * Removed obsolete note about the newsletter textual part
132
+ * Introduced text part generator right now only for the Composer (with permission of Frank M.)
133
+ * Added check on System>Status for images with relative URL
134
+ * Addec check for Freesoul Deactivate Plugins
135
+ * Minimal for layout now consider the button_label attribute
136
+
137
  = 7.4.2 =
138
 
139
  * Fixed the post date (regression)
subscription/subscription.php CHANGED
@@ -530,7 +530,7 @@ class NewsletterSubscription extends NewsletterModule {
530
 
531
  // Exists?
532
  $user = $this->get_user_by_email($subscription->data->email);
533
-
534
  $subscription = apply_filters('newsletter_subscription', $subscription, $user);
535
 
536
  // Do we accept repeated subscriptions?
@@ -538,7 +538,7 @@ class NewsletterSubscription extends NewsletterModule {
538
  //$this->show_message('error', $user);
539
  return new WP_Error('exists', 'Email address already registered and Newsletter sets to block repeated registrations. You can change this behavior or the user message above on subscription configuration panel.');
540
  }
541
-
542
 
543
  if ($user != null) {
544
 
@@ -549,7 +549,7 @@ class NewsletterSubscription extends NewsletterModule {
549
  if ($user->status == TNP_User::STATUS_BOUNCED || $user->status == TNP_User::STATUS_COMPLAINED) {
550
  return new WP_Error('bounced', 'Subscriber present and blocked');
551
  }
552
-
553
  if ($user->status == TNP_User::STATUS_UNSUBSCRIBED) {
554
  // Special behavior?
555
  }
@@ -585,7 +585,7 @@ class NewsletterSubscription extends NewsletterModule {
585
  $user->status = $subscription->optin == 'single' ? TNP_User::STATUS_CONFIRMED : TNP_User::STATUS_NOT_CONFIRMED;
586
  $user->updated = time();
587
  }
588
-
589
  $user->ip = $this->process_ip($user->ip);
590
 
591
  $user = apply_filters('newsletter_user_subscribe', $user);
@@ -1804,6 +1804,15 @@ class NewsletterSubscription extends NewsletterModule {
1804
  $form .= $this->get_form_hidden_fields($attrs);
1805
 
1806
  $form .= '<input class="tnp-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
 
 
 
 
 
 
 
 
 
1807
  $form .= '<input class="tnp-submit" type="submit" value="' . esc_attr($attrs['button']) . '"'
1808
  . ' style="background-color:' . esc_attr($attrs['button_color']) . '">';
1809
 
530
 
531
  // Exists?
532
  $user = $this->get_user_by_email($subscription->data->email);
533
+
534
  $subscription = apply_filters('newsletter_subscription', $subscription, $user);
535
 
536
  // Do we accept repeated subscriptions?
538
  //$this->show_message('error', $user);
539
  return new WP_Error('exists', 'Email address already registered and Newsletter sets to block repeated registrations. You can change this behavior or the user message above on subscription configuration panel.');
540
  }
541
+
542
 
543
  if ($user != null) {
544
 
549
  if ($user->status == TNP_User::STATUS_BOUNCED || $user->status == TNP_User::STATUS_COMPLAINED) {
550
  return new WP_Error('bounced', 'Subscriber present and blocked');
551
  }
552
+
553
  if ($user->status == TNP_User::STATUS_UNSUBSCRIBED) {
554
  // Special behavior?
555
  }
585
  $user->status = $subscription->optin == 'single' ? TNP_User::STATUS_CONFIRMED : TNP_User::STATUS_NOT_CONFIRMED;
586
  $user->updated = time();
587
  }
588
+
589
  $user->ip = $this->process_ip($user->ip);
590
 
591
  $user = apply_filters('newsletter_user_subscribe', $user);
1804
  $form .= $this->get_form_hidden_fields($attrs);
1805
 
1806
  $form .= '<input class="tnp-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
1807
+
1808
+ if (isset($attrs['button_label'])) {
1809
+ $label = $attrs['button_label'];
1810
+ } else if (isset($attrs['button'])) { // Backward compatibility
1811
+ $label = $attrs['button'];
1812
+ } else {
1813
+ $label = $this->form_options['subscribe'];
1814
+ }
1815
+
1816
  $form .= '<input class="tnp-submit" type="submit" value="' . esc_attr($attrs['button']) . '"'
1817
  . ' style="background-color:' . esc_attr($attrs['button_color']) . '">';
1818
 
system/status.php CHANGED
@@ -555,7 +555,7 @@ $tnp_wpdb = new TNP_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
555
  <span class="tnp-maybe">MAY BE</span>
556
  </td>
557
  <td>
558
- Be sure Newsletter is set as active in EVERY context.
559
  </td>
560
  </tr>
561
  <?php } ?>
@@ -567,10 +567,23 @@ $tnp_wpdb = new TNP_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
567
  <span class="tnp-maybe">MAY BE</span>
568
  </td>
569
  <td>
570
- Be sure Newsletter is set as active in EVERY context.
571
  </td>
572
  </tr>
573
  <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  </tbody>
575
  </table>
576
 
@@ -673,6 +686,44 @@ $tnp_wpdb = new TNP_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
673
  </td>
674
  </tr>
675
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
676
  <tr>
677
  <?php
678
  $uploads = wp_upload_dir();
555
  <span class="tnp-maybe">MAY BE</span>
556
  </td>
557
  <td>
558
+ Be sure Newsletter is set as active on EVERY context.
559
  </td>
560
  </tr>
561
  <?php } ?>
567
  <span class="tnp-maybe">MAY BE</span>
568
  </td>
569
  <td>
570
+ Be sure Newsletter is set as active on EVERY context.
571
  </td>
572
  </tr>
573
  <?php } ?>
574
+
575
+ <?php if (is_plugin_active('freesoul-deactivate-plugins/freesoul-deactivate-plugins.php')) { ?>
576
+ <tr>
577
+ <td><a href="https://wordpress.org/plugins/freesoul-deactivate-plugins/" target="_blank">Freesoul Deactivate Plugins</a></td>
578
+ <td>
579
+ <span class="tnp-maybe">MAY BE</span>
580
+ </td>
581
+ <td>
582
+ Be sure Newsletter is set as active on EVERY context.
583
+ </td>
584
+ </tr>
585
+ <?php } ?>
586
+
587
  </tbody>
588
  </table>
589
 
686
  </td>
687
  </tr>
688
 
689
+
690
+ <tr>
691
+ <?php
692
+ $attachments = get_posts([
693
+ 'post_type' => 'attachment',
694
+ 'post_mime_type' => 'image',
695
+ 'numberposts' => 1,
696
+ 'post_status' => null,
697
+ 'post_parent' => null
698
+ ]);
699
+ $condition = 1;
700
+ $src = 'No media found to make a test';
701
+ if ($attachments) {
702
+ $src = wp_get_attachment_image_src($attachments[0]->ID);
703
+ $src = $src[0];
704
+ $condition = (strpos($src, 'http') !== 0) ? 0 : 1;
705
+ }
706
+ ?>
707
+ <td>Images URL</td>
708
+ <td>
709
+ <?php $this->condition_flag($condition) ?>
710
+ </td>
711
+ <td>
712
+ Example: <?php echo esc_html($src); ?>
713
+
714
+ <?php if ($condition == 0) { ?>
715
+ <br><br>
716
+ Your uploadimages seems to be returned with a relative URL: they won't work in your newsletter. Check the <code>WP_CONTENT_URL</code>
717
+ above and fix it if is showing a warning. If not, probably a plugin or some custom code is forcing relative URLs for your
718
+ images. Check that with your site developer.
719
+ <?php } else { ?>
720
+
721
+ <?php } ?>
722
+ </td>
723
+ </tr>
724
+
725
+
726
+
727
  <tr>
728
  <?php
729
  $uploads = wp_upload_dir();
tnp-header.php CHANGED
@@ -30,10 +30,10 @@ $warning = false;
30
 
31
  //$warning |= empty($status_options['mail']);
32
 
33
- $current_user_email = $current_user->user_email;
34
- if (strpos($current_user_email, 'admin@') === 0) {
35
- $current_user_email = '';
36
- }
37
  ?>
38
 
39
  <div class="tnp-drowpdown" id="tnp-header">
30
 
31
  //$warning |= empty($status_options['mail']);
32
 
33
+ $current_user_email = ''; //$current_user->user_email;
34
+ //if (strpos($current_user_email, 'admin@') === 0) {
35
+ // $current_user_email = '';
36
+ //}
37
  ?>
38
 
39
  <div class="tnp-drowpdown" id="tnp-header">