Newsletter - Version 5.2.7

Version Description

Download this release

Release Info

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

Code changes from version 5.2.6 to 5.2.7

Files changed (51) hide show
  1. admin.css +9 -1
  2. emails/blocks/cta/block.php +21 -35
  3. emails/blocks/cta/options.php +12 -3
  4. emails/blocks/giphy/blockx.php +34 -0
  5. emails/blocks/giphy/icon.png +0 -0
  6. emails/blocks/giphy/options.php +51 -0
  7. emails/blocks/html/blockx.php +27 -0
  8. emails/blocks/html/icon.png +0 -0
  9. emails/blocks/html/options.php +15 -0
  10. emails/blocks/list/blockx.php +51 -0
  11. emails/blocks/list/icon.png +0 -0
  12. emails/blocks/list/options.php +74 -0
  13. emails/blocks/list/style.css +6 -0
  14. emails/blocks/posts/block.php +262 -0
  15. emails/blocks/posts/icon.png +0 -0
  16. emails/blocks/posts/images/blank.png +0 -0
  17. emails/blocks/posts/options.php +57 -0
  18. emails/blocks/preheader/block.php +24 -12
  19. emails/blocks/preheader/options.php +10 -2
  20. emails/blocks/separator/block.php +7 -8
  21. emails/blocks/separator/options.php +4 -10
  22. emails/edit-composer.php +1 -1
  23. emails/edit-editor.php +1 -1
  24. emails/edit.php +1 -1
  25. emails/emails.php +148 -34
  26. emails/index.php +1 -1
  27. emails/tnp-composer/_/content-06-posts.block.php +94 -0
  28. emails/tnp-composer/_/content-06-posts.block.png +0 -0
  29. emails/tnp-composer/_/content-07-twocols.block.php +109 -0
  30. emails/tnp-composer/_/content-07-twocols.block.png +0 -0
  31. emails/tnp-composer/_css/newsletter-builder.css +14 -13
  32. emails/tnp-composer/_scripts/newsletter-builder.js +7 -7
  33. emails/tnp-composer/blocks/content-01-hero.block.php +6 -11
  34. emails/tnp-composer/blocks/content-02-heading.block.php +5 -11
  35. emails/tnp-composer/blocks/content-03-text.block.php +11 -6
  36. emails/tnp-composer/blocks/content-05-image.block.php +5 -5
  37. emails/tnp-composer/blocks/footer-01-footer.block.php +2 -2
  38. emails/tnp-composer/blocks/footer-02-canspam.block.php +4 -11
  39. emails/tnp-composer/blocks/footer-03-social.block.php +6 -5
  40. emails/tnp-composer/blocks/header-01-header.block.php +16 -11
  41. emails/tnp-composer/index.php +14 -7
  42. includes/controls.php +7 -1
  43. includes/helper.php +17 -9
  44. includes/module.php +37 -10
  45. main/status.php +18 -14
  46. plugin.php +8 -3
  47. readme.txt +9 -1
  48. statistics/statistics.php +46 -19
  49. subscription/options.php +5 -2
  50. subscription/subscription.php +34 -0
  51. users/users.php +1 -1
admin.css CHANGED
@@ -1031,6 +1031,14 @@ p.description {
1031
  width: auto;
1032
  }
1033
 
 
 
 
 
 
 
 
 
