Newsletter - Version 3.2.4

Version Description

  • Added target _blank on theme links so they open on a new windows for the online version
  • Changed to the plugins_url() function
  • Added clean up of url tags on composer
Download this release

Release Info

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

Code changes from version 3.2.3 to 3.2.4

config-sample.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Move this file inside the /wp_content/newsletter folder to activate it and rename it
5
- * "config.php".
6
- *
7
- */
8
-
9
- // Even if still called "list" those are the user's "preferences"
10
- // define('NEWSLETTER_LIST_MAX', 20);
11
- // define('NEWSLETTER_PROFILE_MAX', 20);
12
- // define('NEWSLETTER_FORMS_MAX', 10);
13
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
do/subscription.php CHANGED
@@ -14,7 +14,7 @@ if (!empty($options_main['url'])) {
14
  $options = get_option('newsletter', array());
15
 
16
  if (stripos($options['subscription_text'], '<form') !== false) {
17
- $message = str_ireplace('<form', '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '" onsubmit="return newsletter_check(this)"', $options['subscription_text']);
18
  $message = $this->replace_lists($message);
19
  } else {
20
  $form = $newsletter->subscription_form();
14
  $options = get_option('newsletter', array());
15
 
16
  if (stripos($options['subscription_text'], '<form') !== false) {
17
+ $message = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)"', $options['subscription_text']);
18
  $message = $this->replace_lists($message);
19
  } else {
20
  $form = $newsletter->subscription_form();
emails/edit.php CHANGED
@@ -111,6 +111,9 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
111
  if ($controls->is_action('editor')) {
112
  $email['editor'] = $email['editor'] == 0?1:0;
113
  }
 
 
 
114
 
115
  $res = Newsletter::instance()->save_email($email);
116
  if ($res === false) {
@@ -172,7 +175,7 @@ if ($email['editor'] == 0) {
172
 
173
  ?>
174
 
175
- <script type="text/javascript" src="<?php echo NEWSLETTER_URL; ?>/tiny_mce/tiny_mce.js"></script>
176
  <script type="text/javascript">
177
  tinyMCE.init({
178
  mode : "specific_textareas",
@@ -188,7 +191,7 @@ if ($email['editor'] == 0) {
188
  theme_advanced_resizing : true,
189
  theme_advanced_toolbar_location : "top",
190
  document_base_url : "<?php echo get_option('home'); ?>/",
191
- content_css: "<?php echo NEWSLETTER_URL . '/emails/css.php?id=' . $email_id . '&' . time(); ?>"
192
  });
193
 
194
  jQuery(document).ready(function() {
@@ -326,7 +329,7 @@ if ($email['editor'] == 0) {
326
  </td>
327
  </tr>
328
  <tr valign="top">
329
- <th>Track message links?</th>
330
  <td>
331
  <?php $controls->yesno('track'); ?>
332
  <div class="hints">
111
  if ($controls->is_action('editor')) {
112
  $email['editor'] = $email['editor'] == 0?1:0;
113
  }
114
+
115
+ // Cleans up of tag
116
+ $email['message'] = NewsletterModule::clean_url_tags($email['message']);
117
 
118
  $res = Newsletter::instance()->save_email($email);
119
  if ($res === false) {
175
 
176
  ?>
177
 
178
+ <script type="text/javascript" src="<?php echo plugins_url('newsletter'); ?>/tiny_mce/tiny_mce.js"></script>
179
  <script type="text/javascript">
180
  tinyMCE.init({
181
  mode : "specific_textareas",
191
  theme_advanced_resizing : true,
192
  theme_advanced_toolbar_location : "top",
193
  document_base_url : "<?php echo get_option('home'); ?>/",
194
+ content_css: "<?php echo plugins_url('newsletter') . '/emails/css.php?id=' . $email_id . '&' . time(); ?>"
195
  });
196
 
197
  jQuery(document).ready(function() {
329
  </td>
330
  </tr>
331
  <tr valign="top">
332
+ <th>Track clicks and opening?</th>
333
  <td>
334
  <?php $controls->yesno('track'); ?>
335
  <div class="hints">
emails/new.php CHANGED
@@ -130,12 +130,12 @@ function newsletter_emails_get_theme_options($theme) {
130
  <div class="tab-preamble">
131
  <p>After the email is created, you can edit every part of this message.</p>
132
  </div>
133
- <iframe src="<?php echo wp_nonce_url(NEWSLETTER_URL . '/emails/preview.php?' . time()); ?>" width="100%" height="700"></iframe>
134
  </div>
135
 
136
 
137
  <div id="tabs-3">
138
- <iframe src="<?php echo wp_nonce_url(NEWSLETTER_URL . '/emails/preview-text.php?' . time()); ?>" width="100%" height="500"></iframe>
139
  </div>
140
 
141
  </div>
130
  <div class="tab-preamble">
131
  <p>After the email is created, you can edit every part of this message.</p>
132
  </div>
133
+ <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview.php?' . time()); ?>" width="100%" height="700"></iframe>
134
  </div>
135
 
136
 
137
  <div id="tabs-3">
138
+ <iframe src="<?php echo wp_nonce_url(plugins_url('newsletter') . '/emails/preview-text.php?' . time()); ?>" width="100%" height="500"></iframe>
139
  </div>
140
 
141
  </div>
emails/themes/default/theme.php CHANGED
@@ -37,7 +37,7 @@ if (isset($theme_options['theme_posts'])) $posts = get_posts(array('showposts'=>
37
  </div>
38
  <div style="padding: 20px; background-color: #fff; line-height: 18px">
39
 
40
- <p style="text-align: center"><a href="{email_url}">View this email online</a></p>
41
 
42
  <?php if (empty($posts)) { ?>
43
  <p>Here you can start to write your message. Be polite with your readers! Do not forget the subsject of this message.</p>
@@ -46,10 +46,10 @@ if (isset($theme_options['theme_posts'])) $posts = get_posts(array('showposts'=>
46
  <?php foreach ($posts as $post) { setup_postdata($post); ?>
47
  <tr>
48
  <?php if (isset($theme_options['theme_thumbnails'])) { ?>
49
- <td><a href="<?php echo get_permalink(); ?>"><img width="75" src="<?php echo newsletter_get_post_image($post->ID); ?>" alt="image"></a></td>
50
  <?php } ?>
51
  <td valign="top">
52
- <a href="<?php echo get_permalink(); ?>" style="font-size: 20px; line-height: 26px"><?php the_title(); ?></a>
53
  <?php if (isset($theme_options['theme_excerpts'])) the_excerpt(); ?>
54
  </td>
55
  </tr>
@@ -57,7 +57,7 @@ if (isset($theme_options['theme_posts'])) $posts = get_posts(array('showposts'=>
57
  </table>
58
  <?php } ?>
59
 
60
- <p>To change your subscription, <a href="{profile_url}">click here</a>.
61
  </div>
62
 
63
  </div>
37
  </div>
38
  <div style="padding: 20px; background-color: #fff; line-height: 18px">
39
 
40
+ <p style="text-align: center"><a target="_tab" href="{email_url}">View this email online</a></p>
41
 
42
  <?php if (empty($posts)) { ?>
43
  <p>Here you can start to write your message. Be polite with your readers! Do not forget the subsject of this message.</p>
46
  <?php foreach ($posts as $post) { setup_postdata($post); ?>
47
  <tr>
48
  <?php if (isset($theme_options['theme_thumbnails'])) { ?>
49
+ <td><a target="_tab" href="<?php echo get_permalink(); ?>"><img width="75" src="<?php echo newsletter_get_post_image($post->ID); ?>" alt="image"></a></td>
50
  <?php } ?>
51
  <td valign="top">
52
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="font-size: 20px; line-height: 26px"><?php the_title(); ?></a>
53
  <?php if (isset($theme_options['theme_excerpts'])) the_excerpt(); ?>
54
  </td>
55
  </tr>
57
  </table>
58
  <?php } ?>
59
 
60
+ <p>To change your subscription, <a target="_tab" href="{profile_url}">click here</a>.
61
  </div>
62
 
63
  </div>
emails/themes/pint/theme.php CHANGED
@@ -22,7 +22,7 @@ $posts = get_posts(array('post_status'=>'publish', 'showposts'=>9));
22
  <table align="center">
23
  <tr>
24
  <td align="center">
25
- <small><a href="{email_url}" style="color: #666; text-decoration: none">View this email online</a></small>
26
  <br>
27
  <div style="color: #b00; font-size: 50px; font-family: serif; font-style: italic;">
28
  <?php echo get_option('blogname'); ?>
@@ -34,24 +34,24 @@ $posts = get_posts(array('post_status'=>'publish', 'showposts'=>9));
34
  <tr>
35
  <?php for ($i=0; $i<3; $i++) { $post = $posts[$i]; setup_postdata($post); ?>
36
  <td align="center" valign="top">
37
- <a href="<?php echo get_permalink(); ?>" style="font-size: 14px; line-height: 26px; font-weight: bold; color: #000; text-decoration: none"><?php echo substr(get_the_title(), 0, 25); ?>...</a><br>
38
- <a href="<?php echo get_permalink(); ?>" style="display: block; width: 200px; height: 170px; overflow: hidden"><img width="200" src="<?php echo newsletter_get_post_image($post->ID, 'medium'); ?>" alt=""></a>
39
  </td>
40
  <?php } ?>
41
  </tr>
42
  <tr>
43
  <?php for ($i=3; $i<6; $i++) { $post = $posts[$i]; setup_postdata($post); ?>
44
  <td align="center" valign="top">
45
- <a href="<?php echo get_permalink(); ?>" style="font-size: 14px; line-height: 26px; font-weight: bold; color: #000; text-decoration: none"><?php echo substr(get_the_title(), 0, 25); ?>...</a><br>
46
- <a href="<?php echo get_permalink(); ?>" style="display: block; width: 200px; height: 170px; overflow: hidden"><img width="200" src="<?php echo newsletter_get_post_image($post->ID, 'medium'); ?>" alt=""></a>
47
  </td>
48
  <?php } ?>
49
  </tr>
50
  <tr>
51
  <?php for ($i=6; $i<9; $i++) { $post = $posts[$i]; setup_postdata($post); ?>
52
  <td align="center" valign="top">
53
- <a href="<?php echo get_permalink(); ?>" style="font-size: 14px; line-height: 26px; font-weight: bold; color: #000; text-decoration: none"><?php echo substr(get_the_title(), 0, 25); ?>...</a><br>
54
- <a href="<?php echo get_permalink(); ?>" style="display: block; width: 200px; height: 170px; overflow: hidden"><img width="200" src="<?php echo newsletter_get_post_image($post->ID, 'medium'); ?>" alt=""></a>
55
  </td>
56
  <?php } ?>
57
  </tr>
@@ -59,7 +59,7 @@ $posts = get_posts(array('post_status'=>'publish', 'showposts'=>9));
59
 
60
  <br><br>
61
 
62
- <small>To change your subscription, <a href="{profile_url}" style="color: #666; text-decoration: none">click here</a></small>
63
 
64
  </td>
65
  </tr>
22
  <table align="center">
23
  <tr>
24
  <td align="center">
25
+ <small><a target="_tab" href="{email_url}" style="color: #666; text-decoration: none">View this email online</a></small>
26
  <br>
27
  <div style="color: #b00; font-size: 50px; font-family: serif; font-style: italic;">
28
  <?php echo get_option('blogname'); ?>
34
  <tr>
35
  <?php for ($i=0; $i<3; $i++) { $post = $posts[$i]; setup_postdata($post); ?>
36
  <td align="center" valign="top">
37
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="font-size: 14px; line-height: 26px; font-weight: bold; color: #000; text-decoration: none"><?php echo substr(get_the_title(), 0, 25); ?>...</a><br>
38
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="display: block; width: 200px; height: 170px; overflow: hidden"><img width="200" src="<?php echo newsletter_get_post_image($post->ID, 'medium'); ?>" alt=""></a>
39
  </td>
40
  <?php } ?>
41
  </tr>
42
  <tr>
43
  <?php for ($i=3; $i<6; $i++) { $post = $posts[$i]; setup_postdata($post); ?>
44
  <td align="center" valign="top">
45
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="font-size: 14px; line-height: 26px; font-weight: bold; color: #000; text-decoration: none"><?php echo substr(get_the_title(), 0, 25); ?>...</a><br>
46
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="display: block; width: 200px; height: 170px; overflow: hidden"><img width="200" src="<?php echo newsletter_get_post_image($post->ID, 'medium'); ?>" alt=""></a>
47
  </td>
48
  <?php } ?>
49
  </tr>
50
  <tr>
51
  <?php for ($i=6; $i<9; $i++) { $post = $posts[$i]; setup_postdata($post); ?>
52
  <td align="center" valign="top">
53
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="font-size: 14px; line-height: 26px; font-weight: bold; color: #000; text-decoration: none"><?php echo substr(get_the_title(), 0, 25); ?>...</a><br>
54
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="display: block; width: 200px; height: 170px; overflow: hidden"><img width="200" src="<?php echo newsletter_get_post_image($post->ID, 'medium'); ?>" alt=""></a>
55
  </td>
56
  <?php } ?>
57
  </tr>
59
 
60
  <br><br>
61
 
62
+ <small>To change your subscription, <a target="_tab" href="{profile_url}" style="color: #666; text-decoration: none">click here</a></small>
63
 
64
  </td>
65
  </tr>
emails/themes/theme-1/theme.php CHANGED
@@ -81,7 +81,7 @@ $posts = get_posts($filters);
81
  <?php if ($image != null) { ?>
82
  <img src="<?php echo $image; ?>" alt="picture" align="left"/>
83
  <?php } ?>
84
- <p><a href="<?php echo get_permalink(); ?>" style="font-size: 16px; color: #000; text-decoration: none"><?php the_title(); ?></a></p>
85
 
86
  <?php the_excerpt(); ?>
87
  </td>
@@ -91,7 +91,7 @@ $posts = get_posts($filters);
91
  ?>
92
  <tr>
93
  <td style="border-top: 1px solid #eee; border-bottom: 1px solid #eee; font-size: 12px; color: #999">
94
- You received this email because you subscribed for it as {email}. If you'd like, you can <a href="{unsubscription_url}">unsubscribe</a>.
95
  </td>
96
  </tr>
97
  </table>
81
  <?php if ($image != null) { ?>
82
  <img src="<?php echo $image; ?>" alt="picture" align="left"/>
83
  <?php } ?>
84
+ <p><a target="_tab" href="<?php echo get_permalink(); ?>" style="font-size: 16px; color: #000; text-decoration: none"><?php the_title(); ?></a></p>
85
 
86
  <?php the_excerpt(); ?>
87
  </td>
91
  ?>
92
  <tr>
93
  <td style="border-top: 1px solid #eee; border-bottom: 1px solid #eee; font-size: 12px; color: #999">
94
+ You received this email because you subscribed for it as {email}. If you'd like, you can <a target="_tab" href="{unsubscription_url}">unsubscribe</a>.
95
  </td>
96
  </tr>
97
  </table>
emails/themes/theme-3/theme.php CHANGED
@@ -82,7 +82,7 @@ $posts = get_posts($filters);
82
  <?php if ($image != null) { ?>
83
  <img src="<?php echo $image; ?>" alt="picture" align="left" width="100" height="100" style="margin-right: 10px"/>
84
  <?php } ?>
85
- <a href="<?php echo get_permalink(); ?>" style="color: #000; text-decoration: none"><b><?php the_title(); ?></b></a><br />
86
 
87
  <?php the_excerpt(); ?>
88
  </td>
@@ -103,9 +103,9 @@ $posts = get_posts($filters);
103
  This email was sent to <b>{email}</b> because you opted in on <?php echo get_option('blogname'); ?> website.
104
  <br />
105
 
106
- <a href="{profile_url}">Manage Subscriptions</a> |
107
 
108
- <a href="{unsubscription_url}">Unsubscribe</a>
109
  </td>
110
  </tr>
111
  </table>
82
  <?php if ($image != null) { ?>
83
  <img src="<?php echo $image; ?>" alt="picture" align="left" width="100" height="100" style="margin-right: 10px"/>
84
  <?php } ?>
85
+ <a target="_tab" href="<?php echo get_permalink(); ?>" style="color: #000; text-decoration: none"><b><?php the_title(); ?></b></a><br />
86
 
87
  <?php the_excerpt(); ?>
88
  </td>
103
  This email was sent to <b>{email}</b> because you opted in on <?php echo get_option('blogname'); ?> website.
104
  <br />
105
 
106
+ <a target="_tab" href="{profile_url}">Manage Subscriptions</a> |
107
 
108
+ <a target="_tab" href="{unsubscription_url}">Unsubscribe</a>
109
  </td>
110
  </tr>
111
  </table>
emails/themes/vimeo-like/theme.php CHANGED
@@ -74,7 +74,7 @@ $font_size = $theme_options['theme_font_size'];
74
 
75
 
76
 
77
- <p style="color:#456;font-family:arial,sans-serif;font-size:24px;line-height:1.2;margin:15px 0;padding:0"><a href="<?php echo get_option('home'); ?>" style="color:#28c;text-decoration:none" target="_blank"><?php echo get_option('blogname'); ?></a></p>
78
 
79
 
80
  <?php
@@ -90,7 +90,7 @@ foreach ($posts as $post) {
90
 
91
  <td style="width:100%;padding:0 10px 0 0;vertical-align:top">
92
 
93
- <p style="font-family:arial,sans-serif;color:#456;font-size:20px;line-height:22px;margin:0;padding:0"><strong><a href="<?php echo get_permalink(); ?>" style="color:#456;text-decoration:none" target="_blank"><?php the_title(); ?></a></strong></p>
94
 
95
  <p style="font-family:arial,sans-serif;line-height:1.5em;margin:15px 0;padding:0"><?php the_excerpt(); ?>. </p>
96
 
@@ -98,9 +98,9 @@ foreach ($posts as $post) {
98
 
99
  <td style="vertical-align:middle; width: 100px">
100
 
101
- <a href="<?php echo get_permalink(); ?>" target="_blank"><img src="<?php echo $image; ?>" alt="" width="100" border="0" height="100"></a>
102
 
103
- <p style="background:#2786c2;text-align:center;margin:10px 0 0 0;font-size:11px;line-height:14px;font-family:arial,sans-serif;padding:4px 2px;border-radius:4px"><a href="<?php echo get_permalink(); ?>" style="color:#fff;text-decoration:none" target="_blank"><strong><?php echo $theme_options['theme_read_more']; ?></strong></a></p>
104
 
105
  </td>
106
 
74
 
75
 
76
 
77
+ <p style="color:#456;font-family:arial,sans-serif;font-size:24px;line-height:1.2;margin:15px 0;padding:0"><a target="_tab" href="<?php echo get_option('home'); ?>" style="color:#28c;text-decoration:none" target="_blank"><?php echo get_option('blogname'); ?></a></p>
78
 
79
 
80
  <?php
90
 
91
  <td style="width:100%;padding:0 10px 0 0;vertical-align:top">
92
 
93
+ <p style="font-family:arial,sans-serif;color:#456;font-size:20px;line-height:22px;margin:0;padding:0"><strong><a target="_tab" href="<?php echo get_permalink(); ?>" style="color:#456;text-decoration:none" target="_blank"><?php the_title(); ?></a></strong></p>
94
 
95
  <p style="font-family:arial,sans-serif;line-height:1.5em;margin:15px 0;padding:0"><?php the_excerpt(); ?>. </p>
96
 
98
 
99
  <td style="vertical-align:middle; width: 100px">
100
 
101
+ <a target="_tab" href="<?php echo get_permalink(); ?>" target="_blank"><img src="<?php echo $image; ?>" alt="" width="100" border="0" height="100"></a>
102
 
103
+ <p style="background:#2786c2;text-align:center;margin:10px 0 0 0;font-size:11px;line-height:14px;font-family:arial,sans-serif;padding:4px 2px;border-radius:4px"><a target="_tab" href="<?php echo get_permalink(); ?>" style="color:#fff;text-decoration:none" target="_blank"><strong><?php echo $theme_options['theme_read_more']; ?></strong></a></p>
104
 
105
  </td>
106
 
feed/index.php CHANGED
@@ -227,14 +227,14 @@ else {
227
  next time.
228
  </p>
229
  </div>
230
- <iframe src="<?php echo NEWSLETTER_URL; ?>/feed/preview.php?<?php echo time(); ?>" width="100%" height="700"></iframe>
231
  </div>
232
 
233
 
234
  <div id="tabs-4">
235
  <div class="tab-preamble">
236
  <p>
237
- Posts below are the one will be included on next email (sheduled future posts are not counted so
238
  more posts could be included).
239
  </p>
240
  </div>
227
  next time.
228
  </p>
229
  </div>
230
+ <iframe src="<?php echo plugins_url('newsletter'); ?>/feed/preview.php?<?php echo time(); ?>" width="100%" height="700"></iframe>
231
  </div>
232
 
233
 
234
  <div id="tabs-4">
235
  <div class="tab-preamble">
236
  <p>
237
+ Posts below are the one will be included on next email (scheduled future posts are not counted so
238
  more posts could be included).
239
  </p>
240
  </div>
header.php CHANGED
@@ -9,10 +9,9 @@ if (isset($_REQUEST['dismiss']) && check_admin_referer()) {
9
  ?>
10
  <?php if (NEWSLETTER_HEADER) { ?>
11
  <div id="newsletter-header">
12
- <a href="<?php echo $help_url?$help_url:'http://www.satollo.net/plugins/newsletter/newsletter-configuration'; ?>" target="_blank">Get Help</a>
13
- <a href="http://www.satollo.net/plugins/newsletter/newsletter-faq" target="_blank">FAQ</a>
14
  <a href="http://www.satollo.net/forums" target="_blank">Forum</a>
15
- <a href="http://www.satollo.net/membership" target="_blank">Membership</a>
16
  <!--<a href="http://www.satollo.net/plugins/newsletter/newsletter-collaboration" target="_blank">Collaboration</a>-->
17
 
18
  <form style="display: inline; margin: 0;" action="http://www.satollo.net/wp-content/plugins/newsletter/do/subscribe.php" method="post" target="_blank">
@@ -20,9 +19,9 @@ if (isset($_REQUEST['dismiss']) && check_admin_referer()) {
20
  <input type="submit" value="Go">
21
  </form>
22
 
23
- <a href="https://www.facebook.com/satollo.net" target="_blank"><img style="vertical-align: bottom" src="<?php echo NEWSLETTER_URL; ?>/images/facebook.png"></a>
24
 
25
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Y6JXSA7BSU2L" target="_blank"><img style="vertical-align: bottom" src="<?php echo NEWSLETTER_URL; ?>/images/donate.png"></a>
26
  <a href="http://www.satollo.net/donations" target="_blank">Even <b>1$</b> helps: why?</a>
27
  <!--
28
  <a href="http://www.satollo.net/plugins/newsletter/newsletter-delivery-engine" target="_blank">Engine next run in <?php echo wp_next_scheduled('newsletter') - time(); ?> s</a>
9
  ?>
10
  <?php if (NEWSLETTER_HEADER) { ?>
11
  <div id="newsletter-header">
12
+ <a href="http://www.satollo.net/plugins/newsletter/newsletter-documentation" target="_blank">Documentation</a>
 
13
  <a href="http://www.satollo.net/forums" target="_blank">Forum</a>
14
+ <a href="http://www.satollo.net/plugins/newsletter" target="_blank">Extend it now!</a>
15
  <!--<a href="http://www.satollo.net/plugins/newsletter/newsletter-collaboration" target="_blank">Collaboration</a>-->
16
 
17
  <form style="display: inline; margin: 0;" action="http://www.satollo.net/wp-content/plugins/newsletter/do/subscribe.php" method="post" target="_blank">
19
  <input type="submit" value="Go">
20
  </form>
21
 
22
+ <a href="https://www.facebook.com/satollo.net" target="_blank"><img style="vertical-align: bottom" src="<?php echo plugins_url('newsletter'); ?>/images/facebook.png"></a>
23
 
24
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Y6JXSA7BSU2L" target="_blank"><img style="vertical-align: bottom" src="<?php echo plugins_url('newsletter'); ?>/images/donate.png"></a>
25
  <a href="http://www.satollo.net/donations" target="_blank">Even <b>1$</b> helps: why?</a>
26
  <!--
27
  <a href="http://www.satollo.net/plugins/newsletter/newsletter-delivery-engine" target="_blank">Engine next run in <?php echo wp_next_scheduled('newsletter') - time(); ?> s</a>
includes/module.php CHANGED
@@ -122,12 +122,14 @@ class NewsletterModule {
122
  */
123
  function get_options($sub = '') {
124
  $options = get_option($this->get_prefix($sub));
125
- if ($options == false) return array();
 
126
  return $options;
127
  }
128
 
129
  function get_default_options($sub = '') {
130
- if (!empty($sub)) $sub .= '-';
 
131
  @include NEWSLETTER_DIR . '/' . $this->module . '/languages/' . $sub . 'en_US.php';
132
  @include WP_CONTENT_DIR . '/extensions/newsletter/' . $this->module . '/languages/' . $sub . 'en_US.php';
133
  @include NEWSLETTER_DIR . '/' . $this->module . '/languages/' . $sub . WPLANG . '.php';
@@ -162,7 +164,8 @@ class NewsletterModule {
162
  $this->themes->save_options($options['theme'], $options);
163
  }
164
  // TODO: To be remove since there is no more log level at module level (should it be reintroduced?)
165
- if (isset($options['log_level'])) update_option('newsletter_' . $this->module . '_log_level', $options['log_level']);
 
166
  }
167
  }
168
 
@@ -240,15 +243,19 @@ class NewsletterModule {
240
  */
241
  static function add_qs($url, $qs, $amp = true) {
242
  if (strpos($url, '?') !== false) {
243
- if ($amp) return $url . '&amp;' . $qs;
244
- else return $url . '&' . $qs;
 
 
245
  }
246
- else return $url . '?' . $qs;
 
247
  }
248
 
249
  static function normalize_email($email) {
250
  $email = strtolower(trim($email));
251
- if (!is_email($email)) return null;
 
252
  return $email;
253
  }
254
 
@@ -260,20 +267,26 @@ class NewsletterModule {
260
 
261
  static function normalize_sex($sex) {
262
  $sex = trim(strtolower($sex));
263
- if ($sex != 'f' && $sex != 'm') $sex = 'n';
 
264
  return $sex;
265
  }
266
 
267
  static function is_email($email, $empty_ok = false) {
268
  $email = strtolower(trim($email));
269
- if ($empty_ok && $email == '') return true;
 
270
 
271
- if (!is_email($email)) return false;
 
272
 
273
  // TODO: To be moved on the subscription module and make configurable
274
- if (strpos($email, 'mailinator.com') !== false) return false;
275
- if (strpos($email, 'guerrillamailblock.com') !== false) return false;
276
- if (strpos($email, 'emailtemporanea.net') !== false) return false;
 
 
 
277
  return true;
278
  }
279
 
@@ -293,7 +306,8 @@ class NewsletterModule {
293
  }
294
 
295
  static function format_date($time) {
296
- if (empty($time)) return '-';
 
297
  return gmdate(get_option('date_format') . ' ' . get_option('time_format'), $time + get_option('gmt_offset') * 3600);
298
  }
299
 
@@ -358,8 +372,10 @@ class NewsletterModule {
358
  static function split_posts(&$posts, $time = 0) {
359
  $result = array(array(), array());
360
  foreach ($posts as &$post) {
361
- if (self::is_post_old($post, $time)) $result[1][] = $post;
362
- else $result[0][] = $post;
 
 
363
  }
364
  return $result;
365
  }
@@ -371,8 +387,10 @@ class NewsletterModule {
371
  static function get_post_image($post_id = null, $size = 'thumbnail', $alternative = null) {
372
  global $post;
373
 
374
- if (empty($post_id)) $post_id = $post->ID;
375
- if (empty($post_id)) return $alternative;
 
 
376
 
377
  $image_id = function_exists('get_post_thumbnail_id') ? get_post_thumbnail_id($post_id) : false;
378
  if ($image_id) {
@@ -396,6 +414,17 @@ class NewsletterModule {
396
  return is_file(WP_CONTENT_DIR . "/extensions/newsletter/$name/$name.php");
397
  }
398
 
 
 
 
 
 
 
 
 
 
 
 
399
  function get_styles() {
400
 
401
  $list = array('' => 'none');
@@ -405,8 +434,10 @@ class NewsletterModule {
405
 
406
  if ($handle !== false) {
407
  while ($file = readdir($handle)) {
408
- if ($file == '.' || $file == '..') continue;
409
- if (substr($file, -4) != '.css') continue;
 
 
410
  $list[$file] = substr($file, 0, strlen($file) - 4);
411
  }
412
  closedir($handle);
@@ -417,9 +448,12 @@ class NewsletterModule {
417
 
418
  if ($handle !== false) {
419
  while ($file = readdir($handle)) {
420
- if ($file == '.' || $file == '..') continue;
421
- if (isset($list[$file])) continue;
422
- if (substr($file, -4) != '.css') continue;
 
 
 
423
  $list[$file] = substr($file, 0, strlen($file) - 4);
424
  }
425
  closedir($handle);
@@ -428,12 +462,14 @@ class NewsletterModule {
428
  }
429
 
430
  function get_style_url($style) {
431
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/' . $this->module . '/styles/' . $style)) return WP_CONTENT_URL . '/extensions/newsletter/' . $this->module . '/styles/' . $style;
432
- else return NEWSLETTER_URL . '/' . $this->module . '/styles/' . $style;
 
 
433
  }
434
 
435
  function admin_menu() {
436
-
437
  }
438
 
439
  function add_menu_page($page, $title) {
@@ -444,7 +480,8 @@ class NewsletterModule {
444
  }
445
  $name = 'newsletter_' . $this->module . '_' . $page;
446
  eval('function ' . $name . '(){global $newsletter, $wpdb;require \'' . $file . '\';}');
447
- add_submenu_page('newsletter_main_index', $title, $title, ($newsletter->options['editor'] == 1) ? 7 : 10, $name, $name);
 
448
  }
449
 
450
  function add_admin_page($page, $title) {
@@ -456,7 +493,7 @@ class NewsletterModule {
456
 
457
  $name = 'newsletter_' . $this->module . '_' . $page;
458
  eval('function ' . $name . '(){global $newsletter, $wpdb;require \'' . $file . '\';}');
459
- add_submenu_page(null, $title, $title, $newsletter->options['editor'] ? 7 : 10, $name, $name);
460
  }
461
 
462
  function get_admin_page_url($page) {
@@ -504,8 +541,10 @@ class NewsletterModule {
504
  global $wpdb;
505
 
506
  // To simplify the reaload of a user passing the user it self.
507
- if (is_object($id_or_email)) $id_or_email = $id_or_email->id;
508
- else if (is_array($id_or_email)) $id_or_email = $id_or_email['id'];
 
 
509
 
510
  $id_or_email = strtolower(trim($id_or_email));
511
 
@@ -531,11 +570,14 @@ class NewsletterModule {
531
  * @param array|object $user
532
  */
533
  function save_user($user, $return_format = OBJECT) {
534
- if (is_object($user)) $user = (array) $user;
 
535
  if (empty($user['id'])) {
536
  $existing = $this->get_user($user['email']);
537
- if ($existing != null) return false;
538
- if (empty($user['token'])) $user['token'] = NewsletterModule::get_token();
 
 
539
  //if (empty($user['created'])) $user['created'] = time();
540
  // Database default
541
  //if (empty($user['status'])) $user['status'] = 'S';
122
  */
123
  function get_options($sub = '') {
124
  $options = get_option($this->get_prefix($sub));
125
+ if ($options == false)
126
+ return array();
127
  return $options;
128
  }
129
 
130
  function get_default_options($sub = '') {
131
+ if (!empty($sub))
132
+ $sub .= '-';
133
  @include NEWSLETTER_DIR . '/' . $this->module . '/languages/' . $sub . 'en_US.php';
134
  @include WP_CONTENT_DIR . '/extensions/newsletter/' . $this->module . '/languages/' . $sub . 'en_US.php';
135
  @include NEWSLETTER_DIR . '/' . $this->module . '/languages/' . $sub . WPLANG . '.php';
164
  $this->themes->save_options($options['theme'], $options);
165
  }
166
  // TODO: To be remove since there is no more log level at module level (should it be reintroduced?)
167
+ if (isset($options['log_level']))
168
+ update_option('newsletter_' . $this->module . '_log_level', $options['log_level']);
169
  }
170
  }
171
 
243
  */
244
  static function add_qs($url, $qs, $amp = true) {
245
  if (strpos($url, '?') !== false) {
246
+ if ($amp)
247
+ return $url . '&amp;' . $qs;
248
+ else
249
+ return $url . '&' . $qs;
250
  }
251
+ else
252
+ return $url . '?' . $qs;
253
  }
254
 
255
  static function normalize_email($email) {
256
  $email = strtolower(trim($email));
257
+ if (!is_email($email))
258
+ return null;
259
  return $email;
260
  }
261
 
267
 
268
  static function normalize_sex($sex) {
269
  $sex = trim(strtolower($sex));
270
+ if ($sex != 'f' && $sex != 'm')
271
+ $sex = 'n';
272
  return $sex;
273
  }
274
 
275
  static function is_email($email, $empty_ok = false) {
276
  $email = strtolower(trim($email));
277
+ if ($empty_ok && $email == '')
278
+ return true;
279
 
280
+ if (!is_email($email))
281
+ return false;
282
 
283
  // TODO: To be moved on the subscription module and make configurable
284
+ if (strpos($email, 'mailinator.com') !== false)
285
+ return false;
286
+ if (strpos($email, 'guerrillamailblock.com') !== false)
287
+ return false;
288
+ if (strpos($email, 'emailtemporanea.net') !== false)
289
+ return false;
290
  return true;
291
  }
292
 
306
  }
307
 
308
  static function format_date($time) {
309
+ if (empty($time))
310
+ return '-';
311
  return gmdate(get_option('date_format') . ' ' . get_option('time_format'), $time + get_option('gmt_offset') * 3600);
312
  }
313
 
372
  static function split_posts(&$posts, $time = 0) {
373
  $result = array(array(), array());
374
  foreach ($posts as &$post) {
375
+ if (self::is_post_old($post, $time))
376
+ $result[1][] = $post;
377
+ else
378
+ $result[0][] = $post;
379
  }
380
  return $result;
381
  }
387
  static function get_post_image($post_id = null, $size = 'thumbnail', $alternative = null) {
388
  global $post;
389
 
390
+ if (empty($post_id))
391
+ $post_id = $post->ID;
392
+ if (empty($post_id))
393
+ return $alternative;
394
 
395
  $image_id = function_exists('get_post_thumbnail_id') ? get_post_thumbnail_id($post_id) : false;
396
  if ($image_id) {
414
  return is_file(WP_CONTENT_DIR . "/extensions/newsletter/$name/$name.php");
415
  }
416
 
417
+ /**
418
+ * Cleans up a text containing url tags with appended the absolute URL (due to
419
+ * the editor behavior) moving back them to the simple form.
420
+ */
421
+ static function clean_url_tags($text) {
422
+ $text = str_replace('%7B', '{', $text);
423
+ $text = str_replace('%7D', '}', $text);
424
+ $text = preg_replace("/[\"']http.*(\\{[^\\}]+\\})[\"']/i", "\"\\1\"", $text);
425
+ return $text;
426
+ }
427
+
428
  function get_styles() {
429
 
430
  $list = array('' => 'none');
434
 
435
  if ($handle !== false) {
436
  while ($file = readdir($handle)) {
437
+ if ($file == '.' || $file == '..')
438
+ continue;
439
+ if (substr($file, -4) != '.css')
440
+ continue;
441
  $list[$file] = substr($file, 0, strlen($file) - 4);
442
  }
443
  closedir($handle);
448
 
449
  if ($handle !== false) {
450
  while ($file = readdir($handle)) {
451
+ if ($file == '.' || $file == '..')
452
+ continue;
453
+ if (isset($list[$file]))
454
+ continue;
455
+ if (substr($file, -4) != '.css')
456
+ continue;
457
  $list[$file] = substr($file, 0, strlen($file) - 4);
458
  }
459
  closedir($handle);
462
  }
463
 
464
  function get_style_url($style) {
465
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/' . $this->module . '/styles/' . $style))
466
+ return WP_CONTENT_URL . '/extensions/newsletter/' . $this->module . '/styles/' . $style;
467
+ else
468
+ return plugins_url('newsletter') . '/' . $this->module . '/styles/' . $style;
469
  }
470
 
471
  function admin_menu() {
472
+
473
  }
474
 
475
  function add_menu_page($page, $title) {
480
  }
481
  $name = 'newsletter_' . $this->module . '_' . $page;
482
  eval('function ' . $name . '(){global $newsletter, $wpdb;require \'' . $file . '\';}');
483
+ // Rather stupid system to enable a menu voice... it would suffice to say "to editors"
484
+ add_submenu_page('newsletter_main_index', $title, $title, ($newsletter->options['editor'] == 1) ? 'manage_categories' : 'manage_options', $name, $name);
485
  }
486
 
487
  function add_admin_page($page, $title) {
493
 
494
  $name = 'newsletter_' . $this->module . '_' . $page;
495
  eval('function ' . $name . '(){global $newsletter, $wpdb;require \'' . $file . '\';}');
496
+ add_submenu_page(null, $title, $title, ($newsletter->options['editor'] == 1) ? 'manage_categories' : 'manage_options', $name, $name);
497
  }
498
 
499
  function get_admin_page_url($page) {
541
  global $wpdb;
542
 
543
  // To simplify the reaload of a user passing the user it self.
544
+ if (is_object($id_or_email))
545
+ $id_or_email = $id_or_email->id;
546
+ else if (is_array($id_or_email))
547
+ $id_or_email = $id_or_email['id'];
548
 
549
  $id_or_email = strtolower(trim($id_or_email));
550
 
570
  * @param array|object $user
571
  */
572
  function save_user($user, $return_format = OBJECT) {
573
+ if (is_object($user))
574
+ $user = (array) $user;
575
  if (empty($user['id'])) {
576
  $existing = $this->get_user($user['email']);
577
+ if ($existing != null)
578
+ return false;
579
+ if (empty($user['token']))
580
+ $user['token'] = NewsletterModule::get_token();
581
  //if (empty($user['created'])) $user['created'] = time();
582
  // Database default
583
  //if (empty($user['status'])) $user['status'] = 'S';
includes/themes.php CHANGED
@@ -68,7 +68,7 @@ class NewsletterThemes {
68
  if (is_file($screenshot)) {
69
  $data['screenshot'] = $this->get_theme_url($file) . '/screenshot.png';
70
  } else {
71
- $data['screenshot'] = NEWSLETTER_URL . '/images/theme-screenshot.png';
72
  }
73
  $list[$file] = $data;
74
  }
@@ -89,7 +89,7 @@ class NewsletterThemes {
89
  if (is_file($screenshot)) {
90
  $data['screenshot'] = $this->get_theme_url($file) . '/screenshot.png';
91
  } else {
92
- $data['screenshot'] = NEWSLETTER_URL . '/images/theme-screenshot.png';
93
  }
94
  $list[$file] = $data;
95
  }
@@ -137,7 +137,7 @@ class NewsletterThemes {
137
 
138
  $path = NEWSLETTER_DIR . '/' . $this->module . '/themes/' . $theme;
139
  if (is_dir($path)) {
140
- return NEWSLETTER_URL . '/' . $this->module . '/themes/' . $theme;
141
  } else {
142
  return WP_CONTENT_URL . '/extensions/newsletter/' . $this->module . '/themes/' . $theme;
143
  }
68
  if (is_file($screenshot)) {
69
  $data['screenshot'] = $this->get_theme_url($file) . '/screenshot.png';
70
  } else {
71
+ $data['screenshot'] = plugins_url('newsletter') . '/images/theme-screenshot.png';
72
  }
73
  $list[$file] = $data;
74
  }
89
  if (is_file($screenshot)) {
90
  $data['screenshot'] = $this->get_theme_url($file) . '/screenshot.png';
91
  } else {
92
+ $data['screenshot'] = plugins_url('newsletter') . '/images/theme-screenshot.png';
93
  }
94
  $list[$file] = $data;
95
  }
137
 
138
  $path = NEWSLETTER_DIR . '/' . $this->module . '/themes/' . $theme;
139
  if (is_dir($path)) {
140
+ return plugins_url('newsletter') . '/' . $this->module . '/themes/' . $theme;
141
  } else {
142
  return WP_CONTENT_URL . '/extensions/newsletter/' . $this->module . '/themes/' . $theme;
143
  }
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
- Version: 3.2.3
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -13,7 +13,7 @@
13
  */
14
 
15
  // Useed as dummy parameter on css and js links
16
- define('NEWSLETTER_VERSION', '3.2.3');
17
 
18
  global $wpdb, $newsletter;
19
 
@@ -29,13 +29,34 @@ define('NEWSLETTER_SLUG', 'newsletter');
29
  define('NEWSLETTER_DIR', WP_PLUGIN_DIR . '/' . NEWSLETTER_SLUG);
30
  define('NEWSLETTER_INCLUDES_DIR', WP_PLUGIN_DIR . '/' . NEWSLETTER_SLUG . '/includes');
31
 
32
- if (!defined('NEWSLETTER_LIST_MAX')) define('NEWSLETTER_LIST_MAX', 20);
33
- if (!defined('NEWSLETTER_PROFILE_MAX')) define('NEWSLETTER_PROFILE_MAX', 20);
34
- if (!defined('NEWSLETTER_FORMS_MAX')) define('NEWSLETTER_FORMS_MAX', 10);
35
 
36
- if (!defined('NEWSLETTER_CRON_INTERVAL')) define('NEWSLETTER_CRON_INTERVAL', 300);
 
 
 
 
 
 
 
 
 
37
 
38
- if (!defined('NEWSLETTER_HEADER')) define('NEWSLETTER_HEADER', true);
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  // Force the whole system log level to this value
41
  //define('NEWSLETTER_LOG_LEVEL', 4);
@@ -101,7 +122,8 @@ class Newsletter extends NewsletterModule {
101
  parent::__construct('main', '1.1.5');
102
 
103
  $max = $this->options['scheduler_max'];
104
- if (!is_numeric($max)) $max = 100;
 
105
  $this->max_emails = max(floor($max / 12), 1);
106
 
107
  add_action('init', array($this, 'hook_init'));
@@ -110,7 +132,8 @@ class Newsletter extends NewsletterModule {
110
  // This specific event is created by "Feed by mail" panel on configuration
111
  add_action('shutdown', array($this, 'hook_shutdown'));
112
 
113
- if (defined('DOING_CRON') && DOING_CRON) return;
 
114
 
115
  // TODO: Meditation on how to use those ones...
116
  register_activation_hook(__FILE__, array($this, 'hook_activate'));
@@ -183,7 +206,8 @@ class Newsletter extends NewsletterModule {
183
  if (empty($options['sender_email'])) {
184
  // That code was taken from WordPress
185
  $sitename = strtolower($_SERVER['SERVER_NAME']);
186
- if (substr($sitename, 0, 4) == 'www.') $sitename = substr($sitename, 4);
 
187
  // WordPress build an address in the same way using wordpress@...
188
  $options['sender_email'] = 'newsletter@' . $sitename;
189
  $this->save_options($options);
@@ -245,22 +269,6 @@ class Newsletter extends NewsletterModule {
245
  function hook_init() {
246
  global $cache_stop, $hyper_cache_stop, $wpdb;
247
 
248
- if (!defined('NEWSLETTER_URL')) {
249
- define('NEWSLETTER_URL', plugins_url('', __FILE__));
250
- }
251
-
252
- define('NEWSLETTER_SUBSCRIPTION_POPUP_URL', NEWSLETTER_URL . '/do/subscription-popup.php');
253
- define('NEWSLETTER_SUBSCRIBE_URL', NEWSLETTER_URL . '/do/subscribe.php');
254
- define('NEWSLETTER_SUBSCRIBE_POPUP_URL', NEWSLETTER_URL . '/do/subscribe-popup.php');
255
- define('NEWSLETTER_PROFILE_URL', NEWSLETTER_URL . '/do/profile.php');
256
- define('NEWSLETTER_SAVE_URL', NEWSLETTER_URL . '/do/save.php');
257
- define('NEWSLETTER_CONFIRM_URL', NEWSLETTER_URL . '/do/confirm.php');
258
- define('NEWSLETTER_CHANGE_URL', NEWSLETTER_URL . '/do/change.php');
259
- define('NEWSLETTER_UNLOCK_URL', NEWSLETTER_URL . '/do/unlock.php');
260
- define('NEWSLETTER_UNSUBSCRIBE_URL', NEWSLETTER_URL . '/do/unsubscribe.php');
261
- define('NEWSLETTER_UNSUBSCRIPTION_URL', NEWSLETTER_URL . '/do/unsubscription.php');
262
- define('NEWSLETTER_EMAIL_URL', NEWSLETTER_URL . '/do/view.php');
263
-
264
  if (is_admin()) {
265
  if ($this->is_admin_page()) {
266
  wp_enqueue_script('jquery-ui-tabs');
@@ -271,7 +279,8 @@ class Newsletter extends NewsletterModule {
271
  }
272
 
273
  $action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
274
- if (empty($action) || is_admin()) return;
 
275
 
276
  // TODO: Remove!
277
  $cache_stop = true;
@@ -284,7 +293,8 @@ class Newsletter extends NewsletterModule {
284
 
285
  if ($action == 'fu') {
286
  $user = $this->check_user();
287
- if ($user == null) die('No user');
 
288
  $wpdb->query("update " . $wpdb->prefix . "newsletter set followup=2 where id=" . $user->id);
289
  $options_followup = get_option('newsletter_followup');
290
  $this->message = $options_followup['unsubscribed_text'];
@@ -294,20 +304,21 @@ class Newsletter extends NewsletterModule {
294
 
295
  function is_admin_page() {
296
  // TODO: Use the module list to detect that...
297
- if (!isset($_GET['page'])) return false;
 
298
  $page = $_GET['page'];
299
  return strpos($page, 'newsletter_') === 0 || strpos($page, 'newsletter-statistics/') === 0 || strpos($page, 'newsletter/') === 0 ||
300
  strpos($page, 'newsletter-updates/') === 0 || strpos($page, 'newsletter-flows/') === 0;
301
  }
302
 
303
  function hook_admin_init() {
304
-
305
  }
306
 
307
  function hook_admin_head() {
308
  if ($this->is_admin_page()) {
309
- echo '<link type="text/css" rel="stylesheet" href="' . NEWSLETTER_URL . '/admin.css?' . NEWSLETTER_VERSION . '"/>';
310
- echo '<script src="' . NEWSLETTER_URL . '/admin.js?' . NEWSLETTER_VERSION . '"></script>';
311
  }
312
  }
313
 
@@ -341,14 +352,16 @@ class Newsletter extends NewsletterModule {
341
  $this->logger->debug('hook_newsletter> Starting');
342
 
343
  // Do not accept job activation before at least 4 minutes are elapsed from the last run.
344
- if (!$this->check_transient('engine', NEWSLETTER_CRON_INTERVAL)) return;
 
345
 
346
  // Retrieve all email in "sending" status
347
  $emails = $wpdb->get_results("select * from " . NEWSLETTER_EMAILS_TABLE . " where status='sending' and send_on<" . time() . " order by id asc");
348
  $this->logger->debug('hook_newsletter> Emails found in sending status: ' . count($emails));
349
  foreach ($emails as &$email) {
350
  $this->logger->debug('hook_newsletter> Sending email ' . $email->id);
351
- if (!$this->send($email)) break;
 
352
  }
353
  // Remove the semaphore so the delivery engine can be activated again
354
  $this->delete_transient('engine');
@@ -367,7 +380,8 @@ class Newsletter extends NewsletterModule {
367
  function send($email, $users = null) {
368
  global $wpdb;
369
 
370
- if (is_array($email)) $email = (object) $email;
 
371
 
372
  // This stops the update of last_id and sent fields since it's not a scheduled delivery but a test.
373
  $test = $users != null;
@@ -395,7 +409,8 @@ class Newsletter extends NewsletterModule {
395
  foreach ($users as &$user) {
396
 
397
  // Before try to send, check the limits.
398
- if (!$test && $this->limits_exceeded()) return false;
 
399
 
400
  $headers = array('List-Unsubscribe' => '<' . NEWSLETTER_UNSUBSCRIBE_URL . '?nk=' . $user->id . '-' . $user->token . '>');
401
 
@@ -407,7 +422,8 @@ class Newsletter extends NewsletterModule {
407
  $mt = $this->replace($email->message_text, $user, $email->id);
408
 
409
 
410
- if ($email->track == 1) $m = $this->relink($m, $email->id, $user->id);
 
411
 
412
  $s = $this->replace($email->subject, $user);
413
 
@@ -417,8 +433,7 @@ class Newsletter extends NewsletterModule {
417
  if (!empty($wp_user_email)) {
418
  $user->email = $wp_user_email;
419
  $this->logger->debug('Email replaced with: ' . $user->email);
420
- }
421
- else {
422
  $this->logger->debug('WP user has not an email?!');
423
  }
424
  }
@@ -455,13 +470,15 @@ class Newsletter extends NewsletterModule {
455
  if (!$this->limits_set) {
456
  $this->logger->debug('limits_exceeded> Setting the limits for the first time');
457
  $max = $this->options['scheduler_max'];
458
- if (!is_numeric($max)) $max = 100;
 
459
  $this->email_limit = max(floor($max / 12), 1);
460
  $this->logger->debug('limits_exceeded> Max number of emails can send: ' . $this->email_limit);
461
 
462
  $wpdb->query("set session wait_timeout=300");
463
  // From default-constants.php
464
- if (function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < 128 )) @ini_set('memory_limit', '256M');
 
465
 
466
  $this->limits_set = true;
467
  }
@@ -496,7 +513,8 @@ class Newsletter extends NewsletterModule {
496
  return true;
497
  }
498
 
499
- if ($this->mailer == null) $this->mailer_init();
 
500
 
501
  // Simple message is asumed to be html
502
  if (!is_array($message)) {
@@ -561,7 +579,8 @@ class Newsletter extends NewsletterModule {
561
  if ($smtp_options['enabled'] == 1) {
562
  $this->mailer->IsSMTP();
563
  $this->mailer->Host = $smtp_options['host'];
564
- if (!empty($smtp_options['port'])) $this->mailer->Port = (int) $smtp_options['port'];
 
565
 
566
  if (!empty($smtp_options['user'])) {
567
  $this->mailer->SMTPAuth = true;
@@ -608,15 +627,16 @@ class Newsletter extends NewsletterModule {
608
  }
609
 
610
  function form($number = null) {
611
- if ($number == null) return $this->subscription_form();
 
612
  $options = get_option('newsletter_forms');
613
 
614
  $form = $options['form_' . $number];
615
 
616
  if (stripos($form, '<form') !== false) {
617
- $form = str_replace('{newsletter_url}', NEWSLETTER_SUBSCRIBE_URL, $form);
618
  } else {
619
- $form = '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '" onsubmit="return newsletter_check(this)">' .
620
  $form . '</form>';
621
  }
622
 
@@ -626,7 +646,8 @@ class Newsletter extends NewsletterModule {
626
  }
627
 
628
  function find_file($file1, $file2) {
629
- if (is_file($file1)) return $file1;
 
630
  return $file2;
631
  }
632
 
@@ -695,7 +716,8 @@ class Newsletter extends NewsletterModule {
695
  $x = 0;
696
  while (($x = strpos($text, '{date_', $x)) !== false) {
697
  $y = strpos($text, '}', $x);
698
- if ($y === false) continue;
 
699
  $f = substr($text, $x + 6, $y - $x - 6);
700
  $text = substr($text, 0, $x) . date($f) . substr($text, $y + 1);
701
  }
@@ -739,7 +761,8 @@ class Newsletter extends NewsletterModule {
739
  $text = str_replace('{key}', $user->id . '-' . $user->token, $text);
740
  $text = str_replace('%7Bkey%7D', $user->id . '-' . $user->token, $text);
741
 
742
- if (strpos($text, '{profile_form}') !== false) $text = str_replace('{profile_form}', NewsletterSubscription::instance()->get_profile_form($user), $text);
 
743
 
744
  for ($i = 1; $i < NEWSLETTER_PROFILE_MAX; $i++) {
745
  $p = 'profile_' . $i;
@@ -758,11 +781,11 @@ class Newsletter extends NewsletterModule {
758
  $nk = $user->id . '-' . $user->token;
759
 
760
  //$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
761
- $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', NEWSLETTER_CONFIRM_URL . '?nk=' . $nk);
762
- $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_UNSUBSCRIBE_URL . '?nk=' . $nk);
763
  //$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
764
- $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', NEWSLETTER_UNSUBSCRIPTION_URL . '?nk=' . $nk);
765
- $text = $this->replace_url($text, 'CHANGE_URL', NEWSLETTER_CHANGE_URL);
766
 
767
  // Obsolete.
768
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
@@ -771,13 +794,15 @@ class Newsletter extends NewsletterModule {
771
  $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
772
 
773
  $options_profile = get_option('newsletter_profile');
774
- if (empty($options_profile['profile_url'])) $text = $this->replace_url($text, 'PROFILE_URL', NEWSLETTER_PROFILE_URL . '?nk=' . $nk);
775
- else $text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&amp;nt=' . $user->token));
 
 
776
 
777
  //$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
778
- $text = $this->replace_url($text, 'UNLOCK_URL', NEWSLETTER_UNLOCK_URL . '?nk=' . $nk);
779
  if (!empty($email_id)) {
780
- $text = $this->replace_url($text, 'EMAIL_URL', NEWSLETTER_EMAIL_URL . '?id=' . $email_id . '&amp;nk=' . $nk);
781
  }
782
 
783
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
@@ -826,7 +851,8 @@ class Newsletter extends NewsletterModule {
826
  }
827
 
828
  function hook_shutdown() {
829
- if ($this->mailer != null) $this->mailer->SmtpClose();
 
830
  }
831
 
832
  function hook_the_content($content) {
@@ -871,7 +897,7 @@ class Newsletter extends NewsletterModule {
871
  // eval('? >' . $buffer . "\n");
872
  // $buffer = ob_get_clean();
873
  // TODO: add the newsletter check on submit
874
- $buffer = str_ireplace('<form', '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '"', $buffer);
875
  $buffer = $this->replace($buffer, null, null, 'lock');
876
 
877
  $buffer = do_shortcode($buffer);
@@ -903,7 +929,8 @@ class Newsletter extends NewsletterModule {
903
  }
904
 
905
  function notify_admin($user, $subject) {
906
- if ($this->options['notify'] != 1) return;
 
907
  $message = "Subscriber details:\n\n" .
908
  "email: " . $user->email . "\n" .
909
  "first name: " . $user->name . "\n" .
@@ -913,13 +940,15 @@ class Newsletter extends NewsletterModule {
913
  $options_profile = get_option('newsletter_profile');
914
 
915
  for ($i = 0; $i < NEWSLETTER_PROFILE_MAX; $i++) {
916
- if ($options_profile['profile_' . $i] == '') continue;
 
917
  $field = 'profile_' . $i;
918
  $message .= $options_profile['profile_' . $i] . ': ' . $user->$field . "\n";
919
  }
920
 
921
  for ($i = 0; $i < NEWSLETTER_LIST_MAX; $i++) {
922
- if ($options_profile['list_' . $i] == '') continue;
 
923
  $field = 'list_' . $i;
924
  $message .= $options_profile['list_' . $i] . ': ' . $user->$field . "\n";
925
  }
@@ -941,8 +970,10 @@ class Newsletter extends NewsletterModule {
941
  $user = $this->get_user($id);
942
 
943
  if ($user == null || $token != $user->token) {
944
- if ($required) die('No subscriber found.');
945
- else return null;
 
 
946
  }
947
  return $user;
948
  }
@@ -1051,5 +1082,6 @@ function newsletter_activate() {
1051
  register_activation_hook(__FILE__, 'newsletter_deactivate');
1052
 
1053
  function newsletter_deactivate() {
 
1054
  }
1055
 
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
+ Version: 3.2.4
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
13
  */
14
 
15
  // Useed as dummy parameter on css and js links
16
+ define('NEWSLETTER_VERSION', '3.2.4');
17
 
18
  global $wpdb, $newsletter;
19
 
29
  define('NEWSLETTER_DIR', WP_PLUGIN_DIR . '/' . NEWSLETTER_SLUG);
30
  define('NEWSLETTER_INCLUDES_DIR', WP_PLUGIN_DIR . '/' . NEWSLETTER_SLUG . '/includes');
31
 
32
+ // Almost obsolete but the first two must be kept for compatibility with modules
33
+ define('NEWSLETTER_URL', WP_PLUGIN_URL . '/newsletter');
34
+ define('NEWSLETTER_EMAIL_URL', NEWSLETTER_URL . '/do/view.php');
35
 
36
+ define('NEWSLETTER_SUBSCRIPTION_POPUP_URL', NEWSLETTER_URL . '/do/subscription-popup.php');
37
+ define('NEWSLETTER_SUBSCRIBE_URL', NEWSLETTER_URL . '/do/subscribe.php');
38
+ define('NEWSLETTER_SUBSCRIBE_POPUP_URL', NEWSLETTER_URL . '/do/subscribe-popup.php');
39
+ define('NEWSLETTER_PROFILE_URL', NEWSLETTER_URL . '/do/profile.php');
40
+ define('NEWSLETTER_SAVE_URL', NEWSLETTER_URL . '/do/save.php');
41
+ define('NEWSLETTER_CONFIRM_URL', NEWSLETTER_URL . '/do/confirm.php');
42
+ define('NEWSLETTER_CHANGE_URL', NEWSLETTER_URL . '/do/change.php');
43
+ define('NEWSLETTER_UNLOCK_URL', NEWSLETTER_URL . '/do/unlock.php');
44
+ define('NEWSLETTER_UNSUBSCRIBE_URL', NEWSLETTER_URL . '/do/unsubscribe.php');
45
+ define('NEWSLETTER_UNSUBSCRIPTION_URL', NEWSLETTER_URL . '/do/unsubscription.php');
46
 
47
+
48
+ if (!defined('NEWSLETTER_LIST_MAX'))
49
+ define('NEWSLETTER_LIST_MAX', 20);
50
+ if (!defined('NEWSLETTER_PROFILE_MAX'))
51
+ define('NEWSLETTER_PROFILE_MAX', 20);
52
+ if (!defined('NEWSLETTER_FORMS_MAX'))
53
+ define('NEWSLETTER_FORMS_MAX', 10);
54
+
55
+ if (!defined('NEWSLETTER_CRON_INTERVAL'))
56
+ define('NEWSLETTER_CRON_INTERVAL', 300);
57
+
58
+ if (!defined('NEWSLETTER_HEADER'))
59
+ define('NEWSLETTER_HEADER', true);
60
 
61
  // Force the whole system log level to this value
62
  //define('NEWSLETTER_LOG_LEVEL', 4);
122
  parent::__construct('main', '1.1.5');
123
 
124
  $max = $this->options['scheduler_max'];
125
+ if (!is_numeric($max))
126
+ $max = 100;
127
  $this->max_emails = max(floor($max / 12), 1);
128
 
129
  add_action('init', array($this, 'hook_init'));
132
  // This specific event is created by "Feed by mail" panel on configuration
133
  add_action('shutdown', array($this, 'hook_shutdown'));
134
 
135
+ if (defined('DOING_CRON') && DOING_CRON)
136
+ return;
137
 
138
  // TODO: Meditation on how to use those ones...
139
  register_activation_hook(__FILE__, array($this, 'hook_activate'));
206
  if (empty($options['sender_email'])) {
207
  // That code was taken from WordPress
208
  $sitename = strtolower($_SERVER['SERVER_NAME']);
209
+ if (substr($sitename, 0, 4) == 'www.')
210
+ $sitename = substr($sitename, 4);
211
  // WordPress build an address in the same way using wordpress@...
212
  $options['sender_email'] = 'newsletter@' . $sitename;
213
  $this->save_options($options);
269
  function hook_init() {
270
  global $cache_stop, $hyper_cache_stop, $wpdb;
271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  if (is_admin()) {
273
  if ($this->is_admin_page()) {
274
  wp_enqueue_script('jquery-ui-tabs');
279
  }
280
 
281
  $action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
282
+ if (empty($action) || is_admin())
283
+ return;
284
 
285
  // TODO: Remove!
286
  $cache_stop = true;
293
 
294
  if ($action == 'fu') {
295
  $user = $this->check_user();
296
+ if ($user == null)
297
+ die('No user');
298
  $wpdb->query("update " . $wpdb->prefix . "newsletter set followup=2 where id=" . $user->id);
299
  $options_followup = get_option('newsletter_followup');
300
  $this->message = $options_followup['unsubscribed_text'];
304
 
305
  function is_admin_page() {
306
  // TODO: Use the module list to detect that...
307
+ if (!isset($_GET['page']))
308
+ return false;
309
  $page = $_GET['page'];
310
  return strpos($page, 'newsletter_') === 0 || strpos($page, 'newsletter-statistics/') === 0 || strpos($page, 'newsletter/') === 0 ||
311
  strpos($page, 'newsletter-updates/') === 0 || strpos($page, 'newsletter-flows/') === 0;
312
  }
313
 
314
  function hook_admin_init() {
315
+
316
  }
317
 
318
  function hook_admin_head() {
319
  if ($this->is_admin_page()) {
320
+ echo '<link type="text/css" rel="stylesheet" href="' . plugins_url('newsletter') . '/admin.css?' . NEWSLETTER_VERSION . '"/>';
321
+ echo '<script src="' . plugins_url('newsletter') . '/admin.js?' . NEWSLETTER_VERSION . '"></script>';
322
  }
323
  }
324
 
352
  $this->logger->debug('hook_newsletter> Starting');
353
 
354
  // Do not accept job activation before at least 4 minutes are elapsed from the last run.
355
+ if (!$this->check_transient('engine', NEWSLETTER_CRON_INTERVAL))
356
+ return;
357
 
358
  // Retrieve all email in "sending" status
359
  $emails = $wpdb->get_results("select * from " . NEWSLETTER_EMAILS_TABLE . " where status='sending' and send_on<" . time() . " order by id asc");
360
  $this->logger->debug('hook_newsletter> Emails found in sending status: ' . count($emails));
361
  foreach ($emails as &$email) {
362
  $this->logger->debug('hook_newsletter> Sending email ' . $email->id);
363
+ if (!$this->send($email))
364
+ break;
365
  }
366
  // Remove the semaphore so the delivery engine can be activated again
367
  $this->delete_transient('engine');
380
  function send($email, $users = null) {
381
  global $wpdb;
382
 
383
+ if (is_array($email))
384
+ $email = (object) $email;
385
 
386
  // This stops the update of last_id and sent fields since it's not a scheduled delivery but a test.
387
  $test = $users != null;
409
  foreach ($users as &$user) {
410
 
411
  // Before try to send, check the limits.
412
+ if (!$test && $this->limits_exceeded())
413
+ return false;
414
 
415
  $headers = array('List-Unsubscribe' => '<' . NEWSLETTER_UNSUBSCRIBE_URL . '?nk=' . $user->id . '-' . $user->token . '>');
416
 
422
  $mt = $this->replace($email->message_text, $user, $email->id);
423
 
424
 
425
+ if ($email->track == 1)
426
+ $m = $this->relink($m, $email->id, $user->id);
427
 
428
  $s = $this->replace($email->subject, $user);
429
 
433
  if (!empty($wp_user_email)) {
434
  $user->email = $wp_user_email;
435
  $this->logger->debug('Email replaced with: ' . $user->email);
436
+ } else {
 
437
  $this->logger->debug('WP user has not an email?!');
438
  }
439
  }
470
  if (!$this->limits_set) {
471
  $this->logger->debug('limits_exceeded> Setting the limits for the first time');
472
  $max = $this->options['scheduler_max'];
473
+ if (!is_numeric($max))
474
+ $max = 100;
475
  $this->email_limit = max(floor($max / 12), 1);
476
  $this->logger->debug('limits_exceeded> Max number of emails can send: ' . $this->email_limit);
477
 
478
  $wpdb->query("set session wait_timeout=300");
479
  // From default-constants.php
480
+ if (function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < 128 ))
481
+ @ini_set('memory_limit', '256M');
482
 
483
  $this->limits_set = true;
484
  }
513
  return true;
514
  }
515
 
516
+ if ($this->mailer == null)
517
+ $this->mailer_init();
518
 
519
  // Simple message is asumed to be html
520
  if (!is_array($message)) {
579
  if ($smtp_options['enabled'] == 1) {
580
  $this->mailer->IsSMTP();
581
  $this->mailer->Host = $smtp_options['host'];
582
+ if (!empty($smtp_options['port']))
583
+ $this->mailer->Port = (int) $smtp_options['port'];
584
 
585
  if (!empty($smtp_options['user'])) {
586
  $this->mailer->SMTPAuth = true;
627
  }
628
 
629
  function form($number = null) {
630
+ if ($number == null)
631
+ return $this->subscription_form();
632
  $options = get_option('newsletter_forms');
633
 
634
  $form = $options['form_' . $number];
635
 
636
  if (stripos($form, '<form') !== false) {
637
+ $form = str_replace('{newsletter_url}', plugins_url('newsletter/do/subscribe.php'), $form);
638
  } else {
639
+ $form = '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)">' .
640
  $form . '</form>';
641
  }
642
 
646
  }
647
 
648
  function find_file($file1, $file2) {
649
+ if (is_file($file1))
650
+ return $file1;
651
  return $file2;
652
  }
653
 
716
  $x = 0;
717
  while (($x = strpos($text, '{date_', $x)) !== false) {
718
  $y = strpos($text, '}', $x);
719
+ if ($y === false)
720
+ continue;
721
  $f = substr($text, $x + 6, $y - $x - 6);
722
  $text = substr($text, 0, $x) . date($f) . substr($text, $y + 1);
723
  }
761
  $text = str_replace('{key}', $user->id . '-' . $user->token, $text);
762
  $text = str_replace('%7Bkey%7D', $user->id . '-' . $user->token, $text);
763
 
764
+ if (strpos($text, '{profile_form}') !== false)
765
+ $text = str_replace('{profile_form}', NewsletterSubscription::instance()->get_profile_form($user), $text);
766
 
767
  for ($i = 1; $i < NEWSLETTER_PROFILE_MAX; $i++) {
768
  $p = 'profile_' . $i;
781
  $nk = $user->id . '-' . $user->token;
782
 
783
  //$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
784
+ $text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', plugins_url('newsletter/do/confirm.php') . '?nk=' . $nk);
785
+ $text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', plugins_url('newsletter/do/unsubscribe.php') . '?nk=' . $nk);
786
  //$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
787
+ $text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', plugins_url('newsletter/do/unsubscription.php') . '?nk=' . $nk);
788
+ $text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
789
 
790
  // Obsolete.
791
  $text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
794
  $text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
795
 
796
  $options_profile = get_option('newsletter_profile');
797
+ if (empty($options_profile['profile_url']))
798
+ $text = $this->replace_url($text, 'PROFILE_URL', plugins_url('newsletter/do/profile.php') . '?nk=' . $nk);
799
+ else
800
+ $text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&amp;nt=' . $user->token));
801
 
802
  //$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
803
+ $text = $this->replace_url($text, 'UNLOCK_URL', plugins_url('newsletter/do/unlock.php') . '?nk=' . $nk);
804
  if (!empty($email_id)) {
805
+ $text = $this->replace_url($text, 'EMAIL_URL', plugins_url('newsletter/do/view.php') . '?id=' . $email_id . '&amp;nk=' . $nk);
806
  }
807
 
808
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
851
  }
852
 
853
  function hook_shutdown() {
854
+ if ($this->mailer != null)
855
+ $this->mailer->SmtpClose();
856
  }
857
 
858
  function hook_the_content($content) {
897
  // eval('? >' . $buffer . "\n");
898
  // $buffer = ob_get_clean();
899
  // TODO: add the newsletter check on submit
900
+ $buffer = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '"', $buffer);
901
  $buffer = $this->replace($buffer, null, null, 'lock');
902
 
903
  $buffer = do_shortcode($buffer);
929
  }
930
 
931
  function notify_admin($user, $subject) {
932
+ if ($this->options['notify'] != 1)
933
+ return;
934
  $message = "Subscriber details:\n\n" .
935
  "email: " . $user->email . "\n" .
936
  "first name: " . $user->name . "\n" .
940
  $options_profile = get_option('newsletter_profile');
941
 
942
  for ($i = 0; $i < NEWSLETTER_PROFILE_MAX; $i++) {
943
+ if ($options_profile['profile_' . $i] == '')
944
+ continue;
945
  $field = 'profile_' . $i;
946
  $message .= $options_profile['profile_' . $i] . ': ' . $user->$field . "\n";
947
  }
948
 
949
  for ($i = 0; $i < NEWSLETTER_LIST_MAX; $i++) {
950
+ if ($options_profile['list_' . $i] == '')
951
+ continue;
952
  $field = 'list_' . $i;
953
  $message .= $options_profile['list_' . $i] . ': ' . $user->$field . "\n";
954
  }
970
  $user = $this->get_user($id);
971
 
972
  if ($user == null || $token != $user->token) {
973
+ if ($required)
974
+ die('No subscriber found.');
975
+ else
976
+ return null;
977
  }
978
  return $user;
979
  }
1082
  register_activation_hook(__FILE__, 'newsletter_deactivate');
1083
 
1084
  function newsletter_deactivate() {
1085
+
1086
  }
1087
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.0.0
4
  Tested up to: 3.5.1
5
- Stable tag: 3.2.3
6
  Donate link: http://www.satollo.net/donations
7
 
8
  Add a real newsletter to your blog. In seconds. For free.
@@ -11,7 +11,7 @@ Add a real newsletter to your blog. In seconds. For free.
11
 
12
  This plug-in lets you collect subscribers on your blog with a single or double opt-in (law compliant)
13
  subscription process. Perfect for list building, you can create cool emails with visual editor, send and
14
- track them.
15
 
16
  Unlimited subscribers, unlimited emails.
17
 
@@ -56,6 +56,12 @@ No screen shots are available at this time.
56
 
57
  == Changelog ==
58
 
 
 
 
 
 
 
59
  = 3.2.3 =
60
 
61
  * Added schedule list on Diagnostic panel
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.0.0
4
  Tested up to: 3.5.1
5
+ Stable tag: 3.2.4
6
  Donate link: http://www.satollo.net/donations
7
 
8
  Add a real newsletter to your blog. In seconds. For free.
11
 
12
  This plug-in lets you collect subscribers on your blog with a single or double opt-in (law compliant)
13
  subscription process. Perfect for list building, you can create cool emails with visual editor, send and
14
+ track them.
15
 
16
  Unlimited subscribers, unlimited emails.
17
 
56
 
57
  == Changelog ==
58
 
59
+ = 3.2.4 =
60
+
61
+ * Added target _blank on theme links so they open on a new windows for the online version
62
+ * Changed to the plugins_url() function
63
+ * Added clean up of url tags on composer
64
+
65
  = 3.2.3 =
66
 
67
  * Added schedule list on Diagnostic panel
statistics/statistics.php CHANGED
@@ -65,7 +65,7 @@ class NewsletterStatistics extends NewsletterModule {
65
  $text = preg_replace_callback('/(<[aA][^>]+href=["\'])([^>"\']+)(["\'][^>]*>)(.*?)(<\/[Aa]>)/', array($this, 'relink_callback'), $text);
66
 
67
  // TODO: use the WP rewriting
68
- $text = str_replace('</body>', '<img src="' . NEWSLETTER_URL . '/statistics/open.php?r=' . urlencode(base64_encode($email_id . ';' . $user_id)) . '"/></body>', $text);
69
  return $text;
70
  }
71
 
@@ -86,7 +86,7 @@ class NewsletterStatistics extends NewsletterModule {
86
  }
87
  }
88
 
89
- $url = NEWSLETTER_URL . '/statistics/link.php?r=' .
90
  urlencode(base64_encode($this->relink_email_id . ';' . $this->relink_user_id . ';' . $href . ';' . $anchor));
91
 
92
  return $matches[1] . $url . $matches[3] . $matches[4] . $matches[5];
65
  $text = preg_replace_callback('/(<[aA][^>]+href=["\'])([^>"\']+)(["\'][^>]*>)(.*?)(<\/[Aa]>)/', array($this, 'relink_callback'), $text);
66
 
67
  // TODO: use the WP rewriting
68
+ $text = str_replace('</body>', '<img src="' . plugins_url('newsletter') . '/statistics/open.php?r=' . urlencode(base64_encode($email_id . ';' . $user_id)) . '"/></body>', $text);
69
  return $text;
70
  }
71
 
86
  }
87
  }
88
 
89
+ $url = plugins_url('newsletter') . '/statistics/link.php?r=' .
90
  urlencode(base64_encode($this->relink_email_id . ';' . $this->relink_user_id . ';' . $href . ';' . $anchor));
91
 
92
  return $matches[1] . $url . $matches[3] . $matches[4] . $matches[5];
subscription/options.php CHANGED
@@ -87,7 +87,7 @@ if ($controls->is_action('create')) {
87
  ?>
88
 
89
  <?php if ($controls->data['novisual'] != 1) { ?>
90
- <script type="text/javascript" src="<?php echo NEWSLETTER_URL; ?>/tiny_mce/tiny_mce.js"></script>
91
 
92
  <script type="text/javascript">
93
  tinyMCE.init({
@@ -103,7 +103,7 @@ if ($controls->is_action('create')) {
103
  theme_advanced_resizing : true,
104
  theme_advanced_statusbar_location: "bottom",
105
  document_base_url : "<?php echo get_option('home'); ?>/",
106
- content_css : "<?php echo NEWSLETTER_URL; ?>/editor.css?" + new Date().getTime()
107
  });
108
  </script>
109
  <?php } ?>
87
  ?>
88
 
89
  <?php if ($controls->data['novisual'] != 1) { ?>
90
+ <script type="text/javascript" src="<?php echo plugins_url('newsletter'); ?>/tiny_mce/tiny_mce.js"></script>
91
 
92
  <script type="text/javascript">
93
  tinyMCE.init({
103
  theme_advanced_resizing : true,
104
  theme_advanced_statusbar_location: "bottom",
105
  document_base_url : "<?php echo get_option('home'); ?>/",
106
+ content_css : "<?php echo plugins_url('newsletter'); ?>/editor.css?" + new Date().getTime()
107
  });
108
  </script>
109
  <?php } ?>
subscription/page-popup.php CHANGED
@@ -31,7 +31,7 @@ if (strpos(__FILE__, 'wp-content/newsletter') === false && is_file(WP_CONTENT_DI
31
  padding: 0;
32
  }
33
  #container {
34
- background-image: url("<?php echo NEWSLETTER_URL; ?>/images/popup/bg.png");
35
  background-repeat: repeat-x;
36
  padding: 10px 15px;
37
  }
@@ -58,7 +58,7 @@ if (strpos(__FILE__, 'wp-content/newsletter') === false && is_file(WP_CONTENT_DI
58
  }
59
 
60
  input[type=submit] {
61
- background-image: url("<?php echo NEWSLETTER_URL; ?>/images/popup/button.png");
62
  color: #fff;
63
  border: 1px solid #333;
64
  padding: 5px;
31
  padding: 0;
32
  }
33
  #container {
34
+ background-image: url("<?php echo plugins_url('newsletter'); ?>/images/popup/bg.png");
35
  background-repeat: repeat-x;
36
  padding: 10px 15px;
37
  }
58
  }
59
 
60
  input[type=submit] {
61
+ background-image: url("<?php echo plugins_url('newsletter'); ?>/images/popup/button.png");
62
  color: #fff;
63
  border: 1px solid #333;
64
  padding: 5px;
subscription/subscription.php CHANGED
@@ -464,7 +464,7 @@ class NewsletterSubscription extends NewsletterModule {
464
  }
465
 
466
  // Use the standard page.
467
- header('Location: ' . NEWSLETTER_URL . '/subscription/page.php?nm=' . $key . '&nk=' . $user->id . '-' . $user->token . $params);
468
  die();
469
  }
470
 
@@ -620,7 +620,7 @@ class NewsletterSubscription extends NewsletterModule {
620
 
621
  $buffer .= '<div class="newsletter newsletter-subscription">' . "\n";
622
  if (empty($action)) {
623
- $buffer .= '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '" onsubmit="return newsletter_check(this)">' . "\n\n";
624
  } else {
625
  $buffer .= '<form method="post" action="' . $action . '" onsubmit="return newsletter_check(this)">' . "\n\n";
626
  }
@@ -718,7 +718,7 @@ class NewsletterSubscription extends NewsletterModule {
718
  $options = get_option('newsletter_profile');
719
 
720
  $buffer .= '<div class="newsletter newsletter-profile">';
721
- $buffer .= '<form action="' . NEWSLETTER_SAVE_URL . '" method="post">';
722
  // TODO: use nk
723
  $buffer .= '<input type="hidden" name="nk" value="' . $user->id . '-' . $user->token . '"/>';
724
  $buffer .= '<table cellspacing="0" cellpadding="3" border="0">';
@@ -807,12 +807,12 @@ class NewsletterSubscription extends NewsletterModule {
807
  $form = $options['form_' . $number];
808
 
809
  if (stripos($form, '<form') === false) {
810
- $form = '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '">' .
811
  $form . '</form>';
812
  }
813
 
814
  // For compatibility
815
- $form = str_replace('{newsletter_url}', NEWSLETTER_SUBSCRIBE_URL, $form);
816
 
817
  $form = $this->replace_lists($form);
818
 
@@ -927,7 +927,7 @@ function newsletter_shortcode($attrs, $content) {
927
  // Compatibility check
928
  if (stripos($message, '<form') !== false) {
929
  $message .= $module->get_form_javascript();
930
- $message = str_ireplace('<form', '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '" onsubmit="return newsletter_check(this)"', $message);
931
  } else {
932
 
933
  if (strpos($message, '{subscription_form') === false) {
464
  }
465
 
466
  // Use the standard page.
467
+ header('Location: ' . plugins_url('newsletter') . '/subscription/page.php?nm=' . $key . '&nk=' . $user->id . '-' . $user->token . $params);
468
  die();
469
  }
470
 
620
 
621
  $buffer .= '<div class="newsletter newsletter-subscription">' . "\n";
622
  if (empty($action)) {
623
+ $buffer .= '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)">' . "\n\n";
624
  } else {
625
  $buffer .= '<form method="post" action="' . $action . '" onsubmit="return newsletter_check(this)">' . "\n\n";
626
  }
718
  $options = get_option('newsletter_profile');
719
 
720
  $buffer .= '<div class="newsletter newsletter-profile">';
721
+ $buffer .= '<form action="' . plugins_url('newsletter/do/save.php') . '" method="post">';
722
  // TODO: use nk
723
  $buffer .= '<input type="hidden" name="nk" value="' . $user->id . '-' . $user->token . '"/>';
724
  $buffer .= '<table cellspacing="0" cellpadding="3" border="0">';
807
  $form = $options['form_' . $number];
808
 
809
  if (stripos($form, '<form') === false) {
810
+ $form = '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '">' .
811
  $form . '</form>';
812
  }
813
 
814
  // For compatibility
815
+ $form = str_replace('{newsletter_url}', plugins_url('newsletter/do/subscribe.php'), $form);
816
 
817
  $form = $this->replace_lists($form);
818
 
927
  // Compatibility check
928
  if (stripos($message, '<form') !== false) {
929
  $message .= $module->get_form_javascript();
930
+ $message = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)"', $message);
931
  } else {
932
 
933
  if (strpos($message, '{subscription_form') === false) {
users/edit.php CHANGED
@@ -181,7 +181,7 @@ $options_profile = get_option('newsletter_profile');
181
  <tr valign="top">
182
  <th>Profile URL</th>
183
  <td>
184
- <?php echo NEWSLETTER_PROFILE_URL . '?nk=' . $id . '-' . $controls->data['token']; ?>
185
  </td>
186
  </tr>
187
 
181
  <tr valign="top">
182
  <th>Profile URL</th>
183
  <td>
184
+ <?php echo plugins_url('newsletter/do/profile.php') . '?nk=' . $id . '-' . $controls->data['token']; ?>
185
  </td>
186
  </tr>
187
 
users/export.php CHANGED
@@ -23,7 +23,7 @@ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
23
  </p>
24
  </div>
25
 
26
- <form method="post" action="<?php echo NEWSLETTER_URL; ?>/users/csv.php">
27
  <?php $controls->init(); ?>
28
  <table class="form-table">
29
  <tr>
23
  </p>
24
  </div>
25
 
26
+ <form method="post" action="<?php echo plugins_url('newsletter'); ?>/users/csv.php">
27
  <?php $controls->init(); ?>
28
  <table class="form-table">
29
  <tr>
users/index-old.php CHANGED
@@ -248,7 +248,7 @@ else {
248
 
249
  <?php $controls->button_confirm('resend', 'Resend confirmation', 'Proceed?', $s->id); ?>
250
  <?php $controls->button_confirm('resend_welcome', 'Resend welcome', 'Proceed?', $s->id); ?>
251
- <a href="<?php echo NEWSLETTER_PROFILE_URL; ?>?nk=<?php echo $s->id . '-' . $s->token; ?>" class="button" target="_blank">Profile page</a>
252
  </td>
253
  <td><small>
254
  date: <?php echo $s->created; ?><br />
248
 
249
  <?php $controls->button_confirm('resend', 'Resend confirmation', 'Proceed?', $s->id); ?>
250
  <?php $controls->button_confirm('resend_welcome', 'Resend welcome', 'Proceed?', $s->id); ?>
251
+ <a href="<?php echo plugins_url('newsletter/do/profile.php'); ?>?nk=<?php echo $s->id . '-' . $s->token; ?>" class="button" target="_blank">Profile page</a>
252
  </td>
253
  <td><small>
254
  date: <?php echo $s->created; ?><br />
users/index.php CHANGED
@@ -213,7 +213,7 @@ $controls->data['search_page']++;
213
 
214
  <?php $controls->button_confirm('resend', 'Resend confirmation', 'Proceed?', $s->id); ?>
215
  <?php $controls->button_confirm('resend_welcome', 'Resend welcome', 'Proceed?', $s->id); ?>
216
- <a href="<?php echo NEWSLETTER_PROFILE_URL; ?>?nk=<?php echo $s->id . '-' . $s->token; ?>" class="button" target="_blank">Profile page</a>
217
  </td>
218
 
219
 
213
 
214
  <?php $controls->button_confirm('resend', 'Resend confirmation', 'Proceed?', $s->id); ?>
215
  <?php $controls->button_confirm('resend_welcome', 'Resend welcome', 'Proceed?', $s->id); ?>
216
+ <a href="<?php echo plugins_url('newsletter/do/profile.php'); ?>?nk=<?php echo $s->id . '-' . $s->token; ?>" class="button" target="_blank">Profile page</a>
217
  </td>
218
 
219
 
widget.php CHANGED
@@ -27,7 +27,7 @@ class NewsletterWidget extends WP_Widget {
27
  $form = NewsletterSubscription::instance()->get_form_javascript();
28
 
29
  $form .= '<div class="newsletter newsletter-widget">';
30
- $form .= '<form action="' . NEWSLETTER_SUBSCRIBE_URL . '" onsubmit="return newsletter_check(this)" method="post">';
31
  // Referrer
32
  $form .= '<input type="hidden" name="nr" value="widget"/>';
33
 
@@ -102,7 +102,7 @@ class NewsletterWidget extends WP_Widget {
102
  }
103
  }
104
  else {
105
- $buffer = str_ireplace('<form', '<form method="post" action="' . NEWSLETTER_SUBSCRIBE_URL . '" onsubmit="return newsletter_check(this)"', $buffer);
106
  $buffer = str_ireplace('</form>', '<input type="hidden" name="nr" value="widget"/></form>', $buffer);
107
  }
108
 
27
  $form = NewsletterSubscription::instance()->get_form_javascript();
28
 
29
  $form .= '<div class="newsletter newsletter-widget">';
30
+ $form .= '<form action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)" method="post">';
31
  // Referrer
32
  $form .= '<input type="hidden" name="nr" value="widget"/>';
33
 
102
  }
103
  }
104
  else {
105
+ $buffer = str_ireplace('<form', '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)"', $buffer);
106
  $buffer = str_ireplace('</form>', '<input type="hidden" name="nr" value="widget"/></form>', $buffer);
107
  }
108