Newsletter - Version 3.2.7

Version Description

  • Added a controls for the Reports module version 1.0.4
  • Changed opening tracking and removed 1x1 GIF
  • Added support for popup on subscription form
  • Fixed the link to the reports module
Download this release

Release Info

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

Code changes from version 3.2.6 to 3.2.7

emails/emails.php CHANGED
@@ -19,7 +19,7 @@ class NewsletterEmails extends NewsletterModule {
19
 
20
  function __construct() {
21
  $this->themes = new NewsletterThemes('emails');
22
- parent::__construct('emails', '1.0.8');
23
  }
24
 
25
  function upgrade() {
19
 
20
  function __construct() {
21
  $this->themes = new NewsletterThemes('emails');
22
+ parent::__construct('emails', '1.0.9');
23
  }
24
 
25
  function upgrade() {
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 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,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 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,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 target="_tab" 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="_blank" 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="_blank" 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="_blank" 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="_blank" href="{profile_url}">click here</a>.
61
  </div>
62
 
63
  </div>
includes/controls.php CHANGED
@@ -7,25 +7,27 @@ class NewsletterControls {
7
  var $button_data = '';
8
 
9
  function __construct($options = null) {
10
- if ($options == null) $this->data = stripslashes_deep($_POST['options']);
11
- else $this->data = $options;
 
 
12
 
13
  $this->action = $_REQUEST['act'];
14
 
15
- if (isset($_REQUEST['btn'])) $this->button_data = $_REQUEST['btn'];
 
16
 
17
  // Fields analysis
18
  $fields = $_REQUEST['fields'];
19
  if (is_array($fields)) {
20
- foreach ($fields as $name=>$type) {
21
  if ($type == 'datetime') {
22
  // Ex. The user insert 01/07/2012 14:30 and it set the time zone to +2. We cannot use the
23
  // mktime, since it uses the time zone of the machine. We create the time as if we are on
24
  // GMT 0 and then we subtract the GMT offset (the example date and time on GMT+2 happens
25
  // "before").
26
 
27
- $time = gmmktime($_REQUEST[$name . '_hour'], 0, 0,
28
- $_REQUEST[$name . '_month'], $_REQUEST[$name . '_day'], $_REQUEST[$name . '_year']);
29
  $time -= get_option('gmt_offset') * 3600;
30
  $this->data[$name] = $time;
31
  }
@@ -33,15 +35,19 @@ class NewsletterControls {
33
  }
34
  }
35
 
36
- function merge($options) {
37
- if (!is_array($options)) return;
38
- if ($this->data == null) $this->data = array();
39
- $this->data = array_merge($this->data, $options);
40
- }
 
 
41
 
42
  function merge_defaults($defaults) {
43
- if ($this->data == null) $this->data = $defaults;
44
- else $this->data = array_merge($defaults, $this->data);
 
 
45
  }
46
 
47
  /**
@@ -50,10 +56,14 @@ class NewsletterControls {
50
  * Dies if it is not a safe call.
51
  */
52
  function is_action($action = null) {
53
- if ($action == null) return $this->action != null;
54
- if ($this->action == null) return false;
55
- if ($this->action != $action) return false;
56
- if (check_admin_referer()) return true;
 
 
 
 
57
  die('Invalid call');
58
  }
59
 
@@ -87,10 +97,12 @@ class NewsletterControls {
87
 
88
  echo '<select style="width: 60px" name="options[' . $name . ']">';
89
  echo '<option value="0"';
90
- if ($value == 0) echo ' selected';
 
91
  echo '>No</option>';
92
  echo '<option value="1"';
93
- if ($value == 1) echo ' selected';
 
94
  echo '>Yes</option>';
95
  echo '</select>&nbsp;&nbsp;&nbsp;';
96
  }
@@ -100,10 +112,12 @@ class NewsletterControls {
100
 
101
  echo '<select style="width: 100px" name="options[' . $name . ']">';
102
  echo '<option value="0"';
103
- if ($value == 0) echo ' selected';
 
104
  echo '>Disabled</option>';
105
  echo '<option value="1"';
106
- if ($value == 1) echo ' selected';
 
107
  echo '>Enabled</option>';
108
  echo '</select>';
109
  }
@@ -122,13 +136,14 @@ class NewsletterControls {
122
  */
123
  function checkboxes_group($name, $values_labels) {
124
  echo "<div class='newsletter-checkboxes-group'>";
125
- foreach($values_labels as $value=>$label) {
126
  echo "<div class='newsletter-checkboxes-item'>";
127
  echo "<input type='checkbox' id='$name' name='options[$name][]' value='$value'";
128
  if (is_array($this->data[$name]) && array_search($value, $this->data[$name]) !== false)
129
  echo " checked";
130
  echo '/>';
131
- if ($label != '') echo " <label for='$name'>$label</label>";
 
132
  echo "</div>";
133
  }
134
  echo "</div><div style='clear: both'></div>";
@@ -139,7 +154,8 @@ class NewsletterControls {
139
 
140
  foreach ($options as $key => $label) {
141
  echo '<option value="' . $key . '"';
142
- if (is_array($this->data[$name]) && array_search($value, $this->data[$name]) !== false) echo ' selected';
 
143
  echo '>' . htmlspecialchars($label) . '</option>';
144
  }
145
 
@@ -155,7 +171,8 @@ class NewsletterControls {
155
  }
156
  foreach ($options as $key => $label) {
157
  echo '<option value="' . $key . '"';
158
- if ($value == $key) echo ' selected';
 
159
  echo '>' . htmlspecialchars($label) . '</option>';
160
  }
161
  echo '</select>';
@@ -170,9 +187,11 @@ class NewsletterControls {
170
  echo '<optgroup label="' . htmlspecialchars($group['']) . '">';
171
  if (!empty($group)) {
172
  foreach ($group as $key => $label) {
173
- if ($key == '') continue;
 
174
  echo '<option value="' . $key . '"';
175
- if ($value == $key) echo ' selected';
 
176
  echo '>' . htmlspecialchars($label) . '</option>';
177
  }
178
  }
@@ -185,8 +204,8 @@ class NewsletterControls {
185
  * Generated a select control with all available templates. From version 3 there are
186
  * only on kind of templates, they are no more separated by type.
187
  */
188
- function themes($name, $themes, $submit_on_click=true) {
189
- foreach($themes as $key=>$data) {
190
  echo '<label style="display: block; float: left; text-align: center; margin-right: 10px;">';
191
  echo $key . '<br>';
192
  echo '<img src="' . $data['screenshot'] . '" width="100" height="100" style="border: 1px solid #666; padding: 5px"><br>';
@@ -212,13 +231,14 @@ class NewsletterControls {
212
  if ($show_remaining && $delta > 0) {
213
  echo 'Remaining: ';
214
  $delta = $time - time();
215
- $days = floor($delta / (24*3600));
216
- $delta = $delta - $days*24*3600;
217
  $hours = floor($delta / 3600);
218
- $delta = $delta - $hours*3600;
219
  $minutes = floor($delta / 60);
220
 
221
- if ($days > 0) echo $days . ' days ';
 
222
  echo $hours . ' hours ';
223
  echo $minutes . ' minutes ';
224
  }
@@ -249,6 +269,7 @@ class NewsletterControls {
249
  echo '<input class="button-secondary" type="button" value="' . $label . '" onclick="this.form.act.value=\'' . $action . '\';this.form.submit()"/>';
250
  }
251
  }
 
252
  function button_primary($action, $label, $function = null) {
253
  if ($function != null) {
254
  echo '<input class="button-primary" type="button" value="' . $label . '" onclick="this.form.act.value=\'' . $action . '\';' . htmlspecialchars($function) . '"/>';
@@ -257,11 +278,10 @@ class NewsletterControls {
257
  }
258
  }
259
 
260
- function button_confirm($action, $label, $message='', $data = '') {
261
  if (empty($message)) {
262
  echo '<input class="button-secondary" type="button" value="' . $label . '" onclick="this.form.btn.value=\'' . $data . '\';this.form.act.value=\'' . $action . '\';this.form.submit()"/>';
263
- }
264
- else {
265
  echo '<input class="button-secondary" type="button" value="' . $label . '" onclick="this.form.btn.value=\'' . $data . '\';this.form.act.value=\'' . $action . '\';if (confirm(\'' .
266
  htmlspecialchars($message) . '\')) this.form.submit()"/>';
267
  }
@@ -274,7 +294,7 @@ class NewsletterControls {
274
  }
275
 
276
  function wp_editor($name, $settings = array()) {
277
- wp_editor($this->data[$name], $name, array_merge(array('textarea_name'=>'options[' . $name . ']', 'wpautop'=>false), $settings));
278
  }
279
 
280
  function textarea($name, $width = '100%', $height = '50') {
@@ -289,7 +309,7 @@ class NewsletterControls {
289
  echo '</textarea>';
290
  }
291
 
292
- function email($prefix, $editor = null, $disable_option=false) {
293
  if ($disable_option) {
294
  $this->checkbox($prefix . '_disabled', 'Disable this email');
295
  echo '<br>';
@@ -307,13 +327,16 @@ class NewsletterControls {
307
  }
308
 
309
  function checkbox($name, $label = '') {
310
- if ($label != '') echo '<label>';
 
311
  echo '<input type="checkbox" id="' . $name . '" name="options[' . $name . ']" value="1"';
312
- if (!empty($this->data[$name])) echo ' checked="checked"';
 
313
  echo '/>';
314
- if ($label != '') echo '&nbsp;' . $label . '</label>';
 
315
  }
316
-
317
  /**
318
  * Creates a checkbox named $name and checked if the internal data contains under
319
  * the key $name an array containig the passed value.
@@ -321,10 +344,11 @@ class NewsletterControls {
321
  function checkbox_group($name, $value, $label = '') {
322
  echo '<input type="checkbox" id="' . $name . '" name="options[' . $name . '][]" value="' . $value . '"';
323
  if (is_array($this->data[$name]) && array_search($value, $this->data[$name]) !== false)
324
- echo ' checked="checked"';
325
  echo '/>';
326
- if ($label != '') echo ' <label for="' . $name . '">' . $label . '</label>';
327
- }
 
328
 
329
  function color($name) {
330
  echo $this->text($name, 10);
@@ -332,7 +356,7 @@ class NewsletterControls {
332
 
333
  /** Creates a set of checkbox named $name_[category id] (so they are posted with distinct names).
334
  */
335
- function categories($name='category') {
336
  $categories = get_categories();
337
  echo '<div class="newsletter-checkboxes-group">';
338
  foreach ($categories as &$c) {
@@ -348,10 +372,10 @@ class NewsletterControls {
348
  * Creates a set of checkbox to activate the profile preferences. Every checkbox has a DIV around to
349
  * be formatted.
350
  */
351
- function categories_group($name, $show_mode=false) {
352
  $categories = get_categories();
353
  if ($show_mode) {
354
- $this->select($name . '_mode', array('include'=>'To be included', 'exclude'=>'To be excluded'));
355
  }
356
  echo '<div class="newsletter-categories-group">';
357
  foreach ($categories as &$c) {
@@ -363,18 +387,20 @@ class NewsletterControls {
363
  echo '</div>';
364
  }
365
 
366
- function preferences_selects($name = 'preferences', $skip_empty = false) {
 
 
 
 
 
367
  $options_profile = get_option('newsletter_profile');
368
-
369
  echo '<div class="newsletter-preferences-group">';
370
- for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
371
- if (empty($options_profile['list_' . $i])) continue;
372
 
 
 
 
373
  echo '<div class="newsletter-preferences-item">';
374
-
375
- $this->select($name . '_' . $i, array(0=>'Any', 1=>'Yes', 2=>'No'));
376
- echo '(' . $i . ') ' . htmlspecialchars($options_profile['list_' . $i]);
377
-
378
  echo '</div>';
379
  }
380
  echo '<div style="clear: both"></div>';
@@ -383,46 +409,59 @@ class NewsletterControls {
383
  }
384
 
385
  /**
386
- * Creates a set of checkboxes named $name_[preference number] (so they are
387
- * distinct fields).
388
- * Empty preferences are skipped.
389
  */
390
- function preferences($name = 'preferences') {
391
  $options_profile = get_option('newsletter_profile');
392
- echo '<div class="newsletter-preferences-group">';
393
 
 
394
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
395
- if (empty($options_profile['list_' . $i])) continue;
 
396
  echo '<div class="newsletter-preferences-item">';
397
- $this->checkbox($name . '_' . $i, '(' . $i . ') ' . htmlspecialchars($options_profile['list_' . $i]));
398
  echo '</div>';
399
  }
400
  echo '<div style="clear: both"></div>';
401
  echo '<a href="http://www.satollo.net/plugins/newsletter/newsletter-preferences" target="_blank">Click here know more about preferences.</a> They can be configured on Subscription/Form field panel.';
402
  echo '</div>';
403
-
404
  }
405
-
406
- /**
407
- * Creates a set of checkboxes to activate the profile preferences. Every checkbox has the
408
- * same $name and the preference number as value so the selected checkboxes
409
- * are retrieved as an array of values.
410
  */
411
- function preferences_group($name = 'preferences') {
412
  $options_profile = get_option('newsletter_profile');
413
 
414
  echo '<div class="newsletter-preferences-group">';
415
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
416
- if (empty($options_profile['list_' . $i])) continue;
 
 
417
  echo '<div class="newsletter-preferences-item">';
418
- $this->checkbox_group($name, $i, '(' . $i . ') ' . htmlspecialchars($options_profile['list_' . $i]));
 
 
 
419
  echo '</div>';
420
  }
421
  echo '<div style="clear: both"></div>';
422
  echo '<a href="http://www.satollo.net/plugins/newsletter/newsletter-preferences" target="_blank">Click here know more about preferences.</a> They can be configured on Subscription/Form field panel.';
423
  echo '</div>';
424
  }
425
-
 
 
 
 
 
 
 
 
 
 
426
 
427
  function date($name) {
428
  $this->hidden($name);
@@ -433,7 +472,8 @@ class NewsletterControls {
433
  echo '<select id="' . $name . '_month" onchange="' . $onchange . '">';
434
  for ($i = 0; $i < 12; $i++) {
435
  echo '<option value="' . $i . '"';
436
- if ($month - 1 == $i) echo ' selected';
 
437
  echo '>' . date('F', mktime(0, 0, 0, $i + 1, 1, 2000)) . '</option>';
438
  }
439
  echo '</select>';
@@ -441,7 +481,8 @@ class NewsletterControls {
441
  echo '<select id="' . $name . '_day" onchange="' . $onchange . '">';
442
  for ($i = 1; $i <= 31; $i++) {
443
  echo '<option value="' . $i . '"';
444
- if ($day == $i) echo ' selected';
 
445
  echo '>' . $i . '</option>';
446
  }
447
  echo '</select>';
@@ -449,7 +490,8 @@ class NewsletterControls {
449
  echo '<select id="' . $name . '_year" onchange="' . $onchange . '">';
450
  for ($i = 2011; $i <= 2021; $i++) {
451
  echo '<option value="' . $i . '"';
452
- if ($year == $i) echo ' selected';
 
453
  echo '>' . $i . '</option>';
454
  }
455
  echo '</select>';
@@ -466,7 +508,8 @@ class NewsletterControls {
466
  echo '<select name="' . $name . '_month">';
467
  for ($i = 1; $i <= 12; $i++) {
468
  echo '<option value="' . $i . '"';
469
- if ($month == $i) echo ' selected';
 
470
  echo '>' . date('F', mktime(0, 0, 0, $i, 1, 2000)) . '</option>';
471
  }
472
  echo '</select>';
@@ -474,7 +517,8 @@ class NewsletterControls {
474
  echo '<select name="' . $name . '_day">';
475
  for ($i = 1; $i <= 31; $i++) {
476
  echo '<option value="' . $i . '"';
477
- if ($day == $i) echo ' selected';
 
478
  echo '>' . $i . '</option>';
479
  }
480
  echo '</select>';
@@ -482,7 +526,8 @@ class NewsletterControls {
482
  echo '<select name="' . $name . '_year">';
483
  for ($i = 2011; $i <= 2021; $i++) {
484
  echo '<option value="' . $i . '"';
485
- if ($year == $i) echo ' selected';
 
486
  echo '>' . $i . '</option>';
487
  }
488
  echo '</select>';
@@ -490,7 +535,8 @@ class NewsletterControls {
490
  echo '<select name="' . $name . '_hour">';
491
  for ($i = 0; $i <= 23; $i++) {
492
  echo '<option value="' . $i . '"';
493
- if ($hour == $i) echo ' selected';
 
494
  echo '>' . $i . ':00</option>';
495
  }
496
  echo '</select>';
@@ -530,7 +576,8 @@ class NewsletterControls {
530
  }
531
 
532
  function update_option($name, $data = null) {
533
- if ($data == null) $data = $this->data;
 
534
  update_option($name, $data);
535
  if (isset($data['log_level'])) {
536
  update_option($name . '_log_level', $data['log_level']);
7
  var $button_data = '';
8
 
9
  function __construct($options = null) {
10
+ if ($options == null)
11
+ $this->data = stripslashes_deep($_POST['options']);
12
+ else
13
+ $this->data = $options;
14
 
15
  $this->action = $_REQUEST['act'];
16
 
17
+ if (isset($_REQUEST['btn']))
18
+ $this->button_data = $_REQUEST['btn'];
19
 
20
  // Fields analysis
21
  $fields = $_REQUEST['fields'];
22
  if (is_array($fields)) {
23
+ foreach ($fields as $name => $type) {
24
  if ($type == 'datetime') {
25
  // Ex. The user insert 01/07/2012 14:30 and it set the time zone to +2. We cannot use the
26
  // mktime, since it uses the time zone of the machine. We create the time as if we are on
27
  // GMT 0 and then we subtract the GMT offset (the example date and time on GMT+2 happens
28
  // "before").
29
 
30
+ $time = gmmktime($_REQUEST[$name . '_hour'], 0, 0, $_REQUEST[$name . '_month'], $_REQUEST[$name . '_day'], $_REQUEST[$name . '_year']);
 
31
  $time -= get_option('gmt_offset') * 3600;
32
  $this->data[$name] = $time;
33
  }
35
  }
36
  }
37
 
38
+ function merge($options) {
39
+ if (!is_array($options))
40
+ return;
41
+ if ($this->data == null)
42
+ $this->data = array();
43
+ $this->data = array_merge($this->data, $options);
44
+ }
45
 
46
  function merge_defaults($defaults) {
47
+ if ($this->data == null)
48
+ $this->data = $defaults;
49
+ else
50
+ $this->data = array_merge($defaults, $this->data);
51
  }
52
 
53
  /**
56
  * Dies if it is not a safe call.
57
  */
58
  function is_action($action = null) {
59
+ if ($action == null)
60
+ return $this->action != null;
61
+ if ($this->action == null)
62
+ return false;
63
+ if ($this->action != $action)
64
+ return false;
65
+ if (check_admin_referer())
66
+ return true;
67
  die('Invalid call');
68
  }
69
 
97
 
98
  echo '<select style="width: 60px" name="options[' . $name . ']">';
99
  echo '<option value="0"';
100
+ if ($value == 0)
101
+ echo ' selected';
102
  echo '>No</option>';
103
  echo '<option value="1"';
104
+ if ($value == 1)
105
+ echo ' selected';
106
  echo '>Yes</option>';
107
  echo '</select>&nbsp;&nbsp;&nbsp;';
108
  }
112
 
113
  echo '<select style="width: 100px" name="options[' . $name . ']">';
114
  echo '<option value="0"';
115
+ if ($value == 0)
116
+ echo ' selected';
117
  echo '>Disabled</option>';
118
  echo '<option value="1"';
119
+ if ($value == 1)
120
+ echo ' selected';
121
  echo '>Enabled</option>';
122
  echo '</select>';
123
  }
136
  */
137
  function checkboxes_group($name, $values_labels) {
138
  echo "<div class='newsletter-checkboxes-group'>";
139
+ foreach ($values_labels as $value => $label) {
140
  echo "<div class='newsletter-checkboxes-item'>";
141
  echo "<input type='checkbox' id='$name' name='options[$name][]' value='$value'";
142
  if (is_array($this->data[$name]) && array_search($value, $this->data[$name]) !== false)
143
  echo " checked";
144
  echo '/>';
145
+ if ($label != '')
146
+ echo " <label for='$name'>$label</label>";
147
  echo "</div>";
148
  }
149
  echo "</div><div style='clear: both'></div>";
154
 
155
  foreach ($options as $key => $label) {
156
  echo '<option value="' . $key . '"';
157
+ if (is_array($this->data[$name]) && array_search($value, $this->data[$name]) !== false)
158
+ echo ' selected';
159
  echo '>' . htmlspecialchars($label) . '</option>';
160
  }
161
 
171
  }
172
  foreach ($options as $key => $label) {
173
  echo '<option value="' . $key . '"';
174
+ if ($value == $key)
175
+ echo ' selected';
176
  echo '>' . htmlspecialchars($label) . '</option>';
177
  }
178
  echo '</select>';
187
  echo '<optgroup label="' . htmlspecialchars($group['']) . '">';
188
  if (!empty($group)) {
189
  foreach ($group as $key => $label) {
190
+ if ($key == '')
191
+ continue;
192
  echo '<option value="' . $key . '"';
193
+ if ($value == $key)
194
+ echo ' selected';
195
  echo '>' . htmlspecialchars($label) . '</option>';
196
  }
197
  }
204
  * Generated a select control with all available templates. From version 3 there are
205
  * only on kind of templates, they are no more separated by type.
206
  */
207
+ function themes($name, $themes, $submit_on_click = true) {
208
+ foreach ($themes as $key => $data) {
209
  echo '<label style="display: block; float: left; text-align: center; margin-right: 10px;">';
210
  echo $key . '<br>';
211
  echo '<img src="' . $data['screenshot'] . '" width="100" height="100" style="border: 1px solid #666; padding: 5px"><br>';
231
  if ($show_remaining && $delta > 0) {
232
  echo 'Remaining: ';
233
  $delta = $time - time();
234
+ $days = floor($delta / (24 * 3600));
235
+ $delta = $delta - $days * 24 * 3600;
236
  $hours = floor($delta / 3600);
237
+ $delta = $delta - $hours * 3600;
238
  $minutes = floor($delta / 60);
239
 
240
+ if ($days > 0)
241
+ echo $days . ' days ';
242
  echo $hours . ' hours ';
243
  echo $minutes . ' minutes ';
244
  }
269
  echo '<input class="button-secondary" type="button" value="' . $label . '" onclick="this.form.act.value=\'' . $action . '\';this.form.submit()"/>';
270
  }
271
  }
272
+
273
  function button_primary($action, $label, $function = null) {
274
  if ($function != null) {
275
  echo '<input class="button-primary" type="button" value="' . $label . '" onclick="this.form.act.value=\'' . $action . '\';' . htmlspecialchars($function) . '"/>';
278
  }
279
  }
280
 
281
+ function button_confirm($action, $label, $message = '', $data = '') {
282
  if (empty($message)) {
283
  echo '<input class="button-secondary" type="button" value="' . $label . '" onclick="this.form.btn.value=\'' . $data . '\';this.form.act.value=\'' . $action . '\';this.form.submit()"/>';
284
+ } else {
 
285
  echo '<input class="button-secondary" type="button" value="' . $label . '" onclick="this.form.btn.value=\'' . $data . '\';this.form.act.value=\'' . $action . '\';if (confirm(\'' .
286
  htmlspecialchars($message) . '\')) this.form.submit()"/>';
287
  }
294
  }
295
 
296
  function wp_editor($name, $settings = array()) {
297
+ wp_editor($this->data[$name], $name, array_merge(array('textarea_name' => 'options[' . $name . ']', 'wpautop' => false), $settings));
298
  }
299
 
300
  function textarea($name, $width = '100%', $height = '50') {
309
  echo '</textarea>';
310
  }
311
 
312
+ function email($prefix, $editor = null, $disable_option = false) {
313
  if ($disable_option) {
314
  $this->checkbox($prefix . '_disabled', 'Disable this email');
315
  echo '<br>';
327
  }
328
 
329
  function checkbox($name, $label = '') {
330
+ if ($label != '')
331
+ echo '<label>';
332
  echo '<input type="checkbox" id="' . $name . '" name="options[' . $name . ']" value="1"';
333
+ if (!empty($this->data[$name]))
334
+ echo ' checked="checked"';
335
  echo '/>';
336
+ if ($label != '')
337
+ echo '&nbsp;' . $label . '</label>';
338
  }
339
+
340
  /**
341
  * Creates a checkbox named $name and checked if the internal data contains under
342
  * the key $name an array containig the passed value.
344
  function checkbox_group($name, $value, $label = '') {
345
  echo '<input type="checkbox" id="' . $name . '" name="options[' . $name . '][]" value="' . $value . '"';
346
  if (is_array($this->data[$name]) && array_search($value, $this->data[$name]) !== false)
347
+ echo ' checked="checked"';
348
  echo '/>';
349
+ if ($label != '')
350
+ echo ' <label for="' . $name . '">' . $label . '</label>';
351
+ }
352
 
353
  function color($name) {
354
  echo $this->text($name, 10);
356
 
357
  /** Creates a set of checkbox named $name_[category id] (so they are posted with distinct names).
358
  */
359
+ function categories($name = 'category') {
360
  $categories = get_categories();
361
  echo '<div class="newsletter-checkboxes-group">';
362
  foreach ($categories as &$c) {
372
  * Creates a set of checkbox to activate the profile preferences. Every checkbox has a DIV around to
373
  * be formatted.
374
  */
375
+ function categories_group($name, $show_mode = false) {
376
  $categories = get_categories();
377
  if ($show_mode) {
378
+ $this->select($name . '_mode', array('include' => 'To be included', 'exclude' => 'To be excluded'));
379
  }
380
  echo '<div class="newsletter-categories-group">';
381
  foreach ($categories as &$c) {
387
  echo '</div>';
388
  }
389
 
390
+ /**
391
+ * Creates a set of checkboxes named $name_[preference number] (so they are
392
+ * distinct fields).
393
+ * Empty preferences are skipped.
394
+ */
395
+ function preferences($name = 'preferences') {
396
  $options_profile = get_option('newsletter_profile');
 
397
  echo '<div class="newsletter-preferences-group">';
 
 
398
 
399
+ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
400
+ if (empty($options_profile['list_' . $i]))
401
+ continue;
402
  echo '<div class="newsletter-preferences-item">';
403
+ $this->checkbox($name . '_' . $i, '(' . $i . ') ' . htmlspecialchars($options_profile['list_' . $i]));
 
 
 
404
  echo '</div>';
405
  }
406
  echo '<div style="clear: both"></div>';
409
  }
410
 
411
  /**
412
+ * Creates a set of checkboxes all names $name[] and the preference number as value
413
+ * so the selected checkboxes are retrieved as an array of values ($REQUEST[$name]
414
+ * will be an array if at east one preference is checked).
415
  */
416
+ function preferences_group($name = 'preferences') {
417
  $options_profile = get_option('newsletter_profile');
 
418
 
419
+ echo '<div class="newsletter-preferences-group">';
420
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
421
+ if (empty($options_profile['list_' . $i]))
422
+ continue;
423
  echo '<div class="newsletter-preferences-item">';
424
+ $this->checkbox_group($name, $i, '(' . $i . ') ' . htmlspecialchars($options_profile['list_' . $i]));
425
  echo '</div>';
426
  }
427
  echo '<div style="clear: both"></div>';
428
  echo '<a href="http://www.satollo.net/plugins/newsletter/newsletter-preferences" target="_blank">Click here know more about preferences.</a> They can be configured on Subscription/Form field panel.';
429
  echo '</div>';
 
430
  }
431
+
432
+ /** Creates as many selects as the active preferences with the three values
433
+ * 'any', 'yes', 'no' corresponding to the values 0, 1, 2.
 
 
434
  */
435
+ function preferences_selects($name = 'preferences', $skip_empty = false) {
436
  $options_profile = get_option('newsletter_profile');
437
 
438
  echo '<div class="newsletter-preferences-group">';
439
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
440
+ if (empty($options_profile['list_' . $i]))
441
+ continue;
442
+
443
  echo '<div class="newsletter-preferences-item">';
444
+
445
+ $this->select($name . '_' . $i, array(0 => 'Any', 1 => 'Yes', 2 => 'No'));
446
+ echo '(' . $i . ') ' . htmlspecialchars($options_profile['list_' . $i]);
447
+
448
  echo '</div>';
449
  }
450
  echo '<div style="clear: both"></div>';
451
  echo '<a href="http://www.satollo.net/plugins/newsletter/newsletter-preferences" target="_blank">Click here know more about preferences.</a> They can be configured on Subscription/Form field panel.';
452
  echo '</div>';
453
  }
454
+
455
+ /** Creates a single select with the active preferences. */
456
+ function preferences_select($name = 'preference') {
457
+ $options_profile = get_option('newsletter_profile');
458
+
459
+ $lists = array();
460
+ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
461
+ $lists['' . $i] = '(' . $i . ') ' . $options_profile['list_' . $i];
462
+ }
463
+ $this->select($name, $lists);
464
+ }
465
 
466
  function date($name) {
467
  $this->hidden($name);
472
  echo '<select id="' . $name . '_month" onchange="' . $onchange . '">';
473
  for ($i = 0; $i < 12; $i++) {
474
  echo '<option value="' . $i . '"';
475
+ if ($month - 1 == $i)
476
+ echo ' selected';
477
  echo '>' . date('F', mktime(0, 0, 0, $i + 1, 1, 2000)) . '</option>';
478
  }
479
  echo '</select>';
481
  echo '<select id="' . $name . '_day" onchange="' . $onchange . '">';
482
  for ($i = 1; $i <= 31; $i++) {
483
  echo '<option value="' . $i . '"';
484
+ if ($day == $i)
485
+ echo ' selected';
486
  echo '>' . $i . '</option>';
487
  }
488
  echo '</select>';
490
  echo '<select id="' . $name . '_year" onchange="' . $onchange . '">';
491
  for ($i = 2011; $i <= 2021; $i++) {
492
  echo '<option value="' . $i . '"';
493
+ if ($year == $i)
494
+ echo ' selected';
495
  echo '>' . $i . '</option>';
496
  }
497
  echo '</select>';
508
  echo '<select name="' . $name . '_month">';
509
  for ($i = 1; $i <= 12; $i++) {
510
  echo '<option value="' . $i . '"';
511
+ if ($month == $i)
512
+ echo ' selected';
513
  echo '>' . date('F', mktime(0, 0, 0, $i, 1, 2000)) . '</option>';
514
  }
515
  echo '</select>';
517
  echo '<select name="' . $name . '_day">';
518
  for ($i = 1; $i <= 31; $i++) {
519
  echo '<option value="' . $i . '"';
520
+ if ($day == $i)
521
+ echo ' selected';
522
  echo '>' . $i . '</option>';
523
  }
524
  echo '</select>';
526
  echo '<select name="' . $name . '_year">';
527
  for ($i = 2011; $i <= 2021; $i++) {
528
  echo '<option value="' . $i . '"';
529
+ if ($year == $i)
530
+ echo ' selected';
531
  echo '>' . $i . '</option>';
532
  }
533
  echo '</select>';
535
  echo '<select name="' . $name . '_hour">';
536
  for ($i = 0; $i <= 23; $i++) {
537
  echo '<option value="' . $i . '"';
538
+ if ($hour == $i)
539
+ echo ' selected';
540
  echo '>' . $i . ':00</option>';
541
  }
542
  echo '</select>';
576
  }
577
 
578
  function update_option($name, $data = null) {
579
+ if ($data == null)
580
+ $data = $this->data;
581
  update_option($name, $data);
582
  if (isset($data['log_level'])) {
583
  update_option($name . '_log_level', $data['log_level']);
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.6
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.6');
17
 
18
  global $wpdb, $newsletter;
19
 
@@ -119,7 +119,7 @@ class Newsletter extends NewsletterModule {
119
  // Here because the upgrade is called by the parent constructor and uses the scheduler
120
  add_filter('cron_schedules', array($this, 'hook_cron_schedules'), 1000);
121
 
122
- parent::__construct('main', '1.1.5');
123
 
124
  $max = $this->options['scheduler_max'];
125
  if (!is_numeric($max))
@@ -1070,6 +1070,10 @@ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php')) {
1070
  require_once WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php';
1071
  }
1072
 
 
 
 
 
1073
  require_once(dirname(__FILE__) . '/widget.php');
1074
 
1075
  register_activation_hook(__FILE__, 'newsletter_activate');
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.7
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.7');
17
 
18
  global $wpdb, $newsletter;
19
 
119
  // Here because the upgrade is called by the parent constructor and uses the scheduler
120
  add_filter('cron_schedules', array($this, 'hook_cron_schedules'), 1000);
121
 
122
+ parent::__construct('main', '1.1.6');
123
 
124
  $max = $this->options['scheduler_max'];
125
  if (!is_numeric($max))
1070
  require_once WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php';
1071
  }
1072
 
1073
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php')) {
1074
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php';
1075
+ }
1076
+
1077
  require_once(dirname(__FILE__) . '/widget.php');
1078
 
1079
  register_activation_hook(__FILE__, 'newsletter_activate');
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.3.0
4
  Tested up to: 3.5.1
5
- Stable tag: 3.2.6
6
  Donate link: http://www.satollo.net/donations
7
 
8
  Add a real newsletter to your blog. In seconds. For free. With unlimited emails and subscribers.
@@ -11,7 +11,7 @@ Add a real newsletter to your blog. In seconds. For free. With unlimited emails
11
 
12
  This plug-in adds a real newsletter system to your WordPress blog. Perfect for list building,
13
  you can create cool emails with visual editor, send and
14
- track them.
15
 
16
  Unlimited subscribers, unlimited e-mails.
17
 
@@ -55,6 +55,13 @@ No screen shots are available at this time.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
58
  = 3.2.6 =
59
 
60
  * Fixed the forced preferences on subscription panel
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.3.0
4
  Tested up to: 3.5.1
5
+ Stable tag: 3.2.7
6
  Donate link: http://www.satollo.net/donations
7
 
8
  Add a real newsletter to your blog. In seconds. For free. With unlimited emails and subscribers.
11
 
12
  This plug-in adds a real newsletter system to your WordPress blog. Perfect for list building,
13
  you can create cool emails with visual editor, send and
14
+ track them.
15
 
16
  Unlimited subscribers, unlimited e-mails.
17
 
55
 
56
  == Changelog ==
57
 
58
+ = 3.2.7 =
59
+
60
+ * Added a controls for the Reports module version 1.0.4
61
+ * Changed opening tracking and removed 1x1 GIF
62
+ * Added support for popup on subscription form
63
+ * Fixed the link to the reports module
64
+
65
  = 3.2.6 =
66
 
67
  * Fixed the forced preferences on subscription panel
statistics/1x1.gif DELETED
Binary file
statistics/open.php CHANGED
@@ -12,6 +12,6 @@ $wpdb->insert(NEWSLETTER_STATS_TABLE, array(
12
  );
13
 
14
  header('Content-Type: image/gif');
15
- readfile(dirname(__FILE__) . '/1x1.gif');
16
  die();
17
 
12
  );
13
 
14
  header('Content-Type: image/gif');
15
+ echo base64_decode('_R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
16
  die();
17
 
statistics/statistics.php CHANGED
@@ -4,7 +4,7 @@ require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
4
 
5
  class NewsletterStatistics extends NewsletterModule {
6
 
7
- const VERSION = '1.0.2';
8
 
9
  static $instance;
10
 
4
 
5
  class NewsletterStatistics extends NewsletterModule {
6
 
7
+ const VERSION = '1.0.3';
8
 
9
  static $instance;
10
 
statistics/view.php CHANGED
@@ -13,7 +13,7 @@ $email = $module->get_email($_GET['id']);
13
  <div class="preamble">
14
  <p>
15
  Complete statistics for this email are available with
16
- <a href="http://www.satollo.net/plugins/newsletter/reports-module-for-newsletter" target="_blank">Reports for Newsletter</a>.
17
  </p>
18
  </div>
19
 
13
  <div class="preamble">
14
  <p>
15
  Complete statistics for this email are available with
16
+ <a href="http://www.satollo.net/plugins/newsletter/reports-module" target="_blank">Reports for Newsletter</a>.
17
  </p>
18
  </div>
19
 
subscription/page.php CHANGED
@@ -69,7 +69,7 @@ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/subscription/page.php')) {
69
  <body>
70
  <?php if (!empty($alert)) { ?>
71
  <script>
72
- alert("<?php echo addslashes($alert); ?>");
73
  </script>
74
  <?php } ?>
75
  <div id="container">
69
  <body>
70
  <?php if (!empty($alert)) { ?>
71
  <script>
72
+ alert("<?php echo addslashes(strip_tags($alert)); ?>");
73
  </script>
74
  <?php } ?>
75
  <div id="container">
subscription/subscription.php CHANGED
@@ -4,7 +4,7 @@ require_once NEWSLETTER_INCLUDES_DIR . '/module.php';
4
 
5
  class NewsletterSubscription extends NewsletterModule {
6
 
7
- const VERSION = '1.0.2';
8
  const MESSAGE_CONFIRMED = 'confirmed';
9
 
10
  static $instance;
@@ -611,7 +611,7 @@ class NewsletterSubscription extends NewsletterModule {
611
  *
612
  * @return string The html code of the subscription form
613
  */
614
- function get_subscription_form($referrer = null) {
615
  $options_profile = get_option('newsletter_profile');
616
  $options = get_option('newsletter');
617
 
@@ -945,7 +945,7 @@ function newsletter_shortcode($attrs, $content) {
945
  $message = $newsletter->replace($message, $user, null, 'page');
946
 
947
  if (!empty($alert)) {
948
- $message .= '<script>alert("' . addslashes($alert) . '");</script>';
949
  }
950
 
951
  return $message;
4
 
5
  class NewsletterSubscription extends NewsletterModule {
6
 
7
+ const VERSION = '1.0.3';
8
  const MESSAGE_CONFIRMED = 'confirmed';
9
 
10
  static $instance;
611
  *
612
  * @return string The html code of the subscription form
613
  */
614
+ function get_subscription_form($referrer = null, $action=null) {
615
  $options_profile = get_option('newsletter_profile');
616
  $options = get_option('newsletter');
617
 
945
  $message = $newsletter->replace($message, $user, null, 'page');
946
 
947
  if (!empty($alert)) {
948
+ $message .= '<script>alert("' . addslashes(strip_tags($alert)) . '");</script>';
949
  }
950
 
951
  return $message;