1034
  .wp-core-ui .button-secondary:hover, .wp-core-ui .button:hover, .wp-core-ui .button-primary:hover {
1035
  background-color: #5DADE2;
1036
  color: #fff;
@@ -2020,4 +2028,4 @@ input:checked + .slider:before {
2020
 
2021
  .tnp-list-conditions p {
2022
  margin: 0px 10px;
2023
- }
1031
  width: auto;
1032
  }
1033
 
1034
+ .wp-core-ui .button-secondary, .wp-core-ui .button, .wp-core-ui .button-primary {
1035
+ background-color: #3498db;
1036
+ box-shadow: none;
1037
+ color: #fff;
1038
+ font-family: 'Montserrat',sans-serif;
1039
+ margin: 0px 2px;
1040
+ }
1041
+
1042
  .wp-core-ui .button-secondary:hover, .wp-core-ui .button:hover, .wp-core-ui .button-primary:hover {
1043
  background-color: #5DADE2;
1044
  color: #fff;
2028
 
2029
  .tnp-list-conditions p {
2030
  margin: 0px 10px;
2031
+ }
emails/blocks/cta/block.php CHANGED
@@ -3,46 +3,32 @@
3
  * Name: Call To Action
4
  * Section: content
5
  * Description: Call to action button
6
- *
7
  */
8
 
9
  /* @var $options array */
10
  /* @var $wpdb wpdb */
11
 
12
- if (empty($options['text'])) {
13
- $options['text'] = 'Call to action';
14
- }
15
- if (empty($options['background'])) {
16
- $options['background'] = '#256F9C';
17
- }
18
- if (empty($options['color'])) {
19
- $options['color'] = '#ffffff';
20
- }
21
- if (empty($options['url'])) {
22
- $options['url'] = '#';
23
- }
24
- if (empty($options['font_size'])) {
25
- $options['font_size'] = '16';
26
- }
27
- if (empty($options['font_family'])) {
28
- $options['font_family'] = 'Helvetica, Arial, sans-serif';
29
- }
30
- ?>
31
- <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table">
32
- <tr>
33
- <td align="center" style="text-align: center; padding: 20px;" class="padding-copy">
34
-
35
- <a href="<?php echo $options['url'] ?>" target="_blank" rel="noopener" style="line-height: normal; font-size: <?php echo $options['font_size'] ?>px; font-family: <?php echo $options['font_family'] ?>; font-weight: normal; color: <?php echo $options['color'] ?>; text-decoration: none; background-color: <?php echo $options['background'] ?>; border-top: 15px solid <?php echo $options['background'] ?>; border-bottom: 15px solid <?php echo $options['background'] ?>; border-left: 25px solid <?php echo $options['background'] ?>; border-right: 25px solid <?php echo $options['background'] ?>; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;"><?php echo $options['text'] ?></a>
36
 
37
- <div itemscope="" itemtype="http://schema.org/EmailMessage">
38
- <div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
39
- <meta itemprop="url" content="<?php echo $options['url'] ?>" />
40
- <meta itemprop="name" content="<?php echo esc_attr($options['text']) ?>" />
41
- </div>
42
- <meta itemprop="description" content="<?php echo esc_attr($options['text']) ?>" />
43
- </div>
44
- </td>
45
- </tr>
46
- </table>
47
 
 
48
 
 
 
 
 
 
 
 
3
  * Name: Call To Action
4
  * Section: content
5
  * Description: Call to action button
 
6
  */
7
 
8
  /* @var $options array */
9
  /* @var $wpdb wpdb */
10
 
11
+ $default_options = array(
12
+ 'text' => 'Call to action',
13
+ 'background' => '#256F9C',
14
+ 'color' => '#ffffff',
15
+ 'url' => home_url(),
16
+ 'font_family' => $font_family,
17
+ 'font_size' => 16,
18
+ 'block_background'=>'#ffffff'
19
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ $options = array_merge($default_options, $options);
22
+ $options['block_padding_top'] = '15px';
23
+ $options['block_padding_bottom'] = '15px';
24
+ ?>
 
 
 
 
 
 
25
 
26
+ <a href="<?php echo $options['url'] ?>" target="_blank" rel="noopener" style="line-height: normal; font-size: <?php echo $options['font_size'] ?>px; font-family: <?php echo $options['font_family'] ?>; font-weight: normal; color: <?php echo $options['color'] ?>; text-decoration: none; background-color: <?php echo $options['background'] ?>; border-top: 15px solid <?php echo $options['background'] ?>; border-bottom: 15px solid <?php echo $options['background'] ?>; border-left: 25px solid <?php echo $options['background'] ?>; border-right: 25px solid <?php echo $options['background'] ?>; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;"><?php echo $options['text'] ?></a>
27
 
28
+ <div itemscope="" itemtype="http://schema.org/EmailMessage">
29
+ <div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">
30
+ <meta itemprop="url" content="<?php echo esc_attr($options['url']) ?>" />
31
+ <meta itemprop="name" content="<?php echo esc_attr($options['text']) ?>" />
32
+ </div>
33
+ <meta itemprop="description" content="<?php echo esc_attr($options['text']) ?>" />
34
+ </div>
emails/blocks/cta/options.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
- /* @var $options array contains all the options the current block we're ediging contains */
3
- /* @var $controls NewsletterControls */
 
 
4
  ?>
5
 
6
  <table class="form-table">
@@ -17,7 +19,7 @@
17
  </td>
18
  </tr>
19
  <tr>
20
- <th>Text color</th>
21
  <td>
22
  <?php $controls->color('color') ?>
23
  </td>
@@ -40,4 +42,11 @@
40
  <?php $controls->css_font_family('font_family') ?>
41
  </td>
42
  </tr>
 
 
 
 
 
 
 
43
  </table>
1
  <?php
2
+ /*
3
+ * @var $options array contains all the options the current block we're ediging contains
4
+ * @var $controls NewsletterControls
5
+ */
6
  ?>
7
 
8
  <table class="form-table">
19
  </td>
20
  </tr>
21
  <tr>
22
+ <th><?php _e('Color', 'newsletter') ?></th>
23
  <td>
24
  <?php $controls->color('color') ?>
25
  </td>
42
  <?php $controls->css_font_family('font_family') ?>
43
  </td>
44
  </tr>
45
+
46
+ <tr>
47
+ <th><?php _e('Background', 'newsletter') ?></th>
48
+ <td>
49
+ <?php $controls->color('block_background') ?>
50
+ </td>
51
+ </tr>
52
  </table>
emails/blocks/giphy/blockx.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Name: Giphy
4
+ * Section: content
5
+ * Description: Add a Giphy image
6
+ *
7
+ */
8
+
9
+ /* @var $options array */
10
+ /* @var $wpdb wpdb */
11
+
12
+ $default_options = array(
13
+ 'view'=>'View online',
14
+ 'text'=>'Few words summary',
15
+ 'block_background'=>'#ffffff',
16
+ 'font_family'=>$font_family,
17
+ 'font_size'=>13,
18
+ 'color'=>'#999999'
19
+ );
20
+
21
+ $options = array_merge($default_options, $options);
22
+ $options['block_padding_top'] = '15px';
23
+ $options['block_padding_bottom'] = '15px';
24
+
25
+ ?>
26
+
27
+ <table width="100%" border="0" cellpadding="0" align="center" cellspacing="0">
28
+ <tr>
29
+ <td width="100%" valign="top" align="center">
30
+ <img src="<?php echo $options['giphy_url'] ?>" />
31
+ </td>
32
+ </tr>
33
+ </table>
34
+
emails/blocks/giphy/icon.png ADDED
Binary file
emails/blocks/giphy/options.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @var $options array contains all the options the current block we're ediging contains
4
+ * @var $controls NewsletterControls
5
+ */
6
+ ?>
7
+
8
+ <table class="form-table">
9
+ <tr>
10
+ <th><?php _e('Search Giphy', 'newsletter') ?></th>
11
+ <td>
12
+ <?php $controls->text('q') ?>
13
+ </td>
14
+ </tr>
15
+ <tr>
16
+ <th><?php _e('Choose', 'newsletter') ?></th>
17
+ <td>
18
+ <div style="clear: both" id="tnp-giphy-results"></div>
19
+ </td>
20
+ </tr>
21
+ <tr>
22
+ <th><?php _e('Selected', 'newsletter') ?></th>
23
+ <td>
24
+ <?php $controls->text('giphy_url') ?>
25
+ </td>
26
+ </tr>
27
+ </table>
28
+
29
+ <script type="text/javascript">
30
+
31
+ function choose_gif(url) {
32
+ jQuery("#tnp-giphy-results").html("");
33
+ jQuery("#options-giphy_url").val(url);
34
+ }
35
+
36
+ jQuery("#options-q").keyup(
37
+ function () {
38
+ if (typeof(tid) != "undefined") {
39
+ window.clearTimeout(tid);
40
+ }
41
+ tid = window.setTimeout(function () {
42
+ jQuery.get("http://api.giphy.com/v1/gifs/search", {api_key: "57FLbVJJd7oQBZ0fEiRnzhM2VtZp5OP1", q: jQuery("#options-q").val()}, function (data) {
43
+ jQuery("#tnp-giphy-results").html("");
44
+ jQuery.each(data.data, function (index, value) {
45
+ jQuery("#tnp-giphy-results").append('<img src="' + value.images.fixed_width_small.url + '" onclick="choose_gif(\'' + value.images.fixed_height.url + '\')" style="float:left;" />');
46
+ });
47
+ }, "json");
48
+ }, 500);
49
+ });
50
+
51
+ </script>
emails/blocks/html/blockx.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Name: Html
4
+ * Section: content
5
+ * Description: Free HTML block
6
+ *
7
+ */
8
+
9
+ /* @var $options array */
10
+ /* @var $wpdb wpdb */
11
+
12
+ $default_options = array(
13
+ 'html'=>'<p>My <strong>HTML</strong> code<p>'
14
+ );
15
+
16
+ $options = array_merge($default_options, $options);
17
+
18
+ ?>
19
+
20
+ <table width="100%" border="0" cellpadding="0" align="center" cellspacing="0">
21
+ <tr>
22
+ <td width="100%" valign="top" align="center">
23
+ <?php echo $options['html'] ?>
24
+ </td>
25
+ </tr>
26
+ </table>
27
+
emails/blocks/html/icon.png ADDED
Binary file
emails/blocks/html/options.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @var $options array contains all the options the current block we're ediging contains
4
+ * @var $controls NewsletterControls
5
+ */
6
+ ?>
7
+
8
+ <table class="form-table">
9
+ <tr>
10
+ <th><?php _e('HTML code', 'newsletter') ?></th>
11
+ <td>
12
+ <?php $controls->textarea('html') ?>
13
+ </td>
14
+ </tr>
15
+ </table>
emails/blocks/list/blockx.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Name: List
4
+ * Section: content
5
+ * Description: A well designed list for your strength points
6
+ *
7
+ */
8
+
9
+ /* @var $options array */
10
+ /* @var $wpdb wpdb */
11
+
12
+ $defaults = array(
13
+ 'bullet' => '1',
14
+ 'text_1' => 'Element 1',
15
+ 'text_2' => 'Element 2',
16
+ 'text_3' => 'Element 3',
17
+ 'font_size' => '16',
18
+ 'font_family' => 'Helvetica, Arial, sans-serif',
19
+ 'color' => '#000000',
20
+ 'background' => '#ffffff',
21
+ );
22
+
23
+ $options = array_merge($defaults, $options);
24
+
25
+ ?>
26
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: <?php echo $width ?>px!important">
27
+ <tr>
28
+ <td style="padding: 15px 20px;" bgcolor="<?php echo $options['background'] ?>">
29
+
30
+ <table cellspacing="0" cellpadding="5" align="left">
31
+ <?php
32
+ for ($i = 1; $i <= 10; $i++) {
33
+ if (empty($options['text_' . $i])) {
34
+ continue;
35
+ }
36
+ ?>
37
+ <tr>
38
+ <td style="font-size: <?php echo $options['font_size'] ?>px; font-family: <?php echo $options['font_family'] ?>; color: <?php echo $options['color'] ?>;">
39
+ <span style="color: <?php echo $options['bullet_color'] ?>">&#x<?php echo $options['bullet'] ?>;</span>&nbsp;<?php echo $options['text_' . $i] ?>
40
+ </td>
41
+ </tr>
42
+ <?php
43
+ echo '</td></tr>';
44
+ }
45
+ ?>
46
+ </table>
47
+
48
+ </td>
49
+ </tr>
50
+ </table>
51
+
emails/blocks/list/icon.png ADDED
Binary file
emails/blocks/list/options.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $options array contains all the options the current block we're ediging contains */
3
+ /* @var $controls NewsletterControls */
4
+ ?>
5
+
6
+ <table class="form-table">
7
+ <tr>
8
+ <th>Bullet</th>
9
+ <td>
10
+ <?php
11
+ $bullets = array(
12
+ '2713'=>'&#x2713;',
13
+ '2714'=>'&#x2714;',
14
+ '25BA'=>'&#x25BA;',
15
+ 'd7'=>'&#xd7;',
16
+ 'bb'=>'&#xbb;',
17
+ '25c9'=>'&#x25c9;',
18
+ '203A'=>'&#x203A;',
19
+ '25CE'=>'&#x25CE;',
20
+
21
+ // Arrows
22
+ '2192'=>'&#x2192;',
23
+ '2190'=>'&#x2190;',
24
+ '2191'=>'&#x2191;',
25
+ '2193'=>'&#x2193;',
26
+
27
+
28
+ );
29
+
30
+ $controls->select('bullet', $bullets);
31
+ ?>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <th><?php _e('Bullet color', 'newsletter')?></th>
36
+ <td>
37
+ <?php $controls->color('bullet_color') ?>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <th>Items</th>
42
+ <td>
43
+ <?php
44
+ for ($i = 1; $i <= 10; $i++) {
45
+ $controls->text('text_' . $i, 50);
46
+ }
47
+ ?>
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <th>Font family</th>
52
+ <td>
53
+ <?php $controls->css_font_family('font_family') ?>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <th>Font size</th>
58
+ <td>
59
+ <?php $controls->css_font_size('font_size') ?>
60
+ </td>
61
+ </tr>
62
+ <tr>
63
+ <th><?php _e('Color', 'newsletter')?></th>
64
+ <td>
65
+ <?php $controls->color('color') ?>
66
+ </td>
67
+ </tr>
68
+ <tr>
69
+ <th><?php _e('Background', 'newsletter')?></th>
70
+ <td>
71
+ <?php $controls->color('background') ?>
72
+ </td>
73
+ </tr>
74
+ </table>
emails/blocks/list/style.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ @media all and (max-width: 480px) {
2
+ .list-text .mobile {
3
+ font-size: 20px;
4
+ }
5
+ }
6
+
emails/blocks/posts/block.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Name: Last posts
4
+ * Section: content
5
+ * Description: Last opsts list with different layouts
6
+ */
7
+
8
+ /* @var $options array */
9
+ /* @var $wpdb wpdb */
10
+ include NEWSLETTER_INCLUDES_DIR . '/helper.php';
11
+
12
+ $defaults = array(
13
+ 'title' => 'Last news',
14
+ 'block_background' => '#E6E9ED',
15
+ 'color' => '#999999',
16
+ 'font_family' => 'Helvetica, Arial, sans-serif',
17
+ 'font_size' => '13',
18
+ 'max' => 4,
19
+ 'read_more' => __('Read more...', 'newsletter'),
20
+ 'categories' => '',
21
+ 'tags' => '',
22
+ 'block_background' => '#ffffff',
23
+ 'layout' => 'one'
24
+ );
25
+
26
+ $options = array_merge($defaults, $options);
27
+
28
+ $filters = array();
29
+ $filters['posts_per_page'] = (int) $options['max'];
30
+
31
+ if (!empty($options['categories'])) {
32
+ $filters['category__in'] = $options['categories'];
33
+ }
34
+
35
+ if (!empty($options['tags'])) {
36
+ $filters['tag'] = $options['tags'];
37
+ }
38
+
39
+ $posts = get_posts($filters);
40
+
41
+ $alternative = plugins_url('newsletter') . '/emails/blocks/posts/images/blank.png';
42
+
43
+ ?>
44
+
45
+ <?php if ($options['layout'] == 'one') { ?>
46
+ <style>
47
+ .posts-title {
48
+ padding: 0 0 10px 0;
49
+ font-size: 25px;
50
+ font-family: <?php echo $font_family?>;
51
+ font-weight: normal;
52
+ color: #333333;
53
+ }
54
+ .posts-post-date {
55
+ padding: 0 0 5px 25px;
56
+ font-size: 13px;
57
+ font-family: <?php echo $font_family?>;
58
+ font-weight: normal;
59
+ color: #aaaaaa;
60
+ }
61
+ .posts-post-title {
62
+ padding: 0 0 5px 25px;
63
+ font-size: 22px;
64
+ font-family: <?php echo $font_family?>;
65
+ font-weight: normal;
66
+ color: #333333;
67
+ }
68
+ </style>
69
+ <!-- COMPACT ARTICLE SECTION -->
70
+
71
+
72
+
73
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="responsive-table">
74
+ <!-- SPACER -->
75
+ <tr>
76
+ <td colspan="2">&nbsp;</td>
77
+ </tr>
78
+
79
+ <!-- TITLE -->
80
+ <tr>
81
+ <td align="center" inline-class="posts-title" class="padding-copy tnpc-row-edit" data-type="title" colspan="2"><?php echo $options['title'] ?></td>
82
+ </tr>
83
+
84
+ <?php foreach ($posts AS $post) { ?>
85
+
86
+ <tr>
87
+ <td valign="top" style="padding: 40px 0 0 0;" class="mobile-hide tnpc-row-edit" data-type="image">
88
+ <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank">
89
+ <img src="<?php echo tnp_post_thumbnail_src($post, array(105, 105, true), $alternative) ?>" width="105" height="105" border="0" style="display: block; font-family: Arial; color: #666666; font-size: 14px; width: 105px!important; height: 105px!important;">
90
+ </a>
91
+ </td>
92
+ <td style="padding: 40px 0 0 0;" class="no-padding">
93
+ <!-- ARTICLE -->
94
+ <table border="0" cellspacing="0" cellpadding="0" width="100%">
95
+ <tr>
96
+ <td align="left" inline-class="posts-post-date" class="padding-meta">
97
+ <?php echo tnp_post_date($post) ?>
98
+ </td>
99
+ </tr>
100
+ <tr>
101
+ <td align="left" inline-class="posts-post-title" class="padding-copy tnpc-row-edit" data-type="title">
102
+ <?php echo tnp_post_title($post) ?>
103
+ </td>
104
+ </tr>
105
+ <tr>
106
+ <td align="left" style="padding: 10px 0 15px 25px; font-size: 16px; line-height: 24px; font-family: Helvetica, Arial, sans-serif; color: #666666;" class="padding-copy tnpc-row-edit" data-type="text">
107
+ <?php echo tnp_post_excerpt($post) ?>
108
+ </td>
109
+ </tr>
110
+ <tr>
111
+ <td style="padding:0 0 45px 25px;" align="left" class="padding">
112
+ <table border="0" cellspacing="0" cellpadding="0" class="mobile-button-container">
113
+ <tr>
114
+ <td align="center">
115
+ <!-- BULLETPROOF BUTTON -->
116
+ <table width="100%" border="0" cellspacing="0" cellpadding="0" class="mobile-button-container">
117
+ <tr>
118
+ <td align="center" style="padding: 0;" class="padding-copy">
119
+ <table border="0" cellspacing="0" cellpadding="0" class="responsive-table">
120
+ <tr>
121
+ <td align="center">
122
+ <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank" style="font-size: 15px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #ffffff; text-decoration: none; background-color: #256F9C; border-top: 10px solid #256F9C; border-bottom: 10px solid #256F9C; border-left: 20px solid #256F9C; border-right: 20px solid #256F9C; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;" class="mobile-button tnpc-row-edit" data-type="link"><?php echo $options['read_more'] ?></a>
123
+ </td>
124
+ </tr>
125
+ </table>
126
+ </td>
127
+ </tr>
128
+ </table>
129
+ </td>
130
+ </tr>
131
+ </table>
132
+ </td>
133
+ </tr>
134
+ </table>
135
+ </td>
136
+ </tr>
137
+
138
+ <?php } ?>
139
+
140
+ </table>
141
+
142
+
143
+
144
+ <?php } else { ?>
145
+
146
+ <style>
147
+ .posts-title {
148
+ font-size: 25px;
149
+ line-height: 30px;
150
+ font-family: <?php echo $font_family?>;
151
+ color: #333333;
152
+ }
153
+ .post-subtitle {
154
+ padding: 20px 0 20px 0;
155
+ font-size: 16px;
156
+ line-height: 25px;
157
+ font-family: <?php echo $font_family?>;
158
+ color: #666666;
159
+ }
160
+ .posts-post-title {
161
+ padding: 15px 0 0 0;
162
+ font-family: <?php echo $font_family?>;
163
+ color: #333333;
164
+ font-size: 20px;
165
+ line-height: 25px;
166
+ }
167
+ .posts-post-excerpt {
168
+ padding: 5px 0 0 0;
169
+ font-family: <?php echo $font_family?>;
170
+ color: #666666;
171
+ font-size: 14px;
172
+ line-height: 20px;
173
+ }
174
+ </style>
175
+ <!-- TWO COLUMN SECTION -->
176
+ <br><br>
177
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="responsive-table">
178
+ <tr>
179
+ <td>
180
+ <!-- TITLE SECTION AND COPY -->
181
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
182
+ <tr>
183
+ <td align="center" inline-class="posts-title" class="padding-copy tnpc-row-edit" data-type="title"><?php echo $options['title'] ?></td>
184
+ </tr>
185
+ <tr>
186
+ <td align="center" inline-class="posts-subtitle" class="padding-copy tnpc-row-edit" data-type="text">The twelve jurors were all writing very busily on slates.</td>
187
+ </tr>
188
+ </table>
189
+ </td>
190
+ </tr>
191
+ </table>
192
+
193
+ <!-- TWO COLUMNS -->
194
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
195
+ <?php foreach (array_chunk($posts, 2) AS $row) { ?>
196
+ <tr>
197
+ <td valign="top" style="padding: 10px;" class="mobile-wrapper">
198
+
199
+ <!-- LEFT COLUMN -->
200
+ <table cellpadding="0" cellspacing="0" border="0" width="47%" align="left" class="responsive-table">
201
+ <tr>
202
+ <td style="padding: 20px 0 40px 0;">
203
+ <table cellpadding="0" cellspacing="0" border="0" width="100%">
204
+ <tr>
205
+ <td align="center" valign="middle" class="tnpc-row-edit" data-type="image">
206
+ <a href="<?php echo tnp_post_permalink($row[0]) ?>" target="_blank">
207
+ <img src="<?php echo tnp_post_thumbnail_src($row[0], array(240, 160, true)) ?>" width="240" height="160" border="0" class="img-max">
208
+ </a>
209
+ </td>
210
+ </tr>
211
+ <tr>
212
+ <td align="center" inline-class="posts-post-title" class="tnpc-row-edit" data-type="title"><?php echo tnp_post_title($row[0]) ?></td>
213
+ </tr>
214
+ <tr>
215
+ <td align="center" inline-class="posts-post-excerpt" class="tnpc-row-edit" data-type="text"><?php echo tnp_post_excerpt($row[0]) ?></td>
216
+ </tr>
217
+ <tr>
218
+ <td align="center" style="padding: 5px 0 0 0; font-family: Arial, sans-serif; color: #666666; font-size: 14px; line-height: 20px;"><a href="<?php echo tnp_post_permalink($row[0]) ?>" style="color: #256F9C; text-decoration: none;" class="tnpc-row-edit" data-type="link"><?php echo $options['read_more'] ?></a></td>
219
+ </tr>
220
+ </table>
221
+ </td>
222
+ </tr>
223
+ </table>
224
+
225
+ <?php if (!empty($row[1])) { ?>
226
+ <!-- RIGHT COLUMN -->
227
+ <table cellpadding="0" cellspacing="0" border="0" width="47%" align="right" class="responsive-table">
228
+ <tr>
229
+ <td style="padding: 20px 0 40px 0;">
230
+ <table cellpadding="0" cellspacing="0" border="0" width="100%">
231
+ <tr>
232
+ <td align="center" valign="middle" class="tnpc-row-edit" data-type="image">
233
+ <a href="<?php echo tnp_post_permalink($row[1]) ?>" target="_blank">
234
+ <img src="<?php echo tnp_post_thumbnail_src($row[1], array(240, 160, true)) ?>" width="240" height="160" border="0" class="img-max">
235
+ </a>
236
+ </td>
237
+ </tr>
238
+ <tr>
239
+ <td align="center" inline-class="posts-post-title" class="tnpc-row-edit" data-type="title"><?php echo tnp_post_title($row[1]) ?></td>
240
+ </tr>
241
+ <tr>
242
+ <td align="center" inline-class="posts-post-excerpt" class="tnpc-row-edit" data-type="text"><?php echo tnp_post_excerpt($row[1]) ?></td>
243
+ </tr>
244
+ <tr>
245
+ <td align="center" style="padding: 5px 0 0 0; font-family: Arial, sans-serif; color: #666666; font-size: 14px; line-height: 20px;"><a href="<?php echo tnp_post_permalink($row[1]) ?>" style="color: #256F9C; text-decoration: none;" class="tnpc-row-edit" data-type="link"><?php echo $options['read_more'] ?></a></td>
246
+ </tr>
247
+ </table>
248
+ </td>
249
+ </tr>
250
+ </table>
251
+ <?php } ?>
252
+
253
+ </td>
254
+ </tr>
255
+
256
+ <?php } ?>
257
+
258
+ </table>
259
+
260
+
261
+
262
+ <?php } ?>
emails/blocks/posts/icon.png ADDED
Binary file
emails/blocks/posts/images/blank.png ADDED
Binary file
emails/blocks/posts/options.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @var $options array contains all the options the current block we're ediging contains
4
+ * @var $controls NewsletterControls
5
+ */
6
+ ?>
7
+
8
+ <table class="form-table">
9
+ <tr>
10
+ <th><?php _e('Title', 'newsletter') ?></th>
11
+ <td>
12
+ <?php $controls->text('title'); ?>
13
+ </td>
14
+ </tr>
15
+ <tr>
16
+ <th><?php _e('Read more label', 'newsletter') ?></th>
17
+ <td>
18
+ <?php $controls->text('read_more'); ?>
19
+ </td>
20
+ </tr>
21
+ <tr>
22
+ <th><?php _e('Max', 'newsletter') ?></th>
23
+ <td>
24
+ <?php $controls->select_number('max', 1, 20); ?>
25
+ </td>
26
+ </tr>
27
+ <tr>
28
+ <th><?php _e('Categories', 'newsletter') ?></th>
29
+ <td>
30
+ <?php $controls->categories_group('categories'); ?>
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <th><?php _e('Tags', 'newsletter') ?></th>
35
+ <td>
36
+ <?php $controls->text('tags'); ?>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th><?php _e('View', 'newsletter') ?></th>
41
+ <td>
42
+ <?php $controls->text('view', 70) ?>
43
+ </td>
44
+ </tr>
45
+ <tr>
46
+ <th><?php _e('Layout', 'newsletter') ?></th>
47
+ <td>
48
+ <?php $controls->select('layout', array('one' => 'One column', 'two' => 'Two columns')) ?>
49
+ </td>
50
+ </tr>
51
+ <tr>
52
+ <th><?php _e('Block background', 'newsletter') ?></th>
53
+ <td>
54
+ <?php $controls->color('block_background') ?>
55
+ </td>
56
+ </tr>
57
+ </table>
emails/blocks/preheader/block.php CHANGED
@@ -9,24 +9,36 @@
9
  /* @var $options array */
10
  /* @var $wpdb wpdb */
11
 
 
 
 
 
 
 
 
 
12
 
 
13
 
14
- if (empty($options['view'])) {
15
- $options['view'] = 'View online';
16
- }
17
- if (empty($options['text'])) {
18
- $options['text'] = 'Few words summary';
19
- }
20
  ?>
 
 
 
 
 
 
 
 
 
21
 
22
-
23
- <table border="0" cellpadding="0" cellspacing="0" width="750" class="responsive-table" style="max-width: 100%!important">
24
  <tr>
25
- <td style="padding: 20px; text-align: center; font-size: 13px!important; color: #444;" width="50%" valign="top" align="center">
26
- <?php echo $options['text']?>
27
  </td>
28
- <td style="padding: 20px; text-align: center;" width="50%" valign="top" align="center">
29
- <a href="{email_url}" target="_blank" rel="noopener" style="text-decoration: none; color: #444; font-size: 13px!important;"><?php echo $options['view']?></a>
30
  </td>
31
  </tr>
32
  </table>
 
9
  /* @var $options array */
10
  /* @var $wpdb wpdb */
11
 
12
+ $default_options = array(
13
+ 'view'=>'View online',
14
+ 'text'=>'Few words summary',
15
+ 'block_background'=>'#ffffff',
16
+ 'font_family'=>$font_family,
17
+ 'font_size'=>13,
18
+ 'color'=>'#999999'
19
+ );
20
 
21
+ $options = array_merge($default_options, $options);
22
 
 
 
 
 
 
 
23
  ?>
24
+ <style>
25
+ .preheader-link {
26
+ padding: 20px;
27
+ text-align: center;
28
+ font-size: <?php echo $options['font_size'] ?>px;
29
+ font-family: <?php echo $options['font_family'] ?>;
30
+ color: <?php echo $options['color'] ?>;
31
+ }
32
+ </style>
33
 
34
+ <table width="100%" border="0" cellpadding="0" align="center" cellspacing="0">
 
35
  <tr>
36
+ <td class="preheader-link" width="50%" valign="top" align="center">
37
+ <?php echo $options['text'] ?>
38
  </td>
39
+ <td class="preheader-link" width="50%" valign="top" align="center">
40
+ <a href="{email_url}" target="_blank" rel="noopener" style="text-decoration: none; font-size: <?php echo $options['font_size'] ?>px; font-family: <?php echo $options['font_family'] ?>; color: <?php echo $options['color'] ?>"><?php echo $options['view'] ?></a>
41
  </td>
42
  </tr>
43
  </table>
44
+
emails/blocks/preheader/options.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
- /* @var $options array contains all the options the current block we're ediging contains */
3
- /* @var $controls NewsletterControls */
 
 
4
  ?>
5
 
6
  <table class="form-table">
@@ -15,5 +17,11 @@
15
  <td>
16
  <?php $controls->text('view', 70) ?>
17
  </td>
 
 
 
 
 
 
18
  </tr>
19
  </table>
1
  <?php
2
+ /*
3
+ * @var $options array contains all the options the current block we're ediging contains
4
+ * @var $controls NewsletterControls
5
+ */
6
  ?>
7
 
8
  <table class="form-table">
17
  <td>
18
  <?php $controls->text('view', 70) ?>
19
  </td>
20
+ </tr>
21
+ <tr>
22
+ <th><?php _e('Background', 'newsletter')?></th>
23
+ <td>
24
+ <?php $controls->color('block_background') ?>
25
+ </td>
26
  </tr>
27
  </table>
emails/blocks/separator/block.php CHANGED
@@ -9,20 +9,19 @@
9
  /* @var $options array */
10
  /* @var $wpdb wpdb */
11
 
 
 
 
 
12
 
 
13
 
14
- if (empty($options['color'])) {
15
- $options['color'] = '#dddddd';
16
- }
17
- if (empty($options['height'])) {
18
- $options['height'] = 1;
19
- }
20
  ?>
21
 
22
 
23
- <table border="0" cellpadding="0" cellspacing="0" width="750" class="responsive-table" style="max-width: 100%!important">
24
  <tr>
25
- <td style="padding: 20px;" bgcolor="<?php echo $options['background'] ?>">
26
  <div style="height: <?php echo $options['height'] ?>px!important; background-color: <?php echo $options['color'] ?>; border: 0; margin:0; padding: 0; line-height: 0; width: 100%!important; display: block;"></div>
27
  </td>
28
  </tr>
9
  /* @var $options array */
10
  /* @var $wpdb wpdb */
11
 
12
+ $default_options = array(
13
+ 'color'=>'#dddddd',
14
+ 'height'=>1
15
+ );
16
 
17
+ $options = array_merge($default_options, $options);
18
 
 
 
 
 
 
 
19
  ?>
20
 
21
 
22
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%">
23
  <tr>
24
+ <td style="padding: 20px;">
25
  <div style="height: <?php echo $options['height'] ?>px!important; background-color: <?php echo $options['color'] ?>; border: 0; margin:0; padding: 0; line-height: 0; width: 100%!important; display: block;"></div>
26
  </td>
27
  </tr>
emails/blocks/separator/options.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
- /* @var $options array contains all the options the current block we're ediging contains */
3
- /* @var $controls NewsletterControls */
 
 
4
  ?>
5
 
6
  <table class="form-table">
@@ -11,14 +13,6 @@
11
  <?php $controls->color('color') ?>
12
  </td>
13
  </tr>
14
- <!--
15
- <tr>
16
- <th>Link to</th>
17
- <td>
18
- <?php $controls->text('url', 50, 'https://...') ?>
19
- </td>
20
- </tr>
21
- -->
22
  <tr>
23
  <th><?php _e('Height', 'newsletter')?></th>
24
  <td>
1
  <?php
2
+ /*
3
+ * @var $options array contains all the options the current block we're ediging contains
4
+ * @var $controls NewsletterControls
5
+ */
6
  ?>
7
 
8
  <table class="form-table">
13
  <?php $controls->color('color') ?>
14
  </td>
15
  </tr>
 
 
 
 
 
 
 
 
16
  <tr>
17
  <th><?php _e('Height', 'newsletter')?></th>
18
  <td>
emails/edit-composer.php CHANGED
@@ -12,7 +12,7 @@
12
 
13
  <!-- Flat Mobile Browser -->
14
  <div class="fake-mobile-browser-ui">
15
- <iframe id="tnpc-preview-mobile" src="" width="250" height="445" alt="Test" frameborder="0"></iframe>
16
  <div class="frame">
17
  <span class="bt-4"></span>
18
  </div>
12
 
13
  <!-- Flat Mobile Browser -->
14
  <div class="fake-mobile-browser-ui">
15
+ <iframe id="tnpc-preview-mobile" src="" width="320" height="445" alt="Test" frameborder="0"></iframe>
16
  <div class="frame">
17
  <span class="bt-4"></span>
18
  </div>
emails/edit-editor.php CHANGED
@@ -1,4 +1,4 @@
1
- <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.3/tinymce.min.js"></script>
2
  <script type="text/javascript">
3
 
4
  // https://www.tinymce.com/docs/advanced/editor-control-identifiers/#toolbarcontrols
1
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.3/tinymce.min.js"></script>
2
  <script type="text/javascript">
3
 
4
  // https://www.tinymce.com/docs/advanced/editor-control-identifiers/#toolbarcontrols
emails/edit.php CHANGED
@@ -23,8 +23,8 @@ if ($composer) {
23
  wp_enqueue_style('tnpc-style', plugins_url('/tnp-composer/_css/newsletter-builder.css', __FILE__));
24
  }
25
 
26
- // Preferences conversions
27
  if (!$controls->is_action()) {
 
28
  if (!isset($email['options']['lists'])) {
29
 
30
  $options_profile = get_option('newsletter_profile');
23
  wp_enqueue_style('tnpc-style', plugins_url('/tnp-composer/_css/newsletter-builder.css', __FILE__));
24
  }
25
 
 
26
  if (!$controls->is_action()) {
27
+ // Preferences conversions
28
  if (!isset($email['options']['lists'])) {
29
 
30
  $options_profile = get_option('newsletter_profile');
emails/emails.php CHANGED
@@ -57,27 +57,82 @@ class NewsletterEmails extends NewsletterModule {
57
  wp_die();
58
  }
59
 
60
- function tnpc_render_callback() {
 
 
 
 
 
 
 
 
 
 
61
  $block_options = get_option('newsletter_main');
62
- $block = $this->get_block($_POST['b']);
 
 
 
63
  if (!$block) {
64
- die('Not found');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
- if (strpos($block['filename'], '.block')) {
 
 
 
67
  include NEWSLETTER_DIR . '/emails/tnp-composer/blocks/' . $block['filename'] . '.php';
68
- wp_die();
69
  } else {
70
-
71
- if (isset($_POST['options']) && is_array($_POST['options'])) {
72
- $options = stripslashes_deep($_POST['options']);
73
- } else {
74
- $options = array();
75
- }
76
-
77
  ob_start();
78
  include $block['dir'] . '/block.php';
79
  $content = ob_get_clean();
80
- $content = $this->inline_css($content, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  $data = '';
83
  foreach ($options as $key => $value) {
@@ -89,20 +144,49 @@ class NewsletterEmails extends NewsletterModule {
89
  }
90
  }
91
  }
92
-
93
- if (isset($_POST['full'])) {
94
- echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse" class="tnpc-row tnpc-row-block" data-id="', esc_attr($_POST['b']), '">';
95
  echo '<tr>';
96
- echo '<td data-options="', esc_attr($data), '" bgcolor="#ffffff" align="center" style="padding: 0; font-family: Helvetica, Arial, sans-serif;" class="edit-block">';
97
  }
 
 
 
 
 
 
 
 
98
  echo $content;
99
- if (isset($_POST['full'])) {
 
 
 
100
  echo '</td></tr></table>';
101
  }
102
- wp_die();
103
  }
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  function tnpc_preview_callback() {
107
  $email = Newsletter::instance()->get_email($_REQUEST['id'], ARRAY_A);
108
 
@@ -134,15 +218,15 @@ class NewsletterEmails extends NewsletterModule {
134
  header("HTTP/1.0 404 Not Found");
135
  die('Email not found');
136
  }
137
-
138
  $user = NewsletterSubscription::instance()->get_user_from_request();
139
-
140
  if (!is_user_logged_in() || !(current_user_can('editor') || current_user_can('administrator'))) {
141
-
142
  if ($email->status == 'new') {
143
  header("HTTP/1.0 404 Not Found");
144
  die('Not sent yet');
145
- }
146
 
147
  if ($email->private == 1) {
148
  if (!$user) {
@@ -414,8 +498,10 @@ class NewsletterEmails extends NewsletterModule {
414
  $relative_dir = substr($dir, strlen(WP_CONTENT_DIR));
415
  while ($file = readdir($handle)) {
416
 
 
 
417
  // The block unique key, we should find out how to biuld it, maybe an hash of the (relative) dir?
418
- $key = $relative_dir . '/' . $file;
419
 
420
  $full_file = $dir . '/' . $file . '/block.php';
421
  if (!is_file($full_file)) {
@@ -437,20 +523,33 @@ class NewsletterEmails extends NewsletterModule {
437
  $data['dir'] = $dir . '/' . $file;
438
 
439
  $data['icon'] = content_url($relative_dir . '/' . $file . '/icon.png');
440
- $list[$key] = $data;
441
  }
442
  closedir($handle);
443
  return $list;
444
  }
445
 
 
 
 
 
 
 
446
  function get_blocks() {
447
 
448
- $blocks = array();
 
 
449
 
 
 
 
450
  $handle = opendir(NEWSLETTER_DIR . '/emails/tnp-composer/blocks');
451
  while ($file = readdir($handle)) {
452
- if (strpos($file, '.php') === false) continue;
453
-
 
 
454
  $path_parts = pathinfo($file);
455
  $filename = $path_parts['filename'];
456
  $section = substr($filename, 0, strpos($filename, '-'));
@@ -461,32 +560,47 @@ class NewsletterEmails extends NewsletterModule {
461
  $block['icon'] = plugins_url('newsletter') . '/emails/tnp-composer/blocks/' . $filename . '.png';
462
  $block['section'] = $section;
463
  $block['description'] = '';
464
- $blocks[$filename] = $block;
 
465
  }
466
  closedir($handle);
467
 
 
468
  $list = $this->scan_blocks_dir(__DIR__ . '/blocks');
469
 
470
- $blocks = array_merge($blocks, $list);
 
471
  $dirs = apply_filters('newsletter_blocks_dir', array());
472
 
473
  foreach ($dirs as $dir) {
474
  $dir = str_replace('\\', '/', $dir);
475
  $list = $this->scan_blocks_dir($dir);
476
- $blocks = array_merge($blocks, $list);
477
  }
 
478
  return $blocks;
479
  }
480
 
 
 
 
 
 
 
481
  function get_block($id) {
482
  switch ($id) {
483
- // case 'content-05-image.block': $id = '/plugins/newsletter/emails/blocks/image';
484
- // break;
485
- case 'content-04-cta.block': $id = '/plugins/newsletter/emails/blocks/cta';
 
 
486
  break;
487
  // case 'content-02-heading.block': $id = '/plugins/newsletter/emails/blocks/heading';
488
  // break;
489
  }
 
 
 
490
 
491
  // TODO: Correct id for compatibility
492
  $blocks = $this->get_blocks();
57
  wp_die();
58
  }
59
 
60
+ /**
61
+ * Renders a block identified by its id, using the block options and adding a wrapper
62
+ * if required (for the first block rendering.
63
+ * @param type $block_id
64
+ * @param type $wrapper
65
+ * @param type $options
66
+ */
67
+ function render_block($block_id = null, $wrapper = false, $options = array()) {
68
+ $width = 600;
69
+ $font_family = 'Helvetica, Arial, sans-serif';
70
+
71
  $block_options = get_option('newsletter_main');
72
+
73
+ $block = $this->get_block($block_id);
74
+
75
+ // Block not found
76
  if (!$block) {
77
+ if ($wrapper) {
78
+ echo '<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="border-collapse: collapse; width: 100%;" class="tnpc-row tnpc-row-block" data-id="', esc_attr($block_id), '">';
79
+ echo '<tr>';
80
+ echo '<td data-options="', esc_attr($data), '" bgcolor="#ffffff" align="center" style="padding: 0; font-family: Helvetica, Arial, sans-serif;" class="edit-block">';
81
+ }
82
+ echo '<!--[if mso]><table border="0" cellpadding="0" align="center" cellspacing="0" width="' . $width . '"><tr><td width="' . $width . '"><![endif]-->';
83
+ echo "\n";
84
+
85
+ echo 'Block not found';
86
+
87
+ echo '<!--[if mso]></td></tr></table><![endif]-->';
88
+ if ($wrapper) {
89
+ echo '</td></tr></table>';
90
+ }
91
+ return;
92
  }
93
+ $is_old_block = isset($block['filename']) && strpos($block['filename'], '.block');
94
+
95
+ if ($is_old_block) {
96
+ ob_start();
97
  include NEWSLETTER_DIR . '/emails/tnp-composer/blocks/' . $block['filename'] . '.php';
98
+ $content = ob_get_clean();
99
  } else {
 
 
 
 
 
 
 
100
  ob_start();
101
  include $block['dir'] . '/block.php';
102
  $content = ob_get_clean();
103
+ }
104
+
105
+ // Obsolete
106
+ $content = str_replace('{width}', $width, $content);
107
+ $content = $this->inline_css($content, true);
108
+
109
+ // CSS driven by the block
110
+ if (!isset($options['block_background'])) $options['block_background'] = '';
111
+ $style = '';
112
+ if (isset($options['block_padding_top'])) $style .= 'padding-top: ' . $options['block_padding_top'] . '; ';
113
+ if (isset($options['block_padding_left'])) $style .= 'padding-left: ' . $options['block_padding_left'] . '; ';
114
+ if (isset($options['block_padding_right'])) $style .= 'padding-right: ' . $options['block_padding_right'] . '; ';
115
+ if (isset($options['block_padding_bottom'])) $style .= 'padding-bottom: ' . $options['block_padding_bottom'] . '; ';
116
+
117
+ // Old block type
118
+ if ($is_old_block) {
119
+
120
+ echo '<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="border-collapse: collapse; width: 100%;" class="tnpc-row" data-id="', esc_attr($block_id), "\">\n";
121
+ echo "<tr>\n";
122
+ echo '<td align="center" style="padding: 0;" class="edit-block">', "\n";
123
+ echo '<!--[if mso]><table border="0" cellpadding="0" align="center" cellspacing="0" width="' . $width . '"><tr><td width="' . $width . '"><![endif]-->', "\n";
124
+
125
+ echo '<table border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: ', $width, 'px!important">', "\n";
126
+ echo "<tr>\n";
127
+ echo '<td align="center" style="', $style, 'text-align: center;" bgcolor="', $options['block_background'], '" width="100%">', "\n";
128
+
129
+ echo $content;
130
+
131
+ echo "</td>\n</tr>\n</table>";
132
+ echo '<!--[if mso]></td></tr></table><![endif]-->';
133
+ echo "\n</td>\n</tr></table>\n\n";
134
+
135
+ } else {
136
 
137
  $data = '';
138
  foreach ($options as $key => $value) {
144
  }
145
  }
146
  }
147
+
148
+ if ($wrapper) {
149
+ echo '<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="border-collapse: collapse; width: 100%;" class="tnpc-row tnpc-row-block" data-id="', esc_attr($block_id), '">';
150
  echo '<tr>';
151
+ echo '<td data-options="', esc_attr($data), '" align="center" style="padding: 0; font-family: Helvetica, Arial, sans-serif;" class="edit-block">';
152
  }
153
+
154
+ // Container that fixes the width and makes the block responsive
155
+ echo '<!--[if mso]><table border="0" cellpadding="0" align="center" cellspacing="0" width="' . $width . '"><tr><td width="' . $width . '"><![endif]-->';
156
+ echo "\n";
157
+ echo '<table border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: ', $width, 'px!important">', "\n";
158
+ echo "<tr>\n";
159
+ echo '<td align="center" style="', $style, 'text-align: center;" bgcolor="', $options['block_background'], '" width="100%">', "\n";
160
+
161
  echo $content;
162
+
163
+ echo "</td>\n</tr>\n</table>";
164
+ echo '<!--[if mso]></td></tr></table><![endif]-->';
165
+ if ($wrapper) {
166
  echo '</td></tr></table>';
167
  }
 
168
  }
169
  }
170
 
171
+ /**
172
+ * Ajax call to render a block with a new set of options after the settings popup
173
+ * has been saved.
174
+ *
175
+ * @param type $block_id
176
+ * @param type $wrapper
177
+ */
178
+ function tnpc_render_callback() {
179
+ $block_id = $_POST['b'];
180
+ $wrapper = isset($_POST['full']);
181
+ if (isset($_POST['options']) && is_array($_POST['options'])) {
182
+ $options = stripslashes_deep($_POST['options']);
183
+ } else {
184
+ $options = array();
185
+ }
186
+ $this->render_block($block_id, $wrapper, $options);
187
+ wp_die();
188
+ }
189
+
190
  function tnpc_preview_callback() {
191
  $email = Newsletter::instance()->get_email($_REQUEST['id'], ARRAY_A);
192
 
218
  header("HTTP/1.0 404 Not Found");
219
  die('Email not found');
220
  }
221
+
222
  $user = NewsletterSubscription::instance()->get_user_from_request();
223
+
224
  if (!is_user_logged_in() || !(current_user_can('editor') || current_user_can('administrator'))) {
225
+
226
  if ($email->status == 'new') {
227
  header("HTTP/1.0 404 Not Found");
228
  die('Not sent yet');
229
+ }
230
 
231
  if ($email->private == 1) {
232
  if (!$user) {
498
  $relative_dir = substr($dir, strlen(WP_CONTENT_DIR));
499
  while ($file = readdir($handle)) {
500
 
501
+ if ($file == '.' || $file == '..') continue;
502
+
503
  // The block unique key, we should find out how to biuld it, maybe an hash of the (relative) dir?
504
+ $block_id = sanitize_key($file);
505
 
506
  $full_file = $dir . '/' . $file . '/block.php';
507
  if (!is_file($full_file)) {
523
  $data['dir'] = $dir . '/' . $file;
524
 
525
  $data['icon'] = content_url($relative_dir . '/' . $file . '/icon.png');
526
+ $list[$block_id] = $data;
527
  }
528
  closedir($handle);
529
  return $list;
530
  }
531
 
532
+ /**
533
+ * Array of arrays with every registered block and legacy block converted to the new
534
+ * format.
535
+ *
536
+ * @return array
537
+ */
538
  function get_blocks() {
539
 
540
+ static $blocks = null;
541
+
542
+ if (!is_null($blocks)) return $blocks;
543
 
544
+ $blocks = array();
545
+
546
+ // Legacy blocks
547
  $handle = opendir(NEWSLETTER_DIR . '/emails/tnp-composer/blocks');
548
  while ($file = readdir($handle)) {
549
+ if (strpos($file, '.php') === false) {
550
+ continue;
551
+ }
552
+
553
  $path_parts = pathinfo($file);
554
  $filename = $path_parts['filename'];
555
  $section = substr($filename, 0, strpos($filename, '-'));
560
  $block['icon'] = plugins_url('newsletter') . '/emails/tnp-composer/blocks/' . $filename . '.png';
561
  $block['section'] = $section;
562
  $block['description'] = '';
563
+ // The block ID is the file name for legacy blocks
564
+ $blocks[sanitize_key($filename)] = $block;
565
  }
566
  closedir($handle);
567
 
568
+ // Packaged standard blocks
569
  $list = $this->scan_blocks_dir(__DIR__ . '/blocks');
570
 
571
+ $blocks = array_merge($list, $blocks);
572
+
573
  $dirs = apply_filters('newsletter_blocks_dir', array());
574
 
575
  foreach ($dirs as $dir) {
576
  $dir = str_replace('\\', '/', $dir);
577
  $list = $this->scan_blocks_dir($dir);
578
+ $blocks = array_merge($list, $blocks);
579
  }
580
+ $blocks = array_reverse($blocks);
581
  return $blocks;
582
  }
583
 
584
+ /**
585
+ * Return a single block (associative array) checking for legacy ID as well.
586
+ *
587
+ * @param string $id
588
+ * @return array
589
+ */
590
  function get_block($id) {
591
  switch ($id) {
592
+ case 'content-07-twocols.block':
593
+ case 'content-06-posts.block':
594
+ $id = 'posts';
595
+ break;
596
+ case 'content-04-cta.block': $id = 'cta';
597
  break;
598
  // case 'content-02-heading.block': $id = '/plugins/newsletter/emails/blocks/heading';
599
  // break;
600
  }
601
+
602
+ // Conversion for old full path ID
603
+ $id = sanitize_key(basename($id));
604
 
605
  // TODO: Correct id for compatibility
606
  $blocks = $this->get_blocks();
emails/index.php CHANGED
@@ -111,7 +111,7 @@ $emails = Newsletter::instance()->get_emails('message');
111
  <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $email->sent . ' ' . __('of', 'newsletter') . ' ' . $email->total; ?></td>
112
  <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $module->format_date($email->send_on); ?></td>
113
  <td><?php echo $email->track == 1 ? __('Yes', 'newsletter') : __('No', 'newsletter'); ?></td>
114
- <td><a class="button-primary" href="<?php echo $module->get_admin_page_url($composer ? 'composer' : 'edit'); ?>&amp;id=<?php echo $email->id; ?>"><i class="fa fa-<?php echo $composer ? 'th-large' : 'pencil' ?>"></i> <?php _e('Edit', 'newsletter') ?></a></td>
115
  <td>
116
  <a class="button-primary" href="<?php echo NewsletterStatistics::instance()->get_statistics_url($email->id); ?>"><i class="fa fa-bar-chart"></i> <?php _e('Statistics', 'newsletter') ?></a>
117
  </td>
111
  <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $email->sent . ' ' . __('of', 'newsletter') . ' ' . $email->total; ?></td>
112
  <td><?php if ($email->status == 'sent' || $email->status == 'sending') echo $module->format_date($email->send_on); ?></td>
113
  <td><?php echo $email->track == 1 ? __('Yes', 'newsletter') : __('No', 'newsletter'); ?></td>
114
+ <td><a class="button-primary" href="<?php echo $module->get_admin_page_url('edit'); ?>&amp;id=<?php echo $email->id; ?>"><i class="fa fa-<?php echo $composer ? 'th-large' : 'pencil' ?>"></i> <?php _e('Edit', 'newsletter') ?></a></td>
115
  <td>
116
  <a class="button-primary" href="<?php echo NewsletterStatistics::instance()->get_statistics_url($email->id); ?>"><i class="fa fa-bar-chart"></i> <?php _e('Statistics', 'newsletter') ?></a>
117
  </td>
emails/tnp-composer/_/content-06-posts.block.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include NEWSLETTER_INCLUDES_DIR . '/helper.php';
3
+
4
+ $filters = array();
5
+ $filters['showposts'] = isset($_POST['num']) ? intval($_POST['num']) : 3;
6
+ if (!empty($_POST['categories'])) {
7
+ $filters['category__in'] = $_POST['categories'];
8
+ }
9
+ if (!empty($_POST['tags'])) {
10
+ $filters['tag'] = $_POST['tags'];
11
+ }
12
+ $posts = get_posts($filters);
13
+
14
+ $bgcolor = isset($_POST['bgcolor']) ? $_POST['bgcolor'] : '#E6E9ED';
15
+
16
+ ?>
17
+
18
+ <!-- COMPACT ARTICLE SECTION -->
19
+ <?php echo $wrapper_open ?>
20
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: <?php echo $width ?>px!important">
21
+ <tr>
22
+ <td bgcolor="<?php echo $bgcolor ?>" align="center" style="padding: 70px 15px 70px 15px;" class="section-padding edit-block">
23
+
24
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row tnpc-row-posts" data-id="content-06" data-block="content-06-posts">
25
+ <tr>
26
+ <td bgcolor="<?php echo $bgcolor ?>" align="center" style="padding: 70px 15px 70px 15px;" class="section-padding edit-block">
27
+
28
+ <table border="0" cellpadding="0" cellspacing="0" width="500" style="padding:0 0 20px 0;" class="responsive-table">
29
+ <!-- TITLE -->
30
+ <tr>
31
+ <td align="center" style="padding: 0 0 10px 0; font-size: 25px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #333333;" class="padding-copy tnpc-row-edit" data-type="title" colspan="2">From Our Blog</td>
32
+ </tr>
33
+
34
+ <?php foreach ($posts AS $post) { ?>
35
+
36
+ <tr>
37
+ <td valign="top" style="padding: 40px 0 0 0;" class="mobile-hide tnpc-row-edit" data-type="image">
38
+ <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank">
39
+ <img src="<?php echo tnp_post_thumbnail_src($post) ?>" width="105" height="105" border="0" style="display: block; font-family: Arial; color: #666666; font-size: 14px; width: 105px!important; height: 105px!important;">
40
+ </a>
41
+ </td>
42
+ <td style="padding: 40px 0 0 0;" class="no-padding">
43
+ <!-- ARTICLE -->
44
+ <table border="0" cellspacing="0" cellpadding="0" width="100%">
45
+ <tr>
46
+ <td align="left" style="padding: 0 0 5px 25px; font-size: 13px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #aaaaaa;" class="padding-meta">
47
+ <?php echo tnp_post_date($post) ?>
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td align="left" style="padding: 0 0 5px 25px; font-size: 22px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #333333;" class="padding-copy tnpc-row-edit" data-type="title">
52
+ <?php echo tnp_post_title($post) ?>
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td align="left" style="padding: 10px 0 15px 25px; font-size: 16px; line-height: 24px; font-family: Helvetica, Arial, sans-serif; color: #666666;" class="padding-copy tnpc-row-edit" data-type="text">
57
+ <?php echo tnp_post_excerpt($post) ?>
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <td style="padding:0 0 45px 25px;" align="left" class="padding">
62
+ <table border="0" cellspacing="0" cellpadding="0" class="mobile-button-container">
63
+ <tr>
64
+ <td align="center">
65
+ <!-- BULLETPROOF BUTTON -->
66
+ <table width="100%" border="0" cellspacing="0" cellpadding="0" class="mobile-button-container">
67
+ <tr>
68
+ <td align="center" style="padding: 0;" class="padding-copy">
69
+ <table border="0" cellspacing="0" cellpadding="0" class="responsive-table">
70
+ <tr>
71
+ <td align="center">
72
+ <a href="<?php echo tnp_post_permalink($post) ?>" target="_blank" style="font-size: 15px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #ffffff; text-decoration: none; background-color: #256F9C; border-top: 10px solid #256F9C; border-bottom: 10px solid #256F9C; border-left: 20px solid #256F9C; border-right: 20px solid #256F9C; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;" class="mobile-button tnpc-row-edit" data-type="link">Go To Article &rarr;</a>
73
+ </td>
74
+ </tr>
75
+ </table>
76
+ </td>
77
+ </tr>
78
+ </table>
79
+ </td>
80
+ </tr>
81
+ </table>
82
+ </td>
83
+ </tr>
84
+ </table>
85
+ </td>
86
+ </tr>
87
+
88
+ <?php } ?>
89
+
90
+ </table>
91
+ </td>
92
+ </tr>
93
+ </table>
94
+ <?php echo $wrapper_close ?>
emails/tnp-composer/_/content-06-posts.block.png ADDED
Binary file
emails/tnp-composer/_/content-07-twocols.block.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include NEWSLETTER_INCLUDES_DIR . '/helper.php';
3
+
4
+ $filters = array();
5
+ $filters['showposts'] = isset($_POST['num']) ? intval($_POST['num']) : 3;
6
+ if (!empty($_POST['categories'])) {
7
+ $filters['category__in'] = $_POST['categories'];
8
+ }
9
+ if (!empty($_POST['tags'])) {
10
+ $filters['tag'] = $_POST['tags'];
11
+ }
12
+ $posts = get_posts($filters);
13
+
14
+ $bgcolor = isset($_POST['bgcolor']) ? $_POST['bgcolor'] : '#E6E9ED';
15
+
16
+ ?>
17
+
18
+ <!-- TWO COLUMN SECTION -->
19
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row tnpc-row-posts" data-id="content-07" data-block="content-07-twocols">
20
+ <tr>
21
+ <td bgcolor="<?php echo $bgcolor ?>" align="center" style="padding: 70px 15px 70px 15px;" class="section-padding edit-block">
22
+ <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table">
23
+ <tr>
24
+ <td>
25
+ <!-- TITLE SECTION AND COPY -->
26
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
27
+ <tr>
28
+ <td align="center" style="font-size: 25px; font-family: Helvetica, Arial, sans-serif; color: #333333;" class="padding-copy tnpc-row-edit" data-type="title">Great News!</td>
29
+ </tr>
30
+ <tr>
31
+ <td align="center" style="padding: 20px 0 20px 0; font-size: 16px; line-height: 25px; font-family: Helvetica, Arial, sans-serif; color: #666666;" class="padding-copy tnpc-row-edit" data-type="text">The twelve jurors were all writing very busily on slates.</td>
32
+ </tr>
33
+ </table>
34
+ </td>
35
+ </tr>
36
+ <tr>
37
+ <td>
38
+ <!-- TWO COLUMNS -->
39
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
40
+ <?php foreach (array_chunk($posts, 2) AS $row) { ?>
41
+ <tr>
42
+ <td valign="top" style="padding: 0;" class="mobile-wrapper">
43
+
44
+ <!-- LEFT COLUMN -->
45
+ <table cellpadding="0" cellspacing="0" border="0" width="47%" align="left" class="responsive-table">
46
+ <tr>
47
+ <td style="padding: 20px 0 40px 0;">
48
+ <table cellpadding="0" cellspacing="0" border="0" width="100%">
49
+ <tr>
50
+ <td align="center" bgcolor="#F5F7FA" valign="middle" class="tnpc-row-edit" data-type="image">
51
+ <a href="<?php echo tnp_post_permalink($row[0]) ?>" target="_blank">
52
+ <img src="<?php echo tnp_post_thumbnail_src($row[0], array(240, 160, true)) ?>" width="240" height="160" style="display: block; color: #666666; font-family: Helvetica, arial, sans-serif; font-size: 13px; width: 240px; height: 160px;" border="0" class="img-max">
53
+ </a>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <td align="center" style="padding: 15px 0 0 0; font-family: Arial, sans-serif; color: #333333; font-size: 20px;" bgcolor="#F5F7FA" class="tnpc-row-edit" data-type="title"><?php echo tnp_post_title($row[0]) ?></td>
58
+ </tr>
59
+ <tr>
60
+ <td align="center" style="padding: 5px 0 0 0; font-family: Arial, sans-serif; color: #666666; font-size: 14px; line-height: 20px;" bgcolor="#F5F7FA" class="tnpc-row-edit" data-type="text"><?php echo tnp_post_excerpt($row[0]) ?></td>
61
+ </tr>
62
+ <tr>
63
+ <td align="center" style="padding: 5px 0 0 0; font-family: Arial, sans-serif; color: #666666; font-size: 14px; line-height: 20px;" bgcolor="#F5F7FA"><a href="<?php echo tnp_post_permalink($row[0]) ?>" style="color: #256F9C; text-decoration: none;" class="tnpc-row-edit" data-type="link">Go To Article &rarr;</a></td>
64
+ </tr>
65
+ </table>
66
+ </td>
67
+ </tr>
68
+ </table>
69
+
70
+ <?php if (!empty($row[1])) { ?>
71
+ <!-- RIGHT COLUMN -->
72
+ <table cellpadding="0" cellspacing="0" border="0" width="47%" align="right" class="responsive-table">
73
+ <tr>
74
+ <td style="padding: 20px 0 40px 0;">
75
+ <table cellpadding="0" cellspacing="0" border="0" width="100%">
76
+ <tr>
77
+ <td align="center" bgcolor="#F5F7FA" valign="middle" class="tnpc-row-edit" data-type="image">
78
+ <a href="<?php echo tnp_post_permalink($row[1]) ?>" target="_blank">
79
+ <img src="<?php echo tnp_post_thumbnail_src($row[1], array(240, 160)) ?>" width="240" height="160" style="display: block; color: #666666; font-family: Helvetica, arial, sans-serif; font-size: 13px; width: 240px; height: 160px;" border="0" class="img-max">
80
+ </a>
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <td align="center" style="padding: 15px 0 0 0; font-family: Arial, sans-serif; color: #333333; font-size: 20px;" bgcolor="#F5F7FA" class="tnpc-row-edit" data-type="title"><?php echo tnp_post_title($row[1]) ?></td>
85
+ </tr>
86
+ <tr>
87
+ <td align="center" style="padding: 5px 0 0 0; font-family: Arial, sans-serif; color: #666666; font-size: 14px; line-height: 20px;" bgcolor="#F5F7FA" class="tnpc-row-edit" data-type="text"><?php echo tnp_post_excerpt($row[1]) ?></td>
88
+ </tr>
89
+ <tr>
90
+ <td align="center" style="padding: 5px 0 0 0; font-family: Arial, sans-serif; color: #666666; font-size: 14px; line-height: 20px;" bgcolor="#F5F7FA"><a href="<?php echo tnp_post_permalink($row[1]) ?>" style="color: #256F9C; text-decoration: none;" class="tnpc-row-edit" data-type="link">Go To Article &rarr;</a></td>
91
+ </tr>
92
+ </table>
93
+ </td>
94
+ </tr>
95
+ </table>
96
+ <?php } ?>
97
+
98
+ </td>
99
+ </tr>
100
+
101
+ <?php } ?>
102
+
103
+ </table>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+ </td>
108
+ </tr>
109
+ </table>
emails/tnp-composer/_/content-07-twocols.block.png ADDED
Binary file
emails/tnp-composer/_css/newsletter-builder.css CHANGED
@@ -25,9 +25,6 @@
25
  vertical-align: middle;
26
  }
27
 
28
-
29
-
30
-
31
  #newsletter-builder {
32
  position: relative;
33
  overflow: hidden;
@@ -123,7 +120,7 @@
123
  padding-left: 50px;
124
  padding-right: 50px;
125
  margin-top: 30px;
126
- padding-top: 50px;
127
  border-radius: 10px;
128
  border: 1px solid #eee;
129
  margin-bottom: 30px;
@@ -133,9 +130,10 @@
133
  #newsletter-builder-area-center-frame-content {
134
  /*float: left;*/
135
  width: 750px;
136
- background-color: rgba(153,153,153,1);
137
  min-height: 50px;
138
- padding-bottom: 100px;
 
139
  }
140
 
141
  #newsletter-mobile-preview-area {
@@ -173,10 +171,11 @@
173
  box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
174
  }
175
  .tnpc-row-delete, .tnpc-row-edit-block {
176
- height: 40px;
177
- width: 40px;
178
  background-color: rgba(255,255,255,0.5);
179
- right: -40px;
 
180
  position: absolute;
181
  color: rgba(102,102,102,1);
182
  -webkit-transition: all 0.5s;
@@ -185,10 +184,10 @@
185
  transition: all 0.5s;
186
  opacity: 0;
187
  text-align: center;
188
- font-size: 20px;
189
  }
190
  .tnpc-row-delete i, .tnpc-row-edit-block i {
191
- line-height: 40px;
192
  }
193
  .tnpc-row-delete:hover {
194
  background-color: rgba(255,0,0,1);
@@ -199,7 +198,9 @@
199
  opacity: 1;
200
  }
201
  .tnpc-row-delete {
202
- top: 40px;
 
 
203
  }
204
  .tnpc-row-edit-block {
205
  top: 0px;
@@ -480,7 +481,7 @@
480
 
481
 
482
  .fake-browser-ui {
483
- padding: 40px 0 0;
484
  border-radius: 3px;
485
  border-bottom: 10px solid #ccc;
486
  background: #ddd;
25
  vertical-align: middle;
26
  }
27
 
 
 
 
28
  #newsletter-builder {
29
  position: relative;
30
  overflow: hidden;
120
  padding-left: 50px;
121
  padding-right: 50px;
122
  margin-top: 30px;
123
+ padding-top: 10px;
124
  border-radius: 10px;
125
  border: 1px solid #eee;
126
  margin-bottom: 30px;
130
  #newsletter-builder-area-center-frame-content {
131
  /*float: left;*/
132
  width: 750px;
133
+ /*background-color: rgba(153,153,153,1);*/
134
  min-height: 50px;
135
+ padding-bottom: 75px;
136
+ border: 1px dashed #eee;
137
  }
138
 
139
  #newsletter-mobile-preview-area {
171
  box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
172
  }
173
  .tnpc-row-delete, .tnpc-row-edit-block {
174
+ height: 30px;
175
+ width: 30px;
176
  background-color: rgba(255,255,255,0.5);
177
+ right: 30px;
178
+ z-index: 5;
179
  position: absolute;
180
  color: rgba(102,102,102,1);
181
  -webkit-transition: all 0.5s;
184
  transition: all 0.5s;
185
  opacity: 0;
186
  text-align: center;
187
+ font-size: 18px;
188
  }
189
  .tnpc-row-delete i, .tnpc-row-edit-block i {
190
+ line-height: 30px;
191
  }
192
  .tnpc-row-delete:hover {
193
  background-color: rgba(255,0,0,1);
198
  opacity: 1;
199
  }
200
  .tnpc-row-delete {
201
+ top: 0px;
202
+ right: 0px;
203
+ z-index: 5;
204
  }
205
  .tnpc-row-edit-block {
206
  top: 0px;
481
 
482
 
483
  .fake-browser-ui {
484
+ padding: 30px 0 0;
485
  border-radius: 3px;
486
  border-bottom: 10px solid #ccc;
487
  background: #ddd;
emails/tnp-composer/_scripts/newsletter-builder.js CHANGED
@@ -436,11 +436,11 @@ function tnp_mobile_preview() {
436
  var d = document.getElementById("tnp-mobile-preview").contentWindow.document;
437
  d.open();
438
 
439
- d.write("<!DOCTYPE html><html><head>");
440
  d.write("<link rel='stylesheet' href='" + TNP_HOME_URL + "?na=emails-composer-css&ver=" + Math.random() + "' type='text/css'");
441
- d.write("</head><body style='margin: 0; padding: 0;'><div style='width: 320px!important'>");
442
  d.write(jQuery("#newsletter-builder-area-center-frame-content").html());
443
- d.write("</div></body></html>");
444
  d.close();
445
  }
446
 
@@ -460,12 +460,12 @@ function create() {
460
  jQuery("#tnpc-form").submit();
461
  } else {
462
  jQuery.get(TNP_HOME_URL + "?na=emails-composer-css&ver=" + Math.random(), {action: "tnpc_css"}, function (data) {
463
- export_content = '<!DOCTYPE html><html><head><title>Newsletter</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="X-UA-Compatible" content="IE=edge" />';
464
  export_content += '<style type="text/css">' + data + '</style>';
465
- export_content += '<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic" rel="stylesheet" type="text/css">';
466
- export_content += '</head><body style="margin: 0; padding: 0;">';
467
  export_content += preload_export_html;
468
- export_content += '</body></html>';
469
  jQuery("#tnpc-edit-export .text").val(export_content);
470
  jQuery('#tnpc-form input[name="options[body]"]').attr('value', export_content);
471
  jQuery("#tnpc-form").submit();
436
  var d = document.getElementById("tnp-mobile-preview").contentWindow.document;
437
  d.open();
438
 
439
+ d.write("<!DOCTYPE html>\n<html>\n<head>\n");
440
  d.write("<link rel='stylesheet' href='" + TNP_HOME_URL + "?na=emails-composer-css&ver=" + Math.random() + "' type='text/css'");
441
+ d.write("</head>\n<body style='margin: 0; padding: 0;'><div style='width: 320px!important'>");
442
  d.write(jQuery("#newsletter-builder-area-center-frame-content").html());
443
+ d.write("</div>\n</body>\n</html>");
444
  d.close();
445
  }
446
 
460
  jQuery("#tnpc-form").submit();
461
  } else {
462
  jQuery.get(TNP_HOME_URL + "?na=emails-composer-css&ver=" + Math.random(), {action: "tnpc_css"}, function (data) {
463
+ export_content = '<!DOCTYPE html>\n<html>\n<head>\n<title>Newsletter</title>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<meta http-equiv="X-UA-Compatible" content="IE=edge">\n';
464
  export_content += '<style type="text/css">' + data + '</style>';
465
+ //export_content += '\n<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic" rel="stylesheet" type="text/css">';
466
+ export_content += '</head>\n<body style="margin: 0; padding: 0;">\n';
467
  export_content += preload_export_html;
468
+ export_content += '\n</body>\n</html>';
469
  jQuery("#tnpc-edit-export .text").val(export_content);
470
  jQuery('#tnpc-form input[name="options[body]"]').attr('value', export_content);
471
  jQuery("#tnpc-form").submit();
emails/tnp-composer/blocks/content-01-hero.block.php CHANGED
@@ -1,8 +1,6 @@
1
- <!-- ONE COLUMN SECTION -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="content-01">
3
- <tr>
4
- <td bgcolor="#ffffff" align="center" style="padding: 70px 15px 70px 15px; font-family: Helvetica, Arial, sans-serif;" class="section-padding edit-block">
5
- <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table">
6
  <tr>
7
  <td>
8
  <!-- HERO IMAGE -->
@@ -10,7 +8,7 @@
10
  <tr>
11
  <td class="padding-copy tnpc-row-edit" data-type="image">
12
  <a href="#" target="_blank">
13
- <img src="https://unsplash.it/500/300?image=885" width="500" border="0" alt="Insert alt text here" style="max-width: 100%!important; width: 500px!important; height: auto!important; display: block; color: #666666; font-family: Helvetica, arial, sans-serif; font-size: 16px;" class="img-max">
14
  </a>
15
  </td>
16
  </tr>
@@ -19,10 +17,10 @@
19
  <!-- COPY -->
20
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
21
  <tr>
22
- <td align="center" style="font-size: 25px; color: #333333; padding-top: 30px;" class="padding-copy tnpc-row-edit" data-type="title">An Awesome Title</td>
23
  </tr>
24
  <tr>
25
- <td align="center" style="padding: 20px 0 0 0; font-size: 16px; line-height: 25px; color: #666666;" class="padding-copy tnpc-row-edit" data-type="text">The judge, by the way, was the King; and as he wore his crown over the wig, (look at the frontispiece if you want to see how he did it,) he did not look at all comfortable, and it was certainly not becoming.</td>
26
  </tr>
27
  </table>
28
  </td>
@@ -48,6 +46,3 @@
48
  </td>
49
  </tr>
50
  </table>
51
- </td>
52
- </tr>
53
- </table>
1
+
2
+
3
+ <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table" align="center">
 
 
4
  <tr>
5
  <td>
6
  <!-- HERO IMAGE -->
8
  <tr>
9
  <td class="padding-copy tnpc-row-edit" data-type="image">
10
  <a href="#" target="_blank">
11
+ <img src="https://unsplash.it/500/300?image=885" width="500" border="0" alt="Insert alt text here" style="max-width: 100%!important; width: 500px!important; height: auto!important; display: block;" class="img-max">
12
  </a>
13
  </td>
14
  </tr>
17
  <!-- COPY -->
18
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
19
  <tr>
20
+ <td align="center" style="font-size: 25px; color: #333333; padding-top: 30px; font-family: Helvetica, arial, sans-serif; " class="padding-copy tnpc-row-edit" data-type="title">An Awesome Title</td>
21
  </tr>
22
  <tr>
23
+ <td align="center" style="padding: 20px 0 0 0; font-size: 16px; line-height: 25px; color: #666666; font-family: Helvetica, arial, sans-serif; " class="padding-copy tnpc-row-edit" data-type="text">The judge, by the way, was the King; and as he wore his crown over the wig, (look at the frontispiece if you want to see how he did it,) he did not look at all comfortable, and it was certainly not becoming.</td>
24
  </tr>
25
  </table>
26
  </td>
46
  </td>
47
  </tr>
48
  </table>
 
 
 
emails/tnp-composer/blocks/content-02-heading.block.php CHANGED
@@ -1,16 +1,10 @@
1
- <!-- ONE COLUMN SECTION -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="content-02">
3
  <tr>
4
- <td bgcolor="#ffffff" align="center" style="padding: 15px;" class="section-padding edit-block">
5
 
6
- <table border="0" cellpadding="0" cellspacing="0" width="500" class="responsive-table" style="max-width: 100%!important">
7
- <tr>
8
- <td>
9
- <div style="line-height: normal; font-size: 25px; font-family: Helvetica; color: #333333; text-align: center; border: 0; width: 100%!important; display: block; background-color: transparent" class="tnpc-row-edit" data-type="title">An Awesome Title</div>
10
- </td>
11
- </tr>
12
- </table>
13
 
14
  </td>
15
  </tr>
16
- </table>
1
+
2
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%" >
3
  <tr>
4
+ <td bgcolor="#ffffff" align="center" style="padding: 15px;">
5
 
6
+ <div style="line-height: normal; font-size: 25px; font-family: Helvetica; color: #333333; text-align: center; border: 0; width: 100%!important; display: block; background-color: transparent" class="tnpc-row-edit" data-type="title">An Awesome Title</div>
 
 
 
 
 
 
7
 
8
  </td>
9
  </tr>
10
+ </table>
emails/tnp-composer/blocks/content-03-text.block.php CHANGED
@@ -1,12 +1,17 @@
1
- <!-- ONE COLUMN SECTION -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="content-03">
3
  <tr>
4
- <td bgcolor="#ffffff" align="center" style="padding: 20px 15px 20px 15px; font-family: Helvetica, Arial, sans-serif;" class="section-padding edit-block">
5
- <table border="0" cellpadding="0" cellspacing="0" class="responsive-table" width="500">
 
6
  <tr>
7
- <td align="center" style="padding: 0 0 0 0; font-size: 16px; line-height: 25px; color: #666666;" class="padding-copy tnpc-row-edit" data-type="text">The judge, by the way, was the King; and as he wore his crown over the wig, (look at the frontispiece if you want to see how he did it,) he did not look at all comfortable, and it was certainly not becoming.</td>
 
 
 
8
  </tr>
9
  </table>
 
10
  </td>
11
  </tr>
12
- </table>
1
+
2
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%">
3
  <tr>
4
+ <td bgcolor="#ffffff" align="center" style="padding: 20px 15px 20px 15px;">
5
+
6
+ <table border="0" cellpadding="0" cellspacing="0" class="responsive-table" width="100%" style="width: 100%!important">
7
  <tr>
8
+ <td align="left" style="text-align: left; padding: 0 0 0 0; font-size: 16px; line-height: 25px; color: #666666; font-family: Helvetica, Arial, sans-serif;" class="padding-copy tnpc-row-edit" data-type="text">
9
+ The judge, by the way, was the King; and as he wore his crown over the wig, (look at the frontispiece if
10
+ you want to see how he did it,) he did not look at all comfortable, and it was certainly not becoming.
11
+ </td>
12
  </tr>
13
  </table>
14
+
15
  </td>
16
  </tr>
17
+ </table>
emails/tnp-composer/blocks/content-05-image.block.php CHANGED
@@ -1,14 +1,14 @@
1
- <!-- ONE COLUMN SECTION -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="content-05">
3
  <tr>
4
- <td bgcolor="#ffffff" align="center" style="padding: 0; font-family: Helvetica, Arial, sans-serif;" class="section-padding edit-block">
5
 
6
  <div class="tnpc-row-edit" data-type="image">
7
  <a href="#" target="_blank">
8
- <img src="https://unsplash.it/800/300?image=998" border="0" alt="Insert alt text here" style="max-width: 100%!important; height: auto!important;display: block; color: #666666;" class="img-max">
9
  </a>
10
  </div>
11
 
12
  </td>
13
  </tr>
14
- </table>
1
+
2
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%">
3
  <tr>
4
+ <td bgcolor="#ffffff" align="center" style="padding: 0;">
5
 
6
  <div class="tnpc-row-edit" data-type="image">
7
  <a href="#" target="_blank">
8
+ <img src="https://unsplash.it/800/300?image=998" border="0" alt="Insert alt text here" width="<?php echo $width ?>" style="width: <?php echo $width ?>px; max-width: 100%!important; height: auto!important;display: block; color: #666666;" class="img-max">
9
  </a>
10
  </div>
11
 
12
  </td>
13
  </tr>
14
+ </table>
emails/tnp-composer/blocks/footer-01-footer.block.php CHANGED
@@ -1,7 +1,7 @@
1
  <!-- FOOTER -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="footer-02">
3
  <tr>
4
- <td bgcolor="#ffffff" align="center" style="padding: 20px 0px;" class="edit-block">
5
 
6
  <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
7
  <tr>
1
  <!-- FOOTER -->
2
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
3
  <tr>
4
+ <td bgcolor="#ffffff" align="center" style="padding: 20px 0px;">
5
 
6
  <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
7
  <tr>
emails/tnp-composer/blocks/footer-02-canspam.block.php CHANGED
@@ -1,11 +1,8 @@
1
- <!-- CANSPAM -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="footer-01">
3
- <tr>
4
- <td bgcolor="#ffffff" align="center" style="padding: 20px 0px;" class="edit-block">
5
-
6
- <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
7
  <tr>
8
- <td align="center" style="font-size: 12px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color:#666666;">
9
  <div class="tnpc-row-edit" data-type="text" style="color:#666666;">
10
  <?php echo !empty($block_options['footer_title']) ? $block_options['footer_title'] : 'Your Company' ?>
11
  <br/>
@@ -17,7 +14,3 @@
17
  </tr>
18
  </table>
19
 
20
- </td>
21
- </tr>
22
- </table>
23
- <!-- /CANSPAM -->
1
+
2
+
3
+ <table width="100%" style="width: 100%!important" border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
 
 
 
4
  <tr>
5
+ <td align="center" style="padding: 20px 15px 20px 15px; font-size: 12px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color:#666666;">
6
  <div class="tnpc-row-edit" data-type="text" style="color:#666666;">
7
  <?php echo !empty($block_options['footer_title']) ? $block_options['footer_title'] : 'Your Company' ?>
8
  <br/>
14
  </tr>
15
  </table>
16
 
 
 
 
 
emails/tnp-composer/blocks/footer-03-social.block.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  $social_icon_url = plugins_url('newsletter') . '/emails/themes/default/images';
3
  ?>
4
- <!-- SOCIAL -->
5
- <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tnpc-row" data-id="footer-03">
6
  <tr>
7
- <td bgcolor="#ffffff" align="center" style="padding: 20px 0px;" class="edit-block">
8
 
9
- <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
10
  <tr>
11
  <td align="center" style="font-size: 12px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color:#666666;">
12
  <?php if (!empty($block_options['facebook_url'])) { $configured = true; ?>
@@ -66,7 +66,8 @@ $social_icon_url = plugins_url('newsletter') . '/emails/themes/default/images';
66
  </td>
67
  </tr>
68
  </table>
 
69
  </tr>
70
  </table>
71
- <!-- /SOCIAL -->
72
 
1
  <?php
2
  $social_icon_url = plugins_url('newsletter') . '/emails/themes/default/images';
3
  ?>
4
+ <?php echo $wrapper_open ?>
5
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%" style="width: 100%!important; max-width: <?php echo $width ?>px!important">
6
  <tr>
7
+ <td bgcolor="#ffffff" align="center" style="padding: 20px 15px 20px 15px;" class="section-padding edit-block">
8
 
9
+ <table border="0" cellspacing="0" cellpadding="0" align="center" class="responsive-table">
10
  <tr>
11
  <td align="center" style="font-size: 12px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color:#666666;">
12
  <?php if (!empty($block_options['facebook_url'])) { $configured = true; ?>
66
  </td>
67
  </tr>
68
  </table>
69
+ </td>
70
  </tr>
71
  </table>
72
+ <?php echo $wrapper_close ?>
73
 
emails/tnp-composer/blocks/header-01-header.block.php CHANGED
@@ -1,8 +1,17 @@
1
- <!-- HEADER -->
2
- <table border="0" cellpadding="0" cellspacing="0" width="100%" data-id="header-01" class="tnpc-row" data-id="header-01">
 
 
 
 
 
 
 
 
 
3
  <tr>
4
- <td bgcolor="#333333" class="edit-block">
5
- <div align="center" style="padding: 0px 15px 0px 15px;">
6
  <table border="0" cellpadding="0" cellspacing="0" width="500" class="wrapper">
7
  <!-- LOGO/PREHEADER TEXT -->
8
  <tr>
@@ -11,11 +20,7 @@
11
  <tr>
12
  <td width="100" align="left" class="tnpc-row-edit" data-type="image">
13
  <a href="#" target="_blank">
14
- <?php if (!empty($block_options['header_logo']['url'])) { ?>
15
- <img alt="<?php echo esc_attr($block_options['header_title']) ?>" src="<?php echo $block_options['header_logo']['url'] ?>" style="display: block; width: 180px;" border="0">
16
- <?php } else { ?>
17
- <img alt="<?php echo esc_attr($block_options['header_title']) ?>" src="https://placehold.it/180x100&text=<?php echo esc_attr($block_options['header_title']) ?>" style="display: block; width: 180px;" border="0">
18
- <?php } ?>
19
  </a>
20
  </td>
21
  <td width="400" align="right" class="mobile-hide">
@@ -32,7 +37,7 @@
32
  </td>
33
  </tr>
34
  </table>
35
- </div>
36
  </td>
37
  </tr>
38
- </table>
1
+ <?php
2
+ if (!empty($block_options['header_logo']['url'])) {
3
+ $logo_url = $block_options['header_logo']['url'];
4
+ } else {
5
+ $logo_url = 'https://placehold.it/180x100&text=' . urlencode($block_options['header_title']);
6
+ }
7
+ $logo_alt = $block_options['header_title'];
8
+ ?>
9
+
10
+
11
+ <table border="0" cellpadding="0" align="center" cellspacing="0" width="100%">
12
  <tr>
13
+ <td bgcolor="#333333" align="center" style="padding: 0px 15px 0px 15px;">
14
+
15
  <table border="0" cellpadding="0" cellspacing="0" width="500" class="wrapper">
16
  <!-- LOGO/PREHEADER TEXT -->
17
  <tr>
20
  <tr>
21
  <td width="100" align="left" class="tnpc-row-edit" data-type="image">
22
  <a href="#" target="_blank">
23
+ <img alt="<?php echo esc_attr($logo_alt) ?>" src="<?php echo $logo_url ?>" style="display: block; width: 180px;" border="0">
 
 
 
 
24
  </a>
25
  </td>
26
  <td width="400" align="right" class="mobile-hide">
37
  </td>
38
  </tr>
39
  </table>
40
+
41
  </td>
42
  </tr>
43
+ </table>
emails/tnp-composer/index.php CHANGED
@@ -54,14 +54,21 @@ $block_options = get_option('newsletter_main');
54
  <div id="newsletter-builder-area-center-frame-content">
55
 
56
  <?php
57
- if (isset($email)) {
58
  echo NewsletterModule::extract_body($body);
59
  } else {
60
- include __DIR__ . '/blocks/header-01-header.block.php';
61
- include __DIR__ . '/blocks/content-05-image.block.php';
62
- include __DIR__ . '/blocks/content-01-hero.block.php';
63
- include __DIR__ . '/blocks/footer-01-footer.block.php';
64
- include __DIR__ . '/blocks/footer-02-canspam.block.php';
 
 
 
 
 
 
 
65
  }
66
  ?>
67
 
@@ -92,7 +99,7 @@ $block_options = get_option('newsletter_main');
92
  TNP_HOME_URL = "<?php echo home_url('/', is_ssl() ? 'https' : 'http') ?>";
93
  </script>
94
  <script type="text/javascript" src="<?php echo plugins_url('newsletter'); ?>/emails/tnp-composer/_scripts/newsletter-builder.js?ver=<?php echo time() ?>"></script>
95
- <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.3/tinymce.min.js"></script>
96
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.nicescroll/3.6.8-fix/jquery.nicescroll.min.js"></script>
97
  <script>
98
  jQuery(function () {
54
  <div id="newsletter-builder-area-center-frame-content">
55
 
56
  <?php
57
+ if (isset($email) && !$controls->is_action('reset')) {
58
  echo NewsletterModule::extract_body($body);
59
  } else {
60
+ NewsletterEmails::instance()->render_block('preheader', true, array());
61
+ NewsletterEmails::instance()->render_block('header-01-header.block', true, array());
62
+ NewsletterEmails::instance()->render_block('content-01-hero.block', true, array());
63
+ NewsletterEmails::instance()->render_block('footer-02-canspam.block', true, array());
64
+ NewsletterEmails::instance()->render_block('footer-01-footer.block', true, array());
65
+ //NewsletterEmails::instance()->render_block('footer-01-footer.block', true, array());
66
+ //NewsletterEmails::instance()->render_block('footer-02-canspam.block', true, array());
67
+ //include __DIR__ . '/blocks/header-01-header.block.php';
68
+ //include __DIR__ . '/blocks/content-05-image.block.php';
69
+ //include __DIR__ . '/blocks/content-01-hero.block.php';
70
+ //include __DIR__ . '/blocks/footer-01-footer.block.php';
71
+ //include __DIR__ . '/blocks/footer-02-canspam.block.php';
72
  }
73
  ?>
74
 
99
  TNP_HOME_URL = "<?php echo home_url('/', is_ssl() ? 'https' : 'http') ?>";
100
  </script>
101
  <script type="text/javascript" src="<?php echo plugins_url('newsletter'); ?>/emails/tnp-composer/_scripts/newsletter-builder.js?ver=<?php echo time() ?>"></script>
102
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.3/tinymce.min.js"></script>
103
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.nicescroll/3.6.8-fix/jquery.nicescroll.min.js"></script>
104
  <script>
105
  jQuery(function () {
includes/controls.php CHANGED
@@ -935,7 +935,12 @@ class NewsletterControls {
935
  }
936
 
937
  function color($name) {
938
- echo $this->text($name, 10);
 
 
 
 
 
939
  }
940
 
941
  /** Creates a set of checkbox named $name_[category id] (so they are posted with distinct names).
@@ -1181,6 +1186,7 @@ class NewsletterControls {
1181
  }
1182
  echo '<script type="text/javascript">
1183
  jQuery(document).ready(function(){
 
1184
  jQuery("textarea.dynamic").focus(function() {
1185
  jQuery("textarea.dynamic").css("height", "50px");
1186
  jQuery(this).css("height", "400px");
935
  }
936
 
937
  function color($name) {
938
+
939
+ $value = $this->get_value($name);
940
+ echo '<input id="options-', esc_attr($name), '" class="tnp-controls-color" name="options[' . $name . ']" type="text" size="' . $size . '" value="';
941
+ echo esc_attr($value);
942
+ echo '">';
943
+
944
  }
945
 
946
  /** Creates a set of checkbox named $name_[category id] (so they are posted with distinct names).
1186
  }
1187
  echo '<script type="text/javascript">
1188
  jQuery(document).ready(function(){
1189
+ $(".tnp-controls-color").wpColorPicker();
1190
  jQuery("textarea.dynamic").focus(function() {
1191
  jQuery("textarea.dynamic").css("height", "50px");
1192
  jQuery(this).css("height", "400px");
includes/helper.php CHANGED
@@ -7,13 +7,20 @@ function tnp_post_thumbnail_src($post, $size = 'thumbnail', $alternative = '') {
7
  if (is_object($post)) {
8
  $post = $post->ID;
9
  }
10
-
11
  if (is_array($size)) {
12
  $media_id = get_post_thumbnail_id($post);
13
- if (!$media_id) return $alternative;
14
- return tnp_media_resize($media_id, $size);
 
 
 
 
 
 
 
15
  }
16
-
17
  $media = wp_get_attachment_image_src(get_post_thumbnail_id($post), $size);
18
  if (strpos($media[0], 'http') !== 0) {
19
  $media[0] = 'http:' . $media[0];
@@ -73,21 +80,22 @@ function tnp_media_resize($media_id, $size) {
73
 
74
  $editor = wp_get_image_editor($absolute_file);
75
  if (is_wp_error($editor)) {
76
- //echo 'error 1';
77
- return $uploads['baseurl'] . '/' . $relative_file;
78
  }
79
 
80
  $editor->set_quality(80);
81
  $resized = $editor->resize($width, $height, $crop);
82
 
83
  if (is_wp_error($resized)) {
84
- //echo 'error 2';
85
- return $uploads['baseurl'] . '/' . $relative_file;
86
  }
87
 
88
  $saved = $editor->save($absolute_thumb);
89
  if (is_wp_error($saved)) {
90
- return $uploads['baseurl'] . '/' . $relative_file;
 
91
  }
92
  }
93
 
7
  if (is_object($post)) {
8
  $post = $post->ID;
9
  }
10
+
11
  if (is_array($size)) {
12
  $media_id = get_post_thumbnail_id($post);
13
+ if (!$media_id) {
14
+ return $alternative;
15
+ }
16
+ $src = tnp_media_resize($media_id, $size);
17
+ if (is_wp_error($src)) {
18
+ Newsletter::instance()->logger->error($src);
19
+ } else {
20
+ return $src;
21
+ }
22
  }
23
+
24
  $media = wp_get_attachment_image_src(get_post_thumbnail_id($post), $size);
25
  if (strpos($media[0], 'http') !== 0) {
26
  $media[0] = 'http:' . $media[0];
80
 
81
  $editor = wp_get_image_editor($absolute_file);
82
  if (is_wp_error($editor)) {
83
+ return $editor;
84
+ //return $uploads['baseurl'] . '/' . $relative_file;
85
  }
86
 
87
  $editor->set_quality(80);
88
  $resized = $editor->resize($width, $height, $crop);
89
 
90
  if (is_wp_error($resized)) {
91
+ return $resized;
92
+ //return $uploads['baseurl'] . '/' . $relative_file;
93
  }
94
 
95
  $saved = $editor->save($absolute_thumb);
96
  if (is_wp_error($saved)) {
97
+ return $saved;
98
+ //return $uploads['baseurl'] . '/' . $relative_file;
99
  }
100
  }
101
 
includes/module.php CHANGED
@@ -814,11 +814,13 @@ class NewsletterModule {
814
  function get_list($id) {
815
  global $wpdb;
816
  $id = (int) $id;
817
- if (!$id) return null;
 
818
  $list = get_option('newsletter_list_' . $id, array());
819
  $profile = get_option('newsletter_profile');
820
  $list['name'] = $profile['list_' . $id];
821
  $list['subscriber_count'] = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C' and list_" . $id . "=1");
 
822
  return $list;
823
  }
824
 
@@ -865,6 +867,7 @@ class NewsletterModule {
865
  $value = trim($rules[2][$i]);
866
  $value = preg_replace('|\s+|', ' ', $value);
867
  $content = str_replace('class="' . $class . '"', 'class="' . $class . '" style="' . $value . '"', $content);
 
868
  }
869
  }
870
 
@@ -917,6 +920,14 @@ class NewsletterModule {
917
  return $r;
918
  }
919
 
 
 
 
 
 
 
 
 
920
  function set_user_field($id, $field, $value) {
921
  $this->store->set_field(NEWSLETTER_USERS_TABLE, $id, $field, $value);
922
  }
@@ -1033,10 +1044,11 @@ class NewsletterModule {
1033
  $options_subscription = NewsletterSubscription::instance()->options;
1034
 
1035
  $home_url = home_url('/');
1036
-
1037
  $nek = false;
1038
  if ($email) {
1039
  $text = str_replace('{email_id}', $email->id, $text);
 
1040
  $text = str_replace('{email_subject}', $email->subject, $text);
1041
  $text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email->id . '&amp;nk=' . $nk);
1042
  $nek = $email->id . '-' . $email->token;
@@ -1055,13 +1067,17 @@ class NewsletterModule {
1055
  $text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
1056
  $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
1057
 
1058
- if (empty($options_profile['profile_url']))
1059
- $text = $this->replace_url($text, 'PROFILE_URL', $home_url . '?na=p&nk=' . $nk);
1060
- else
1061
- $text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&amp;nt=' . $user->token));
 
 
 
 
 
1062
 
1063
  $text = $this->replace_url($text, 'UNLOCK_URL', $home_url . '?na=ul&nk=' . $nk);
1064
-
1065
  } else {
1066
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', '#');
1067
  $text = $this->replace_url($text, 'ACTIVATION_URL', '#');
@@ -1126,13 +1142,13 @@ class NewsletterModule {
1126
  header('Cache-Control: no-cache,no-store,private');
1127
  echo "<!DOCTYPE html>\n";
1128
  echo '<html><head></head><body>';
1129
- echo '<form method="post" action="' . home_url('/') . '" id="form">';
1130
  foreach ($_REQUEST as $name => $value) {
1131
  if ($name == 'submit')
1132
  continue;
1133
  if (is_array($value)) {
1134
  foreach ($value as $element) {
1135
- echo '<input type="hidden" name="';
1136
  echo esc_attr($name);
1137
  echo '[]" value="';
1138
  echo esc_attr(stripslashes($element));
@@ -1154,7 +1170,9 @@ class NewsletterModule {
1154
  echo '<noscript><input type="submit" value="';
1155
  echo esc_attr($submit_label);
1156
  echo '"></noscript></form>';
1157
- echo '<script>document.getElementById("form").submit();</script>';
 
 
1158
  echo '</body></html>';
1159
  die();
1160
  }
@@ -1193,6 +1211,15 @@ class NewsletterModule {
1193
  }
1194
  return (int) $var;
1195
  }
 
 
 
 
 
 
 
 
 
1196
 
1197
  }
1198
 
814
  function get_list($id) {
815
  global $wpdb;
816
  $id = (int) $id;
817
+ if (!$id)
818
+ return null;
819
  $list = get_option('newsletter_list_' . $id, array());
820
  $profile = get_option('newsletter_profile');
821
  $list['name'] = $profile['list_' . $id];
822
  $list['subscriber_count'] = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C' and list_" . $id . "=1");
823
+ $list['status'] = (int) $profile['list_' . $id . '_status'];
824
  return $list;
825
  }
826
 
867
  $value = trim($rules[2][$i]);
868
  $value = preg_replace('|\s+|', ' ', $value);
869
  $content = str_replace('class="' . $class . '"', 'class="' . $class . '" style="' . $value . '"', $content);
870
+ $content = str_replace('inline-class="' . $class . '"', 'style="' . $value . '"', $content);
871
  }
872
  }
873
 
920
  return $r;
921
  }
922
 
923
+ function set_user_list($user, $list, $value) {
924
+ global $wpdb;
925
+
926
+ $list = (int) $list;
927
+ $value = $value ? 0 : 1;
928
+ $wpdb->update(NEWSLETTER_USERS_TABLE, array('list_' . $list => $value), array('id' => $user->id));
929
+ }
930
+
931
  function set_user_field($id, $field, $value) {
932
  $this->store->set_field(NEWSLETTER_USERS_TABLE, $id, $field, $value);
933
  }
1044
  $options_subscription = NewsletterSubscription::instance()->options;
1045
 
1046
  $home_url = home_url('/');
1047
+
1048
  $nek = false;
1049
  if ($email) {
1050
  $text = str_replace('{email_id}', $email->id, $text);
1051
+ $text = str_replace('{email_key}', $email->id . '-' . $email->token, $text);
1052
  $text = str_replace('{email_subject}', $email->subject, $text);
1053
  $text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email->id . '&amp;nk=' . $nk);
1054
  $nek = $email->id . '-' . $email->token;
1067
  $text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
1068
  $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
1069
 
1070
+
1071
+ if (empty($options_profile['profile_url'])) {
1072
+ $profile_url = $home_url . '?na=p&nk=' . $nk;
1073
+ } else {
1074
+ $profile_url = self::add_qs($options_profile['profile_url'], 'nk=' . $nk);
1075
+ }
1076
+
1077
+ $profile_url = apply_filters('newsletter_profile_url', $profile_url, $user);
1078
+ $text = $this->replace_url($text, 'PROFILE_URL', $profile_url);
1079
 
1080
  $text = $this->replace_url($text, 'UNLOCK_URL', $home_url . '?na=ul&nk=' . $nk);
 
1081
  } else {
1082
  $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', '#');
1083
  $text = $this->replace_url($text, 'ACTIVATION_URL', '#');
1142
  header('Cache-Control: no-cache,no-store,private');
1143
  echo "<!DOCTYPE html>\n";
1144
  echo '<html><head></head><body>';
1145
+ echo '<form method="post" action="https://www.domain.tld" id="form" style="width: 1px; height: 1px; overflow: hidden">';
1146
  foreach ($_REQUEST as $name => $value) {
1147
  if ($name == 'submit')
1148
  continue;
1149
  if (is_array($value)) {
1150
  foreach ($value as $element) {
1151
+ echo '<input type="text" name="';
1152
  echo esc_attr($name);
1153
  echo '[]" value="';
1154
  echo esc_attr(stripslashes($element));
1170
  echo '<noscript><input type="submit" value="';
1171
  echo esc_attr($submit_label);
1172
  echo '"></noscript></form>';
1173
+ echo '<script>';
1174
+ echo 'document.getElementById("form").action="' . home_url('/') . '";';
1175
+ echo 'document.getElementById("form").submit();</script>';
1176
  echo '</body></html>';
1177
  die();
1178
  }
1211
  }
1212
  return (int) $var;
1213
  }
1214
+
1215
+ static function sanitize_ip($ip) {
1216
+ if (empty($ip)) return $ip;
1217
+ return preg_replace('/[^0-9a-fA-F:., ]/', '', $ip);
1218
+ }
1219
+
1220
+ static function get_remote_ip() {
1221
+ return self::sanitize_ip($_SERVER['REMOTE_ADDR']);
1222
+ }
1223
 
1224
  }
1225
 
main/status.php CHANGED
@@ -2,6 +2,7 @@
2
  if (!defined('ABSPATH'))
3
  exit;
4
 
 
5
  @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
6
  $module = Newsletter::instance();
7
  $controls = new NewsletterControls();
@@ -732,22 +733,22 @@ $options = $module->get_options('status');
732
  Send details
733
  </td>
734
  <td>
735
- <?php if ($send_mean > 1) { ?>
736
- <span class="tnp-ko">KO</span>
737
- <?php } else { ?>
738
- <span class="tnp-ok">OK</span>
739
- <?php } ?>
740
  </td>
741
  <td>
742
  <?php if ($send_mean > 1) { ?>
743
- <strong>Sending an email is taking more than 1 second, rather slow.</strong>
744
- <a href="https://www.thenewsletterplugin.com/documentation/status-panel#status-performance" target="_blank">Read more</a>.
745
  <?php } ?>
746
  Average time to send an email: <?php echo sprintf("%.2f", $send_mean) ?> seconds<br>
747
  <?php if ($send_mean > 0) { ?>
748
- Max speed: <?php echo sprintf("%.2f", 1.0/$send_mean*3600) ?> emails per hour<br>
749
  <?php } ?>
750
-
751
  Max mean time measured: <?php echo sprintf("%.2f", $send_max) ?> seconds<br>
752
  Min mean time measured: <?php echo sprintf("%.2f", $send_min) ?> seconds<br>
753
  Total email in the sample: <?php echo $send_total_emails ?><br>
@@ -781,7 +782,7 @@ $options = $module->get_options('status');
781
 
782
 
783
 
784
- <?php
785
  $memory = intval(WP_MEMORY_LIMIT);
786
  if (false !== strpos(WP_MEMORY_LIMIT, 'G'))
787
  $memory *= 1024;
@@ -792,7 +793,7 @@ $options = $module->get_options('status');
792
  </td>
793
  <td>
794
  <?php if ($memory < 64) { ?>
795
- <span class="tnp-ko">KO</span>
796
  <?php } else if ($memory < 128) { ?>
797
  <span class="tnp-maybe">MAYBE</span>
798
  <?php } else { ?>
@@ -800,7 +801,9 @@ $options = $module->get_options('status');
800
  <?php } ?>
801
  </td>
802
  <td>
803
- Your memory limit is set to <?php echo $memory ?> megabyte<br>
 
 
804
  <?php if ($memory < 64) { ?>
805
  This value is too low you should increase it adding <code>define('WP_MEMORY_LIMIT', '64M');</code> to your <code>wp-config.php</code>.
806
  <a href="https://www.thenewsletterplugin.com/documentation/status-panel#status-memory" target="_blank">Read more</a>.
@@ -815,7 +818,8 @@ $options = $module->get_options('status');
815
 
816
  </td>
817
  </tr>
818
-
 
819
  <?php
820
  $ip = gethostbyname($_SERVER['HTTP_HOST']);
821
  $name = gethostbyaddr($ip);
@@ -1068,4 +1072,4 @@ $options = $module->get_options('status');
1068
 
1069
  <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
1070
 
1071
- </div>
2
  if (!defined('ABSPATH'))
3
  exit;
4
 
5
+
6
  @include_once NEWSLETTER_INCLUDES_DIR . '/controls.php';
7
  $module = Newsletter::instance();
8
  $controls = new NewsletterControls();
733
  Send details
734
  </td>
735
  <td>
736
+ <?php if ($send_mean > 1) { ?>
737
+ <span class="tnp-ko">KO</span>
738
+ <?php } else { ?>
739
+ <span class="tnp-ok">OK</span>
740
+ <?php } ?>
741
  </td>
742
  <td>
743
  <?php if ($send_mean > 1) { ?>
744
+ <strong>Sending an email is taking more than 1 second, rather slow.</strong>
745
+ <a href="https://www.thenewsletterplugin.com/documentation/status-panel#status-performance" target="_blank">Read more</a>.
746
  <?php } ?>
747
  Average time to send an email: <?php echo sprintf("%.2f", $send_mean) ?> seconds<br>
748
  <?php if ($send_mean > 0) { ?>
749
+ Max speed: <?php echo sprintf("%.2f", 1.0 / $send_mean * 3600) ?> emails per hour<br>
750
  <?php } ?>
751
+
752
  Max mean time measured: <?php echo sprintf("%.2f", $send_max) ?> seconds<br>
753
  Min mean time measured: <?php echo sprintf("%.2f", $send_min) ?> seconds<br>
754
  Total email in the sample: <?php echo $send_total_emails ?><br>
782
 
783
 
784
 
785
+ <?php /*
786
  $memory = intval(WP_MEMORY_LIMIT);
787
  if (false !== strpos(WP_MEMORY_LIMIT, 'G'))
788
  $memory *= 1024;
793
  </td>
794
  <td>
795
  <?php if ($memory < 64) { ?>
796
+ <span class="tnp-ko">MAYBE</span>
797
  <?php } else if ($memory < 128) { ?>
798
  <span class="tnp-maybe">MAYBE</span>
799
  <?php } else { ?>
801
  <?php } ?>
802
  </td>
803
  <td>
804
+ WordPress WP_MEMORY_LIMIT is set to <?php echo $memory ?> megabyte but your PHP setting could allow more than that.
805
+ Anyway we suggest to set the value to at least 64M.
806
+ <a href="https://www.thenewsletterplugin.com/documentation/status-panel#status-memory" target="_blank">Read more</a>.
807
  <?php if ($memory < 64) { ?>
808
  This value is too low you should increase it adding <code>define('WP_MEMORY_LIMIT', '64M');</code> to your <code>wp-config.php</code>.
809
  <a href="https://www.thenewsletterplugin.com/documentation/status-panel#status-memory" target="_blank">Read more</a>.
818
 
819
  </td>
820
  </tr>
821
+ */ ?>
822
+
823
  <?php
824
  $ip = gethostbyname($_SERVER['HTTP_HOST']);
825
  $name = gethostbyaddr($ip);
1072
 
1073
  <?php include NEWSLETTER_DIR . '/tnp-footer.php'; ?>
1074
 
1075
+ </div>
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.2.6
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.2.6');
18
 
19
  global $wpdb, $newsletter;
20
 
@@ -66,6 +66,7 @@ require_once NEWSLETTER_INCLUDES_DIR . '/logger.php';
66
  require_once NEWSLETTER_INCLUDES_DIR . '/store.php';
67
  require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
68
  require_once NEWSLETTER_INCLUDES_DIR . '/themes.php';
 
69
 
70
  class Newsletter extends NewsletterModule {
71
 
@@ -398,6 +399,9 @@ class Newsletter extends NewsletterModule {
398
  wp_enqueue_media();
399
  wp_enqueue_style('tnp-admin', plugins_url('newsletter') . '/admin.css', array(), filemtime(NEWSLETTER_DIR . '/admin.css'));
400
  wp_enqueue_script('tnp-admin', plugins_url('newsletter') . '/admin.js', array('jquery'), time());
 
 
 
401
 
402
  wp_enqueue_style('tnp-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css');
403
  wp_enqueue_script('tnp-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js');
@@ -537,8 +541,9 @@ class Newsletter extends NewsletterModule {
537
  if ($users == null) {
538
 
539
  $skip_this_run = apply_filters('newsletter_send_skip', false, $email);
540
- if ($skip_this_run)
541
  return false;
 
542
 
543
  if (empty($email->query)) {
544
  $email->query = "select * from " . NEWSLETTER_USERS_TABLE . " where status='C'";
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.2.7
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.2.7');
18
 
19
  global $wpdb, $newsletter;
20
 
66
  require_once NEWSLETTER_INCLUDES_DIR . '/store.php';
67
  require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
68
  require_once NEWSLETTER_INCLUDES_DIR . '/themes.php';
69
+ require_once NEWSLETTER_INCLUDES_DIR . '/TNP.php';
70
 
71
  class Newsletter extends NewsletterModule {
72
 
399
  wp_enqueue_media();
400
  wp_enqueue_style('tnp-admin', plugins_url('newsletter') . '/admin.css', array(), filemtime(NEWSLETTER_DIR . '/admin.css'));
401
  wp_enqueue_script('tnp-admin', plugins_url('newsletter') . '/admin.js', array('jquery'), time());
402
+
403
+ wp_enqueue_style('wp-color-picker');
404
+ wp_enqueue_script('wp-color-picker');
405
 
406
  wp_enqueue_style('tnp-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css');
407
  wp_enqueue_script('tnp-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js');
541
  if ($users == null) {
542
 
543
  $skip_this_run = apply_filters('newsletter_send_skip', false, $email);
544
+ if ($skip_this_run) {
545
  return false;
546
+ }
547
 
548
  if (empty($email->query)) {
549
  $email->query = "select * from " . NEWSLETTER_USERS_TABLE . " where status='C'";
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.4
5
- Stable tag: 5.2.5
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -88,6 +88,14 @@ Thank you, The Newsletter Team
88
 
89
  == Changelog ==
90
 
 
 
 
 
 
 
 
 
91
  = 5.2.6 =
92
 
93
  * Fixed url attributes on privacy field shortcode
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.4
5
+ Stable tag: 5.2.7
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
88
 
89
  == Changelog ==
90
 
91
+ = NEXT =
92
+
93
+ * Improved block layout
94
+ * Added filter on profile url
95
+ * Removed old obsolete query
96
+ * Improved the antibot
97
+ * Antiflood configurable to 30 minutes
98
+
99
  = 5.2.6 =
100
 
101
  * Fixed url attributes on privacy field shortcode
statistics/statistics.php CHANGED
@@ -64,10 +64,10 @@ class NewsletterStatistics extends NewsletterModule {
64
 
65
  $parts = parse_url($url);
66
 
67
- $verified = $parts['host'] == $_SERVER['HTTP_HOST'];
68
- if (!$verified) {
69
  $verified = $signature == md5($email_id . ';' . $user_id . ';' . $url . ';' . $anchor . $this->options['key']);
70
- }
71
 
72
  if (!$verified) {
73
  header("HTTP/1.0 404 Not Found");
@@ -94,19 +94,33 @@ class NewsletterStatistics extends NewsletterModule {
94
 
95
  setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
96
 
97
- $ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
98
 
99
- $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
100
- 'email_id' => $email_id,
101
- 'user_id' => $user_id,
102
- 'url' => $url,
103
- 'ip' => $ip
104
- )
105
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  $wpdb->query($wpdb->prepare("update " . NEWSLETTER_SENT_TABLE . " set open=2, ip=%s where email_id=%d and user_id=%d limit 1", $ip, $email_id, $user_id));
108
 
109
- header('Location: ' . apply_filters('newsletter_redirect_url', $url, $email, $user));
 
110
  die();
111
  }
112
 
@@ -138,8 +152,8 @@ class NewsletterStatistics extends NewsletterModule {
138
  } else {
139
  $this->logger->info('Email with no token hence not signature to check');
140
  }
141
-
142
- $ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
143
 
144
  $row = $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_STATS_TABLE . " where email_id=%d and user_id=%d and url='' limit 1", $email->id, $user->id));
145
  if ($row) {
@@ -150,7 +164,7 @@ class NewsletterStatistics extends NewsletterModule {
150
  $res = $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
151
  'email_id' => (int) $email_id,
152
  'user_id' => (int) $user_id,
153
- 'ip' => $_SERVER['REMOTE_ADDR'])
154
  );
155
  if (!$res) {
156
  $this->logger->fatal($wpdb->last_error);
@@ -223,10 +237,9 @@ class NewsletterStatistics extends NewsletterModule {
223
  return $matches[0];
224
  }
225
 
226
- if (strpos($href, '?na=') !== false) {
227
- return $matches[0];
228
- }
229
-
230
  // Do not relink anchors
231
  if (substr($href, 0, 1) == '#') {
232
  return $matches[0];
@@ -324,6 +337,20 @@ class NewsletterStatistics extends NewsletterModule {
324
  return (int) $wpdb->get_var($wpdb->prepare("select count(*) from " . NEWSLETTER_SENT_TABLE . " where status>0 and email_id=%d", $this->to_int_id($email_id)));
325
  }
326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  }
328
 
329
  NewsletterStatistics::instance();
64
 
65
  $parts = parse_url($url);
66
 
67
+ //$verified = $parts['host'] == $_SERVER['HTTP_HOST'];
68
+ //if (!$verified) {
69
  $verified = $signature == md5($email_id . ';' . $user_id . ';' . $url . ';' . $anchor . $this->options['key']);
70
+ //}
71
 
72
  if (!$verified) {
73
  header("HTTP/1.0 404 Not Found");
94
 
95
  setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
96
 
97
+ $is_action = strpos($url, '?na=');
98
 
99
+ $ip = $this->get_remote_ip();
100
+
101
+ if (!$is_action) {
102
+ $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
103
+ 'email_id' => $email_id,
104
+ 'user_id' => $user_id,
105
+ 'url' => $url,
106
+ 'ip' => $ip
107
+ )
108
+ );
109
+ } else {
110
+ $this->logger->debug('Is an action');
111
+ // Uhm...
112
+ // if (!strpos($url, 'nk=')) {
113
+ // $url = $this->add_qs($url, 'nk=' . $user->id . '-' . $user->token, false);
114
+ // }
115
+ // if (!strpos($url, 'nek=')) {
116
+ // $url = $this->add_qs($url, 'nek=' . $email->id . '-' . $email->token, false);
117
+ // }
118
+ }
119
 
120
  $wpdb->query($wpdb->prepare("update " . NEWSLETTER_SENT_TABLE . " set open=2, ip=%s where email_id=%d and user_id=%d limit 1", $ip, $email_id, $user_id));
121
 
122
+ wp_safe_redirect(apply_filters('newsletter_redirect_url', $url, $email, $user));
123
+
124
  die();
125
  }
126
 
152
  } else {
153
  $this->logger->info('Email with no token hence not signature to check');
154
  }
155
+
156
+ $ip = $this->get_remote_ip();
157
 
158
  $row = $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_STATS_TABLE . " where email_id=%d and user_id=%d and url='' limit 1", $email->id, $user->id));
159
  if ($row) {
164
  $res = $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
165
  'email_id' => (int) $email_id,
166
  'user_id' => (int) $user_id,
167
+ 'ip' => $ip)
168
  );
169
  if (!$res) {
170
  $this->logger->fatal($wpdb->last_error);
237
  return $matches[0];
238
  }
239
 
240
+ // if (strpos($href, '?na=') !== false) {
241
+ // return $matches[0];
242
+ // }
 
243
  // Do not relink anchors
244
  if (substr($href, 0, 1) == '#') {
245
  return $matches[0];
337
  return (int) $wpdb->get_var($wpdb->prepare("select count(*) from " . NEWSLETTER_SENT_TABLE . " where status>0 and email_id=%d", $this->to_int_id($email_id)));
338
  }
339
 
340
+ function add_click($url, $user_id, $email_id, $ip = null) {
341
+ global $wpdb;
342
+ if (is_null($ip)) {
343
+ $ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
344
+ }
345
+ $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
346
+ 'email_id' => $user_id,
347
+ 'user_id' => $email_id,
348
+ 'url' => $url,
349
+ 'ip' => $ip
350
+ )
351
+ );
352
+ }
353
+
354
  }
355
 
356
  NewsletterStatistics::instance();
subscription/options.php CHANGED
@@ -274,7 +274,10 @@ if (empty($controls->data['page'])) {
274
  30 => '30 ' . __('seconds', 'newsletter'),
275
  60 => '1 ' . __('minute', 'newsletter'),
276
  120 => '2 ' . __('minutes', 'newsletter'),
277
- 300 => '5 ' . __('minutes', 'newsletter')
 
 
 
278
  ));
279
  ?>
280
  <?php $controls->help('https://www.thenewsletterplugin.com/documentation/antiflood') ?>
@@ -323,7 +326,7 @@ if (empty($controls->data['page'])) {
323
  </tr>
324
 
325
  <tr>
326
- <th><?php _e ('Alternative activation page', 'newsletter'); ?></th>
327
  <td>
328
  <?php $controls->text('confirmation_url', 70, 'https://...'); ?>
329
  </td>
274
  30 => '30 ' . __('seconds', 'newsletter'),
275
  60 => '1 ' . __('minute', 'newsletter'),
276
  120 => '2 ' . __('minutes', 'newsletter'),
277
+ 300 => '5 ' . __('minutes', 'newsletter'),
278
+ 600 => '10 ' . __('minutes', 'newsletter'),
279
+ 900 => '15 ' . __('minutes', 'newsletter'),
280
+ 1800 => '30 ' . __('minutes', 'newsletter')
281
  ));
282
  ?>
283
  <?php $controls->help('https://www.thenewsletterplugin.com/documentation/antiflood') ?>
326
  </tr>
327
 
328
  <tr>
329
+ <th><?php _e('Alternative activation page', 'newsletter'); ?></th>
330
  <td>
331
  <?php $controls->text('confirmation_url', 70, 'https://...'); ?>
332
  </td>
subscription/subscription.php CHANGED
@@ -84,6 +84,40 @@ class NewsletterSubscription extends NewsletterModule {
84
  global $newsletter, $wpdb;
85
 
86
  switch ($newsletter->action) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  case 'm':
88
  include dirname(__FILE__) . '/page.php';
89
  die();
84
  global $newsletter, $wpdb;
85
 
86
  switch ($newsletter->action) {
87
+ case 'profile-change':
88
+ if ($this->antibot_form_check()) {
89
+ $user = $this->get_user_from_request();
90
+ if (!$user || $user->status != 'C') {
91
+ die('Subscriber not found or not active.');
92
+ }
93
+
94
+ $email = $this->get_email_from_request();
95
+ if (!$email) {
96
+ die('Newsletter not found');
97
+ }
98
+
99
+ if (isset($_REQUEST['list'])) {
100
+ $list_id = (int) $_REQUEST['list'];
101
+
102
+ // Check if the list is public
103
+ $list = $this->get_list($list_id);
104
+ if (!$list || $list['status'] == 0) {
105
+ die('Private list.');
106
+ }
107
+
108
+ $url = $_REQUEST['redirect'];
109
+
110
+ $this->set_user_list($user, $list_id, $_REQUEST['value']);
111
+ NewsletterStatistics::instance()->add_click(wp_sanitize_redirect($url), $user->id, $email->id);
112
+ wp_safe_redirect($url);
113
+ die();
114
+ }
115
+ } else {
116
+ $this->request_to_antibot_form('Continue');
117
+ }
118
+
119
+ die();
120
+
121
  case 'm':
122
  include dirname(__FILE__) . '/page.php';
123
  die();
users/users.php CHANGED
@@ -90,7 +90,7 @@ class NewsletterUsers extends NewsletterModule {
90
  $sql .= "PRIMARY KEY (`id`),\nUNIQUE KEY `email` (`email`),\nKEY `wp_user_id` (`wp_user_id`)\n) $charset_collate;";
91
 
92
  dbDelta($sql);
93
- $this->upgrade_query("alter table " . NEWSLETTER_USERS_TABLE . " convert to character set $charset_collate");
94
  }
95
 
96
  function admin_menu() {
90
  $sql .= "PRIMARY KEY (`id`),\nUNIQUE KEY `email` (`email`),\nKEY `wp_user_id` (`wp_user_id`)\n) $charset_collate;";
91
 
92
  dbDelta($sql);
93
+
94
  }
95
 
96
  function admin_menu() {